Index name different from constraint name

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Index name different from constraint name
Date: 2005-10-26 14:27:00
Message-ID: 20051026142700.GQ6026@ns.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Greetings,

Not entirely sure if this would be considered a 'bug' but it's
certainly annoying and creates some confusion. Basically, it's like
this:

test=> create table a (
test(> b int primary key
test(> );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "a_pkey" for table "a"
CREATE TABLE
test=> \d a
Table "sfrost.a"
Column | Type | Modifiers
--------+---------+-----------
b | integer | not null
Indexes:
"a_pkey" PRIMARY KEY, btree (b)

-- Now, attempt to rename the table, and associated stuff

test=> alter table a rename to c;
ALTER TABLE
test=> alter index a_pkey rename to c_pkey;
ALTER INDEX
test=> \d c
Table "sfrost.c"
Column | Type | Modifiers
--------+---------+-----------
b | integer | not null
Indexes:
"c_pkey" PRIMARY KEY, btree (b)

-- All looks good, but there's something hidden...

test=> \q

> pg_dump -s -n sfrost test
--
-- PostgreSQL database dump
--

[...]

CREATE TABLE c (
b integer NOT NULL
);

[...]

ALTER TABLE ONLY c
ADD CONSTRAINT a_pkey PRIMARY KEY (b);

[...]

--
-- PostgreSQL database dump complete
--

The *constraint* name isn't changed, and that's what pg_dump uses. Fair
enough on pg_dump's part, but it's very confusing that \d (or even \d++)
doesn't show the issue that's created by just renaming the index. It
would seem to me that \d can use its current format when the names are
the same, but if they're different it should display the index and the
constraint seperately.

Sorry, havn't really got time to write a patch at the moment. Hopefully
someone might have a minute to look into it tho.

Thanks,

Stephen

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-10-26 14:45:03 Re: BUG #1999: contrib/spi doesn't receive the configured CFLAGS
Previous Message Kevin Grittner 2005-10-26 14:20:49 Re: BUG #1993: Adding/subtracting negative time