pgsql: Implement ALTER TABLE ADD UNIQUE/PRIMARY KEY USING INDEX. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Implement ALTER TABLE ADD UNIQUE/PRIMARY KEY USING INDEX.
Date
Msg-id E1Phpjr-0005er-Vw@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Implement ALTER TABLE ADD UNIQUE/PRIMARY KEY USING INDEX.

This feature allows a unique or pkey constraint to be created using an
already-existing unique index.  While the constraint isn't very
functionally different from the bare index, it's nice to be able to do that
for documentation purposes.  The main advantage over just issuing a plain
ALTER TABLE ADD UNIQUE/PRIMARY KEY is that the index can be created with
CREATE INDEX CONCURRENTLY, so that there is not a long interval where the
table is locked against updates.

On the way, refactor some of the code in DefineIndex() and index_create()
so that we don't have to pass through those functions in order to create
the index constraint's catalog entries.  Also, in parse_utilcmd.c, pass
around the ParseState pointer in struct CreateStmtContext to save on
notation, and add error location pointers to some error reports that didn't
have one before.

Gurjeet Singh, reviewed by Steve Singer and Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=88452d5ba6b3e8ad49133ac1a660ce0725710f8c

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml          |   79 +++++-
src/backend/catalog/index.c                |  442 ++++++++++++++++++++++------
src/backend/catalog/toasting.c             |   10 +-
src/backend/commands/indexcmds.c           |  149 +---------
src/backend/commands/tablecmds.c           |   82 +++++
src/backend/nodes/copyfuncs.c              |    2 +
src/backend/nodes/equalfuncs.c             |    2 +
src/backend/nodes/outfuncs.c               |    4 +
src/backend/parser/gram.y                  |   36 +++
src/backend/parser/parse_utilcmd.c         |  311 +++++++++++++++-----
src/include/catalog/index.h                |   17 +-
src/include/nodes/parsenodes.h             |    9 +
src/test/regress/expected/create_index.out |   37 +++
src/test/regress/sql/create_index.sql      |   26 ++
14 files changed, 911 insertions(+), 295 deletions(-)


pgsql-committers by date:

Previous
From: Magnus Hagander
Date:
Subject: pgsql: Typo fix for MemSet size.
Next
From: noreply@github.com
Date:
Subject: [PGBuildFarm/server-code] ffe3a5: remove options not used in failures case