Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9b95f2f

Browse files
committed
Use ExecPrepareExpr in place of ExecPrepareCheck where appropriate.
Change one more place where ExecInitCheck/ExecPrepareCheck's insistenceon getting implicit-AND-format quals wasn't really helpful, because thecaller 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 processresultRelInfo->ri_PartitionCheck quals. However, implicit-AND formatdoes seem to be what we want for that, so leave it alone.
1 parent5459cfd commit9b95f2f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

‎src/backend/catalog/partition.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,12 @@ get_qual_from_partbound(Relation rel, Relation parent, Node *bound)
921921
* map_partition_varattnos - maps varattno of any Vars in expr from the
922922
* parent attno to partition attno.
923923
*
924-
* We must allow fora case where physical attnos of a partition can be
924+
* We must allow forcases where physical attnos of a partition can be
925925
* different from the parent's.
926+
*
927+
* Note: this will work on any node tree, so really the argument and result
928+
* should be declared "Node *". But a substantial majority of the callers
929+
* are working on Lists, so it's less messy to do the casts internally.
926930
*/
927931
List*
928932
map_partition_varattnos(List*expr,inttarget_varno,

‎src/backend/commands/tablecmds.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ typedef struct AlteredTableInfo
167167
OidnewTableSpace;/* new tablespace; 0 means no change */
168168
boolchgPersistence;/* T if SET LOGGED/UNLOGGED is used */
169169
charnewrelpersistence;/* 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 tabletobe 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
*/
1336113361
if (!skip_validate)
1336213362
{
@@ -13376,7 +13376,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1337613376
Oidpart_relid=lfirst_oid(lc);
1337713377
Relationpart_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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp