mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-22 03:53:24 +02:00
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
32 lines
915 B
SQL
32 lines
915 B
SQL
--
|
|
-- 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;
|
|
|
|
--
|
|
-- [re]plan counting
|
|
--
|
|
CREATE TABLE stats_plan_test ();
|
|
PREPARE prep1 AS SELECT COUNT(*) FROM stats_plan_test;
|
|
EXECUTE prep1;
|
|
EXECUTE prep1;
|
|
EXECUTE prep1;
|
|
ALTER TABLE stats_plan_test ADD COLUMN x int;
|
|
EXECUTE prep1;
|
|
SELECT 42;
|
|
SELECT 42;
|
|
SELECT 42;
|
|
SELECT plans, calls, rows, query FROM pg_stat_statements
|
|
WHERE query NOT LIKE 'PREPARE%' ORDER BY query COLLATE "C";
|
|
-- 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";
|
|
|
|
-- Cleanup
|
|
DROP TABLE stats_plan_test;
|
|
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
|