v14_comments.no-cfbot
application/octet-stream
Filename: v14_comments.no-cfbot
Type: application/octet-stream
Part: 0
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 6b4b00eb..fb199230 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -202,6 +202,7 @@ transformBoolExprOr(ParseState *pstate, BoolExpr *expr)
OrClauseGroupKey hashkey;
bool found;
Oid opno;
+ TYPCATEGORY category;
Node *leftop, *rightop;
/* At first, transform the arg and evaluate constant expressions. */
@@ -243,7 +244,7 @@ transformBoolExprOr(ParseState *pstate, BoolExpr *expr)
if (!OidIsValid(opno))
{
- /* Commuter doesn't exist, we can't reverse the order */
+ /* commutator doesn't exist, we can't reverse the order */
or_list = lappend(or_list, orqual);
continue;
}
@@ -262,6 +263,33 @@ transformBoolExprOr(ParseState *pstate, BoolExpr *expr)
continue;
}
+ /* transformation only works with both side type is not { array | compoiste | domain } */
+ category = TypeCategory(exprType(const_expr));
+ if (category == TYPCATEGORY_ARRAY || category == TYPTYPE_DOMAIN
+ || category == TYPTYPE_COMPOSITE)
+ {
+ or_list = lappend(or_list, orqual);
+ continue;
+ }
+
+ category = TypeCategory(exprType(nconst_expr));
+ if (category == TYPCATEGORY_ARRAY || category == TYPTYPE_DOMAIN
+ || category == TYPTYPE_COMPOSITE)
+ {
+ or_list = lappend(or_list, orqual);
+ continue;
+ }
+
+ /*
+ * if the non-const (left side of operator expression) contain voltain functions
+ * then we cannot do the transformation
+ */
+ if (contain_volatile_functions((Node *) nconst_expr))
+ {
+ or_list = lappend(or_list, orqual);
+ continue;
+ }
+
/*
* At this point we definitely have a transformable clause.
* Classify it and add into specific group of clauses, or create new
@@ -333,7 +361,7 @@ transformBoolExprOr(ParseState *pstate, BoolExpr *expr)
else
array_type = InvalidOid;
- if (array_type != InvalidOid)
+ if (OidIsValid(array_type))
{
/*
* OK: coerce all the right-hand non-Var inputs to the common
@@ -392,8 +420,10 @@ transformBoolExprOr(ParseState *pstate, BoolExpr *expr)
else
{
/*
- * This part works on intarray test (OR there is made on
- * elements of a custom type)
+ * If the const node (right side of operator expression) 's type
+ * don't have “true” array type, then we cannnot do the transformation.
+ * We simply concatenate the expression node.
+ *
*/
list_free(entry->consts);
or_list = list_concat(or_list, entry->exprs);