From ee00c194fe2e5162fe77a4a150109e6342476bbd Mon Sep 17 00:00:00 2001 From: Corey Huinker Date: Thu, 5 Nov 2026 20:47:51 -0500 Subject: [PATCH v35 4/5] WIP - Reorganize Safe Cast operations to avoid uninitialized collation. This is an LLM-suggested fix to avoid the collation/strength not set before use warning. --- src/backend/parser/parse_collate.c | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/backend/parser/parse_collate.c b/src/backend/parser/parse_collate.c index 043cebd23de..0071e93df1c 100644 --- a/src/backend/parser/parse_collate.c +++ b/src/backend/parser/parse_collate.c @@ -441,32 +441,6 @@ assign_collations_walker(Node *node, assign_collations_context *context) exprSetCollation(node, collation); } break; - - case T_SafeTypeCastExpr: - { - /* - * Like CaseExpr, we do not recurse into the input expression. - * It was already marked with collations during - * transformSafeTypeCast, and its collation reaches the result - * only through castexpr's placeholder. - */ - SafeTypeCastExpr *stc = (SafeTypeCastExpr *) node; - - (void) assign_collations_walker((Node *) stc->castexpr, - &loccontext); - (void) assign_collations_walker((Node *) stc->defexpr, - &loccontext); - } - break; - case T_SafeCastElement: - { - /* Likewise, see T_SafeTypeCastExpr above */ - SafeCastElement *elem = (SafeCastElement *) node; - - (void) assign_collations_walker((Node *) elem->castexpr, - &loccontext); - } - break; case T_TargetEntry: (void) expression_tree_walker(node, assign_collations_walker, @@ -694,6 +668,32 @@ assign_collations_walker(Node *node, assign_collations_context *context) &loccontext); } break; + case T_SafeTypeCastExpr: + { + /* + * Like CaseExpr, we do not recurse into the input + * expression. It was already marked with + * collations during transformSafeTypeCast, and its + * collation reaches the result only through + * castexpr's placeholder. + */ + SafeTypeCastExpr *stc = (SafeTypeCastExpr *) node; + + (void) assign_collations_walker((Node *) stc->castexpr, + &loccontext); + (void) assign_collations_walker((Node *) stc->defexpr, + &loccontext); + } + break; + case T_SafeCastElement: + { + /* Likewise, see T_SafeTypeCastExpr above */ + SafeCastElement *elem = (SafeCastElement *) node; + + (void) assign_collations_walker((Node *) elem->castexpr, + &loccontext); + } + break; case T_SubscriptingRef: { /* -- 2.54.0 (Apple Git-157)