aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 96cf42a7f82..4cf2efb2ad9 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -167,7 +167,7 @@ typedef struct AlteredTableInfo
Oid newTableSpace; /* new tablespace; 0 means no change */
bool chgPersistence; /* T if SET LOGGED/UNLOGGED is used */
char newrelpersistence; /* if above is true */
- List *partition_constraint; /* for attach partition validation */
+ Expr *partition_constraint; /* for attach partition validation */
/* Objects to rebuild after completing ALTER TYPE operations */
List *changedConstraintOids; /* OIDs of constraints to rebuild */
List *changedConstraintDefs; /* string definitions of same */
@@ -3740,7 +3740,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
*/
if (((tab->relkind == RELKIND_RELATION ||
tab->relkind == RELKIND_PARTITIONED_TABLE) &&
- tab->partition_constraint == NIL) ||
+ tab->partition_constraint == NULL) ||
tab->relkind == RELKIND_MATVIEW)
AlterTableCreateToastTable(tab->relid, (Datum) 0, lockmode);
}
@@ -4182,7 +4182,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
* generated by ALTER TABLE commands, but don't rebuild data.
*/
if (tab->constraints != NIL || tab->new_notnull ||
- tab->partition_constraint != NIL)
+ tab->partition_constraint != NULL)
ATRewriteTable(tab, InvalidOid, lockmode);
/*
@@ -4330,7 +4330,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (tab->partition_constraint)
{
needscan = true;
- partqualstate = ExecPrepareCheck(tab->partition_constraint, estate);
+ partqualstate = ExecPrepareExpr(tab->partition_constraint, estate);
}
foreach(l, tab->newvals)
@@ -13354,9 +13354,9 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
RelationGetRelationName(attachRel))));
/*
- * Set up to have the table to be scanned to validate the partition
+ * Set up to have the table be scanned to validate the partition
* constraint (see partConstraint above). If it's a partitioned table, we
- * instead schdule its leaf partitions to be scanned instead.
+ * instead schedule its leaf partitions to be scanned.
*/
if (!skip_validate)
{
@@ -13376,7 +13376,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
Oid part_relid = lfirst_oid(lc);
Relation part_rel;
Expr *constr;
- List *my_constr;
/* Lock already taken */
if (part_relid != RelationGetRelid(attachRel))
@@ -13398,12 +13397,11 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
/* Grab a work queue entry */
tab = ATGetQueueEntry(wqueue, part_rel);
+ /* Adjust constraint to match this partition */
constr = linitial(partConstraint);
- my_constr = make_ands_implicit((Expr *) constr);
- tab->partition_constraint = map_partition_varattnos(my_constr,
- 1,
- part_rel,
- rel);
+ tab->partition_constraint = (Expr *)
+ map_partition_varattnos((List *) constr, 1,
+ part_rel, rel);
/* keep our lock until commit */
if (part_rel != attachRel)
heap_close(part_rel, NoLock);