Re: plpgsql; execute query inside exists
От | Alban Hertroys |
---|---|
Тема | Re: plpgsql; execute query inside exists |
Дата | |
Msg-id | CAF-3MvPm=q__TorCtqDjyofi1CF14bbpcad-wpg_R=uLiAgUHQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: plpgsql; execute query inside exists (Merlin Moncure <mmoncure@gmail.com>) |
Ответы |
Re: plpgsql; execute query inside exists
|
Список | 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 по дате отправления: