Re: plpgsql; execute query inside exists

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: jozsef(dot)kurucz(at)invitel(dot)hu, pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql; execute query inside exists
Date: 2011-10-17 13:44:24
Message-ID: CAF-3MvPm=q__TorCtqDjyofi1CF14bbpcad-wpg_R=uLiAgUHQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 17 October 2011 15:20, Merlin Moncure <mmoncure(at)gmail(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David McKeone 2011-10-17 13:53:08 Mac OS X 10.6 - libpq.dylib vs. libpq.a and PQisthreadsafe()
Previous Message Merlin Moncure 2011-10-17 13:42:00 Re: index bloat question