1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Determine the set of constraints applied to a domain at executor

startup, not in the parser; this allows ALTER DOMAIN to work correctly
with domain constraint operations stored in rules.  Rod Taylor;
code review by Tom Lane.
This commit is contained in:
Tom Lane
2003-02-03 21:15:45 +00:00
parent 464598b637
commit 3752e85bad
24 changed files with 524 additions and 339 deletions

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.238 2003/01/23 23:38:56 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.239 2003/02/03 21:15:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -933,29 +933,28 @@ _copyBooleanTest(BooleanTest *from)
}
/*
* _copyConstraintTest
* _copyCoerceToDomain
*/
static ConstraintTest *
_copyConstraintTest(ConstraintTest *from)
static CoerceToDomain *
_copyCoerceToDomain(CoerceToDomain *from)
{
ConstraintTest *newnode = makeNode(ConstraintTest);
CoerceToDomain *newnode = makeNode(CoerceToDomain);
COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(testtype);
COPY_STRING_FIELD(name);
COPY_STRING_FIELD(domname);
COPY_NODE_FIELD(check_expr);
COPY_SCALAR_FIELD(resulttype);
COPY_SCALAR_FIELD(resulttypmod);
COPY_SCALAR_FIELD(coercionformat);
return newnode;
}
/*
* _copyConstraintTestValue
* _copyCoerceToDomainValue
*/
static ConstraintTestValue *
_copyConstraintTestValue(ConstraintTestValue *from)
static CoerceToDomainValue *
_copyCoerceToDomainValue(CoerceToDomainValue *from)
{
ConstraintTestValue *newnode = makeNode(ConstraintTestValue);
CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
COPY_SCALAR_FIELD(typeId);
COPY_SCALAR_FIELD(typeMod);
@@ -2476,11 +2475,11 @@ copyObject(void *from)
case T_BooleanTest:
retval = _copyBooleanTest(from);
break;
case T_ConstraintTest:
retval = _copyConstraintTest(from);
case T_CoerceToDomain:
retval = _copyCoerceToDomain(from);
break;
case T_ConstraintTestValue:
retval = _copyConstraintTestValue(from);
case T_CoerceToDomainValue:
retval = _copyCoerceToDomainValue(from);
break;
case T_TargetEntry:
retval = _copyTargetEntry(from);

View File

@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.182 2003/01/23 23:38:56 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.183 2003/02/03 21:15:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -383,19 +383,25 @@ _equalBooleanTest(BooleanTest *a, BooleanTest *b)
}
static bool
_equalConstraintTest(ConstraintTest *a, ConstraintTest *b)
_equalCoerceToDomain(CoerceToDomain *a, CoerceToDomain *b)
{
COMPARE_NODE_FIELD(arg);
COMPARE_SCALAR_FIELD(testtype);
COMPARE_STRING_FIELD(name);
COMPARE_STRING_FIELD(domname);
COMPARE_NODE_FIELD(check_expr);
COMPARE_SCALAR_FIELD(resulttype);
COMPARE_SCALAR_FIELD(resulttypmod);
/*
* Special-case COERCE_DONTCARE, so that pathkeys can build coercion
* nodes that are equal() to both explicit and implicit coercions.
*/
if (a->coercionformat != b->coercionformat &&
a->coercionformat != COERCE_DONTCARE &&
b->coercionformat != COERCE_DONTCARE)
return false;
return true;
}
static bool
_equalConstraintTestValue(ConstraintTestValue *a, ConstraintTestValue *b)
_equalCoerceToDomainValue(CoerceToDomainValue *a, CoerceToDomainValue *b)
{
COMPARE_SCALAR_FIELD(typeId);
COMPARE_SCALAR_FIELD(typeMod);
@@ -1599,11 +1605,11 @@ equal(void *a, void *b)
case T_BooleanTest:
retval = _equalBooleanTest(a, b);
break;
case T_ConstraintTest:
retval = _equalConstraintTest(a, b);
case T_CoerceToDomain:
retval = _equalCoerceToDomain(a, b);
break;
case T_ConstraintTestValue:
retval = _equalConstraintTestValue(a, b);
case T_CoerceToDomainValue:
retval = _equalCoerceToDomainValue(a, b);
break;
case T_TargetEntry:
retval = _equalTargetEntry(a, b);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.194 2003/01/20 18:54:47 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.195 2003/02/03 21:15:44 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@@ -745,21 +745,20 @@ _outBooleanTest(StringInfo str, BooleanTest *node)
}
static void
_outConstraintTest(StringInfo str, ConstraintTest *node)
_outCoerceToDomain(StringInfo str, CoerceToDomain *node)
{
WRITE_NODE_TYPE("CONSTRAINTTEST");
WRITE_NODE_TYPE("COERCETODOMAIN");
WRITE_NODE_FIELD(arg);
WRITE_ENUM_FIELD(testtype, ConstraintTestType);
WRITE_STRING_FIELD(name);
WRITE_STRING_FIELD(domname);
WRITE_NODE_FIELD(check_expr);
WRITE_OID_FIELD(resulttype);
WRITE_INT_FIELD(resulttypmod);
WRITE_ENUM_FIELD(coercionformat, CoercionForm);
}
static void
_outConstraintTestValue(StringInfo str, ConstraintTestValue *node)
_outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
{
WRITE_NODE_TYPE("CONSTRAINTTESTVALUE");
WRITE_NODE_TYPE("COERCETODOMAINVALUE");
WRITE_OID_FIELD(typeId);
WRITE_INT_FIELD(typeMod);
@@ -1548,11 +1547,11 @@ _outNode(StringInfo str, void *obj)
case T_BooleanTest:
_outBooleanTest(str, obj);
break;
case T_ConstraintTest:
_outConstraintTest(str, obj);
case T_CoerceToDomain:
_outCoerceToDomain(str, obj);
break;
case T_ConstraintTestValue:
_outConstraintTestValue(str, obj);
case T_CoerceToDomainValue:
_outCoerceToDomainValue(str, obj);
break;
case T_TargetEntry:
_outTargetEntry(str, obj);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.146 2003/01/10 21:08:11 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.147 2003/02/03 21:15:44 tgl Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
@@ -635,29 +635,28 @@ _readBooleanTest(void)
}
/*
* _readConstraintTest
* _readCoerceToDomain
*/
static ConstraintTest *
_readConstraintTest(void)
static CoerceToDomain *
_readCoerceToDomain(void)
{
READ_LOCALS(ConstraintTest);
READ_LOCALS(CoerceToDomain);
READ_NODE_FIELD(arg);
READ_ENUM_FIELD(testtype, ConstraintTestType);
READ_STRING_FIELD(name);
READ_STRING_FIELD(domname);
READ_NODE_FIELD(check_expr);
READ_OID_FIELD(resulttype);
READ_INT_FIELD(resulttypmod);
READ_ENUM_FIELD(coercionformat, CoercionForm);
READ_DONE();
}
/*
* _readConstraintTestValue
* _readCoerceToDomainValue
*/
static ConstraintTestValue *
_readConstraintTestValue(void)
static CoerceToDomainValue *
_readCoerceToDomainValue(void)
{
READ_LOCALS(ConstraintTestValue);
READ_LOCALS(CoerceToDomainValue);
READ_OID_FIELD(typeId);
READ_INT_FIELD(typeMod);
@@ -900,10 +899,10 @@ parseNodeString(void)
return_value = _readNullTest();
else if (MATCH("BOOLEANTEST", 11))
return_value = _readBooleanTest();
else if (MATCH("CONSTRAINTTEST", 14))
return_value = _readConstraintTest();
else if (MATCH("CONSTRAINTTESTVALUE", 19))
return_value = _readConstraintTestValue();
else if (MATCH("COERCETODOMAIN", 14))
return_value = _readCoerceToDomain();
else if (MATCH("COERCETODOMAINVALUE", 19))
return_value = _readCoerceToDomainValue();
else if (MATCH("TARGETENTRY", 11))
return_value = _readTargetEntry();
else if (MATCH("RANGETBLREF", 11))