Re: CREATE SCHEMA IF NOT EXISTS

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David E(dot) Wheeler" <david(at)justatheory(dot)com>, "Dickson S(dot) Guedes" <listas(at)guedesoft(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE SCHEMA IF NOT EXISTS
Date: 2012-10-03 17:29:38
Message-ID: CAFcNs+qQtEgNZF4eA9p0MS71+TFBQCanv36zYGr_sTeoPpELDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/10/3 Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>

> Excerpts from Fabrízio de Royes Mello's message of mié oct 03 10:11:03
> -0300 2012:
>
> > Maybe something like this?
> >
> > ereport(ERROR,
> > (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> > errmsg("IF NOT EXISTS cannot be used with schema elements"),
> > parser_errposition(@9)));
>
> Seems reasonable, but where? Please submit a complete patch.
>
>
The attached patch implements the behavior we've discussed.

If we use "IF NOT EXISTS" with schema elements then occurs an error like
this:

[local]:5432 fabrizio(at)fabrizio=# CREATE SCHEMA IF NOT EXISTS test_schema_1
CREATE TABLE abc (
a serial,
b int UNIQUE
);
ERROR: IF NOT EXISTS cannot be used with schema elements
LINE 1: CREATE SCHEMA IF NOT EXISTS test_schema_1
^
Time: 0,773 ms

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello

Attachment Content-Type Size
create_schema_if_not_exists_v7.patch application/octet-stream 8.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-10-03 17:53:28 Re: do we EXEC_BACKEND on Mac OS X?
Previous Message Bruce Momjian 2012-10-03 17:08:17 Re: do we EXEC_BACKEND on Mac OS X?