Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions - Mailing list pgsql-hackers

From jian he
Subject Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Date
Msg-id CACJufxEUr33CoQMsZdEehNU7wj_QOiyk8VW=W+aB03PF2J_qKQ@mail.gmail.com
Whole thread
In response to Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions  (jian he <jian.universality@gmail.com>)
Responses Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
List pgsql-hackers
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/

Attachment

pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: Improve pgindent's formatting named fields in struct literals and varidic functions
Next
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Introduce XID age based replication slot invalidation