diff --git a/.github/workflows/postgresql-11-build.yml b/.github/workflows/postgresql-11-build.yml index cc2726e1..079077ad 100644 --- a/.github/workflows/postgresql-11-build.yml +++ b/.github/workflows/postgresql-11-build.yml @@ -22,7 +22,8 @@ jobs: libipc-run-perl -y docbook-xsl docbook-xsl libxml2 libxml2-utils \ libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \ libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \ - llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev + llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev \ + libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-11-ppg-package.yml b/.github/workflows/postgresql-11-ppg-package.yml index 976b93b1..570aae8f 100644 --- a/.github/workflows/postgresql-11-ppg-package.yml +++ b/.github/workflows/postgresql-11-ppg-package.yml @@ -18,7 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget + libipc-run-perl wget libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-12-build.yml b/.github/workflows/postgresql-12-build.yml index ffdaa18f..99da685a 100644 --- a/.github/workflows/postgresql-12-build.yml +++ b/.github/workflows/postgresql-12-build.yml @@ -22,7 +22,8 @@ jobs: libipc-run-perl docbook-xsl docbook-xsl libxml2 libxml2-utils \ libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \ libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \ - llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev + llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev \ + libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-12-pgdg-package.yml b/.github/workflows/postgresql-12-pgdg-package.yml index 05b3afdb..b5b6a57e 100644 --- a/.github/workflows/postgresql-12-pgdg-package.yml +++ b/.github/workflows/postgresql-12-pgdg-package.yml @@ -18,7 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget -y + libipc-run-perl wget -y libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-12-ppg-package.yml b/.github/workflows/postgresql-12-ppg-package.yml index e6c8487f..4f099303 100644 --- a/.github/workflows/postgresql-12-ppg-package.yml +++ b/.github/workflows/postgresql-12-ppg-package.yml @@ -18,10 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget - sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ - zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget + libipc-run-perl wget libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-13-build.yml b/.github/workflows/postgresql-13-build.yml index 27eb9548..b7191ba8 100644 --- a/.github/workflows/postgresql-13-build.yml +++ b/.github/workflows/postgresql-13-build.yml @@ -22,7 +22,8 @@ jobs: libipc-run-perl -y docbook-xsl docbook-xsl libxml2 libxml2-utils \ libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \ libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \ - llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev + llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev \ + libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-13-pgdg-package.yml b/.github/workflows/postgresql-13-pgdg-package.yml index ee257818..7ce86bbc 100644 --- a/.github/workflows/postgresql-13-pgdg-package.yml +++ b/.github/workflows/postgresql-13-pgdg-package.yml @@ -18,7 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget -y + libipc-run-perl wget -y libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-13-ppg-package.yml b/.github/workflows/postgresql-13-ppg-package.yml index 93dedb68..d6f3418a 100644 --- a/.github/workflows/postgresql-13-ppg-package.yml +++ b/.github/workflows/postgresql-13-ppg-package.yml @@ -18,7 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget + libipc-run-perl wget libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-14-build.yml b/.github/workflows/postgresql-14-build.yml index 2a47321b..cfe84e88 100644 --- a/.github/workflows/postgresql-14-build.yml +++ b/.github/workflows/postgresql-14-build.yml @@ -23,7 +23,7 @@ jobs: libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \ libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \ llvm-11 llvm-11-dev libselinux1-dev python3-dev \ - uuid-dev liblz4-dev + uuid-dev liblz4-dev libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-14-pgdg-package.yml b/.github/workflows/postgresql-14-pgdg-package.yml index 8303d606..e6fb8a38 100644 --- a/.github/workflows/postgresql-14-pgdg-package.yml +++ b/.github/workflows/postgresql-14-pgdg-package.yml @@ -17,7 +17,8 @@ jobs: sudo apt purge postgresql-client-common postgresql-common \ postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev wget \ - zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl + zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl \ + libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-14-ppg-package.yml b/.github/workflows/postgresql-14-ppg-package.yml index 337dccd5..a3c740a6 100644 --- a/.github/workflows/postgresql-14-ppg-package.yml +++ b/.github/workflows/postgresql-14-ppg-package.yml @@ -18,7 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget + libipc-run-perl wget libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-15-build.yml b/.github/workflows/postgresql-15-build.yml index c0c76e0f..ea00314c 100644 --- a/.github/workflows/postgresql-15-build.yml +++ b/.github/workflows/postgresql-15-build.yml @@ -23,7 +23,7 @@ jobs: libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \ libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \ llvm-11 llvm-11-dev libselinux1-dev python3-dev \ - uuid-dev liblz4-dev + uuid-dev liblz4-dev libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-15-pgdg-package.yml b/.github/workflows/postgresql-15-pgdg-package.yml index ab5b5c9d..0fb45c79 100644 --- a/.github/workflows/postgresql-15-pgdg-package.yml +++ b/.github/workflows/postgresql-15-pgdg-package.yml @@ -17,7 +17,8 @@ jobs: sudo apt purge postgresql-client-common postgresql-common \ postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev wget \ - zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl + zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl \ + libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/.github/workflows/postgresql-15-ppg-package.yml b/.github/workflows/postgresql-15-ppg-package.yml index e6b963da..7f6f867c 100644 --- a/.github/workflows/postgresql-15-ppg-package.yml +++ b/.github/workflows/postgresql-15-ppg-package.yml @@ -18,7 +18,7 @@ jobs: postgresql postgresql* sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \ zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \ - libipc-run-perl wget + libipc-run-perl wget libtext-diff-perl sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \ /usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \ /etc/postgresql diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..24c1f8fb --- /dev/null +++ b/TESTING.md @@ -0,0 +1,31 @@ +# How to run the tests + +This document describes how to run the tests suites when building pg & pgsm from source. + +The steps can also be adapted when postgres is installed using a package manager, in that case the relevant directories will be in their usual global locations (`/usr/lib/postgresql`) + +## pg_regress + +1. setup and start a postgres cluster +2. create a database named "contrib\_regression" +3. Install the pg\_stat\_statements extension +4. Run the tests using (with the working directory as the pgsm git repository): + + ``` + /src/test/regress/pg_regress --bindir /bin --temp-config pg_stat_monitor.conf --inputdir regression/ --dbname=contrib_regression basic version guc pgsm_query_id functions counters relations database error_insert application_name application_name_unique top_query cmd_type error rows tags user + ``` + +# prove + +1. setup and start postgres cluster +2. create a database named "contrib\_regression" +3. Install the pg\_stat\_monitor and pg\_stat\_statements extensions +4. When executing the tests multiple times, delete the `tmp_check` directory between runs +5. When executing the tests and encountering failures, databases created by some tests might remain in the cluster. + Connect to the cluster, and delete these databases if they cause errors. +6. Run the tests using (with the working directory as the pgsm git repository): + + ``` + prove -I /src/src/test/perl/ -I . t/*.pl + ``` + diff --git a/t/007_settings_pgsm_query_shared_buffer.pl b/t/007_settings_pgsm_query_shared_buffer.pl index 35ab0a68..a848a3ab 100644 --- a/t/007_settings_pgsm_query_shared_buffer.pl +++ b/t/007_settings_pgsm_query_shared_buffer.pl @@ -59,7 +59,7 @@ print " out: $out \n"; ok($cmdret == 0, "Run pgbench"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, lower(query), calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor"); PGSM::append_to_file($stdout); @@ -82,7 +82,7 @@ print " out: $out \n"; ok($cmdret == 0, "Run pgbench"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, lower(query), calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor"); PGSM::append_to_file($stdout); @@ -105,7 +105,7 @@ print " out: $out \n"; ok($cmdret == 0, "Run pgbench"); -($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); +($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, lower(query), calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']); ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor"); PGSM::append_to_file($stdout); diff --git a/t/expected/007_settings_pgsm_query_shared_buffer.out b/t/expected/007_settings_pgsm_query_shared_buffer.out index 8e7687aa..cc8565da 100644 --- a/t/expected/007_settings_pgsm_query_shared_buffer.out +++ b/t/expected/007_settings_pgsm_query_shared_buffer.out @@ -15,16 +15,10 @@ CREATE database example; SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20; datname | query | calls ---------+---------------------------------------------------------------------------------------------------------------+------- - example | BEGIN | 10000 - example | END | 10000 - example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 example | alter table pgbench_accounts add primary key (aid) | 1 example | alter table pgbench_branches add primary key (bid) | 1 example | alter table pgbench_tellers add primary key (tid) | 1 + example | BEGIN | 10000 example | begin | 1 example | commit | 1 example | copy pgbench_accounts from stdin | 1 @@ -33,8 +27,14 @@ SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_m example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 + example | END | 10000 example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 + example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 + example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 + example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 + example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 + example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 (20 rows) SELECT pg_stat_monitor_reset(); @@ -52,16 +52,10 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20; datname | query | calls ---------+---------------------------------------------------------------------------------------------------------------+------- - example | BEGIN | 10000 - example | END | 10000 - example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 example | alter table pgbench_accounts add primary key (aid) | 1 example | alter table pgbench_branches add primary key (bid) | 1 example | alter table pgbench_tellers add primary key (tid) | 1 + example | BEGIN | 10000 example | begin | 1 example | commit | 1 example | copy pgbench_accounts from stdin | 1 @@ -70,8 +64,14 @@ SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_m example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 + example | END | 10000 example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 + example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 + example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 + example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 + example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 + example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 (20 rows) SELECT pg_stat_monitor_reset(); @@ -89,16 +89,10 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20; datname | query | calls ---------+---------------------------------------------------------------------------------------------------------------+------- - example | BEGIN | 10000 - example | END | 10000 - example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 example | alter table pgbench_accounts add primary key (aid) | 1 example | alter table pgbench_branches add primary key (bid) | 1 example | alter table pgbench_tellers add primary key (tid) | 1 + example | BEGIN | 10000 example | begin | 1 example | commit | 1 example | copy pgbench_accounts from stdin | 1 @@ -107,8 +101,14 @@ SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_m example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 + example | END | 10000 example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 + example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 + example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 + example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 + example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 + example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 (20 rows) SELECT pg_stat_monitor_reset(); diff --git a/t/expected/007_settings_pgsm_query_shared_buffer.out.15 b/t/expected/007_settings_pgsm_query_shared_buffer.out.15 index c01b7f26..bc46b27a 100755 --- a/t/expected/007_settings_pgsm_query_shared_buffer.out.15 +++ b/t/expected/007_settings_pgsm_query_shared_buffer.out.15 @@ -12,29 +12,29 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals (1 row) CREATE database example; -SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20; - datname | query | calls ----------+---------------------------------------------------------------------------------------------------------------+------- - example | BEGIN | 10000 - example | END | 10000 - example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 - example | alter table pgbench_accounts add primary key (aid) | 1 - example | alter table pgbench_branches add primary key (bid) | 1 - example | alter table pgbench_tellers add primary key (tid) | 1 - example | begin | 1 - example | commit | 1 - example | copy pgbench_accounts from stdin with (freeze on) | 1 - example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1 - example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1 - example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 - example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 - example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 - example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 - example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 +SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, lower(query), calls DESC Limit 20; + datname | query | calls +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------+------- + example | alter table pgbench_accounts add primary key (aid) | 1 + example | alter table pgbench_branches add primary key (bid) | 1 + example | alter table pgbench_tellers add primary key (tid) | 1 + example | BEGIN | 10000 + example | begin | 1 + example | commit | 1 + example | copy pgbench_accounts from stdin with (freeze on) | 1 + example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1 + example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1 + example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 + example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 + example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 + example | END | 10000 + example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 + example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 + example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 + example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 + example | select count(*) from pgbench_branches | 1 + example | select o.n, p.partstrat, pg_catalog.count(i.inhparent) from pg_catalog.pg_class as c join pg_catalog.pg_namespace as n on (n.oid = c.relnamespace) cr | 1 + example | truncate pgbench_history | 1 (20 rows) SELECT pg_stat_monitor_reset(); @@ -49,29 +49,29 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals pg_stat_monitor.pgsm_query_shared_buffer | 2 | MB | postmaster | integer | configuration file | 1 | 10000 | | 20 | 2 | f (1 row) -SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20; - datname | query | calls ----------+---------------------------------------------------------------------------------------------------------------+------- - example | BEGIN | 10000 - example | END | 10000 - example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 - example | alter table pgbench_accounts add primary key (aid) | 1 - example | alter table pgbench_branches add primary key (bid) | 1 - example | alter table pgbench_tellers add primary key (tid) | 1 - example | begin | 1 - example | commit | 1 - example | copy pgbench_accounts from stdin with (freeze on) | 1 - example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1 - example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1 - example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 - example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 - example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 - example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 - example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 +SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, lower(query), calls DESC Limit 20; + datname | query | calls +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------+------- + example | alter table pgbench_accounts add primary key (aid) | 1 + example | alter table pgbench_branches add primary key (bid) | 1 + example | alter table pgbench_tellers add primary key (tid) | 1 + example | BEGIN | 10000 + example | begin | 1 + example | commit | 1 + example | copy pgbench_accounts from stdin with (freeze on) | 1 + example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1 + example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1 + example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 + example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 + example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 + example | END | 10000 + example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 + example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 + example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 + example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 + example | select count(*) from pgbench_branches | 1 + example | select o.n, p.partstrat, pg_catalog.count(i.inhparent) from pg_catalog.pg_class as c join pg_catalog.pg_namespace as n on (n.oid = c.relnamespace) cr | 1 + example | truncate pgbench_history | 1 (20 rows) SELECT pg_stat_monitor_reset(); @@ -86,29 +86,29 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | configuration file | 1 | 10000 | | 20 | 20 | f (1 row) -SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20; - datname | query | calls ----------+---------------------------------------------------------------------------------------------------------------+------- - example | BEGIN | 10000 - example | END | 10000 - example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 - example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 - example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000 - example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000 - example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000 - example | alter table pgbench_accounts add primary key (aid) | 1 - example | alter table pgbench_branches add primary key (bid) | 1 - example | alter table pgbench_tellers add primary key (tid) | 1 - example | begin | 1 - example | commit | 1 - example | copy pgbench_accounts from stdin with (freeze on) | 1 - example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1 - example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1 - example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 - example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 - example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 - example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 - example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 +SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, lower(query), calls DESC Limit 20; + datname | query | calls +---------+-------------------------------------------------------------------------------------------------------------------------------------------------------+------- + example | alter table pgbench_accounts add primary key (aid) | 1 + example | alter table pgbench_branches add primary key (bid) | 1 + example | alter table pgbench_tellers add primary key (tid) | 1 + example | BEGIN | 10000 + example | begin | 1 + example | commit | 1 + example | copy pgbench_accounts from stdin with (freeze on) | 1 + example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1 + example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1 + example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1 + example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1 + example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1 + example | END | 10000 + example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10 + example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000 + example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100 + example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000 + example | select count(*) from pgbench_branches | 1 + example | select o.n, p.partstrat, pg_catalog.count(i.inhparent) from pg_catalog.pg_class as c join pg_catalog.pg_namespace as n on (n.oid = c.relnamespace) cr | 1 + example | truncate pgbench_history | 1 (20 rows) SELECT pg_stat_monitor_reset(); diff --git a/t/pgsm.pm b/t/pgsm.pm index d5545c04..9164204f 100644 --- a/t/pgsm.pm +++ b/t/pgsm.pm @@ -2,6 +2,7 @@ package PGSM; use File::Basename; use File::Compare; +use Text::Diff; use Test::More; our @ISA= qw( Exporter ); @@ -150,7 +151,13 @@ sub setup_files_dir sub compare_results { # Compare expected and results files and return the result - return compare($expected_filename_with_path, $out_filename_with_path); + $res = compare($expected_filename_with_path, $out_filename_with_path); + if( $res ) + { + $diff = diff $expected_filename_with_path => $out_filename_with_path; + diag($diff); + } + return $res; } -1; \ No newline at end of file +1;