hi.
src4=# explain (verbose, costs off) SELECT CAST('a' AS int DEFAULT 2
ON CONVERSION ERROR);
QUERY PLAN
-----------------------------------------------------------
Result
Output: CAST( AS integer DEFAULT 2 ON CONVERSION ERROR)
Query Identifier: 2101562107364949876
(3 rows)
The above v26 output is not good, the attached file fixes this issue.
I also polished the comments and more regression tests.
The main big change compare to v26 is in preprocess_aggrefs_walker.
--- a/src/backend/optimizer/prep/prepagg.c
+++ b/src/backend/optimizer/prep/prepagg.c
@@ -358,6 +358,17 @@ preprocess_aggrefs_walker(Node *node, PlannerInfo *root)
*/
return false;
}
+ if (IsA(node, SafeTypeCastExpr))
+ {
+ SafeTypeCastExpr *castexpr = (SafeTypeCastExpr *) node;
+
+ /*
+ * "source" may also contain an Aggref node, but since it is kept only
+ * for deparsing purposes, we must not recurse into it when processing
+ * aggregate nodes here.
+ */
+ return expression_tree_walker((Node *) castexpr->castexpr,
preprocess_aggrefs_walker, root);
+ }
Assert(!IsA(node, SubLink));
return expression_tree_walker(node, preprocess_aggrefs_walker, root);
}
--
jian
https://www.enterprisedb.com/