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.
As part of this PR, also updated regression test cases that are related to
following JIRA issues as well.
PG-354 pg_stat_monitor: Remove pg_stat_monitor_settings view
Now we not using pg_stat_monitor_settings view, due to this change majority of
TAP testcase requried output changes.
PG-558: Create test case to verify the function names and count in PGSM.
Added additional output file for SQL test case.
PG-554: Remove redundant expected output files from regression.
Removed unnecessary output files in TAP testcases where these were not needed.
This commit brings following changes to this branch:
1) Port changes/additions TAP testing from main branch to this branch, under PG-292.
2) Changes to test cases due to GUCs change, under PG-331.
3) Call counts verfications, under PG-338.
4) Changes to github workflows to accomodate automation for TAP testing, under PG-343.