summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/selfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r--src/backend/utils/adt/selfuncs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 5f5d7959d8e..f4b3e91baa8 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -2131,6 +2131,9 @@ scalararraysel(PlannerInfo *root,
*
* Note: the result is integral, but we use "double" to avoid overflow
* concerns. Most callers will use it in double-type expressions anyway.
+ *
+ * Note: in some code paths root can be passed as NULL, resulting in
+ * slightly worse estimates.
*/
double
estimate_array_length(PlannerInfo *root, Node *arrayexpr)
@@ -2154,7 +2157,7 @@ estimate_array_length(PlannerInfo *root, Node *arrayexpr)
{
return list_length(((ArrayExpr *) arrayexpr)->elements);
}
- else if (arrayexpr)
+ else if (arrayexpr && root)
{
/* See if we can find any statistics about it */
VariableStatData vardata;