From 9e76f6f961a090b5666be844c2378df1e228c3a6 Mon Sep 17 00:00:00 2001 From: Diego Fronza Date: Thu, 14 Oct 2021 10:39:25 -0300 Subject: [PATCH] PG-260: Fix regression tests. 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. --- regression/expected/counters.out | 2 +- regression/expected/state.out | 2 +- regression/expected/tags.out | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/regression/expected/counters.out b/regression/expected/counters.out index c96775e..ebf26f7 100644 --- a/regression/expected/counters.out +++ b/regression/expected/counters.out @@ -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 diff --git a/regression/expected/state.out b/regression/expected/state.out index 147054a..b051091 100644 --- a/regression/expected/state.out +++ b/regression/expected/state.out @@ -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 diff --git a/regression/expected/tags.out b/regression/expected/tags.out index 9da2b13..dffe468 100644 --- a/regression/expected/tags.out +++ b/regression/expected/tags.out @@ -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();