Re: support fix query_id for temp table
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Christoph Berg <myon@debian.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, ma lz <ma100@hotmail.com>
Date: 2025-03-18T03:56:42Z
Lists: pgsql-hackers, pgsql-general
On Mon, Mar 17, 2025 at 10:38:36PM +0100, Christoph Berg wrote:
> Here's that patch with regression tests added. I would think changing
> this would be a big usability improvement for anyone using temp tables
> a lot.
Not the first time I am seeing this argument this month. It is the
second time.
+ /*
+ * If this is a temp table, jumble the name instead of the table oid.
+ */
+ if (expr->rtekind == RTE_RELATION && isAnyTempNamespace(get_rel_namespace(expr->relid)))
+ {
+ rel_name = get_rel_name(expr->relid);
+ AppendJumble(jstate, (const unsigned char *)rel_name, strlen(rel_name));
+ }
+ else
+ JUMBLE_FIELD(relid);
This is OK on its own, still feels a bit incomplete, as the relid also
includes an assumption about the namespace. I would suggested to add
a hardcoded "pg_temp" here, to keep track of this assumption, at
least.
typedef struct RangeTblEntry
{
- pg_node_attr(custom_read_write)
+ pg_node_attr(custom_read_write, custom_query_jumble)
This structure still includes some query_jumble_ignore, which are not
required once custom_query_jumble is added.
We had better document at the top of RangeTblEntry why we are using a
custom function.
--
Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use relation name instead of OID in query jumbling for RangeTblEntry
- 787514b30bb7 18.0 landed
-
Fix two issues with custom_query_jumble in gen_node_support.pl
- 27ee6ede6bc9 18.0 landed
-
pg_stat_statements: Add more tests with temp tables and namespaces
- 3430215fe35f 18.0 landed
-
Add support for custom_query_jumble as a node field attribute
- 5ac462e2b7ac 18.0 landed