]> granicus.if.org Git - postgresql/commit
Fix dependencies generated during ALTER TABLE ADD CONSTRAINT USING INDEX.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 11 Aug 2012 16:51:30 +0000 (12:51 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 11 Aug 2012 16:51:30 +0000 (12:51 -0400)
commitca07d7ebe04de9225e7f14c8504539869c7e3ff0
tree460e0f8bcb2219ca57dcdea8089f74617f66e417
parente2af6537b5c81d9354e08896012cdd5c38bea311
Fix dependencies generated during ALTER TABLE ADD CONSTRAINT USING INDEX.

This command generated new pg_depend entries linking the index to the
constraint and the constraint to the table, which match the entries made
when a unique or primary key constraint is built de novo.  However, it did
not bother to get rid of the entries linking the index directly to the
table.  We had considered the issue when the ADD CONSTRAINT USING INDEX
patch was written, and concluded that we didn't need to get rid of the
extra entries.  But this is wrong: ALTER COLUMN TYPE wasn't expecting such
redundant dependencies to exist, as reported by Hubert Depesz Lubaczewski.
On reflection it seems rather likely to break other things as well, since
there are many bits of code that crawl pg_depend for one purpose or
another, and most of them are pretty naive about what relationships they're
expecting to find.  Fortunately it's not that hard to get rid of the extra
dependency entries, so let's do that.

Back-patch to 9.1, where ALTER TABLE ADD CONSTRAINT USING INDEX was added.
src/backend/catalog/index.c
src/backend/commands/tablecmds.c
src/include/catalog/index.h