Excerpts from David E. Wheeler's message of mar oct 02 16:37:30 -0300 2012:
> On Oct 2, 2012, at 12:30 PM, Alvaro Herrera <alvhe...@2ndquadrant.com> wrote:
> 
> > How about call this for precedent:
> > 
> > mkdir -p /tmp/foo/bar
> > mkdir -p /tmp/foo/baz
> > 
> > In this case you end up with directory "foo" and at least two subdirs in
> > it, bar and baz.  This works even if /tmp/foo existed previously and
> > even if there was some other stuff in it.
> 
> Well, what about this, then?
> 
> create schema if not exists foo create table second (a int);
> create schema if not exists foo create table second (b int);

Yes, exactly -- what about this case?  This is precisely the reason we
don't have CREATE TABLE IF NOT EXISTS.

I don't know what the best answer is.  Most people seem to think that
the answer ought to be that you end up with a single column second.a,
and the second command errors out.

So if you do this:

create schema if not exists foo create table first (a int);
create schema if not exists foo create table first (b int),
                                create table second (a int);

you end up with *only* the first table, because the second command
errors out when the first table is observed to exist.

Now, what if you were to do this instead:

create schema if not exists foo
   create table if not exists first (a int);
create schema if not exists foo
   create table if not exists first (b int),
   create table if not exists second (a int);

The you end up with first.a and second.a.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to