aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/typecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/typecmds.c')
-rw-r--r--src/backend/commands/typecmds.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 1d3077cc324..5fa2ac6bc90 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.136 2009/07/28 02:56:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.137 2009/07/30 02:45:36 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -867,22 +867,11 @@ DefineDomain(CreateDomainStmt *stmt)
*/
foreach(listptr, schema)
{
- Node *newConstraint = lfirst(listptr);
- Constraint *constr;
-
- /* Check for unsupported constraint types */
- if (IsA(newConstraint, FkConstraint))
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("foreign key constraints not possible for domains")));
+ Constraint *constr = lfirst(listptr);
- /* otherwise it should be a plain Constraint */
- if (!IsA(newConstraint, Constraint))
+ if (!IsA(constr, Constraint))
elog(ERROR, "unrecognized node type: %d",
- (int) nodeTag(newConstraint));
-
- constr = (Constraint *) newConstraint;
-
+ (int) nodeTag(constr));
switch (constr->contype)
{
case CONSTR_DEFAULT:
@@ -995,6 +984,12 @@ DefineDomain(CreateDomainStmt *stmt)
errmsg("primary key constraints not possible for domains")));
break;
+ case CONSTR_FOREIGN:
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("foreign key constraints not possible for domains")));
+ break;
+
case CONSTR_ATTR_DEFERRABLE:
case CONSTR_ATTR_NOT_DEFERRABLE:
case CONSTR_ATTR_DEFERRED:
@@ -1849,13 +1844,6 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
/* Check it's a domain and check user has permission for ALTER DOMAIN */
checkDomainOwner(tup, typename);
- /* Check for unsupported constraint types */
- if (IsA(newConstraint, FkConstraint))
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("foreign key constraints not possible for domains")));
-
- /* otherwise it should be a plain Constraint */
if (!IsA(newConstraint, Constraint))
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(newConstraint));
@@ -1880,6 +1868,12 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
errmsg("primary key constraints not possible for domains")));
break;
+ case CONSTR_FOREIGN:
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("foreign key constraints not possible for domains")));
+ break;
+
case CONSTR_ATTR_DEFERRABLE:
case CONSTR_ATTR_NOT_DEFERRABLE:
case CONSTR_ATTR_DEFERRED:
@@ -2188,23 +2182,23 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
/*
* Assign or validate constraint name
*/
- if (constr->name)
+ if (constr->conname)
{
if (ConstraintNameIsUsed(CONSTRAINT_DOMAIN,
domainOid,
domainNamespace,
- constr->name))
+ constr->conname))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("constraint \"%s\" for domain \"%s\" already exists",
- constr->name, domainName)));
+ constr->conname, domainName)));
}
else
- constr->name = ChooseConstraintName(domainName,
- NULL,
- "check",
- domainNamespace,
- NIL);
+ constr->conname = ChooseConstraintName(domainName,
+ NULL,
+ "check",
+ domainNamespace,
+ NIL);
/*
* Convert the A_EXPR in raw_expr into an EXPR
@@ -2284,7 +2278,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
/*
* Store the constraint in pg_constraint
*/
- CreateConstraintEntry(constr->name, /* Constraint Name */
+ CreateConstraintEntry(constr->conname, /* Constraint Name */
domainNamespace, /* namespace */
CONSTRAINT_CHECK, /* Constraint Type */
false, /* Is Deferrable */