Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread David E. Wheeler
On Oct 3, 2012, at 4:49 PM, Tom Lane wrote: > Committed with some adjustments, notably repairing the > order-of-operations error I complained about before. Awesome, thanks! David -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Tom Lane
=?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > The attached patch implements the behavior we've discussed. Committed with some adjustments, notably repairing the order-of-operations error I complained about before. regards, tom lane -- Sent via pgsql-hackers mail

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Tom Lane
=?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > The attached patch implements the behavior we've discussed. OK, I'll pick this up again, since we seem to have consensus on this behavior. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postg

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Fabrízio de Royes Mello
2012/10/3 Alvaro Herrera > 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 eleme

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Alvaro Herrera
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(

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Fabrízio de Royes Mello
2012/10/3 Alvaro Herrera > Excerpts from Fabrízio de Royes Mello's message of mié oct 03 09:27:41 > -0300 2012: > > 2012/10/2 Fabrízio de Royes Mello > > > > > > > > You're right... the latest proposed patch don't implements it. > > > > > > I'll change the patch and send soon... > > > > > > > >

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Alvaro Herrera
Excerpts from Fabrízio de Royes Mello's message of mié oct 03 09:27:41 -0300 2012: > 2012/10/2 Fabrízio de Royes Mello > > > > > You're right... the latest proposed patch don't implements it. > > > > I'll change the patch and send soon... > > > > > What is more reasonable? > * show a syntax erro

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-03 Thread Fabrízio de Royes Mello
2012/10/2 Fabrízio de Royes Mello > > You're right... the latest proposed patch don't implements it. > > I'll change the patch and send soon... > > What is more reasonable? * show a syntax error or * show a message that you can not use the INE with contained objects Regards, -- Fabrízio de Roy

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Stirling Newberry
This case points to a weakness in many programming languages, not having a clear ifof (if and only if) versus if construction. The sane use case for create schema foo if not exists is for building a database dynamically, where several points may be the first to put a table in a schema, and sc

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Fabrízio de Royes Mello
2012/10/2 Alvaro Herrera > Excerpts from Andrew Dunstan's message of mar oct 02 17:24:38 -0300 2012: > > > > On 10/02/2012 03:48 PM, Tom Lane wrote: > > > Alvaro Herrera writes: > > > >> Well, if that's the rationale then you end up with no schema foo at > all > > >> (i.e. both die), which seems

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Alvaro Herrera
Excerpts from Andrew Dunstan's message of mar oct 02 17:24:38 -0300 2012: > > On 10/02/2012 03:48 PM, Tom Lane wrote: > > Alvaro Herrera writes: > >> Well, if that's the rationale then you end up with no schema foo at all > >> (i.e. both die), which seems even more surprising (though I admit it

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Andrew Dunstan
On 10/02/2012 03:48 PM, Tom Lane wrote: Alvaro Herrera writes: Excerpts from David E. Wheeler's message of mar oct 02 16:16:37 -0300 2012: On Oct 2, 2012, at 12:08 PM, Alvaro Herrera wrote: create schema if not exists foo create table first (a int); create schema if not exists foo create ta

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread David E. Wheeler
On Oct 2, 2012, at 12:48 PM, Tom Lane wrote: > I think we should just disallow putting any contained objects in the > statement when IF NOT EXISTS is used. It's simple to understand, simple > to document and implement, and I think it covers all the sane use-cases > anyway. +1 David -- Sent

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Alvaro Herrera
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 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

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Tom Lane
Alvaro Herrera writes: > Excerpts from David E. Wheeler's message of mar oct 02 16:16:37 -0300 2012: >> On Oct 2, 2012, at 12:08 PM, Alvaro Herrera wrote: >>> create schema if not exists foo create table first (a int); >>> create schema if not exists foo create table second (a int); >>> >>> As fa

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread David E. Wheeler
On Oct 2, 2012, at 12:30 PM, Alvaro Herrera 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

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Alvaro Herrera
Excerpts from David E. Wheeler's message of mar oct 02 16:16:37 -0300 2012: > On Oct 2, 2012, at 12:08 PM, Alvaro Herrera wrote: > > > create schema if not exists foo create table first (a int); > > create schema if not exists foo create table second (a int); > > > > > > As far as I can see, wi

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread David E. Wheeler
On Oct 2, 2012, at 12:08 PM, Alvaro Herrera wrote: > create schema if not exists foo create table first (a int); > create schema if not exists foo create table second (a int); > > > As far as I can see, with the patch as it currently stands, you would > end up with only table "first" in the sch

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Alvaro Herrera
Excerpts from Volker Grabsch's message of sáb sep 29 06:32:13 -0300 2012: > Dickson S. Guedes schrieb: > > - https://commitfest.postgresql.org/action/patch_view?id=907 > > > > The patch is small and implements a new syntax to CREATE SCHEMA > > that allow the creation of a schema be skipped when IF

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-10-02 Thread Alvaro Herrera
The fundamental issue with this patch hasn't been answered sufficiently, I think. Consider the following sequence of commands: create schema if not exists foo create table first (a int); create schema if not exists foo create table second (a int); As far as I can see, with the patch as it curr

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-09-29 Thread Volker Grabsch
Dickson S. Guedes schrieb: > - https://commitfest.postgresql.org/action/patch_view?id=907 > > The patch is small and implements a new syntax to CREATE SCHEMA > that allow the creation of a schema be skipped when IF NOT EXISTS is > used. > > [...] > > - Should this patch implements others INEs like

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-09-21 Thread Fabrízio de Royes Mello
2012/9/21 David E. Wheeler > On Sep 21, 2012, at 10:59 AM, Tom Lane 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 SCHEM

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-09-21 Thread Michael Paquier
On Sat, Sep 22, 2012 at 3:06 AM, David E. Wheeler wrote: > On Sep 21, 2012, at 10:59 AM, Tom Lane 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

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-09-21 Thread Tom Lane
"Dickson S. Guedes" writes: > I reviewed this v5 of patch: > - https://commitfest.postgresql.org/action/patch_view?id=907 > The patch is small and implements a new syntax to CREATE SCHEMA > that allow the creation of a schema be skipped when IF NOT EXISTS is > used. I don't believe this has bee

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-09-21 Thread David E. Wheeler
On Sep 21, 2012, at 10:59 AM, Tom Lane 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

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-28 Thread Dickson S. Guedes
2012/8/28 David E. Wheeler : > On Aug 28, 2012, at 8:19 AM, Fabrízio de Royes Mello wrote: > >>> - Should this patch implements others INEs like ADD COLUMN IF NOT EXISTS? >> >> If this feature is important I believe we must implement it. >> >> Exists several "CREATE" statements without "IF NOT EXIS

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-28 Thread David E. Wheeler
On Aug 28, 2012, at 8:19 AM, Fabrízio de Royes Mello wrote: >> - Should this patch implements others INEs like ADD COLUMN IF NOT EXISTS? > > If this feature is important I believe we must implement it. > > Exists several "CREATE" statements without "IF NOT EXISTS" option too, so we > can discus

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-28 Thread Fabrízio de Royes Mello
2012/8/27 Dickson S. Guedes > > [...] > > Two questions: > > - Should this patch implements others INEs like ADD COLUMN IF NOT EXISTS? > If this feature is important I believe we must implement it. Exists several "CREATE" statements without "IF NOT EXISTS" option too, so we can discuss more abo

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-27 Thread Dickson S. Guedes
Hello, I reviewed this v5 of patch: - https://commitfest.postgresql.org/action/patch_view?id=907 The patch is small and implements a new syntax to CREATE SCHEMA that allow the creation of a schema be skipped when IF NOT EXISTS is used. It was applied to 483c2c1071c45e275782d33d646c3018f02f9f94

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-17 Thread Fabrízio de Royes Mello
2012/8/17 Alvaro Herrera > Excerpts from Dickson S. Guedes's message of vie ago 17 10:37:25 -0400 > 2012: > > 2012/8/17 Fabrízio de Royes Mello : > > > > > > 2012/8/17 Alvaro Herrera > > >> > > >> Excerpts from Fabrízio de Royes Mello's message of vie ago 17 09:16:30 > > >> -0400 2012: > > >> >

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-17 Thread Dickson S. Guedes
2012/8/17 Fabrízio de Royes Mello : > > 2012/8/17 Alvaro Herrera >> >> Excerpts from Fabrízio de Royes Mello's message of vie ago 17 09:16:30 >> -0400 2012: >> >> > The attached patch contains regression tests for it. >> >> I think you're missing support in copyfuncs.c and equalfuncs.c for the >>

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-17 Thread Fabrízio de Royes Mello
2012/8/17 Alvaro Herrera > Excerpts from Fabrízio de Royes Mello's message of vie ago 17 09:16:30 > -0400 2012: > > > The attached patch contains regression tests for it. > > I think you're missing support in copyfuncs.c and equalfuncs.c for the > new field in the node. > > You're completely righ

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-17 Thread Alvaro Herrera
Excerpts from Fabrízio de Royes Mello's message of vie ago 17 09:16:30 -0400 2012: > The attached patch contains regression tests for it. I think you're missing support in copyfuncs.c and equalfuncs.c for the new field in the node. -- Álvaro Herrerahttp://www.2ndQuadrant.com/ P

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-17 Thread Fabrízio de Royes Mello
2012/8/17 Fabrízio de Royes Mello > > I started testing this, but I didn't see regression tests for it. >> Could you write them?. >> >> > The attached patch contains regression tests for it. > > Please, don't consider de last patch (v2) because I make a little mistake on "create_schema.sgml" stru

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-17 Thread Fabrízio de Royes Mello
2012/8/16 Dickson S. Guedes > 2012/8/16 Fabrízio de Royes Mello : > > The attached patch implement this feature: > > > > CREATE SCHEMA [ IF NOT EXISTS ] schema_name [ AUTHORIZATION user_name ] [ > > schema_element [ ... ] ] > > CREATE SCHEMA [ IF NOT EXISTS ] AUTHORIZATION user_name [ schema_elem

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-16 Thread Dickson S. Guedes
2012/8/16 Fabrízio de Royes Mello : > The attached patch implement this feature: > > CREATE SCHEMA [ IF NOT EXISTS ] schema_name [ AUTHORIZATION user_name ] [ > schema_element [ ... ] ] > CREATE SCHEMA [ IF NOT EXISTS ] AUTHORIZATION user_name [ schema_element [ > ... ] ] > > Now, PostgreSQL don't

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-16 Thread Fabrízio de Royes Mello
2012/8/16 David E. Wheeler > On Aug 16, 2012, at 10:36 AM, Fabrízio de Royes Mello wrote: > > > The attached patch implement this feature: > > > > CREATE SCHEMA [ IF NOT EXISTS ] schema_name [ AUTHORIZATION user_name ] > [ schema_element [ ... ] ] > > CREATE SCHEMA [ IF NOT EXISTS ] AUTHORIZATION

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-16 Thread David E. Wheeler
On Aug 16, 2012, at 10:36 AM, Fabrízio de Royes Mello wrote: > The attached patch implement this feature: > > CREATE SCHEMA [ IF NOT EXISTS ] schema_name [ AUTHORIZATION user_name ] [ > schema_element [ ... ] ] > CREATE SCHEMA [ IF NOT EXISTS ] AUTHORIZATION user_name [ schema_element [ > ... ]

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-16 Thread Andrew Dunstan
On 08/16/2012 01:36 PM, Fabrízio de Royes Mello wrote: 2012/8/15 David E. Wheeler > On Aug 15, 2012, at 11:31 AM, Fabrízio de Royes Mello wrote: >> Is there any reason not to add $subject? Would it be difficult? > > Looking to the source code I

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-16 Thread Fabrízio de Royes Mello
2012/8/15 David E. Wheeler > On Aug 15, 2012, at 11:31 AM, Fabrízio de Royes Mello wrote: > > >> Is there any reason not to add $subject? Would it be difficult? > > > > Looking to the source code I think this feature isn't hard to > implement... I'm writing a little path to do that and I'll send

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-15 Thread David E. Wheeler
On Aug 15, 2012, at 11:31 AM, Fabrízio de Royes Mello wrote: >> Is there any reason not to add $subject? Would it be difficult? > > Looking to the source code I think this feature isn't hard to implement... > I'm writing a little path to do that and I'll send soon... Cool, thanks! David --

Re: [HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-15 Thread Fabrízio de Royes Mello
2012/8/15 David E. Wheeler > Hackers, > > Is there any reason not to add $subject? Would it be difficult? Looking to the source code I think this feature isn't hard to implement... I'm writing a little path to do that and I'll send soon... > Would save me having to write a DO statement every

[HACKERS] CREATE SCHEMA IF NOT EXISTS

2012-08-15 Thread David E. Wheeler
Hackers, Is there any reason not to add $subject? Would it be difficult? Would save me having to write a DO statement every time I needed it (which in migration scripts is fairly often). Thanks, David -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to