Skip to content

Commit 92647fc

Browse files
committed
Avoid possible divide-by-zero in gincostestimate.
Per report from Jeff Janes.
1 parent a0e8df5 commit 92647fc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/utils/adt/selfuncs.c

+4
Original file line numberDiff line numberDiff line change
@@ -6458,6 +6458,10 @@ gincostestimate(PG_FUNCTION_ARGS)
64586458
numDataPages = Min(numDataPages, numPages - numEntryPages);
64596459
}
64606460

6461+
/* In an empty index, numEntries could be zero. Avoid divide-by-zero */
6462+
if (numEntries < 1)
6463+
numEntries = 1;
6464+
64616465
/*
64626466
* Include predicate in selectivityQuals (should match
64636467
* genericcostestimate)

0 commit comments

Comments
 (0)