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

Commit8b965c5

Browse files
committed
compute_bitmap_pages' loop_count parameter should be double not int.
The value was double in the original implementation of this logic.Commitda08a65 pulled it out into a subroutine, but carelesslydeclared the parameter as int when it should have been double.On most platforms, the only ill effect would be to clamp the valueto be not more than INT_MAX, which would seldom be exceeded andprobably wouldn't change the estimates too much anyway. Nonetheless,it's wrong and can cause complaints from ubsan.While here, improve the comments and parameter names.This is an ABI change in a globally exposed subroutine, soback-patching would create some risk of breaking extensions.The value of the fix doesn't seem high enough to warrant takingthat risk, so fix in HEAD only.Per report from Alexander Lakhin.Discussion:https://postgr.es/m/f5e15fe1-202d-1936-f47c-f0c69a936b72@gmail.com
1 parent64b1fb5 commit8b965c5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6393,12 +6393,20 @@ get_parallel_divisor(Path *path)
63936393

63946394
/*
63956395
* compute_bitmap_pages
6396+
* Estimate number of pages fetched from heap in a bitmap heap scan.
63966397
*
6397-
* compute number of pages fetched from heap in bitmap heap scan.
6398+
* 'baserel' is the relation to be scanned
6399+
* 'bitmapqual' is a tree of IndexPaths, BitmapAndPaths, and BitmapOrPaths
6400+
* 'loop_count' is the number of repetitions of the indexscan to factor into
6401+
*estimates of caching behavior
6402+
*
6403+
* If cost_p isn't NULL, the indexTotalCost estimate is returned in *cost_p.
6404+
* If tuples_p isn't NULL, the tuples_fetched estimate is returned in *tuples_p.
63986405
*/
63996406
double
6400-
compute_bitmap_pages(PlannerInfo*root,RelOptInfo*baserel,Path*bitmapqual,
6401-
intloop_count,Cost*cost,double*tuple)
6407+
compute_bitmap_pages(PlannerInfo*root,RelOptInfo*baserel,
6408+
Path*bitmapqual,doubleloop_count,
6409+
Cost*cost_p,double*tuples_p)
64026410
{
64036411
CostindexTotalCost;
64046412
SelectivityindexSelectivity;
@@ -6488,10 +6496,10 @@ compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual,
64886496
(lossy_pages /heap_pages)*baserel->tuples);
64896497
}
64906498

6491-
if (cost)
6492-
*cost=indexTotalCost;
6493-
if (tuple)
6494-
*tuple=tuples_fetched;
6499+
if (cost_p)
6500+
*cost_p=indexTotalCost;
6501+
if (tuples_p)
6502+
*tuples_p=tuples_fetched;
64956503

64966504
returnpages_fetched;
64976505
}

‎src/include/optimizer/cost.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ extern void set_result_size_estimates(PlannerInfo *root, RelOptInfo *rel);
210210
externvoidset_foreign_size_estimates(PlannerInfo*root,RelOptInfo*rel);
211211
externPathTarget*set_pathtarget_cost_width(PlannerInfo*root,PathTarget*target);
212212
externdoublecompute_bitmap_pages(PlannerInfo*root,RelOptInfo*baserel,
213-
Path*bitmapqual,intloop_count,Cost*cost,double*tuple);
213+
Path*bitmapqual,doubleloop_count,
214+
Cost*cost_p,double*tuples_p);
214215

215216
#endif/* COST_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp