Subject: [PATCH 04/11] Fix handling of ScalarArrayOpExpr with ALL clause

From: Tomas Vondra <[email-masked]>
Date: Wed, 4 Mar 2020 15:57:09 +0100

Simply reject all ALL cases, irrespectedly of the estimation function.
---
 src/backend/statistics/dependencies.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index a75b9d73db..72dc1cd1bd 100644
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -806,6 +806,15 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
 		/* If it's an scalar array operator, check for Var IN Const. */
 		ScalarArrayOpExpr	   *expr = (ScalarArrayOpExpr *) rinfo->clause;
 
+		/*
+		 * Reject ALL() variant, we only care about ANY/IN.
+		 *
+		 * FIXME Maybe we should check if all the values are the same, and
+		 * allow ALL in that case? Doesn't seem very practical, though.
+		 */
+		if (!expr->useOr)
+			return false;
+
 		/* Only expressions with two arguments are candidates. */
 		if (list_length(expr->args) != 2)
 			return false;
-- 
2.21.1

--slpdzd2ak5mtvkke
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="0005-Apply-multi-column-MCV-lists-to-ScalarArrayOpExpr.patch"