postgresql/contrib/pg_stat_statements/expected/planning.out
Alexander Korotkov 6ab1dbd26b Add NOT NULL checking of pg_stat_statements_reset() in tests
This is preliminary patch.  It adds NOT NULL checking for the result of
pg_stat_statements_reset() function. It is needed for upcoming patch
"Track statement entry timestamp" that will change the result type of
this function to the timestamp of a reset performed.

Discussion: https://postgr.es/m/flat/72e80e7b160a6eb189df9ef6f068cce3765d37f8.camel%40moonset.ru
Author: Andrei Zubkov
Reviewed-by: Julien Rouhaud, Hayato Kuroda, Yuki Seino, Chengxi Sun
Reviewed-by: Anton Melnikov, Darren Rush, Michael Paquier, Sergei Kornilov
Reviewed-by: Alena Rybakina, Andrei Lepikhov
2023-11-27 02:52:17 +02:00

89 lines
2.0 KiB
Plaintext

--
-- Information related to planning
--
-- These tests require track_planning to be enabled.
SET pg_stat_statements.track_planning = TRUE;
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
t
---
t
(1 row)
--
-- [re]plan counting
--
CREATE TABLE stats_plan_test ();
PREPARE prep1 AS SELECT COUNT(*) FROM stats_plan_test;
EXECUTE prep1;
count
-------
0
(1 row)
EXECUTE prep1;
count
-------
0
(1 row)
EXECUTE prep1;
count
-------
0
(1 row)
ALTER TABLE stats_plan_test ADD COLUMN x int;
EXECUTE prep1;
count
-------
0
(1 row)
SELECT 42;
?column?
----------
42
(1 row)
SELECT 42;
?column?
----------
42
(1 row)
SELECT 42;
?column?
----------
42
(1 row)
SELECT plans, calls, rows, query FROM pg_stat_statements
WHERE query NOT LIKE 'PREPARE%' ORDER BY query COLLATE "C";
plans | calls | rows | query
-------+-------+------+----------------------------------------------------------
0 | 1 | 0 | ALTER TABLE stats_plan_test ADD COLUMN x int
0 | 1 | 0 | CREATE TABLE stats_plan_test ()
3 | 3 | 3 | SELECT $1
0 | 1 | 1 | SELECT pg_stat_statements_reset() IS NOT NULL AS t
1 | 0 | 0 | SELECT plans, calls, rows, query FROM pg_stat_statements+
| | | WHERE query NOT LIKE $1 ORDER BY query COLLATE "C"
(5 rows)
-- for the prepared statement we expect at least one replan, but cache
-- invalidations could force more
SELECT plans >= 2 AND plans <= calls AS plans_ok, calls, rows, query FROM pg_stat_statements
WHERE query LIKE 'PREPARE%' ORDER BY query COLLATE "C";
plans_ok | calls | rows | query
----------+-------+------+-------------------------------------------------------
t | 4 | 4 | PREPARE prep1 AS SELECT COUNT(*) FROM stats_plan_test
(1 row)
-- Cleanup
DROP TABLE stats_plan_test;
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
t
---
t
(1 row)