Add query denormalization regression test for prepared statements
Ensures that the denormalization of prepared statements is working, also ensure that a query which takes more time to execute replaces the previous denormalized query.pull/481/head
parent
522786c581
commit
3133851333
4
Makefile
4
Makefile
|
@ -12,7 +12,7 @@ LDFLAGS_SL += $(filter -lm, $(LIBS))
|
|||
|
||||
TAP_TESTS = 1
|
||||
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression
|
||||
REGRESS = basic version guc pgsm_query_id functions counters relations database error_insert application_name application_name_unique top_query different_parent_queries cmd_type error rows tags user level_tracking
|
||||
REGRESS = basic version guc pgsm_query_id functions counters relations database error_insert application_name application_name_unique top_query different_parent_queries cmd_type error rows tags user level_tracking denorm_prepared_statements
|
||||
|
||||
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
|
||||
# which typical installcheck users do not have (e.g. buildfarm clients).
|
||||
|
@ -40,4 +40,4 @@ update-typedefs:
|
|||
indent:
|
||||
pgindent --typedefs=typedefs-full.list .
|
||||
|
||||
.PHONY: update-typedefs indent
|
||||
.PHONY: update-typedefs indent
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
Set pg_stat_monitor.pgsm_normalized_query='off';
|
||||
CREATE TABLE t1 (a TEXT, b TEXT, c TEXT);
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES($1, $2, $3);
|
||||
EXECUTE prepstmt('A', 'B', 'C');
|
||||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
substring | calls
|
||||
--------------------------------------------------------------------------------+-------
|
||||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES(A, B, C); | 1
|
||||
SELECT pg_stat_monitor_reset() | 1
|
||||
(2 rows)
|
||||
|
||||
EXECUTE prepstmt(REPEAT('XYZ', 8192), md5(random()::text), REPEAT('RANDOM', 4096));
|
||||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
substring | calls
|
||||
---------------------------------------------------------------------------------------------------------------------------------+-------
|
||||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES(XYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZX | 2
|
||||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1
|
||||
SELECT pg_stat_monitor_reset() | 1
|
||||
(3 rows)
|
||||
|
||||
DROP TABLE t1;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
|
@ -0,0 +1,19 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
Set pg_stat_monitor.pgsm_normalized_query='off';
|
||||
|
||||
CREATE TABLE t1 (a TEXT, b TEXT, c TEXT);
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES($1, $2, $3);
|
||||
|
||||
EXECUTE prepstmt('A', 'B', 'C');
|
||||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
EXECUTE prepstmt(REPEAT('XYZ', 8192), md5(random()::text), REPEAT('RANDOM', 4096));
|
||||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DROP EXTENSION pg_stat_monitor;
|
Loading…
Reference in New Issue