Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2d140d3

Browse files
committed
Reconsider old decision to try to constant-fold default and constraint
expressions before they are stored. This seems like not such a hot idea, particularly now that the constant-folder will try to inline SQL functions.
1 parent 51d2e3b commit 2d140d3

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

src/backend/catalog/heap.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.238 2002/12/16 18:39:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.239 2003/01/08 22:06:20 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1604,11 +1604,6 @@ AddRelationRawConstraints(Relation rel,
16041604
if (contain_agg_clause(expr))
16051605
elog(ERROR, "cannot use aggregate function in CHECK constraint expression");
16061606

1607-
/*
1608-
* Might as well try to reduce any constant expressions.
1609-
*/
1610-
expr = eval_const_expressions(expr);
1611-
16121607
/*
16131608
* Constraints are evaluated with execQual, which expects an
16141609
* implicit-AND list, so convert expression to implicit-AND form.
@@ -1733,7 +1728,7 @@ cookDefault(ParseState *pstate,
17331728
* column's type. We store the expression without coercion, however,
17341729
* to avoid premature coercion in cases like
17351730
*
1736-
* CREATE TABLE tbl (fld timestamp DEFAULT 'now'::text);
1731+
* CREATE TABLE tbl (fld timestamp DEFAULT 'now');
17371732
*
17381733
* NB: this should match the code in rewrite/rewriteHandler.c that will
17391734
* actually do the coercion, to ensure we don't accept an unusable
@@ -1755,11 +1750,6 @@ cookDefault(ParseState *pstate,
17551750
format_type_be(type_id));
17561751
}
17571752

1758-
/*
1759-
* Might as well try to reduce any constant expressions.
1760-
*/
1761-
expr = eval_const_expressions(expr);
1762-
17631753
return (expr);
17641754
}
17651755

src/backend/commands/tablecmds.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.64 2002/12/30 19:45:17 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.65 2003/01/08 22:06:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2756,7 +2756,10 @@ AlterTableAddCheckConstraint(Relation rel, Constraint *constr)
27562756
elog(ERROR, "cannot use aggregate function in CHECK constraint expression");
27572757

27582758
/*
2759-
* Might as well try to reduce any constant expressions.
2759+
* Might as well try to reduce any constant expressions, so as to
2760+
* minimize overhead while testing the constraint at each row.
2761+
*
2762+
* Note that the stored form of the constraint will NOT be const-folded.
27602763
*/
27612764
expr = eval_const_expressions(expr);
27622765

src/backend/commands/typecmds.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.28 2003/01/08 21:40:39 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.29 2003/01/08 22:06:23 tgl Exp $
1212
*
1313
* DESCRIPTION
1414
* The "DefineFoo" routines take the parse tree and pick out the
@@ -1623,11 +1623,6 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
16231623
if (contain_agg_clause(expr))
16241624
elog(ERROR, "cannot use aggregate function in CHECK constraint expression");
16251625

1626-
/*
1627-
* Might as well try to reduce any constant expressions.
1628-
*/
1629-
expr = eval_const_expressions(expr);
1630-
16311626
/*
16321627
* Convert to string form for storage.
16331628
*/

0 commit comments

Comments
 (0)