From ff1c6eb8590bfba8e5ce2d8be70182402246d1f9 Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Mon, 29 Jun 2026 16:11:26 +0800
Subject: [PATCH v1 1/1] coerce_type

discard unncessary CollateExprs

discuccsion: https://postgr.es/m/
---
 src/backend/parser/parse_coerce.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 3b92ae2a920..f83e1933706 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -397,7 +397,10 @@ coerce_type(ParseState *pstate, Node *node,
 		 */
 		CollateExpr *coll = (CollateExpr *) node;
 
-		result = coerce_type(pstate, (Node *) coll->arg,
+		while (node && IsA(node, CollateExpr))
+			node = (Node *) ((CollateExpr *) node)->arg;
+
+		result = coerce_type(pstate, node,
 							 inputTypeId, targetTypeId, targetTypeMod,
 							 ccontext, cformat, location);
 		if (type_is_collatable(targetTypeId))
-- 
2.34.1

