Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements
Date
Msg-id 20140401043434.GP4582@tamriel.snowman.net
Whole thread Raw
In response to Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements  (Michael Paquier <michael.paquier@gmail.com>)
Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
* Michael Paquier (michael.paquier@gmail.com) wrote:
> On Tue, Apr 1, 2014 at 7:28 AM, Fabrízio de Royes Mello
> <fabriziomello@gmail.com> 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 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
> default for login is NOLOGIN, the user test should not be able to log
> in the server.

That's more-or-less the behavior we're trying to work out.  I've been
meaning to go back and look at what we've been doing with the existing
COR cases and just haven't gotten to it yet.  The pertinent question
being if we assume the user intended for the values not specified to be
reset to their defaults, or not.

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.  Of course, were a user to use 'drop if exists'
followed by a 'create', they'd get the same behavior..  However, 'create
if not exists' would leave the sequence alone, but in a potentially
unknown state.
Thanks,
    Stephen

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements
Next
From: Fabrízio de Royes Mello
Date:
Subject: Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements