mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add exclusion constraints, which generalize the concept of uniqueness to
support any indexable commutative operator, not just equality. Two rows violate the exclusion constraint if "row1.col OP row2.col" is TRUE for each of the columns in the constraint. Jeff Davis, reviewed by Robert Haas
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.452 2009/11/20 20:38:10 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.453 2009/12/07 05:22:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2157,8 +2157,11 @@ _copyConstraint(Constraint *from)
|
||||
COPY_NODE_FIELD(raw_expr);
|
||||
COPY_STRING_FIELD(cooked_expr);
|
||||
COPY_NODE_FIELD(keys);
|
||||
COPY_NODE_FIELD(exclusions);
|
||||
COPY_NODE_FIELD(options);
|
||||
COPY_STRING_FIELD(indexspace);
|
||||
COPY_STRING_FIELD(access_method);
|
||||
COPY_NODE_FIELD(where_clause);
|
||||
COPY_NODE_FIELD(pktable);
|
||||
COPY_NODE_FIELD(fk_attrs);
|
||||
COPY_NODE_FIELD(pk_attrs);
|
||||
@ -2595,6 +2598,7 @@ _copyIndexStmt(IndexStmt *from)
|
||||
COPY_NODE_FIELD(indexParams);
|
||||
COPY_NODE_FIELD(options);
|
||||
COPY_NODE_FIELD(whereClause);
|
||||
COPY_NODE_FIELD(excludeOpNames);
|
||||
COPY_SCALAR_FIELD(unique);
|
||||
COPY_SCALAR_FIELD(primary);
|
||||
COPY_SCALAR_FIELD(isconstraint);
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.374 2009/11/20 20:38:10 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.375 2009/12/07 05:22:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1179,6 +1179,7 @@ _equalIndexStmt(IndexStmt *a, IndexStmt *b)
|
||||
COMPARE_NODE_FIELD(indexParams);
|
||||
COMPARE_NODE_FIELD(options);
|
||||
COMPARE_NODE_FIELD(whereClause);
|
||||
COMPARE_NODE_FIELD(excludeOpNames);
|
||||
COMPARE_SCALAR_FIELD(unique);
|
||||
COMPARE_SCALAR_FIELD(primary);
|
||||
COMPARE_SCALAR_FIELD(isconstraint);
|
||||
@ -2103,8 +2104,11 @@ _equalConstraint(Constraint *a, Constraint *b)
|
||||
COMPARE_NODE_FIELD(raw_expr);
|
||||
COMPARE_STRING_FIELD(cooked_expr);
|
||||
COMPARE_NODE_FIELD(keys);
|
||||
COMPARE_NODE_FIELD(exclusions);
|
||||
COMPARE_NODE_FIELD(options);
|
||||
COMPARE_STRING_FIELD(indexspace);
|
||||
COMPARE_STRING_FIELD(access_method);
|
||||
COMPARE_NODE_FIELD(where_clause);
|
||||
COMPARE_NODE_FIELD(pktable);
|
||||
COMPARE_NODE_FIELD(fk_attrs);
|
||||
COMPARE_NODE_FIELD(pk_attrs);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.373 2009/11/28 00:46:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.374 2009/12/07 05:22:22 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@ -1798,6 +1798,7 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
|
||||
WRITE_NODE_FIELD(indexParams);
|
||||
WRITE_NODE_FIELD(options);
|
||||
WRITE_NODE_FIELD(whereClause);
|
||||
WRITE_NODE_FIELD(excludeOpNames);
|
||||
WRITE_BOOL_FIELD(unique);
|
||||
WRITE_BOOL_FIELD(primary);
|
||||
WRITE_BOOL_FIELD(isconstraint);
|
||||
@ -2378,6 +2379,7 @@ _outConstraint(StringInfo str, Constraint *node)
|
||||
WRITE_NODE_FIELD(keys);
|
||||
WRITE_NODE_FIELD(options);
|
||||
WRITE_STRING_FIELD(indexspace);
|
||||
/* access_method and where_clause not currently used */
|
||||
break;
|
||||
|
||||
case CONSTR_UNIQUE:
|
||||
@ -2385,6 +2387,16 @@ _outConstraint(StringInfo str, Constraint *node)
|
||||
WRITE_NODE_FIELD(keys);
|
||||
WRITE_NODE_FIELD(options);
|
||||
WRITE_STRING_FIELD(indexspace);
|
||||
/* access_method and where_clause not currently used */
|
||||
break;
|
||||
|
||||
case CONSTR_EXCLUSION:
|
||||
appendStringInfo(str, "EXCLUSION");
|
||||
WRITE_NODE_FIELD(exclusions);
|
||||
WRITE_NODE_FIELD(options);
|
||||
WRITE_STRING_FIELD(indexspace);
|
||||
WRITE_STRING_FIELD(access_method);
|
||||
WRITE_NODE_FIELD(where_clause);
|
||||
break;
|
||||
|
||||
case CONSTR_FOREIGN:
|
||||
|
Reference in New Issue
Block a user