aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-03-26 18:14:03 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-03-26 18:14:03 -0400
commit9b95f2fa1e2684fa209a3594db2254b8841bf380 (patch)
tree06fc122b56fbe559ef5540a86b7dca4388e0cefb /src/backend/commands/tablecmds.c
parent5459cfd3ad52b87a1e2ed293ae55e733c6964715 (diff)
downloadpostgresql-9b95f2fa1e2684fa209a3594db2254b8841bf380.tar.gz
postgresql-9b95f2fa1e2684fa209a3594db2254b8841bf380.zip
Use ExecPrepareExpr in place of ExecPrepareCheck where appropriate.
Change one more place where ExecInitCheck/ExecPrepareCheck's insistence on getting implicit-AND-format quals wasn't really helpful, because the caller had to do make_ands_implicit() for no reason that it cared about. Using ExecPrepareExpr directly simplifies the code and saves cycles. The only remaining use of these functions is to process resultRelInfo->ri_PartitionCheck quals. However, implicit-AND format does seem to be what we want for that, so leave it alone.
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);