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

Commit5a44161

Browse files
committed
Avoid crash in estimate_array_length with null root pointer.
Commit9391f71 added a "PlannerInfo *root" parameter toestimate_array_length, but failed to consider the possibility thatNULL would be passed for that, leading to a null pointer dereference.We could rectify the particular case shown in the bug report by fixingsimplify_function/inline_function to pass through the root pointer.However, as long as eval_const_expressions is documented to acceptNULL for root, similar hazards would remain. For now, let's just dothe narrow fix of hardening estimate_array_length to not crash.Its behavior with NULL root will be the same as it was before9391f71, so this is not too awful.Per report from Fredrik Widlert (via Paul Ramsey). Back-patch to v17where9391f71 came in.Discussion:https://postgr.es/m/518339E7-173E-45EC-A0FF-9A4A62AA4F40@cleverelephant.ca
1 parentf3f06b1 commit5a44161

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

‎src/backend/optimizer/path/costsize.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4724,6 +4724,9 @@ cost_rescan(PlannerInfo *root, Path *path,
47244724
*preferred since it allows caching of the results.)
47254725
*The result includes both a one-time (startup) component,
47264726
*and a per-evaluation component.
4727+
*
4728+
* Note: in some code paths root can be passed as NULL, resulting in
4729+
* slightly worse estimates.
47274730
*/
47284731
void
47294732
cost_qual_eval(QualCost*cost,List*quals,PlannerInfo*root)

‎src/backend/utils/adt/selfuncs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,9 @@ scalararraysel(PlannerInfo *root,
21312131
*
21322132
* Note: the result is integral, but we use "double" to avoid overflow
21332133
* concerns. Most callers will use it in double-type expressions anyway.
2134+
*
2135+
* Note: in some code paths root can be passed as NULL, resulting in
2136+
* slightly worse estimates.
21342137
*/
21352138
double
21362139
estimate_array_length(PlannerInfo*root,Node*arrayexpr)
@@ -2154,7 +2157,7 @@ estimate_array_length(PlannerInfo *root, Node *arrayexpr)
21542157
{
21552158
returnlist_length(((ArrayExpr*)arrayexpr)->elements);
21562159
}
2157-
elseif (arrayexpr)
2160+
elseif (arrayexpr&&root)
21582161
{
21592162
/* See if we can find any statistics about it */
21602163
VariableStatDatavardata;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp