Re: creating index names automatically? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: creating index names automatically?
Date
Msg-id 3390.1261335513@sss.pgh.pa.us
Whole thread Raw
In response to Re: creating index names automatically?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: creating index names automatically?  (Michael Glaesemann <grzm@seespotcode.net>)
List pgsql-hackers
I wrote:
> Although, having said that, I realize we just opened that can of worms
> with the exclusion-constraint patch:

> regression=# create table foo (f1 text, exclude (lower(f1) with =));
> NOTICE:  CREATE TABLE / EXCLUDE will create implicit index "foo_exclusion" for table "foo"
> CREATE TABLE

> The above behavior seems to need improvement already.

And poking further, CREATE TABLE LIKE INCLUDING INDEXES is another place
where we've already bought into automatically generating index names for
arbitrary non-constraint indexes.  And it's even dumber --- you get
names involving "_key" for indexes that aren't even unique.  So it seems
like we already have a bit of a problem here.

The first thoughts I have about this are:

* Use FigureColname to derive a name for an expression column, except
I'd be inclined to have the fallback case be "expr" not "?column?".

* Append "_index" not "_key" if it's not a constraint-related index.

I'm also a bit tempted to propose that we start using FigureColname
for the actual attribute names of expression indexes, instead of the
not terribly helpful "pg_expression_n" convention.  In this case we'd
have to append a number if necessary to make the name unique among the
column names of the index.

Comments?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Removing pg_migrator limitations
Next
From: Robert Haas
Date:
Subject: Re: Removing pg_migrator limitations