pg_stat_monitor/regression/sql
Zsolt Parragi 130d6b5fce
PG-592: Treat queries with different parent queries as separate entries (#403)
* PG-592: Treat queries with different parent queries as separate entries

1. Previously pg_stat_monitor had a `topquery` and `topqueryid` field, but it was only a sample:
it showed one of the top queries executing the specific query.

With this change, the same entry executed by two different functions will result in two entries in the statistics table.

2. This also fixes a bug where the content of these field disappeared for every second query executed:
previously the update function changed topqueryid to `0` if it was non zero, and changed it to the proper id when it was 0.
This resulted in an alternating behavior, where for every second executed query the top query disappeared.

After these changes, the top query is always shown.

3. The previous implementation also leaked dsa memory used to store the parent queries. This is now also fixed.

* PG-502: Fixing review comments

* dsa_free changed to assert as it can never happen
* restructured the ifs to be cleaner
  Note: kept the two-level ifs, as that makes more sense with the assert
  Note: didn't convert nested_level checks to macro, as it is used differently at different parts of the code

* PG-502: Fixing review comments

* PG-592 Add regression test

* Make test compatible with PG12

* Remove redundant line

---------

Co-authored-by: Artem Gavrilov <artem.gavrilov@percona.com>
2024-08-06 23:43:48 +02: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
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
pgsm_query_id.sql PG-606: New GUC required for enabling/disabling of pgsm_query_id calculation… (#383) 2023-02-23 19:08:09 +05: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
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-563: Update TAP testcases and output due to changes by DEV. 2022-12-27 18:14:32 +05: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