diff --git a/tsl/src/nodes/decompress_chunk/qual_pushdown.c b/tsl/src/nodes/decompress_chunk/qual_pushdown.c index c692319b5b6..052870dd783 100644 --- a/tsl/src/nodes/decompress_chunk/qual_pushdown.c +++ b/tsl/src/nodes/decompress_chunk/qual_pushdown.c @@ -63,8 +63,18 @@ pushdown_quals(PlannerInfo *root, CompressionSettings *settings, RelOptInfo *chu context.can_pushdown = true; context.needs_recheck = false; expr = (Expr *) modify_expression((Node *) ri->clause, &context); + if (context.can_pushdown) { + /* + * We have to call eval_const_expressions after pushing down + * the quals, to normalize the bool expressions. Namely, we might add an + * AND boolexpr on minmax metadata columns, but the normal form is not + * allowed to have nested AND boolexprs. They break some functions like + * generate_bitmap_or_paths(). + */ + expr = (Expr *) eval_const_expressions(root, (Node *) expr); + if (IsA(expr, BoolExpr) && ((BoolExpr *) expr)->boolop == AND_EXPR) { /* have to separate out and expr into different restrict infos */