From: | Jakub Ouhrabka <jouh8664(at)ss1000(dot)ms(dot)mff(dot)cuni(dot)cz> |
---|---|
To: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: how to make functions multi-user safe? |
Date: | 2002-12-05 13:23:03 |
Message-ID: | Pine.LNX.4.44.0212051411230.24253-100000@server |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
hi,
> Due to the limitation that SetQuerySnapshot() is not called from within plpgsql functions, we
> are having trouble making a function safe for a multiuser environment.
>
> Our goal: To have a multiuser-safe function that checks for the existence of a table. If the table
> exists, it should return the name of the table. If it does not exist, it will call another
> function that creates the table and then it should return the name of the table after it's been created.
> ...
i'd suggest encapsulating the whole function in LOCK lock_table IN
EXCLUSIVE MODE; to avoid concurrent access to the function and using
UPDATE pg_class SET relname=relname WHERE relname=quote_ident(''foo'') for
checking for the table existence (if there are any affected rows...). i
think that for update and delete the snapshot is taken when executing the
statement not before the function start as in the case of select.
hth,
kuba
From | Date | Subject | |
---|---|---|---|
Next Message | Csaba Nagy | 2002-12-05 13:26:38 | Re: DbVisualizer and PG 7.3? |
Previous Message | Nick Gazaloff | 2002-12-05 12:28:44 | Collation with different glibc versions, part 2 |