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

Commit2759924

Browse files
committed
Fix runtime partition pruning for HASH partitioned tables
This could only affect HASH partitioned tables with at least 2 partitionkey columns.If partition pruning was delayed until execution and the query containedan IS NULL qual on one of the partitioned keys, and some subsequentpartitioned key was being compared to a non-Const, then this could resultin a crash due to the incorrect keyno being used to calculate thestateidx for the expression evaluation code.Here we fix this by properly skipping partitioned keys which have anullkey set. Effectively, this must be the same as what's going oninside perform_pruning_base_step().Sergei Glukhov also provided a patch, but that's not what's being usedhere.Reported-by: Sergei GlukhovReviewed-by: tender wang, Sergei GlukhovDiscussion:https://postgr.es/m/d05b26fa-af54-27e1-f693-6c31590802fa@postgrespro.ruBackpatch-through: 11, where runtime partition pruning was added.
1 parent8f1d44b commit2759924

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

‎src/backend/executor/execPartition.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ ExecInitPruningContext(PartitionPruneContext *context,
16731673
foreach(lc,pruning_steps)
16741674
{
16751675
PartitionPruneStepOp*step= (PartitionPruneStepOp*)lfirst(lc);
1676-
ListCell*lc2;
1676+
ListCell*lc2=list_head(step->exprs);
16771677
intkeyno;
16781678

16791679
/* not needed for other step kinds */
@@ -1682,22 +1682,27 @@ ExecInitPruningContext(PartitionPruneContext *context,
16821682

16831683
Assert(list_length(step->exprs) <=partnatts);
16841684

1685-
keyno=0;
1686-
foreach(lc2,step->exprs)
1685+
for (keyno=0;keyno<partnatts;keyno++)
16871686
{
1688-
Expr*expr= (Expr*)lfirst(lc2);
1687+
if (bms_is_member(keyno,step->nullkeys))
1688+
continue;
16891689

1690-
/* not needed for Consts */
1691-
if (!IsA(expr,Const))
1690+
if (lc2!=NULL)
16921691
{
1693-
intstateidx=PruneCxtStateIdx(partnatts,
1694-
step->step.step_id,
1695-
keyno);
1692+
Expr*expr=lfirst(lc2);
1693+
1694+
/* not needed for Consts */
1695+
if (!IsA(expr,Const))
1696+
{
1697+
intstateidx=PruneCxtStateIdx(partnatts,
1698+
step->step.step_id,
1699+
keyno);
16961700

1697-
context->exprstates[stateidx]=
1698-
ExecInitExpr(expr,context->planstate);
1701+
context->exprstates[stateidx]=
1702+
ExecInitExpr(expr,context->planstate);
1703+
}
1704+
lc2=lnext(lc2);
16991705
}
1700-
keyno++;
17011706
}
17021707
}
17031708
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp