summaryrefslogtreecommitdiff
path: root/contrib/pgstattuple/pgstatapprox.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pgstattuple/pgstatapprox.c')
-rw-r--r--contrib/pgstattuple/pgstatapprox.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/contrib/pgstattuple/pgstatapprox.c b/contrib/pgstattuple/pgstatapprox.c
index 3a99333d443..23306e11a78 100644
--- a/contrib/pgstattuple/pgstatapprox.c
+++ b/contrib/pgstattuple/pgstatapprox.c
@@ -195,6 +195,9 @@ statapprox_heap(Relation rel, output_type *stat)
stat->tuple_count = vac_estimate_reltuples(rel, nblocks, scanned,
stat->tuple_count);
+ /* It's not clear if we could get -1 here, but be safe. */
+ stat->tuple_count = Max(stat->tuple_count, 0);
+
/*
* Calculate percentages if the relation has one or more pages.
*/