提交 fb537b53 编写于 作者: D Daniel Gustafsson

Set statistics to zero when no sampled rows

In the unlikely event that we reach this codepath with a samplerows
value of zero (which albeit unlikely could happen), avoid performing
a division by zero and instead set the null fraction to zero as we
clearly don't have any more information to go on. The HLL code calls
calls the compute_stats function pointer with zero samplerows, and
while that's using a different compute_stats function, it's an easy
mistake to make when not all functions can handle a division by zero.
This is defensive programming prompted by a report that triggered an
old bug like this without actually hitting this, but there is little
reason to take the risk of a crash. Suspenders go well with belts.
Reviewed-by: NHeikki Linnakangas <hlinnakangas@pivotal.io>
上级 cc2e211f
......@@ -3862,10 +3862,16 @@ compute_scalar_stats(VacAttrStatsP stats,
}
else
{
/* ORCA complains if a column has no statistics whatsoever,
* so store something */
/*
* ORCA complains if a column has no statistics whatsoever, so store
* either the best we can figure out given what we have, or zero in
* case we don't have enough.
*/
stats->stats_valid = true;
stats->stanullfrac = (double) null_cnt / (double) samplerows;
if (samplerows)
stats->stanullfrac = (double) null_cnt / (double) samplerows;
else
stats->stanullfrac = 0.0;
if (is_varwidth)
stats->stawidth = 0; /* "unknown" */
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册