LIKE INCLUDING COMMENTS code is a flight of fancy - Mailing list pgsql-hackers

From Tom Lane
Subject LIKE INCLUDING COMMENTS code is a flight of fancy
Date
Msg-id 3180.1261334488@sss.pgh.pa.us
Whole thread Raw
Responses Re: LIKE INCLUDING COMMENTS code is a flight of fancy  (Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>)
List pgsql-hackers
I just got done fixing a different problem in that area, and then I
noticed this:

regression=# create table src (f1 text);
CREATE TABLE
regression=# create index srclower on src(lower(f1));
CREATE INDEX
regression=# comment on column srclower.pg_expression_1 is 'a comment';
COMMENT
regression=# create index srcupper on src(upper(f1));
CREATE INDEX
regression=# comment on column srcupper.pg_expression_1 is 'another comment';
COMMENT
regression=# create table dest (like src including all);
ERROR:  relation "dest_key" already exists

The reason this fails is that the LIKE INCLUDING COMMENTS code thinks it
can use ChooseRelationName() in advance of actually creating the
indexes (cf. chooseIndexName in parse_utilcmd.c).  This does not work.
That function is only meant to select a name for an index that will be
created immediately --- otherwise, its logic for avoiding collisions
does not work at all.  As illustrated above.

I don't immediately see a fix for this that isn't a great deal more
trouble than the feature is worth.  I suggest that we might want to just
rip out the support for copying comments on indexes.  Or maybe even the
whole copy-comments aspect of it.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Removing pg_migrator limitations
Next
From: Tom Lane
Date:
Subject: Re: Removing pg_migrator limitations