diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-11-15 02:50:21 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-11-15 02:50:21 +0000 |
commit | 6b603e67dcd1a93a56f3c6b5f36fd8f08e2ee35d (patch) | |
tree | 5d4a4a590f20c0516bb380e6169114120be3d58f /src/include | |
parent | 2986aa6a668bce3cfb83606bb52e9d01ae66ad6c (diff) | |
download | postgresql-6b603e67dcd1a93a56f3c6b5f36fd8f08e2ee35d.tar.gz postgresql-6b603e67dcd1a93a56f3c6b5f36fd8f08e2ee35d.zip |
Add DOMAIN check constraints.
Rod Taylor
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/indexing.h | 5 | ||||
-rw-r--r-- | src/include/catalog/pg_constraint.h | 19 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 9 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 4 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 19 | ||||
-rw-r--r-- | src/include/optimizer/var.h | 3 | ||||
-rw-r--r-- | src/include/parser/parse_expr.h | 5 |
7 files changed, 52 insertions, 12 deletions
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index fce84e72ae9..4a76a27dec6 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: indexing.h,v 1.76 2002/10/18 20:33:57 tgl Exp $ + * $Id: indexing.h,v 1.77 2002/11/15 02:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,6 +40,7 @@ #define ConstraintNameNspIndex "pg_constraint_conname_nsp_index" #define ConstraintOidIndex "pg_constraint_oid_index" #define ConstraintRelidIndex "pg_constraint_conrelid_index" +#define ConstraintTypidIndex "pg_constraint_contypid_index" #define ConversionDefaultIndex "pg_conversion_default_index" #define ConversionNameNspIndex "pg_conversion_name_nsp_index" #define ConversionOidIndex "pg_conversion_oid_index" @@ -129,6 +130,8 @@ DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index on pg_class using btree(relname DECLARE_INDEX(pg_constraint_conname_nsp_index on pg_constraint using btree(conname name_ops, connamespace oid_ops)); /* This following index is not used for a cache and is not unique */ DECLARE_INDEX(pg_constraint_conrelid_index on pg_constraint using btree(conrelid oid_ops)); +/* This following index is not used for a cache and is not unique */ +DECLARE_INDEX(pg_constraint_contypid_index on pg_constraint using btree(contypid oid_ops)); DECLARE_UNIQUE_INDEX(pg_constraint_oid_index on pg_constraint using btree(oid oid_ops)); DECLARE_UNIQUE_INDEX(pg_conversion_default_index on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops, oid oid_ops)); DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index on pg_conversion using btree(conname name_ops, connamespace oid_ops)); diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h index ffe6a740ca8..80ff185579e 100644 --- a/src/include/catalog/pg_constraint.h +++ b/src/include/catalog/pg_constraint.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_constraint.h,v 1.4 2002/09/22 00:37:09 tgl Exp $ + * $Id: pg_constraint.h,v 1.5 2002/11/15 02:50:10 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -140,6 +140,15 @@ typedef FormData_pg_constraint *Form_pg_constraint; * the FKCONSTR_MATCH_xxx constants defined in parsenodes.h. */ +/* + * Used for constraint support functions where the + * and conrelid, contypid columns being looked up + */ +typedef enum CONSTRAINTCATEGORY { + CONSTRAINT_RELATION, + CONSTRAINT_DOMAIN, + CONSTRAINT_ASSERTION +} CONSTRAINTCATEGORY; /* * prototypes for functions in pg_constraint.c @@ -166,10 +175,10 @@ extern Oid CreateConstraintEntry(const char *constraintName, extern void RemoveConstraintById(Oid conId); -extern bool ConstraintNameIsUsed(Oid relId, Oid relNamespace, - const char *cname); -extern char *GenerateConstraintName(Oid relId, Oid relNamespace, - int *counter); +extern bool ConstraintNameIsUsed(CONSTRAINTCATEGORY conCat, Oid objId, Oid objNamespace, + const char *cname); +extern char *GenerateConstraintName(CONSTRAINTCATEGORY conCat, Oid objId, Oid objNamespace, + int *counter); extern bool ConstraintNameIsGenerated(const char *cname); #endif /* PG_CONSTRAINT_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index f62d1cb8159..f955815926d 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.77 2002/11/06 22:31:24 tgl Exp $ + * $Id: execnodes.h,v 1.78 2002/11/15 02:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -113,6 +113,13 @@ typedef struct ExprContext Datum *ecxt_aggvalues; /* precomputed values for Aggref nodes */ bool *ecxt_aggnulls; /* null flags for Aggref nodes */ + /* + * Carry the domain value through the executor for application + * in a domain constraint + */ + Datum domainValue_datum; + bool domainValue_isNull; + /* Functions to call back when ExprContext is shut down */ ExprContext_CB *ecxt_callbacks; } ExprContext; diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index cec75309210..112eac34680 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.122 2002/11/10 02:17:25 momjian Exp $ + * $Id: nodes.h,v 1.123 2002/11/15 02:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -171,6 +171,7 @@ typedef enum NodeTag T_ViewStmt, T_LoadStmt, T_CreateDomainStmt, + T_DomainConstraintValue, T_CreatedbStmt, T_DropdbStmt, T_VacuumStmt, @@ -231,6 +232,7 @@ typedef enum NodeTag T_NullTest, T_BooleanTest, T_ConstraintTest, + T_ConstraintTestValue, T_CaseExpr, T_CaseWhen, T_FkConstraint, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 962452992e8..1198a81de5e 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.213 2002/11/13 00:44:09 momjian Exp $ + * $Id: parsenodes.h,v 1.214 2002/11/15 02:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -285,10 +285,27 @@ typedef struct ConstraintTest Node *arg; /* input expression */ ConstraintTestType testtype; /* test type */ char *name; /* name of constraint (for error msgs) */ + char *domname; /* name of domain (for error messages) */ Node *check_expr; /* for CHECK test, a boolean expression */ } ConstraintTest; /* + * Placeholder node for the value to be processed by a domains + * check constraint. + */ +typedef struct DomainConstraintValue +{ + NodeTag type; +} DomainConstraintValue; + +typedef struct ConstraintTestValue +{ + NodeTag type; + Oid typeId; + int32 typeMod; +} ConstraintTestValue; + +/* * ColumnDef - column definition (used in various creates) * * If the column has a default value, we may have the value expression diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index a153c4d0570..68ffc8e373a 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: var.h,v 1.21 2002/06/20 20:29:51 momjian Exp $ + * $Id: var.h,v 1.22 2002/11/15 02:50:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,7 @@ extern bool contain_var_reference(Node *node, int varno, int varattno, int levelsup); extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup); extern bool contain_var_clause(Node *node); +extern bool contain_var_tuple_clause(Node *node); extern List *pull_var_clause(Node *node, bool includeUpperVars); extern Node *flatten_join_alias_vars(Node *node, List *rtable, bool force); diff --git a/src/include/parser/parse_expr.h b/src/include/parser/parse_expr.h index a7af335dd12..bcf84912acf 100644 --- a/src/include/parser/parse_expr.h +++ b/src/include/parser/parse_expr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_expr.h,v 1.28 2002/06/20 20:29:51 momjian Exp $ + * $Id: parse_expr.h,v 1.29 2002/11/15 02:50:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,8 @@ extern int max_expr_depth; extern bool Transform_null_equals; -extern Node *transformExpr(ParseState *pstate, Node *expr); + +extern Node *transformExpr(ParseState *pstate, Node *expr, ConstraintTestValue *domVal); extern Oid exprType(Node *expr); extern int32 exprTypmod(Node *expr); extern bool exprIsLengthCoercion(Node *expr, int32 *coercedTypmod); |