On 10/11/2012 09:22 PM, Simon Riggs wrote: >> >> That is a lot more typing and it's not exactly intuitive. One obvious >> thing that would help is a function pg_table_exists(text) that would >> return true or false. But even with that there's a lot of syntactic >> sugar in there that is less than ideal: begin/end, dollar-quoting, do. >> Whatever becomes of this particular patch, I think we'd make a lot of >> people really happy if we could find a way to dispense with some of >> that stuff in simple cases. > > Yeh, definitely. > > So we just need a function called pg_if_table_exists(table, SQL) which > wraps a test in a subtransaction. > > And you write > > SELECT pg_if_table_exists('foo', 'TRUNCATE TABLE foo'); > > and we can even get rid of all that other DDL crud that's been added.... > > and we can have pg_if_table_not_exists() also. >
If we can do something like : SELECT pg_if_table_exists('bar' , pg_if_table_exists('foo', 'TRUNCATE TABLE foo, bar, foobar')) ; or SELECT pg_if_tables_exists('TRUNCATE TABLE foo, bar, foobar', 'foo', 'bar') ; I say yes ! -- Sébastien Lardière PostgreSQL DBA Team Manager Hi-Media -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers