Re: CREATE IF NOT EXISTS INDEX

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE IF NOT EXISTS INDEX
Date: 2014-10-01 01:03:24
Message-ID: CAFcNs+pf5HqZovDyCqMLC4+Xe2mtt18kKwYB3P4KjmpQkoSnNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 30, 2014 at 9:12 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
>
> On 09/30/2014 04:58 PM, Fabrízio de Royes Mello wrote:
> > On Tue, Sep 30, 2014 at 8:47 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> >>
> >> On 09/30/2014 04:16 PM, Andres Freund wrote:
> >>> On 2014-09-30 16:03:01 -0700, Josh Berkus wrote:
> >>>> On 09/30/2014 03:53 PM, Andres Freund wrote:
> >>>>> Good point. I think it's fair enough to only allow CINE on named
> >>>>> indexes.
> >>>>
> >>>> On the other hand, the way we form system-generated names is
> > predicable,
> >>>> so I think it would be perfectly OK to include them. Desirable, in
> > fact.
> >>>
> >>> It's not really that predicable. Think about expression indexes. They
> >>> also don't contain information about opclasses et all.
> >>>
> >>> Seems like pit of hairy semantics.
> >>>
> >>>> Not that I'm a fan of omitting the name ...
> >>>
> >>> Me neither.
> >>
> >> I'd be OK with a CINE which required you to name the index.
> >>
> >> How does your patch work at present, Fabrizio?
> >>
> >
> > My patch will work just if you name the index, because postgres
generates a
> > index name that doesn't exists.
> >
> > I don't check to a name if we use IF NOT EXISTS, but I can add this
check.
>
> The consensus is that we don't want IF NOT EXISTS to work for
> automatically generated index names. For that reason, we'd want it to
> error out if someone does this:
>
> CREATE INDEX IF NOT EXISTS ON table(col);
>
> My suggestion for the error message:
>
> "IF NOT EXISTS requires that you name the index."
>

Done.

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello

Attachment Content-Type Size
create_index_if_not_exists_v2.patch text/x-diff 11.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-10-01 01:22:28 Re: CREATE IF NOT EXISTS INDEX
Previous Message Mark Wong 2014-10-01 00:39:49 crash from pfree and brin index