@@ -167,7 +167,7 @@ typedef struct AlteredTableInfo
167167 Oid newTableSpace ; /* new tablespace; 0 means no change */
168168 bool chgPersistence ; /* T if SET LOGGED/UNLOGGED is used */
169169 char 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 */
172172 List * changedConstraintOids ; /* OIDs of constraints to rebuild */
173173 List * changedConstraintDefs ; /* string definitions of same */
@@ -3740,7 +3740,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
37403740 */
37413741 if (((tab -> relkind == RELKIND_RELATION ||
37423742 tab -> relkind == RELKIND_PARTITIONED_TABLE ) &&
3743- tab -> partition_constraint == NIL ) ||
3743+ tab -> partition_constraint == NULL ) ||
37443744 tab -> relkind == RELKIND_MATVIEW )
37453745 AlterTableCreateToastTable (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 */
41844184 if (tab -> constraints != NIL || tab -> new_notnull ||
4185- tab -> partition_constraint != NIL )
4185+ tab -> partition_constraint != NULL )
41864186 ATRewriteTable (tab , InvalidOid , lockmode );
41874187
41884188 /*
@@ -4330,7 +4330,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
43304330 if (tab -> partition_constraint )
43314331 {
43324332 needscan = true;
4333- partqualstate = ExecPrepareCheck (tab -> partition_constraint , estate );
4333+ partqualstate = ExecPrepareExpr (tab -> partition_constraint , estate );
43344334 }
43354335
43364336 foreach (l , tab -> newvals )
@@ -13354,9 +13354,9 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1335413354 RelationGetRelationName (attachRel ))));
1335513355
1335613356 /*
13357- * Set up to have the table to 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- * instead schdule its leaf partitions to be scanned instead .
13359+ * instead schedule its leaf partitions to be scanned.
1336013360 */
1336113361 if (!skip_validate )
1336213362 {
@@ -13376,7 +13376,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1337613376 Oid part_relid = lfirst_oid (lc );
1337713377 Relation part_rel ;
1337813378 Expr * constr ;
13379- List * my_constr ;
1338013379
1338113380 /* Lock already taken */
1338213381 if (part_relid != RelationGetRelid (attachRel ))
@@ -13398,12 +13397,11 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1339813397 /* Grab a work queue entry */
1339913398 tab = ATGetQueueEntry (wqueue , part_rel );
1340013399
13400+ /* Adjust constraint to match this partition */
1340113401 constr = 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 */
1340813406 if (part_rel != attachRel )
1340913407 heap_close (part_rel , NoLock );
0 commit comments