Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-10-03 Thread Heikki Linnakangas
On 10/03/2014 05:38 AM, Fabrízio de Royes Mello wrote: On Thu, Oct 2, 2014 at 9:38 PM, Marti Raudsepp wrote: The documentation claims: CREATE [ IF NOT EXISTS ] SEQUENCE name But grammar implements it the other way around: CREATE SEQUENCE IF NOT EXISTS name; You are correct. Fix attached. Th

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-10-03 Thread Marko Tiikkaja
On 10/3/14, 4:38 AM, Fabrízio de Royes Mello wrote: On Thu, Oct 2, 2014 at 9:38 PM, Marti Raudsepp wrote: On Tue, Aug 26, 2014 at 4:20 PM, Heikki Linnakangas wrote: On 04/14/2014 10:31 PM, Fabrízio de Royes Mello wrote: The attached patch contains CINE for sequences. I just strip this code

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-10-02 Thread Fabrízio de Royes Mello
On Thu, Oct 2, 2014 at 9:38 PM, Marti Raudsepp wrote: > > On Tue, Aug 26, 2014 at 4:20 PM, Heikki Linnakangas > wrote: > > On 04/14/2014 10:31 PM, Fabrízio de Royes Mello wrote: > >> The attached patch contains CINE for sequences. > >> > >> I just strip this code from the patch rejected before. >

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-10-02 Thread Marti Raudsepp
On Tue, Aug 26, 2014 at 4:20 PM, Heikki Linnakangas wrote: > On 04/14/2014 10:31 PM, Fabrízio de Royes Mello wrote: >> The attached patch contains CINE for sequences. >> >> I just strip this code from the patch rejected before. > > Committed with minor changes Hmm, the CommitFest app lists Marko

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-08-26 Thread Fabrízio de Royes Mello
On Tue, Aug 26, 2014 at 10:20 AM, Heikki Linnakangas < hlinnakan...@vmware.com> wrote: > On 04/14/2014 10:31 PM, Fabrízio de Royes Mello wrote: > >> On Tue, Apr 1, 2014 at 2:46 PM, Robert Haas >> wrote: >> >>> >>> Where this is a bit more interesting is in the case of sequences, where > rese

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-08-26 Thread Heikki Linnakangas
On 04/14/2014 10:31 PM, Fabrízio de Royes Mello wrote: On Tue, Apr 1, 2014 at 2:46 PM, Robert Haas wrote: Where this is a bit more interesting is in the case of sequences, where resetting the sequence to zero may cause further inserts into an existing table to fail. Yeah. Sequences do have

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-04-14 Thread Fabrízio de Royes Mello
On Tue, Apr 1, 2014 at 2:46 PM, Robert Haas wrote: > > >> Where this is a bit more interesting is in the case of sequences, where > >> resetting the sequence to zero may cause further inserts into an > >> existing table to fail. > > > > Yeah. Sequences do have contained data, which makes COR hard

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-04-01 Thread Fabrízio de Royes Mello
On Tue, Apr 1, 2014 at 2:46 PM, Robert Haas wrote: > On Tue, Apr 1, 2014 at 10:03 AM, Tom Lane wrote: > > I'm willing to bend that to the extent of saying that COR leaves in place > > subsidiary properties that you might add *with additional statements* --- > > for example, foreign keys for a ta

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-04-01 Thread Robert Haas
On Tue, Apr 1, 2014 at 10:03 AM, Tom Lane wrote: > I'm willing to bend that to the extent of saying that COR leaves in place > subsidiary properties that you might add *with additional statements* --- > for example, foreign keys for a table, or privilege grants for a role. > But the properties of

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-04-01 Thread Tom Lane
Stephen Frost writes: > * Michael Paquier (michael.paqu...@gmail.com) wrote: >> Except if I am missing something, the second query means that it is >> going to replace the existing user test with a new one, with the >> settings specified in the 2nd query, all being default values. As the >> defaul

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Michael Paquier
On Tue, Apr 1, 2014 at 1:34 PM, Stephen Frost wrote: > * Michael Paquier (michael.paqu...@gmail.com) wrote: >> On Tue, Apr 1, 2014 at 7:28 AM, Fabrízio de Royes Mello >> wrote: >> > Think about the statements below: >> > >> > CREATE ROLE test NOLOGIN; >> > CREATE OR REPLACE ROLE test; >> > >> > I

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Fabrízio de Royes Mello
On Tue, Apr 1, 2014 at 1:14 AM, Michael Paquier wrote: > > On Tue, Apr 1, 2014 at 7:28 AM, Fabrízio de Royes Mello > wrote: > > Think about the statements below: > > > > CREATE ROLE test NOLOGIN; > > CREATE OR REPLACE ROLE test; > > > > If we execute the statements above the result should be the

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Stephen Frost
* Michael Paquier (michael.paqu...@gmail.com) wrote: > On Tue, Apr 1, 2014 at 7:28 AM, Fabrízio de Royes Mello > wrote: > > Think about the statements below: > > > > CREATE ROLE test NOLOGIN; > > CREATE OR REPLACE ROLE test; > > > > If we execute the statements above the result should be the role

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Michael Paquier
On Tue, Apr 1, 2014 at 7:28 AM, Fabrízio de Royes Mello wrote: > Think about the statements below: > > CREATE ROLE test NOLOGIN; > CREATE OR REPLACE ROLE test; > > If we execute the statements above the result should be the role 'test' can > login. Correct? Except if I am missing something, the se

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Fabrízio de Royes Mello
On Mon, Mar 31, 2014 at 5:46 PM, Stephen Frost wrote: > > * Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > > Because they maintain user data? > > Eh? You mean like the sequence #? Yes, I'd expect 'CREATE OR REPLACE > SEQUENCE' to want a minvalue or something on a 'replace' case to en

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Stephen Frost
* Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > Because they maintain user data? Eh? You mean like the sequence #? Yes, I'd expect 'CREATE OR REPLACE SEQUENCE' to want a minvalue or something on a 'replace' case to ensure that it doesn't roll backwards unless explicitly asked for.

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Fabrízio de Royes Mello
On Mon, Mar 31, 2014 at 5:00 PM, Stephen Frost wrote: > > * Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > > On Mon, Mar 31, 2014 at 4:52 PM, Stephen Frost wrote: > > > > > > * Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > > > > - CREATE SEQUENCE [ IF NOT EXISTS ] > > > >

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Stephen Frost
* Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > On Mon, Mar 31, 2014 at 4:52 PM, Stephen Frost wrote: > > > > * Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > > > - CREATE SEQUENCE [ IF NOT EXISTS ] > > > - CREATE DOMAIN [ IF NOT EXISTS ] > > > - CREATE EVENT TRIGGER [ IF

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Fabrízio de Royes Mello
On Mon, Mar 31, 2014 at 4:52 PM, Stephen Frost wrote: > > * Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > > - CREATE SEQUENCE [ IF NOT EXISTS ] > > - CREATE DOMAIN [ IF NOT EXISTS ] > > - CREATE EVENT TRIGGER [ IF NOT EXISTS ] > > - CREATE ROLE [ IF NOT EXISTS ] > > > > Seems that no

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-31 Thread Stephen Frost
* Fabrízio de Royes Mello (fabriziome...@gmail.com) wrote: > - CREATE SEQUENCE [ IF NOT EXISTS ] > - CREATE DOMAIN [ IF NOT EXISTS ] > - CREATE EVENT TRIGGER [ IF NOT EXISTS ] > - CREATE ROLE [ IF NOT EXISTS ] > > Seems that no one reviewed this part or was rejected with others? Why don't those f

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-26 Thread Fabrízio de Royes Mello
On Sun, Mar 2, 2014 at 1:04 AM, Fabrízio de Royes Mello < fabriziome...@gmail.com> wrote: > > On Sat, Mar 1, 2014 at 7:39 PM, Tom Lane wrote: > > > > =?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > > > On Sat, Mar 1, 2014 at 2:11 PM, Tom Lane wrote: > > >> [ re schema upgrade scenarios ] >

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-01 Thread Fabrízio de Royes Mello
On Sat, Mar 1, 2014 at 7:39 PM, Tom Lane wrote: > > =?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > > On Sat, Mar 1, 2014 at 2:11 PM, Tom Lane wrote: > >> [ re schema upgrade scenarios ] > >> Why wouldn't COR semantics answer that requirement just as well, if not > >> better? > > > Just bec

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-01 Thread Fabrízio de Royes Mello
On Sat, Mar 1, 2014 at 2:11 PM, Tom Lane wrote: > > =?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > > On Sat, Jan 18, 2014 at 11:12 PM, Stephen Frost wrote: > >> Fabrízio, can you clarify the use-case for things like CREATE AGGREGATE > >> to have IF NOT EXISTS rather than OR REPLACE, or if

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-01 Thread Tom Lane
=?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > On Sat, Mar 1, 2014 at 2:11 PM, Tom Lane wrote: >> [ re schema upgrade scenarios ] >> Why wouldn't COR semantics answer that requirement just as well, if not >> better? > Just because it will replace the object content... and in some cases thi

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-03-01 Thread Tom Lane
=?ISO-8859-1?Q?Fabr=EDzio_de_Royes_Mello?= writes: > On Sat, Jan 18, 2014 at 11:12 PM, Stephen Frost wrote: >> Fabrízio, can you clarify the use-case for things like CREATE AGGREGATE >> to have IF NOT EXISTS rather than OR REPLACE, or if there is a reason >> why both should exist? Complicating o

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2014-02-28 Thread Fabrízio de Royes Mello
On Sat, Jan 18, 2014 at 11:12 PM, Stephen Frost wrote: > > Fabrízio, can you clarify the use-case for things like CREATE AGGREGATE > to have IF NOT EXISTS rather than OR REPLACE, or if there is a reason > why both should exist? Complicating our CREATE options is not something > we really wish to

[HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-09-10 Thread Pavel Stehule
I tested this patch and it is not patchable now. Please, can you fix patch? Regards Pavel

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-07-26 Thread Karol Trzcionka
W dniu 26.07.2013 02:44, Fabrízio de Royes Mello pisze: > Should be... I fix that in attached patch. Hello, as I can see there are more inconsistent places. First style: OperatorCreate --- Second style: ProcedureCreate TypeCreate DefineTSParser DefineType DefineEnum --- Third style: CreateCast Defi

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-07-24 Thread Karol Trzcionka
Hello, patch works fine but is there any reason to comparing each ifNotExists in different way? i.e. ProcedureCreate if (!ifNotExists) ... else { ... return } TypeCreate if (ifNotExists) { ... return } ... --- Shouldn't it be more consistent? Regards, Karol -- Sent via pgsql-hackers mailing

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-07-14 Thread Martijn van Oosterhout
On Sun, Jul 14, 2013 at 03:36:09AM -0300, Fabrízio de Royes Mello wrote: > > Next, changes in src/backend, starting with parser changes: the patch > > adds "IF_P NOT EXISTS" variants for various productions. For example: > > I think opt_if_not_exists should be used for the others as well. > > >

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-29 Thread Fabrízio de Royes Mello
On Mon, Jun 24, 2013 at 8:05 AM, Andres Freund wrote: > > > I'd argue if we go that way - which seems to be a good idea - we really > ought to make a complete pass and add it to all commands where it's > currently missing. > Yeah... this is my purpose, but I decide do that in two steps. First wit

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-29 Thread Fabrízio de Royes Mello
On Thu, Jun 20, 2013 at 1:24 PM, Peter Eisentraut wrote: > On 6/20/13 11:04 AM, Robert Haas wrote: > > I kind of don't see the point of having IF NOT EXISTS for things that > > have OR REPLACE, and am generally in favor of implementing OR REPLACE > > rather than IF NOT EXISTS where possible. > >

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-24 Thread Andres Freund
On 2013-06-12 14:29:59 -0300, Fabrízio de Royes Mello wrote: > On Fri, May 24, 2013 at 12:22 PM, Fabrízio de Royes Mello < > fabriziome...@gmail.com> wrote: > > > Hi all, > > > > I working in a patch to include support of "IF NOT EXISTS" into "CREATE" > > statements that not have it yet. > > > > I

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-20 Thread Peter Eisentraut
On 6/20/13 11:04 AM, Robert Haas wrote: > I kind of don't see the point of having IF NOT EXISTS for things that > have OR REPLACE, and am generally in favor of implementing OR REPLACE > rather than IF NOT EXISTS where possible. I tend to agree. >> > Btw., I also want REPLACE BUT DO NOT CREATE. >

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-20 Thread Robert Haas
On Wed, Jun 12, 2013 at 3:00 PM, Peter Eisentraut wrote: > On 6/12/13 1:29 PM, Fabrízio de Royes Mello wrote: >> The attached patch add support to "IF NOT EXISTS" to "CREATE" statements >> listed below: >> >> - CREATE AGGREGATE [ IF NOT EXISTS ] ... >> - CREATE CAST [ IF NOT EXISTS ] ... >> - CREA

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-20 Thread Amit Langote
On Thu, Jun 20, 2013 at 9:48 PM, Fabrízio de Royes Mello wrote: > > On Thu, Jun 20, 2013 at 1:52 AM, Amit Langote > wrote: >> >> Is it possible to: >> >> CREATE [ OR REPLACE | IF NOT EXISTS ] OPERATOR CLASS >> >> I am in a situation where I need to conditionally create an operator >> class (that

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-20 Thread Fabrízio de Royes Mello
On Thu, Jun 20, 2013 at 1:52 AM, Amit Langote wrote: > > Is it possible to: > > CREATE [ OR REPLACE | IF NOT EXISTS ] OPERATOR CLASS > > I am in a situation where I need to conditionally create an operator > class (that is, create only if already does not exist). > > [...] > The intention is cove

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-19 Thread Amit Langote
On Wed, Jun 19, 2013 at 12:45 PM, Fabrízio de Royes Mello wrote: > On Mon, Jun 17, 2013 at 11:33 PM, Peter Eisentraut wrote: >> >> Replace/alter the object if it already exists, but fail if it does not >> exist. >> >> The complete set of variants is: >> >> - object does not exist: >> >> - pro

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-18 Thread Fabrízio de Royes Mello
On Mon, Jun 17, 2013 at 11:33 PM, Peter Eisentraut wrote: > > Replace/alter the object if it already exists, but fail if it does not > exist. > > The complete set of variants is: > > - object does not exist: > > - proceed (normal CREATE) > - error (my above description) > > - object exists

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-18 Thread Fabrízio de Royes Mello
On Mon, Jun 17, 2013 at 12:36 AM, Robins Tharakan wrote: > Hi, > > Did some basic checks on this patch. List-wise feedback below. > > [...] > > Dear Robins, Thanks for your review. I attach your considerations to Commit Fest [1]. Regards, [1] https://commitfest.postgresql.org/action/patch_view

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-17 Thread Peter Eisentraut
On Wed, 2013-06-12 at 16:31 -0300, Fabrízio de Royes Mello wrote: > > Btw., I also want REPLACE BUT DO NOT CREATE. > > Can you explain more about it? > Replace/alter the object if it already exists, but fail if it does not exist. The complete set of variants is: - object does not exist: -

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-16 Thread Robins Tharakan
Hi, Did some basic checks on this patch. List-wise feedback below. - Removed unnecessary extra-lines: Yes - Cleanly applies to Git-Head: Yes - Documentation Updated: Yes - Tests Updated: Yes - All tests pass: Yes. (But see Note below) - Does it Work (CREATE AGGREGATE): Yes - Does it Work (CREATE

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-12 Thread Tom Dunstan
On 13 June 2013 04:30, Peter Eisentraut wrote: > I'm wondering where "IF NOT EXISTS" and "OR REPLACE" will meet. > CREATE OR REPLACE (or ALTER / UPDATE ?) would definitely be useful for enums, where it would be nice if we could teach an ORM to generate DDL based on the current values of the enum

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-12 Thread Fabrízio de Royes Mello
On Wed, Jun 12, 2013 at 4:00 PM, Peter Eisentraut wrote: > > > I'm wondering where "IF NOT EXISTS" and "OR REPLACE" will meet. > > For example, why doesn't your list include CREATE FUNCTION? > > I have on my personal todo list to add "OR REPLACE" support to CREATE > AGGREGATE and CREATE OPERATOR.

Re: [HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-06-12 Thread Peter Eisentraut
On 6/12/13 1:29 PM, Fabrízio de Royes Mello wrote: > The attached patch add support to "IF NOT EXISTS" to "CREATE" statements > listed below: > > - CREATE AGGREGATE [ IF NOT EXISTS ] ... > - CREATE CAST [ IF NOT EXISTS ] ... > - CREATE COLLATION [ IF NOT EXISTS ] ... > - CREATE OPERATOR [ IF NOT E

[HACKERS] Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

2013-05-24 Thread Fabrízio de Royes Mello
Hi all, I working in a patch to include support of "IF NOT EXISTS" into "CREATE" statements that not have it yet. I started with "DefineStmt" section from "src/backend/parser/gram.y": - CREATE AGGREGATE [ IF NOT EXISTS ] ... - CREATE OPERATOR [ IF NOT EXISTS ] ... - CREATE TYPE [ IF NOT EXISTS ]