non-cachable 'C' language functions - Mailing list pgsql-sql

From Forest Wilkinson
Subject non-cachable 'C' language functions
Date
Msg-id kj89psotsjohu3nqb2nb2iotigd5d844d2@4ax.com
Whole thread Raw
Responses Re: non-cachable 'C' language functions
List 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



pgsql-sql by date:

Previous
From: "Zot O'Connor"
Date:
Subject: [Fwd: I will be at Linux World]
Next
From: "David Lloyd-Jones"
Date:
Subject: Week of the Year?