Skip to content

Commit

Permalink
PG-260: Fix regression tests.
Browse files Browse the repository at this point in the history
The regression tests required some adjustmentes as they were based on a
wrong behavior in pg_stat_monitor that was fixed in the last commits.

The problem was that pg_stat_monitor_reset() was not properly clearing
the query buffers, as such, some garbage queries were residing in the
buffers after calling pg_stat_monitor_reset().

One example of a problem, a query such as "SELECT 1 AS num" and the
same query with comments such as:
SELECT $1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3)
*/
Are evaluated to the same query ID, if a test issue the first query, call
pg_stat_monitor_reset() to clear query buffer, then issue the second
query with comments, the result in pg_stat_monitor view would still contain
the first query without comments, this was leading to tests expecting
the wrong output, which is now fixed.
  • Loading branch information
darkfronza committed Oct 14, 2021
1 parent 0e06a4c commit 9e76f6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion regression/expected/counters.out
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end $$;
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls
---------------------------------------------------------------------------------------------------+-------
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a; | 1000
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a | 1000
SELECT pg_stat_monitor_reset(); | 1
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C"; | 1
do $$ +| 1
Expand Down
2 changes: 1 addition & 1 deletion regression/expected/state.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ERROR: division by zero
SELECT query, state_code, state FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | state_code | state
----------------------------------------------------------------------------------+------------+---------------------
SELECT $1 AS num | 3 | FINISHED
SELECT $1 | 3 | FINISHED
SELECT 1/0; | 4 | FINISHED WITH ERROR
SELECT pg_stat_monitor_reset(); | 3 | FINISHED
SELECT query, state_code, state FROM pg_stat_monitor ORDER BY query COLLATE "C"; | 2 | ACTIVE
Expand Down
10 changes: 5 additions & 5 deletions regression/expected/tags.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ SELECT 1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */;
(1 row)

SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | comments
-------------------------------------------------------------------------+------------------------------------------------------
SELECT $1 AS num | { "application", psql_app, "real_ip", 192.168.1.3)
SELECT pg_stat_monitor_reset(); |
SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; |
query | comments
---------------------------------------------------------------------------+------------------------------------------------------
SELECT $1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */ | { "application", psql_app, "real_ip", 192.168.1.3)
SELECT pg_stat_monitor_reset(); |
SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; |
(3 rows)

SELECT pg_stat_monitor_reset();
Expand Down

0 comments on commit 9e76f6f

Please sign in to comment.