public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: RangeTblEntry jumble omissions
Date: Fri, 23 Feb 2024 16:26:53 +0100
Message-ID: <[email protected]> (raw)

I think there are some fields from the RangeTblEntry struct missing in 
the jumble (function _jumbleRangeTblEntry()).  Probably, some of these 
were really just forgotten, in other cases this might be an intentional 
decision, but then it might be good to document it.  This has come up in 
thread [0] and there is a patch [1], but I figured I'd start a new 
thread here to get the attention of those who know more about 
pg_stat_statements.

I think the following fields are missing.  (See also attached patch.)

- alias

Currently, two queries like

SELECT * FROM t1 AS foo
SELECT * FROM t1 AS bar

are counted together by pg_stat_statements -- that might be ok, but they 
both get listed under whichever one is run first, so here if you are 
looking for the "AS bar" query, you won't find it.

- join_using_alias

Similar situation, currently

SELECT * FROM t1 JOIN t2 USING (a, b)
SELECT * FROM t1 JOIN t2 USING (a, b) AS x

are counted together.

- funcordinality

This was probably just forgotten.  It should be included because the 
WITH ORDINALITY clause changes the query result.

- lateral

Also probably forgotten.  A query specifying LATERAL is clearly 
different from one without it.

Thoughts?  Anything else missing perhaps?


[0]: 
https://www.postgresql.org/message-id/flat/[email protected]
[1]: 
https://www.postgresql.org/message-id/attachment/154249/v2-0002-Remove-custom-_jumbleRangeTblEntry.p...
From 8176e6f91abd8809e79e1c8e9335522031da2755 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Fri, 23 Feb 2024 16:10:57 +0100
Subject: [PATCH] Add more RangeTblEntry fields to jumble

---
 src/backend/nodes/queryjumblefuncs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c
index 82f725baaa5..3b0012a720d 100644
--- a/src/backend/nodes/queryjumblefuncs.c
+++ b/src/backend/nodes/queryjumblefuncs.c
@@ -372,9 +372,11 @@ _jumbleRangeTblEntry(JumbleState *jstate, Node *node)
 			break;
 		case RTE_JOIN:
 			JUMBLE_FIELD(jointype);
+			JUMBLE_NODE(join_using_alias);
 			break;
 		case RTE_FUNCTION:
 			JUMBLE_NODE(functions);
+			JUMBLE_FIELD(funcordinality);
 			break;
 		case RTE_TABLEFUNC:
 			JUMBLE_NODE(tablefunc);
@@ -400,4 +402,6 @@ _jumbleRangeTblEntry(JumbleState *jstate, Node *node)
 			elog(ERROR, "unrecognized RTE kind: %d", (int) expr->rtekind);
 			break;
 	}
+	JUMBLE_NODE(alias);
+	JUMBLE_FIELD(lateral);
 }
-- 
2.43.2



Attachments:

  [text/plain] 0001-Add-more-RangeTblEntry-fields-to-jumble.patch (1.0K, ../[email protected]/2-0001-Add-more-RangeTblEntry-fields-to-jumble.patch)
  download | inline diff:
From 8176e6f91abd8809e79e1c8e9335522031da2755 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Fri, 23 Feb 2024 16:10:57 +0100
Subject: [PATCH] Add more RangeTblEntry fields to jumble

---
 src/backend/nodes/queryjumblefuncs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c
index 82f725baaa5..3b0012a720d 100644
--- a/src/backend/nodes/queryjumblefuncs.c
+++ b/src/backend/nodes/queryjumblefuncs.c
@@ -372,9 +372,11 @@ _jumbleRangeTblEntry(JumbleState *jstate, Node *node)
 			break;
 		case RTE_JOIN:
 			JUMBLE_FIELD(jointype);
+			JUMBLE_NODE(join_using_alias);
 			break;
 		case RTE_FUNCTION:
 			JUMBLE_NODE(functions);
+			JUMBLE_FIELD(funcordinality);
 			break;
 		case RTE_TABLEFUNC:
 			JUMBLE_NODE(tablefunc);
@@ -400,4 +402,6 @@ _jumbleRangeTblEntry(JumbleState *jstate, Node *node)
 			elog(ERROR, "unrecognized RTE kind: %d", (int) expr->rtekind);
 			break;
 	}
+	JUMBLE_NODE(alias);
+	JUMBLE_FIELD(lateral);
 }
-- 
2.43.2



view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: RangeTblEntry jumble omissions
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox