From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Implement ALTER TABLE ADD UNIQUE/PRIMARY KEY USING INDEX. |
Date: | 2011-01-25 20:43:43 |
Message-ID: | E1Phpjr-0005er-Vw@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-01-25 22:52:31 | pgsql: Replace pg_class.relhasexclusion with pg_index.indisexclusion. |
Previous Message | Magnus Hagander | 2011-01-25 09:51:06 | pgsql: Typo fix for MemSet size. |