99 *
1010 *
1111 * IDENTIFICATION
12- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.185 2002/12/12 15:49:24 tgl Exp $
12+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.186 2002/12/13 19:45:48 tgl Exp $
1313 *
1414 *-------------------------------------------------------------------------
1515 */
@@ -758,7 +758,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
758758num_defaults ;
759759FmgrInfo * in_functions ;
760760Oid * elements ;
761- Node * * constraintexprs ;
761+ ExprState * * constraintexprs ;
762762bool hasConstraints = false;
763763int i ;
764764List * cur ;
@@ -772,7 +772,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
772772TupleTableSlot * slot ;
773773bool file_has_oids ;
774774int * defmap ;
775- Node * * defexprs ;/* array of default att expressions */
775+ ExprState * * defexprs ;/* array of default att expressions */
776776ExprContext * econtext ;/* used for ExecEvalExpr for default atts */
777777MemoryContext oldcontext = CurrentMemoryContext ;
778778
@@ -812,8 +812,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
812812in_functions = (FmgrInfo * )palloc (num_phys_attrs * sizeof (FmgrInfo ));
813813elements = (Oid * )palloc (num_phys_attrs * sizeof (Oid ));
814814defmap = (int * )palloc (num_phys_attrs * sizeof (int ));
815- defexprs = (Node * * )palloc (num_phys_attrs * sizeof (Node * ));
816- constraintexprs = (Node * * )palloc0 (num_phys_attrs * sizeof (Node * ));
815+ defexprs = (ExprState * * )palloc (num_phys_attrs * sizeof (ExprState * ));
816+ constraintexprs = (ExprState * * )palloc0 (num_phys_attrs * sizeof (ExprState * ));
817817
818818for (i = 0 ;i < num_phys_attrs ;i ++ )
819819{
@@ -837,10 +837,12 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
837837{
838838/* attribute is NOT to be copied */
839839/* use default value if one exists */
840- defexprs [num_defaults ]= build_column_default (rel ,i + 1 );
841- if (defexprs [num_defaults ]!= NULL )
840+ Node * defexpr = build_column_default (rel ,i + 1 );
841+
842+ if (defexpr != NULL )
842843{
843- fix_opfuncids (defexprs [num_defaults ]);
844+ fix_opfuncids (defexpr );
845+ defexprs [num_defaults ]= ExecInitExpr ((Expr * )defexpr ,NULL );
844846defmap [num_defaults ]= i ;
845847num_defaults ++ ;
846848}
@@ -872,7 +874,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
872874if (node != (Node * )prm )
873875{
874876fix_opfuncids (node );
875- constraintexprs [i ]= node ;
877+ constraintexprs [i ]= ExecInitExpr (( Expr * ) node , NULL ) ;
876878hasConstraints = true;
877879}
878880}
@@ -1165,10 +1167,10 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
11651167
11661168for (i = 0 ;i < num_phys_attrs ;i ++ )
11671169{
1168- Node * node = constraintexprs [i ];
1170+ ExprState * exprstate = constraintexprs [i ];
11691171bool isnull ;
11701172
1171- if (node == NULL )
1173+ if (exprstate == NULL )
11721174continue ;/* no constraint for this attr */
11731175
11741176/* Insert current row's value into the Param value */
@@ -1180,7 +1182,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
11801182 * to replace the value (consider e.g. a timestamp precision
11811183 * restriction).
11821184 */
1183- values [i ]= ExecEvalExpr (node ,econtext ,
1185+ values [i ]= ExecEvalExpr (exprstate ,econtext ,
11841186& isnull ,NULL );
11851187nulls [i ]= isnull ?'n' :' ' ;
11861188}