git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0e8df5)
Avoid possible divide-by-zero in gincostestimate.
2011年4月21日 23:28:36 +0000 (19:28 -0400)
2011年4月21日 23:28:36 +0000 (19:28 -0400)
Per report from Jeff Janes.


diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 4d800f8a007980dbac1d221d48f0fa8b0e30db66..fa8cecafcbe5b4bef44d12549a35f7e27c838c3c 100644 (file)
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -6458,6 +6458,10 @@ gincostestimate(PG_FUNCTION_ARGS)
numDataPages = Min(numDataPages, numPages - numEntryPages);
}
+ /* In an empty index, numEntries could be zero. Avoid divide-by-zero */
+ if (numEntries < 1)
+ numEntries = 1;
+
/*
* Include predicate in selectivityQuals (should match
* genericcostestimate)
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /