pg_stat_monitor/regression/sql
Zsolt Parragi 5f8b716ef6 PG-2005: Do not keep unnecessary entries in the query stack
PGSM support nested query tracking, and it has to track the current SQL
call stack for this feature to work. But it incorrectly tracked all
previous queries executed within the current top level statement instead
o only the currently active queries.

This was easily visible for example with a FOR LOOP in a user function,
but could be also reproduced in many other ways.

There's also an issue that the related assertion, that compares the
length of the list with the max_stack_depth is incorrect. The stack
depth limits the size of the postgres stack for the C code, not the
number of nested SQL statements.

For now this commit leaves these assertions as-is, as while they are not
technically correct, these at least provide some kind of check on the
nesting depth. Maybe it would make sense to remove them in the future,
but for now, it could be a useful sanity check for testing the actual
fix - we shouldn't hit this assertion anymore with the changes in this
commit.

As for the actual fix, with the changes in this commit pgsm removes list
entries after we finished working on them. At that point we persisted
everything we needed already into the shared memory, and no longer need
the entries in the process local list. This is also true for the
duplicated query string, which if needed was already copied to the
shared memory.
2025-11-12 11:15:37 +01:00
..
application_name.sql [PG-644] Add option to disable application name tracking (#469) 2024-07-23 18:49:33 +02:00
application_name_unique.sql PG-563: Update TAP testcases and output due to changes by DEV. 2022-12-27 18:14:32 +05:00
basic.sql PG-186: Add support to monitor query execution plan. 2021-03-17 18:56:39 +05:00
cmd_type.sql PG-588: Some queries are not being normalised. 2023-02-22 19:31:52 +05:00
counters.sql PG-570: Fix counters test case. 2023-01-03 18:50:53 +05:00
database.sql PG-588: Some queries are not being normalised. 2023-02-22 19:31:52 +05:00
decode_error_level.sql PG-1313 Fix decode_error_level SQL function (#539) 2025-06-19 15:38:44 +02:00
different_parent_queries.sql PG-592: Treat queries with different parent queries as separate entries (#403) 2024-08-06 23:43:48 +02:00
error.sql PG-221: Use alternate of GetUserID function in error hook. 2021-08-31 14:55:53 +00:00
error_insert.sql PG-563: Update TAP testcases and output due to changes by DEV. 2022-12-27 18:14:32 +05:00
functions.sql PG-588: Some queries are not being normalised. 2023-02-22 19:31:52 +05:00
guc.sql PG-563: Update TAP testcases and output due to changes by DEV. 2022-12-27 18:14:32 +05:00
histogram.sql PG-343: Enable TAP testing; PG-292: Automate the QA; PG-338: Calls count.; PG-331: Default values in PMM. 2022-03-22 01:36:47 +05:00
level_tracking.sql [PG-810] PG-17 Support (#463) 2024-07-18 14:59:57 +02:00
parallel.sql PG-1907 Add columns to track parallel worker activity 2025-09-30 11:30:35 +02:00
pgsm_query_id.sql Revert "PG-156: replace query placeholders with actual arguments for… (#517) 2025-02-17 19:13:15 +02:00
relations.sql PG-563: Update TAP testcases and output due to changes by DEV. 2022-12-27 18:14:32 +05:00
rows.sql PG-588: Some queries are not being normalised. 2023-02-22 19:31:52 +05:00
squashing.sql PG-1907 Support constant lists squashing in query jumbling 2025-09-30 11:30:35 +02:00
state.sql PG-188: Added a new column to monitor the query state. 2021-03-21 00:17:17 +05:00
tags.sql PG-451: Fix regression failures in main branch. 2022-07-03 04:26:42 +05:00
top_query.sql PG-2005: Do not keep unnecessary entries in the query stack 2025-11-12 11:15:37 +01:00
user.sql PG-588: Some queries are not being normalised. 2023-02-22 19:31:52 +05:00
version.sql PG-186: Add support to monitor query execution plan. 2021-03-12 18:55:12 +00:00