PG-563: Update TAP testcases and output due to changes by DEV.

As part of this PR, also updated regression test cases that are related to
following JIRA issues as well.

PG-354	pg_stat_monitor: Remove pg_stat_monitor_settings view
Now we not using pg_stat_monitor_settings view, due to this change majority of
TAP testcase requried output changes.

PG-558: Create test case to verify the function names and count in PGSM.
Added additional output file for SQL test case.

PG-554:	Remove redundant expected output files from regression.
Removed unnecessary output files in TAP testcases where these were not needed.
This commit is contained in:
Naeem Akhter
2022-12-24 22:44:05 +05:00
parent 56001d683f
commit b154da01da
68 changed files with 1282 additions and 10492 deletions

View File

@@ -1,18 +1,18 @@
Create EXTENSION pg_stat_monitor;
CREATE EXTENSION pg_stat_monitor;
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
(1 row)
Set application_name = 'naeem' ;
SET application_name = 'naeem' ;
SELECT 1 AS num;
num
-----
1
(1 row)
Set application_name = 'psql' ;
SET application_name = 'psql' ;
SELECT 1 AS num;
num
-----
@@ -25,8 +25,8 @@ SELECT query,application_name FROM pg_stat_monitor ORDER BY query, application_n
SELECT 1 AS num | naeem
SELECT 1 AS num | psql
SELECT pg_stat_monitor_reset() | pg_regress/application_name_unique
Set application_name = 'naeem' | naeem
Set application_name = 'psql' | psql
SET application_name = 'naeem' | naeem
SET application_name = 'psql' | psql
(5 rows)
SELECT pg_stat_monitor_reset();

View File

@@ -1,18 +1,18 @@
Create EXTENSION pg_stat_monitor;
CREATE EXTENSION pg_stat_monitor;
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
(1 row)
Set application_name = 'naeem' ;
SET application_name = 'naeem' ;
SELECT 1 AS num;
num
-----
1
(1 row)
Set application_name = 'psql' ;
SET application_name = 'psql' ;
SELECT 1 AS num;
num
-----

View File

@@ -1,4 +1,4 @@
Drop Table if exists Company;
DROP TABLE IF EXISTS Company;
NOTICE: table "company" does not exist, skipping
CREATE TABLE Company(
ID INT PRIMARY KEY NOT NULL,
@@ -15,13 +15,13 @@ INSERT INTO Company(ID, Name) VALUES (1, 'Percona');
INSERT INTO Company(ID, Name) VALUES (1, 'Percona');
ERROR: duplicate key value violates unique constraint "company_pkey"
DETAIL: Key (id)=(1) already exists.
Drop Table if exists Company;
DROP TABLE IF EXISTS Company;
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
query | elevel | sqlcode | message
-------------------------------------------------------+--------+---------+---------------------------------------------------------------
Drop Table if exists Company | 0 | |
DROP TABLE IF EXISTS Company | 0 | |
INSERT INTO Company(ID, Name) VALUES (1, 'Percona') | 0 | |
INSERT INTO Company(ID, Name) VALUES (1, 'Percona'); | 20 | 23505 | duplicate key value violates unique constraint "company_pkey"
INSERT INTO Company(ID, Name) VALUES (1, 'Percona'); | 21 | 23505 | duplicate key value violates unique constraint "company_pkey"
SELECT pg_stat_monitor_reset() | 0 | |
(4 rows)

View File

@@ -1,4 +1,4 @@
Drop Table if exists Company;
DROP TABLE IF EXISTS Company;
NOTICE: table "company" does not exist, skipping
CREATE TABLE Company(
ID INT PRIMARY KEY NOT NULL,
@@ -15,13 +15,13 @@ INSERT INTO Company(ID, Name) VALUES (1, 'Percona');
INSERT INTO Company(ID, Name) VALUES (1, 'Percona');
ERROR: duplicate key value violates unique constraint "company_pkey"
DETAIL: Key (id)=(1) already exists.
Drop Table if exists Company;
DROP TABLE IF EXISTS Company;
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
query | elevel | sqlcode | message
-------------------------------------------------------+--------+---------+---------------------------------------------------------------
Drop Table if exists Company | 0 | |
DROP TABLE IF EXISTS Company | 0 | |
INSERT INTO Company(ID, Name) VALUES (1, 'Percona') | 0 | |
INSERT INTO Company(ID, Name) VALUES (1, 'Percona'); | 21 | 23505 | duplicate key value violates unique constraint "company_pkey"
INSERT INTO Company(ID, Name) VALUES (1, 'Percona'); | 20 | 23505 | duplicate key value violates unique constraint "company_pkey"
SELECT pg_stat_monitor_reset() | 0 | |
(4 rows)

View File

@@ -1,3 +1,4 @@
DROP ROLE IF EXISTS su;
CREATE USER su WITH SUPERUSER;
SET ROLE su;
CREATE EXTENSION pg_stat_monitor;
@@ -35,6 +36,6 @@ SELECT routine_schema, routine_name, routine_type, data_type FROM information_sc
public | pg_stat_monitor_version | FUNCTION | text
(3 rows)
set role su;
SET ROLE su;
DROP USER u1;
DROP EXTENSION pg_stat_monitor;

View File

@@ -0,0 +1,42 @@
DROP ROLE IF EXISTS su;
NOTICE: role "su" does not exist, skipping
CREATE USER su WITH SUPERUSER;
SET ROLE su;
CREATE EXTENSION pg_stat_monitor;
CREATE USER u1;
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
(1 row)
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
routine_schema | routine_name | routine_type | data_type
----------------+--------------------------+--------------+-----------
public | decode_error_level | FUNCTION | text
public | get_cmd_type | FUNCTION | text
public | get_histogram_timings | FUNCTION | text
public | histogram | FUNCTION | record
public | pg_stat_monitor_internal | FUNCTION | record
public | pg_stat_monitor_reset | FUNCTION | void
public | pg_stat_monitor_version | FUNCTION | text
public | pgsm_create_11_view | FUNCTION | integer
public | pgsm_create_13_view | FUNCTION | integer
public | pgsm_create_14_view | FUNCTION | integer
public | pgsm_create_15_view | FUNCTION | integer
public | pgsm_create_view | FUNCTION | integer
public | range | FUNCTION | ARRAY
(13 rows)
SET ROLE u1;
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
routine_schema | routine_name | routine_type | data_type
----------------+-------------------------+--------------+-----------
public | histogram | FUNCTION | record
public | pg_stat_monitor_reset | FUNCTION | void
public | pg_stat_monitor_version | FUNCTION | text
(3 rows)
SET ROLE su;
DROP USER u1;
DROP EXTENSION pg_stat_monitor;

View File

@@ -1,39 +1,38 @@
CREATE EXTENSION pg_stat_monitor;
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
(1 row)
SELECT name
, setting
, unit
, context
, vartype
, source
, min_val
, max_val
, enumvals
, boot_val
, reset_val
, pending_restart
FROM pg_settings
WHERE name LIKE 'pg_stat_monitor.%'
ORDER
BY name
COLLATE "C";
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
pg_stat_monitor.pgsm_bucket_time | 60 | | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
pg_stat_monitor.pgsm_enable_query_plan | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_extract_comments | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_histogram_buckets | 20 | | postmaster | integer | default | 2 | 50 | | 20 | 20 | f
pg_stat_monitor.pgsm_histogram_max | 100000 | | postmaster | integer | default | 10 | 2147483647 | | 100000 | 100000 | f
pg_stat_monitor.pgsm_histogram_min | 1 | | postmaster | integer | default | 0 | 2147483647 | | 1 | 1 | f
pg_stat_monitor.pgsm_max | 100 | MB | postmaster | integer | default | 1 | 1000 | | 100 | 100 | f
pg_stat_monitor.pgsm_max_buckets | 10 | | postmaster | integer | default | 1 | 10 | | 10 | 10 | f
pg_stat_monitor.pgsm_normalized_query | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_overflow_target | 1 | | postmaster | integer | default | 0 | 1 | | 1 | 1 | f
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
pg_stat_monitor.pgsm_track_planning | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
(15 rows)
select pg_sleep(.5);
pg_sleep
----------
(1 row)
SELECT * FROM pg_stat_monitor_settings WHERE name NOT LIKE 'pg_stat_monitor.pgsm_track_planning' ORDER BY name COLLATE "C";
name | value | default_value | description | minimum | maximum | options | restart
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
pg_stat_monitor.pgsm_extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
pg_stat_monitor.pgsm_histogram_buckets | 20 | 20 | Sets the maximum number of histogram buckets | 2 | 50 | | yes
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
pg_stat_monitor.pgsm_histogram_min | 1 | 1 | Sets the time in millisecond. | 0 | 2147483647 | | yes
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
pg_stat_monitor.pgsm_normalized_query | no | no | Selects whether save query in normalized format. | | | yes, no | no
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
pg_stat_monitor.pgsm_query_max_len | 2048 | 2048 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes
pg_stat_monitor.pgsm_track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
(14 rows)
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
(1 row)
DROP EXTENSION pg_stat_monitor;
DROP EXTENSION pg_stat_monitor;

View File

@@ -0,0 +1,37 @@
CREATE EXTENSION pg_stat_monitor;
SELECT name
, setting
, unit
, context
, vartype
, source
, min_val
, max_val
, enumvals
, boot_val
, reset_val
, pending_restart
FROM pg_settings
WHERE name LIKE 'pg_stat_monitor.%'
ORDER
BY name
COLLATE "C";
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
pg_stat_monitor.pgsm_bucket_time | 60 | | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
pg_stat_monitor.pgsm_enable_query_plan | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_extract_comments | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_histogram_buckets | 20 | | postmaster | integer | default | 2 | 50 | | 20 | 20 | f
pg_stat_monitor.pgsm_histogram_max | 100000 | | postmaster | integer | default | 10 | 2147483647 | | 100000 | 100000 | f
pg_stat_monitor.pgsm_histogram_min | 1 | | postmaster | integer | default | 0 | 2147483647 | | 1 | 1 | f
pg_stat_monitor.pgsm_max | 100 | MB | postmaster | integer | default | 1 | 1000 | | 100 | 100 | f
pg_stat_monitor.pgsm_max_buckets | 10 | | postmaster | integer | default | 1 | 10 | | 10 | 10 | f
pg_stat_monitor.pgsm_normalized_query | off | | user | bool | default | | | | off | off | f
pg_stat_monitor.pgsm_overflow_target | 1 | | postmaster | integer | default | 0 | 1 | | 1 | 1 | f
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
(14 rows)
DROP EXTENSION pg_stat_monitor;

View File

@@ -53,10 +53,10 @@ SELECT pg_stat_monitor_reset();
(1 row)
-- test the schema qualified table
CREATE schema sch1;
CREATE schema sch2;
CREATE schema sch3;
CREATE schema sch4;
CREATE SCHEMA sch1;
CREATE SCHEMA sch2;
CREATE SCHEMA sch3;
CREATE SCHEMA sch4;
CREATE TABLE sch1.foo1(a int);
CREATE TABLE sch2.foo2(b int);
CREATE TABLE sch3.foo3(c int);

View File

@@ -1,5 +1,5 @@
CREATE EXTENSION pg_stat_monitor;
Set pg_stat_monitor.pgsm_track='all';
SET pg_stat_monitor.pgsm_track='all';
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
@@ -11,7 +11,7 @@ $$
BEGIN
return (select $1 + $2);
END; $$ language plpgsql;
CREATE OR REPLACE function add2(int, int) RETURNS int as
CREATE OR REPLACE FUNCTION add2(int, int) RETURNS INTEGER AS
$$
BEGIN
return add($1,$2);
@@ -24,22 +24,22 @@ SELECT add2(1,2);
(1 row)
SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | top_query
-------------------------------------------------------------+------------------
CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS+|
$$ +|
BEGIN +|
return (select $1 + $2); +|
END; $$ language plpgsql |
CREATE OR REPLACE function add2(int, int) RETURNS int as +|
$$ +|
BEGIN +|
return add($1,$2); +|
END; +|
$$ language plpgsql |
SELECT (select $1 + $2) | SELECT add2(1,2)
SELECT add2(1,2) |
SELECT pg_stat_monitor_reset() |
query | top_query
--------------------------------------------------------------+------------------
(select $1 + $2) | SELECT add2(1,2)
CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +|
$$ +|
BEGIN +|
return (select $1 + $2); +|
END; $$ language plpgsql |
CREATE OR REPLACE FUNCTION add2(int, int) RETURNS INTEGER AS+|
$$ +|
BEGIN +|
return add($1,$2); +|
END; +|
$$ language plpgsql |
SELECT add2(1,2) |
SELECT pg_stat_monitor_reset() |
(5 rows)
SELECT pg_stat_monitor_reset();

View File

@@ -1,5 +1,5 @@
CREATE EXTENSION pg_stat_monitor;
Set pg_stat_monitor.pgsm_track='all';
SET pg_stat_monitor.pgsm_track='all';
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
@@ -11,7 +11,7 @@ $$
BEGIN
return (select $1 + $2);
END; $$ language plpgsql;
CREATE OR REPLACE function add2(int, int) RETURNS int as
CREATE OR REPLACE FUNCTION add2(int, int) RETURNS INTEGER AS
$$
BEGIN
return add($1,$2);
@@ -24,22 +24,22 @@ SELECT add2(1,2);
(1 row)
SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | top_query
-------------------------------------------------------------+------------------
(select $1 + $2) | SELECT add2(1,2)
CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS+|
$$ +|
BEGIN +|
return (select $1 + $2); +|
END; $$ language plpgsql |
CREATE OR REPLACE function add2(int, int) RETURNS int as +|
$$ +|
BEGIN +|
return add($1,$2); +|
END; +|
$$ language plpgsql |
SELECT add2(1,2) |
SELECT pg_stat_monitor_reset() |
query | top_query
--------------------------------------------------------------+------------------
CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +|
$$ +|
BEGIN +|
return (select $1 + $2); +|
END; $$ language plpgsql |
CREATE OR REPLACE FUNCTION add2(int, int) RETURNS INTEGER AS+|
$$ +|
BEGIN +|
return add($1,$2); +|
END; +|
$$ language plpgsql |
SELECT (select $1 + $2) | SELECT add2(1,2)
SELECT add2(1,2) |
SELECT pg_stat_monitor_reset() |
(5 rows)
SELECT pg_stat_monitor_reset();