non-cachable 'C' language functions

From: Forest Wilkinson <fspam(at)home(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: non-cachable 'C' language functions
Date: 2000-08-12 01:18:13
Message-ID: kj89psotsjohu3nqb2nb2iotigd5d844d2@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

(using postgresql 6.5.2)

I have created a set of postgres extension functions in C (which use SPI
to perform queries), and added them to my database with something like
this:

CREATE FUNCTION my_next_uid(text) RETURNS text AS
'/usr/lib/pgsql/my_uids.so' LANGUAGE 'c';

My functions are designed to behave like nextval() and friends, except
that they operate on a varchar field in a predetermined table, rather than
a database sequence. For example, my_next_uid() should always return a
unique value, incrementing the current value in said table each time it is
called.

So far, my functions appear to work correctly. However, looking at their
entries in the pg_proc table, I see that their "proiscachable" fields are
set to true. This worries me, because my understanding is that postgres
will re-use values returned by cachable functions, which is undesirable.
(In order for my_next_uid() to be useful, it must retrieve a new value
each time it is used.)

Is my understanding correct? What should I do about it? The postgresql
6.5.2 docs for CREATE FUNCTION don't tell me how to make my functions
non-cachable.

Regards,

Forest Wilkinson

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Lloyd-Jones 2000-08-12 01:27:43 Week of the Year?
Previous Message Zot O'Connor 2000-08-11 23:24:57 [Fwd: I will be at Linux World]