Re: CREATE SCHEMA IF NOT EXISTS

Michael Paquier <michael.paquier@gmail.com>

From: Michael Paquier <michael.paquier@gmail.com>
To: "David E. Wheeler" <david@justatheory.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, "Dickson S. Guedes" <listas@guedesoft.net>, fabriziomello@gmail.com, Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2012-09-21T23:59:07Z
Lists: pgsql-hackers
On Sat, Sep 22, 2012 at 3:06 AM, David E. Wheeler <david@justatheory.com>wrote:

> On Sep 21, 2012, at 10:59 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> > I don't believe this has been thought through nearly carefully enough.
> > If CREATE SCHEMA created a schema and nothing more, then the proposed
> > implementation would probably be fine.  But per spec, CREATE SCHEMA
> > can specify not only creating the schema but a whole bunch of objects
> > within the schema.  As coded, if the schema exists then creation of
> > the specified sub-objects is just skipped, regardless of whether they
> > exist or not.  I doubt that this is really sane behavior.  Would the
> > principle of least astonishment dictate that the IF NOT EXISTS option
> > apply implicitly to each sub-object as well?  (If so, we'd have to
> > extend everything that can appear in OptSchemaEltList; most of those
> > commands don't have IF NOT EXISTS options today.)
>
> I had no idea about that functionality. Seems very strange.
>
Isn't it this SQL?
CREATE SCHEMA foo CREATE TABLE aa (a int) CREATE TABLE bb (b int);
-- 
Michael Paquier
http://michael.otacoo.com

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Document the lack of reading the PGDATABASE environment variable in