@@ -167,7 +167,7 @@ typedef struct AlteredTableInfo
167
167
Oid newTableSpace ; /* new tablespace; 0 means no change */
168
168
bool chgPersistence ; /* T if SET LOGGED/UNLOGGED is used */
169
169
char newrelpersistence ; /* if above is true */
170
- List * partition_constraint ; /* for attach partition validation */
170
+ Expr * partition_constraint ; /* for attach partition validation */
171
171
/* Objects to rebuild after completing ALTER TYPE operations */
172
172
List * changedConstraintOids ; /* OIDs of constraints to rebuild */
173
173
List * changedConstraintDefs ; /* string definitions of same */
@@ -3740,7 +3740,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
3740
3740
*/
3741
3741
if (((tab -> relkind == RELKIND_RELATION ||
3742
3742
tab -> relkind == RELKIND_PARTITIONED_TABLE ) &&
3743
- tab -> partition_constraint == NIL ) ||
3743
+ tab -> partition_constraint == NULL ) ||
3744
3744
tab -> relkind == RELKIND_MATVIEW )
3745
3745
AlterTableCreateToastTable (tab -> relid , (Datum ) 0 , lockmode );
3746
3746
}
@@ -4182,7 +4182,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
4182
4182
* generated by ALTER TABLE commands, but don't rebuild data.
4183
4183
*/
4184
4184
if (tab -> constraints != NIL || tab -> new_notnull ||
4185
- tab -> partition_constraint != NIL )
4185
+ tab -> partition_constraint != NULL )
4186
4186
ATRewriteTable (tab , InvalidOid , lockmode );
4187
4187
4188
4188
/*
@@ -4330,7 +4330,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
4330
4330
if (tab -> partition_constraint )
4331
4331
{
4332
4332
needscan = true;
4333
- partqualstate = ExecPrepareCheck (tab -> partition_constraint , estate );
4333
+ partqualstate = ExecPrepareExpr (tab -> partition_constraint , estate );
4334
4334
}
4335
4335
4336
4336
foreach (l , tab -> newvals )
@@ -13354,9 +13354,9 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
13354
13354
RelationGetRelationName (attachRel ))));
13355
13355
13356
13356
/*
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
13358
13358
* 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.
13360
13360
*/
13361
13361
if (!skip_validate )
13362
13362
{
@@ -13376,7 +13376,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
13376
13376
Oid part_relid = lfirst_oid (lc );
13377
13377
Relation part_rel ;
13378
13378
Expr * constr ;
13379
- List * my_constr ;
13380
13379
13381
13380
/* Lock already taken */
13382
13381
if (part_relid != RelationGetRelid (attachRel ))
@@ -13398,12 +13397,11 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
13398
13397
/* Grab a work queue entry */
13399
13398
tab = ATGetQueueEntry (wqueue , part_rel );
13400
13399
13400
+ /* Adjust constraint to match this partition */
13401
13401
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 );
13407
13405
/* keep our lock until commit */
13408
13406
if (part_rel != attachRel )
13409
13407
heap_close (part_rel , NoLock );
0 commit comments