| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Amul Sul <sulamul(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |
| Date: | 2026-03-31 07:23:40 |
| Message-ID: | CACJufxEUr33CoQMsZdEehNU7wj_QOiyk8VW=W+aB03PF2J_qKQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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);
}
| Attachment | Content-Type | Size |
|---|---|---|
| v27-0001-error-safe-for-casting-text-to-other-types-per-pg_cast.patch | text/x-patch | 9.2 KB |
| v27-0002-CAST-expr-AS-newtype-DEFAULT-expr-ON-CONVERSION-ERROR.patch | text/x-patch | 144.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hayato Kuroda (Fujitsu) | 2026-03-31 07:25:07 | RE: Introduce XID age based replication slot invalidation |
| Previous Message | Jelte Fennema-Nio | 2026-03-31 07:16:40 | Re: Improve pgindent's formatting named fields in struct literals and varidic functions |