From 6c8474745527d6d535cd28120a39ba5e2d6c27aa Mon Sep 17 00:00:00 2001
From: "Sami Imseih (AWS)"
 <simseih@dev-dsk-simseih-1d-3940b79e.us-east-1.amazon.com>
Date: Wed, 12 Feb 2025 18:57:48 +0000
Subject: [PATCH 1/1] experiment_custom_array_expr

---
 src/backend/nodes/queryjumblefuncs.c | 41 ++++++++++++++++++++++++++++
 src/include/nodes/primnodes.h        | 10 ++++---
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/src/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c
index b103a28193..e3abf59106 100644
--- a/src/backend/nodes/queryjumblefuncs.c
+++ b/src/backend/nodes/queryjumblefuncs.c
@@ -58,6 +58,7 @@ static void _jumbleNode(JumbleState *jstate, Node *node);
 static void _jumbleA_Const(JumbleState *jstate, Node *node);
 static void _jumbleList(JumbleState *jstate, Node *node);
 static void _jumbleVariableSetStmt(JumbleState *jstate, Node *node);
+static void _jumbleArrayExpr(JumbleState *jstate, Node *node);
 
 /*
  * Given a possibly multi-statement source string, confine our attention to the
@@ -377,3 +378,43 @@ _jumbleVariableSetStmt(JumbleState *jstate, Node *node)
 	JUMBLE_FIELD(is_local);
 	JUMBLE_LOCATION(location);
 }
+
+static void
+_jumbleArrayExpr(JumbleState *jstate, Node *node)
+{
+	{
+		ListCell   *l;
+		ListCell   *l2;
+		Node	   *elements = (Node *) ((ArrayExpr *) node)->elements;
+
+		if (elements)
+		{
+			foreach(l, (List *) elements)
+			{
+				Node	   *expr = (Node *) lfirst(l);
+
+				if (IsA(expr, FuncExpr))
+				{
+					foreach(l2, ((FuncExpr *) expr)->args)
+					{
+						expr = (Node *) lfirst(l2);
+
+						if (IsA(expr, Const))
+						{
+							Const *c = (Const *) expr;
+
+							RecordConstLocation(jstate, c->location);
+						} else
+							_jumbleNode(jstate, expr);
+					}
+				} else if (IsA(expr, Const))
+				{
+					Const *c = (Const *) expr;
+
+					RecordConstLocation(jstate, c->location);
+				} else
+					_jumbleNode(jstate, expr);
+			}
+		}
+	}
+}
\ No newline at end of file
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 839e71d52f..e1dcc93f4a 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -1386,17 +1386,19 @@ typedef struct CaseTestExpr
  */
 typedef struct ArrayExpr
 {
+	pg_node_attr(custom_query_jumble)
+
 	Expr		xpr;
 	/* type of expression result */
-	Oid			array_typeid pg_node_attr(query_jumble_ignore);
+	Oid			array_typeid;
 	/* OID of collation, or InvalidOid if none */
-	Oid			array_collid pg_node_attr(query_jumble_ignore);
+	Oid			array_collid;
 	/* common type of array elements */
-	Oid			element_typeid pg_node_attr(query_jumble_ignore);
+	Oid			element_typeid;
 	/* the array elements or sub-arrays */
 	List	   *elements;
 	/* true if elements are sub-arrays */
-	bool		multidims pg_node_attr(query_jumble_ignore);
+	bool		multidims;
 	/* token location, or -1 if unknown */
 	ParseLoc	location;
 } ArrayExpr;
-- 
2.47.1

