@@ -167,7 +167,7 @@ typedef struct AlteredTableInfo
167167Oid newTableSpace ;/* new tablespace; 0 means no change */
168168bool chgPersistence ;/* T if SET LOGGED/UNLOGGED is used */
169169char newrelpersistence ;/* if above is true */
170- List * partition_constraint ;/* for attach partition validation */
170+ Expr * partition_constraint ;/* for attach partition validation */
171171/* Objects to rebuild after completing ALTER TYPE operations */
172172List * changedConstraintOids ;/* OIDs of constraints to rebuild */
173173List * changedConstraintDefs ;/* string definitions of same */
@@ -3740,7 +3740,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
37403740 */
37413741if (((tab -> relkind == RELKIND_RELATION ||
37423742tab -> relkind == RELKIND_PARTITIONED_TABLE )&&
3743- tab -> partition_constraint == NIL )||
3743+ tab -> partition_constraint == NULL )||
37443744tab -> relkind == RELKIND_MATVIEW )
37453745AlterTableCreateToastTable (tab -> relid , (Datum )0 ,lockmode );
37463746}
@@ -4182,7 +4182,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
41824182 * generated by ALTER TABLE commands, but don't rebuild data.
41834183 */
41844184if (tab -> constraints != NIL || tab -> new_notnull ||
4185- tab -> partition_constraint != NIL )
4185+ tab -> partition_constraint != NULL )
41864186ATRewriteTable (tab ,InvalidOid ,lockmode );
41874187
41884188/*
@@ -4330,7 +4330,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
43304330if (tab -> partition_constraint )
43314331{
43324332needscan = true;
4333- partqualstate = ExecPrepareCheck (tab -> partition_constraint ,estate );
4333+ partqualstate = ExecPrepareExpr (tab -> partition_constraint ,estate );
43344334}
43354335
43364336foreach (l ,tab -> newvals )
@@ -13354,9 +13354,9 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1335413354RelationGetRelationName (attachRel ))));
1335513355
1335613356/*
13357- * Set up to have the tableto be scanned to validate the partition
13357+ * Set up to have the table be scanned to validate the partition
1335813358 * constraint (see partConstraint above). If it's a partitioned table, we
13359- * insteadschdule its leaf partitions to be scanned instead .
13359+ * insteadschedule its leaf partitions to be scanned.
1336013360 */
1336113361if (!skip_validate )
1336213362{
@@ -13376,7 +13376,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1337613376Oid part_relid = lfirst_oid (lc );
1337713377Relation part_rel ;
1337813378Expr * constr ;
13379- List * my_constr ;
1338013379
1338113380/* Lock already taken */
1338213381if (part_relid != RelationGetRelid (attachRel ))
@@ -13398,12 +13397,11 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1339813397/* Grab a work queue entry */
1339913398tab = ATGetQueueEntry (wqueue ,part_rel );
1340013399
13400+ /* Adjust constraint to match this partition */
1340113401constr = linitial (partConstraint );
13402- my_constr = make_ands_implicit ((Expr * )constr );
13403- tab -> partition_constraint = map_partition_varattnos (my_constr ,
13404- 1 ,
13405- part_rel ,
13406- rel );
13402+ tab -> partition_constraint = (Expr * )
13403+ map_partition_varattnos ((List * )constr ,1 ,
13404+ part_rel ,rel );
1340713405/* keep our lock until commit */
1340813406if (part_rel != attachRel )
1340913407heap_close (part_rel ,NoLock );