From 6f4384ae03443abba12b0815ed16dbab8c316927 Mon Sep 17 00:00:00 2001 From: Ilya Staroverov Date: Mon, 26 Oct 2026 13:10:16 +0300 Subject: [PATCH v1 09/11] Include the type of row constructors in query jumbling RowExpr.row_typeid has not been part of the query ID since query jumbling was added to pg_stat_statements in 9.2. A ROW() constructor cast to a composite type gets that type, so a query with ROW(1, 2) cast to one composite type, the same query with ROW(1, 2) cast to another one, and the same query without a cast, which return values of different types, were merged into a single pg_stat_statements entry. Include RowExpr.row_typeid in query jumbling. This changes the query IDs of the queries with row constructors, so it is for master only. Author: Ilya Staroverov --- contrib/pg_stat_statements/expected/select.out | 8 +++++--- src/include/nodes/primnodes.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/pg_stat_statements/expected/select.out b/contrib/pg_stat_statements/expected/select.out index 9536a2f306..4ba573f019 100644 --- a/contrib/pg_stat_statements/expected/select.out +++ b/contrib/pg_stat_statements/expected/select.out @@ -1279,13 +1279,15 @@ SELECT ROW(s, t) <= ROW('b', 'b') FROM (VALUES ('a', 'a')) AS v(s, t); SELECT calls, query FROM pg_stat_statements ORDER BY query COLLATE "C"; calls | query -------+------------------------------------------------------------------------ - 2 | SELECT (ROW($1, $2)::pgss_pair1).* - 2 | SELECT ROW($1, $2) + 1 | SELECT (ROW($1, $2)::pgss_pair1).* + 1 | SELECT (ROW($1, $2)::pgss_pair2).* + 1 | SELECT ROW($1, $2) + 1 | SELECT ROW($1, $2)::pgss_pair1 2 | SELECT ROW(s, t) < ROW($1, $2) FROM (VALUES ($3, $4)) AS v(s, t) 1 | SELECT ROW(s, t) <= ROW($1, $2) FROM (VALUES ($3, $4)) AS v(s, t) 0 | SELECT calls, query FROM pg_stat_statements ORDER BY query COLLATE "C" 1 | SELECT pg_stat_statements_reset() IS NOT NULL AS t -(6 rows) +(8 rows) DROP TYPE pgss_pair1, pgss_pair2; DROP TABLE pgss_empty_tab; diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 8d83484ab2..f13f75b22d 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -1439,7 +1439,7 @@ typedef struct RowExpr List *args; /* the fields */ /* RECORDOID or a composite type's ID */ - Oid row_typeid pg_node_attr(query_jumble_ignore); + Oid row_typeid; /* * row_typeid cannot be a domain over composite, only plain composite. To -- 2.43.0