Re: plpgsql; execute query inside exists - Mailing list pgsql-general

From Alban Hertroys
Subject Re: plpgsql; execute query inside exists
Date
Msg-id CAF-3MvPm=q__TorCtqDjyofi1CF14bbpcad-wpg_R=uLiAgUHQ@mail.gmail.com
Whole thread Raw
In response to Re: plpgsql; execute query inside exists  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: plpgsql; execute query inside exists  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
On 17 October 2011 15:20, Merlin Moncure <mmoncure@gmail.com> wrote:
> A better way to do this is to query information_schema:
>
> PERFORM 1 FROM information_schema.tables where schema_name = x and
> table_name = y;
>
> IF FOUND THEN
>  CREATE TABLE ...
> END IF;
>
> (there is a race condition in the above code -- do you see it? if
> concurrent access to this function is an issue, you have to LOCK an
> object before running the PERFORM or perhaps use an advisory lock).

Is there? You'd think that with transactional DDL and the code running
in a single transaction (namely inside a stored function) it would be
concurrency-safe.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: index bloat question
Next
From: David McKeone
Date:
Subject: Mac OS X 10.6 - libpq.dylib vs. libpq.a and PQisthreadsafe()