mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
Support deferrable uniqueness constraints.
The current implementation fires an AFTER ROW trigger for each tuple that looks like it might be non-unique according to the index contents at the time of insertion. This works well as long as there aren't many conflicts, but won't scale to massive unique-key reassignments. Improving that case is a TODO item. Dean Rasheed
This commit is contained in:
doc/src/sgml
src
backend
access
bootstrap
catalog
commands
executor
nodes
parser
tcop
utils
bin
include
access
catalog
commands
executor
nodes
utils
test
regress
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.186 2009/07/16 06:33:42 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.187 2009/07/29 20:56:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -87,6 +87,8 @@ static bool relationHasPrimaryKey(Relation rel);
|
||||
* 'primary': mark the index as a primary key in the catalogs.
|
||||
* 'isconstraint': index is for a PRIMARY KEY or UNIQUE constraint,
|
||||
* so build a pg_constraint entry for it.
|
||||
* 'deferrable': constraint is DEFERRABLE.
|
||||
* 'initdeferred': constraint is INITIALLY DEFERRED.
|
||||
* 'is_alter_table': this is due to an ALTER rather than a CREATE operation.
|
||||
* 'check_rights': check for CREATE rights in the namespace. (This should
|
||||
* be true except when ALTER is deleting/recreating an index.)
|
||||
@@ -107,6 +109,8 @@ DefineIndex(RangeVar *heapRelation,
|
||||
bool unique,
|
||||
bool primary,
|
||||
bool isconstraint,
|
||||
bool deferrable,
|
||||
bool initdeferred,
|
||||
bool is_alter_table,
|
||||
bool check_rights,
|
||||
bool skip_build,
|
||||
@@ -447,7 +451,8 @@ DefineIndex(RangeVar *heapRelation,
|
||||
indexRelationId =
|
||||
index_create(relationId, indexRelationName, indexRelationId,
|
||||
indexInfo, accessMethodId, tablespaceId, classObjectId,
|
||||
coloptions, reloptions, primary, isconstraint,
|
||||
coloptions, reloptions, primary,
|
||||
isconstraint, deferrable, initdeferred,
|
||||
allowSystemTableMods, skip_build, concurrent);
|
||||
|
||||
return; /* We're done, in the standard case */
|
||||
@@ -465,7 +470,8 @@ DefineIndex(RangeVar *heapRelation,
|
||||
indexRelationId =
|
||||
index_create(relationId, indexRelationName, indexRelationId,
|
||||
indexInfo, accessMethodId, tablespaceId, classObjectId,
|
||||
coloptions, reloptions, primary, isconstraint,
|
||||
coloptions, reloptions, primary,
|
||||
isconstraint, deferrable, initdeferred,
|
||||
allowSystemTableMods, true, concurrent);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user