mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +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:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.56 2003/01/28 22:13:29 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.57 2003/02/03 21:15:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -540,6 +540,14 @@ clause_selectivity(Query *root,
|
||||
varRelid,
|
||||
jointype);
|
||||
}
|
||||
else if (IsA(clause, CoerceToDomain))
|
||||
{
|
||||
/* Not sure this case is needed, but it can't hurt */
|
||||
s1 = clause_selectivity(root,
|
||||
(Node *) ((CoerceToDomain *) clause)->arg,
|
||||
varRelid,
|
||||
jointype);
|
||||
}
|
||||
|
||||
#ifdef SELECTIVITY_DEBUG
|
||||
elog(DEBUG3, "clause_selectivity: s1 %f", s1);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.59 2002/12/12 15:49:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.60 2003/02/03 21:15:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -185,9 +185,10 @@ expand_targetlist(List *tlist, int command_type,
|
||||
true, /* isnull */
|
||||
att_tup->attbyval);
|
||||
if (!att_tup->attisdropped)
|
||||
new_expr = coerce_type_constraints(new_expr,
|
||||
atttype,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
new_expr = coerce_to_domain(new_expr,
|
||||
InvalidOid,
|
||||
atttype,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
break;
|
||||
case CMD_UPDATE:
|
||||
/* Insert NULLs for dropped columns */
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.125 2003/01/20 18:54:54 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.126 2003/02/03 21:15:44 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -2030,7 +2030,7 @@ expression_tree_walker(Node *node,
|
||||
case T_Var:
|
||||
case T_Const:
|
||||
case T_Param:
|
||||
case T_ConstraintTestValue:
|
||||
case T_CoerceToDomainValue:
|
||||
case T_RangeTblRef:
|
||||
/* primitive node types with no subnodes */
|
||||
break;
|
||||
@@ -2148,10 +2148,8 @@ expression_tree_walker(Node *node,
|
||||
return walker(((NullTest *) node)->arg, context);
|
||||
case T_BooleanTest:
|
||||
return walker(((BooleanTest *) node)->arg, context);
|
||||
case T_ConstraintTest:
|
||||
if (walker(((ConstraintTest *) node)->arg, context))
|
||||
return true;
|
||||
return walker(((ConstraintTest *) node)->check_expr, context);
|
||||
case T_CoerceToDomain:
|
||||
return walker(((CoerceToDomain *) node)->arg, context);
|
||||
case T_TargetEntry:
|
||||
return walker(((TargetEntry *) node)->expr, context);
|
||||
case T_Query:
|
||||
@@ -2374,7 +2372,7 @@ expression_tree_mutator(Node *node,
|
||||
case T_Var:
|
||||
case T_Const:
|
||||
case T_Param:
|
||||
case T_ConstraintTestValue:
|
||||
case T_CoerceToDomainValue:
|
||||
case T_RangeTblRef:
|
||||
/* primitive node types with no subnodes */
|
||||
return (Node *) copyObject(node);
|
||||
@@ -2538,14 +2536,13 @@ expression_tree_mutator(Node *node,
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_ConstraintTest:
|
||||
case T_CoerceToDomain:
|
||||
{
|
||||
ConstraintTest *ctest = (ConstraintTest *) node;
|
||||
ConstraintTest *newnode;
|
||||
CoerceToDomain *ctest = (CoerceToDomain *) node;
|
||||
CoerceToDomain *newnode;
|
||||
|
||||
FLATCOPY(newnode, ctest, ConstraintTest);
|
||||
FLATCOPY(newnode, ctest, CoerceToDomain);
|
||||
MUTATE(newnode->arg, ctest->arg, Expr *);
|
||||
MUTATE(newnode->check_expr, ctest->check_expr, Expr *);
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user