1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Apply some query jumbling to WAIT FOR LSN

The query is now stored as normalized in pg_stat_statements, with its
LSN position ignored in the jumbling, resulting in:
WAIT FOR LSN $1;

The option values in the WITH clause are left untouched.

Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Sirisha Chamarthi <sirichamarthi22@gmail.com>
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>
Reviewed-by: Rithvika Devisetti <devisettirithvika@gmail.com>
Discussion: https://postgr.es/m/1f04f78c-2cfa-47a0-997f-f02572cd10eb@eisentraut.org
Backpatch-through: 19
This commit is contained in:
Michael Paquier
2026-09-02 14:14:19 +09:00
parent 262f2eea95
commit 282111b45c
4 changed files with 58 additions and 2 deletions

View File

@@ -719,6 +719,47 @@ SELECT pg_stat_statements_reset() IS NOT NULL AS t;
t
(1 row)
-- WAIT FOR LSN
WAIT FOR LSN '0/0' WITH (MODE 'primary_flush');
status
---------
success
(1 row)
WAIT FOR LSN '0/1' WITH (MODE 'primary_flush');
status
---------
success
(1 row)
WAIT FOR LSN '0/0' WITH (MODE 'primary_flush', NO_THROW);
status
---------
success
(1 row)
WAIT FOR LSN '0/0' WITH (MODE 'primary_flush', TIMEOUT 1);
status
---------
success
(1 row)
SELECT calls, rows, query FROM pg_stat_statements
WHERE query LIKE 'WAIT FOR LSN%'
ORDER BY query COLLATE "C";
calls | rows | query
-------+------+--------------------------------------------------------
2 | 0 | WAIT FOR LSN $1 WITH (MODE 'primary_flush')
1 | 0 | WAIT FOR LSN $1 WITH (MODE 'primary_flush', NO_THROW)
1 | 0 | WAIT FOR LSN $1 WITH (MODE 'primary_flush', TIMEOUT 1)
(3 rows)
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
t
---
t
(1 row)
-- Special cases. Keep these ones at the end to avoid conflicts.
SET SCHEMA 'foo';
SET SCHEMA 'public';

View File

@@ -365,6 +365,16 @@ DROP TABLE pgss_select_into;
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
-- WAIT FOR LSN
WAIT FOR LSN '0/0' WITH (MODE 'primary_flush');
WAIT FOR LSN '0/1' WITH (MODE 'primary_flush');
WAIT FOR LSN '0/0' WITH (MODE 'primary_flush', NO_THROW);
WAIT FOR LSN '0/0' WITH (MODE 'primary_flush', TIMEOUT 1);
SELECT calls, rows, query FROM pg_stat_statements
WHERE query LIKE 'WAIT FOR LSN%'
ORDER BY query COLLATE "C";
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
-- Special cases. Keep these ones at the end to avoid conflicts.
SET SCHEMA 'foo';
SET SCHEMA 'public';

View File

@@ -17300,6 +17300,7 @@ WaitStmt:
WaitStmt *n = makeNode(WaitStmt);
n->lsn_literal = $4;
n->options = $5;
n->lsn_location = @4;
$$ = (Node *) n;
}
;

View File

@@ -4606,8 +4606,12 @@ typedef struct DropSubscriptionStmt
typedef struct WaitStmt
{
NodeTag type;
char *lsn_literal; /* LSN string from grammar */
List *options; /* List of DefElem nodes */
/* LSN string from grammar */
char *lsn_literal pg_node_attr(query_jumble_ignore);
/* List of DefElem nodes */
List *options;
/* token location, or -1 if unknown */
ParseLoc lsn_location pg_node_attr(query_jumble_location);
} WaitStmt;