LIKE INCLUDING COMMENTS code is a flight of fancy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: LIKE INCLUDING COMMENTS code is a flight of fancy
Date: 2009-12-20 18:41:28
Message-ID: 3180.1261334488@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-12-20 18:49:00 Re: Removing pg_migrator limitations
Previous Message Bruce Momjian 2009-12-20 18:07:12 Re: Removing pg_migrator limitations