Re: pg_stat_statements replaces SQL/JSON ON EMPTY / ON ERROR keywords with parameters

From: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Staroverov Ilja <i(dot)staroverov(at)ftdata(dot)ru>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_stat_statements replaces SQL/JSON ON EMPTY / ON ERROR keywords with parameters
Date: 2026-10-26 18:23:22
Message-ID: CAN12+YJukPcK6mu=XJ0=V1rSwEhptjfxBx6nCpp_1RDO6qP4Kg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I took a look at v5-0002.

+ /*
+ * JSON_TABLE() column name or NULL if this is not for a JSON_TABLE().
+ * Only jumbled for a column without PATH, see queryjumblefuncs.c.
+ */
+ char *column_name pg_node_attr(custom_query_jumble);

I don't think we should do this. I think column_name should just be ignored
for query jumbling.

With v5-0002 applied, I get this:

```
SELECT * FROM jt, JSON_TABLE(js, '$[*]' COLUMNS (a int PATH '$.a')) q;
SELECT * FROM jt, JSON_TABLE(js, '$[*]' COLUMNS (b int PATH '$.b')) q;
SELECT * FROM jt, JSON_TABLE(js, '$[*]' COLUMNS (a int)) q;
SELECT * FROM jt, JSON_TABLE(js, '$[*]' COLUMNS (b int)) q;
```

```
calls | query
-------+--------------------------------------------------------------
2 | SELECT * FROM jt, JSON_TABLE(js, $1 COLUMNS (a int PATH $2)) q
2 | SELECT * FROM jt, JSON_TABLE(js, $1 COLUMNS (b int PATH $2)) q
(2 rows)
```

So when PATH is omitted, the column label becomes part of the query ID. I
don't think that is consistent with how we handle similar column definition
lists elsewhere.

For example:

```
SELECT * FROM pg_temp.pair_record() AS t(a int, b text);
SELECT * FROM pg_temp.pair_record() AS t(x int, y text);
```

```
calls | query
-------+--------------------------------------------------------
2 | SELECT * FROM pg_temp.pair_record() AS t(a int, b text)
(1 row)
```

The column names in the SRF column definition list don't make those separate
entries. I think JSON_TABLE column names should follow the same rule. Explicit
PATH values are not included in the query ID, so I don't think omitting PATH
should make the column name part of the query ID.

So I think `JsonExpr.column_name` should be marked `query_jumble_ignore`
instead of using a custom query jumble function.

--
Sami

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-10-26 18:26:34 Re: Query jumbling ignores XML names, ROLLUP/CUBE, VARIADIC and more
Previous Message Andrey Rachitskiy 2026-10-26 17:14:02 Re: BUG #19796: io_uring crashes with specific kernel/liburing versions + io_max_concurrency due to rings overlap