Merge pull request #178 from Naeem-Akhter/PG-292_tap_tests_branch
PG-292: Automate the Q/A and implement tap testing.pull/179/head
commit
7196d6106f
|
@ -10,13 +10,7 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
repository: 'postgres/postgres'
|
repository: 'postgres/postgres'
|
||||||
ref: 'REL_13_STABLE'
|
ref: 'REL_14_STABLE'
|
||||||
|
|
||||||
- name: Clone pg_stat_monitor repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
path: 'src/pg_stat_monitor'
|
|
||||||
ref: 'master'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
@ -33,6 +27,10 @@ jobs:
|
||||||
sudo rm -rf /usr/share/postgresql
|
sudo rm -rf /usr/share/postgresql
|
||||||
sudo rm -rf /etc/postgresql
|
sudo rm -rf /etc/postgresql
|
||||||
sudo rm -f /usr/bin/pg_config
|
sudo rm -f /usr/bin/pg_config
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install String::Util'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install Data::Str2Num'
|
||||||
|
|
||||||
- name: Create pgsql dir
|
- name: Create pgsql dir
|
||||||
run: mkdir -p /opt/pgsql
|
run: mkdir -p /opt/pgsql
|
||||||
|
|
||||||
|
@ -46,12 +44,12 @@ jobs:
|
||||||
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' \
|
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-maintainer-mode' \
|
||||||
'--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' \
|
'--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' \
|
||||||
'--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' \
|
'--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' \
|
||||||
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/13/man' \
|
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/14/man' \
|
||||||
'--docdir=/usr/share/doc/postgresql-doc-13' \
|
'--docdir=/usr/share/doc/postgresql-doc-14' \
|
||||||
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' \
|
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' \
|
||||||
'--datadir=/usr/share/postgresql/13' '--bindir=/usr/lib/postgresql/13/bin' \
|
'--datadir=/usr/share/postgresql/14' '--bindir=/usr/lib/postgresql/14/bin' \
|
||||||
'--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' \
|
'--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' \
|
||||||
'--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 2:13-x.focal)' \
|
'--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 2:14-x.focal)' \
|
||||||
'--enable-nls' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' \
|
'--enable-nls' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' \
|
||||||
'--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' \
|
'--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' \
|
||||||
'--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
'--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
||||||
|
@ -61,13 +59,13 @@ jobs:
|
||||||
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' \
|
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' \
|
||||||
'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' \
|
'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' \
|
||||||
'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
|
'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
|
||||||
make
|
make world
|
||||||
sudo make install
|
sudo make install-world
|
||||||
|
|
||||||
- name: Start postgresql cluster
|
- name: Start postgresql cluster
|
||||||
run: |
|
run: |
|
||||||
/usr/lib/postgresql/13/bin/initdb -D /opt/pgsql/data
|
/usr/lib/postgresql/14/bin/initdb -D /opt/pgsql/data
|
||||||
/usr/lib/postgresql/13/bin/pg_ctl -D /opt/pgsql/data -l logfile start
|
/usr/lib/postgresql/14/bin/pg_ctl -D /opt/pgsql/data -l logfile start
|
||||||
|
|
||||||
- name: Clone pg_stat_monitor repository
|
- name: Clone pg_stat_monitor repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -76,18 +74,23 @@ jobs:
|
||||||
|
|
||||||
- name: Build pg_stat_monitor
|
- name: Build pg_stat_monitor
|
||||||
run: |
|
run: |
|
||||||
export PATH="/usr/lib/postgresql/13/bin:$PATH"
|
export PATH="/usr/lib/postgresql/14/bin:$PATH"
|
||||||
sudo cp /usr/lib/postgresql/13/bin/pg_config /usr/bin
|
sudo cp /usr/lib/postgresql/14/bin/pg_config /usr/bin
|
||||||
make USE_PGXS=1
|
make USE_PGXS=1
|
||||||
sudo make USE_PGXS=1 install
|
sudo make USE_PGXS=1 install
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Start pg_stat_monitor_tests & Run code coverage
|
- name: Load pg_stat_monitor library and Restart Server
|
||||||
run: |
|
run: |
|
||||||
/usr/lib/postgresql/13/bin/pg_ctl -D /opt/pgsql/data -l logfile stop
|
/usr/lib/postgresql/14/bin/pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> /opt/pgsql/data/postgresql.conf
|
echo "shared_preload_libraries = 'pg_stat_monitor'" >> /opt/pgsql/data/postgresql.conf
|
||||||
/usr/lib/postgresql/13/bin/pg_ctl -D /opt/pgsql/data -l logfile start
|
/usr/lib/postgresql/14/bin/pg_ctl -D /opt/pgsql/data -l logfile start
|
||||||
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Start pg_stat_monitor_tests & Run code coverage
|
||||||
|
run: |
|
||||||
make installcheck
|
make installcheck
|
||||||
|
/usr/lib/postgresql/14/bin/psql -d postgres -p 5432 -c "\list"
|
||||||
make coverage-html
|
make coverage-html
|
||||||
lcov --capture --directory . --output-file coverage/lcov.info
|
lcov --capture --directory . --output-file coverage/lcov.info
|
||||||
pip install cpp-coveralls
|
pip install cpp-coveralls
|
||||||
|
@ -95,3 +98,30 @@ jobs:
|
||||||
coveralls --verbose
|
coveralls --verbose
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Change dir permissions on fail
|
||||||
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
sudo chmod -R ugo+rwx t
|
||||||
|
sudo chmod -R ugo+rwx tmp_check
|
||||||
|
exit 2 # regenerate error so that we can upload files in next step
|
||||||
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Upload logs on fail
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Regressions diff and postgresql log
|
||||||
|
path: |
|
||||||
|
src/pg_stat_monitor/regression.diffs
|
||||||
|
src/pg_stat_monitor/regression.out
|
||||||
|
src/pg_stat_monitor/logfile
|
||||||
|
src/pg_stat_monitor/t/results/
|
||||||
|
src/pg_stat_monitor/tmp_check/log/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/
|
||||||
|
if-no-files-found: warn
|
||||||
|
retention-days: 1
|
||||||
|
|
|
@ -27,6 +27,10 @@ jobs:
|
||||||
sudo rm -rf /usr/share/postgresql
|
sudo rm -rf /usr/share/postgresql
|
||||||
sudo rm -rf /etc/postgresql
|
sudo rm -rf /etc/postgresql
|
||||||
sudo rm -f /usr/bin/pg_config
|
sudo rm -f /usr/bin/pg_config
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install String::Util'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install Data::Str2Num'
|
||||||
|
|
||||||
- name: Create pgsql dir
|
- name: Create pgsql dir
|
||||||
run: mkdir -p /opt/pgsql
|
run: mkdir -p /opt/pgsql
|
||||||
|
|
||||||
|
@ -41,7 +45,7 @@ jobs:
|
||||||
'--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' \
|
'--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' \
|
||||||
'--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' \
|
'--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' \
|
||||||
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/13/man' \
|
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/13/man' \
|
||||||
'--docdir=/usr/share/doc/postgresql-doc-13' \
|
'--docdir=/usr/share/doc/postgresql-doc-13' 'AWK=mawk' \
|
||||||
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' \
|
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' \
|
||||||
'--datadir=/usr/share/postgresql/13' '--bindir=/usr/lib/postgresql/13/bin' \
|
'--datadir=/usr/share/postgresql/13' '--bindir=/usr/lib/postgresql/13/bin' \
|
||||||
'--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' \
|
'--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' \
|
||||||
|
@ -49,7 +53,7 @@ jobs:
|
||||||
'--enable-nls' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' \
|
'--enable-nls' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' \
|
||||||
'--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' \
|
'--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' \
|
||||||
'--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
'--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
||||||
'LLVM_CONFIG=/usr/bin/llvm-config-11' 'CLANG=/usr/bin/clang-11' \
|
'LLVM_CONFIG=/usr/bin/llvm-config-9' 'CLANG=/usr/bin/clang-9' \
|
||||||
'--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' 'PROVE=/usr/bin/prove' \
|
'--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' 'PROVE=/usr/bin/prove' \
|
||||||
'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' \
|
'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' \
|
||||||
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' \
|
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' \
|
||||||
|
@ -72,6 +76,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export PATH="/usr/lib/postgresql/13/bin:$PATH"
|
export PATH="/usr/lib/postgresql/13/bin:$PATH"
|
||||||
sudo cp /usr/lib/postgresql/13/bin/pg_config /usr/bin
|
sudo cp /usr/lib/postgresql/13/bin/pg_config /usr/bin
|
||||||
|
pg_config
|
||||||
make USE_PGXS=1
|
make USE_PGXS=1
|
||||||
sudo make USE_PGXS=1 install
|
sudo make USE_PGXS=1 install
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
@ -83,7 +88,7 @@ jobs:
|
||||||
/usr/lib/postgresql/13/bin/pg_ctl -D /opt/pgsql/data -l logfile start
|
/usr/lib/postgresql/13/bin/pg_ctl -D /opt/pgsql/data -l logfile start
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Start Server installcheck-world tests (without TAP)
|
- name: Start Server installcheck-world tests
|
||||||
run: |
|
run: |
|
||||||
make installcheck-world
|
make installcheck-world
|
||||||
- name: Report on installcheck-world test suites fail
|
- name: Report on installcheck-world test suites fail
|
||||||
|
@ -102,12 +107,30 @@ jobs:
|
||||||
make installcheck
|
make installcheck
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Report on pg_stat_monitor test fail
|
- name: Change dir permissions on fail
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
sudo chmod -R ugo+rwx t
|
||||||
|
sudo chmod -R ugo+rwx tmp_check
|
||||||
|
exit 2 # regenerate error so that we can upload files in next step
|
||||||
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Upload logs on fail
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Regressions diff and postgresql log
|
name: Regressions diff and postgresql log
|
||||||
path: |
|
path: |
|
||||||
src/pg_stat_monitor/regression.diffs
|
src/pg_stat_monitor/regression.diffs
|
||||||
|
src/pg_stat_monitor/regression.out
|
||||||
src/pg_stat_monitor/logfile
|
src/pg_stat_monitor/logfile
|
||||||
|
src/pg_stat_monitor/t/results/
|
||||||
|
src/pg_stat_monitor/tmp_check/log/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/
|
||||||
|
if-no-files-found: warn
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
|
@ -24,6 +24,9 @@ jobs:
|
||||||
sudo rm -rf /usr/share/postgresql
|
sudo rm -rf /usr/share/postgresql
|
||||||
sudo rm -rf /etc/postgresql
|
sudo rm -rf /etc/postgresql
|
||||||
sudo rm -f /usr/bin/pg_config
|
sudo rm -f /usr/bin/pg_config
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install String::Util'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install Data::Str2Num'
|
||||||
|
|
||||||
- name: Install postgresql 13
|
- name: Install postgresql 13
|
||||||
run: |
|
run: |
|
||||||
|
@ -39,22 +42,40 @@ jobs:
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Change sources owner to postgres
|
- name: Change sources owner to postgres
|
||||||
run: sudo chown -R postgres:postgres src/pg_stat_monitor/
|
run: |
|
||||||
|
sudo chown -R postgres:postgres src/pg_stat_monitor/
|
||||||
- name: Start pg_stat_monitor_tests
|
- name: Start pg_stat_monitor_tests
|
||||||
run: |
|
run: |
|
||||||
sudo service postgresql stop
|
sudo service postgresql stop
|
||||||
echo "shared_preload_libraries = 'pg_stat_monitor'" | sudo tee -a /etc/postgresql/13/main/postgresql.conf
|
echo "shared_preload_libraries = 'pg_stat_monitor'" | sudo tee -a /etc/postgresql/13/main/postgresql.conf
|
||||||
sudo service postgresql start
|
sudo service postgresql start
|
||||||
sudo -u postgres bash -c 'make installcheck USE_PGXS=1'
|
sudo -u postgres bash -c 'make installcheck USE_PGXS=1'
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Report on test fail
|
- name: Change dir permissions on fail
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
sudo chmod -R ugo+rwx t
|
||||||
|
sudo chmod -R ugo+rwx tmp_check
|
||||||
|
exit 2 # regenerate error so that we can upload files in next step
|
||||||
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Upload logs on fail
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Regressions diff and postgresql log
|
name: Regressions diff and postgresql log
|
||||||
path: |
|
path: |
|
||||||
src/pg_stat_monitor/regression.diffs
|
src/pg_stat_monitor/regression.diffs
|
||||||
|
src/pg_stat_monitor/regression.out
|
||||||
src/pg_stat_monitor/logfile
|
src/pg_stat_monitor/logfile
|
||||||
|
src/pg_stat_monitor/t/results/
|
||||||
|
src/pg_stat_monitor/tmp_check/log/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/
|
||||||
|
if-no-files-found: warn
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
|
@ -23,6 +23,10 @@ jobs:
|
||||||
sudo rm -rf /usr/share/postgresql
|
sudo rm -rf /usr/share/postgresql
|
||||||
sudo rm -rf /etc/postgresql
|
sudo rm -rf /etc/postgresql
|
||||||
sudo rm -f /usr/bin/pg_config
|
sudo rm -f /usr/bin/pg_config
|
||||||
|
sudo apt-get install libreadline6-dev systemtap-sdt-dev zlib1g-dev libssl-dev libpam0g-dev python-dev bison flex libipc-run-perl wget -y
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install String::Util'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install Data::Str2Num'
|
||||||
|
|
||||||
- name: Install PG Distribution Postgresql 13
|
- name: Install PG Distribution Postgresql 13
|
||||||
run: |
|
run: |
|
||||||
|
@ -31,6 +35,8 @@ jobs:
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -y install postgresql-13 postgresql-client-13 postgresql-contrib postgresql-server-dev-13
|
sudo apt-get -y install postgresql-13 postgresql-client-13 postgresql-contrib postgresql-server-dev-13
|
||||||
sudo chown -R postgres:postgres src/
|
sudo chown -R postgres:postgres src/
|
||||||
|
sudo cpan install IPC::RUN
|
||||||
|
sudo cpan install String::Util
|
||||||
|
|
||||||
- name: Build pg_stat_monitor
|
- name: Build pg_stat_monitor
|
||||||
run: |
|
run: |
|
||||||
|
@ -48,12 +54,30 @@ jobs:
|
||||||
sudo -u postgres bash -c 'make installcheck USE_PGXS=1'
|
sudo -u postgres bash -c 'make installcheck USE_PGXS=1'
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Report on test fail
|
- name: Change dir permissions on fail
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
sudo chmod -R ugo+rwx t
|
||||||
|
sudo chmod -R ugo+rwx tmp_check
|
||||||
|
exit 2 # regenerate error so that we can upload files in next step
|
||||||
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Upload logs on fail
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Regressions diff and postgresql log
|
name: Regressions diff and postgresql log
|
||||||
path: |
|
path: |
|
||||||
src/pg_stat_monitor/regression.diffs
|
src/pg_stat_monitor/regression.diffs
|
||||||
|
src/pg_stat_monitor/regression.out
|
||||||
src/pg_stat_monitor/logfile
|
src/pg_stat_monitor/logfile
|
||||||
|
src/pg_stat_monitor/t/results/
|
||||||
|
src/pg_stat_monitor/tmp_check/log/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/
|
||||||
|
if-no-files-found: warn
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
|
@ -27,6 +27,10 @@ jobs:
|
||||||
sudo rm -rf /usr/share/postgresql
|
sudo rm -rf /usr/share/postgresql
|
||||||
sudo rm -rf /etc/postgresql
|
sudo rm -rf /etc/postgresql
|
||||||
sudo rm -f /usr/bin/pg_config
|
sudo rm -f /usr/bin/pg_config
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install String::Util'
|
||||||
|
sudo /usr/bin/perl -MCPAN -e 'install Data::Str2Num'
|
||||||
|
|
||||||
- name: Create pgsql dir
|
- name: Create pgsql dir
|
||||||
run: mkdir -p /opt/pgsql
|
run: mkdir -p /opt/pgsql
|
||||||
|
|
||||||
|
@ -88,12 +92,30 @@ jobs:
|
||||||
make installcheck
|
make installcheck
|
||||||
working-directory: src/pg_stat_monitor/
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
- name: Report on pg_stat_monitor test fail
|
- name: Change dir permissions on fail
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
sudo chmod -R ugo+rwx t
|
||||||
|
sudo chmod -R ugo+rwx tmp_check
|
||||||
|
exit 2 # regenerate error so that we can upload files in next step
|
||||||
|
working-directory: src/pg_stat_monitor/
|
||||||
|
|
||||||
|
- name: Upload logs on fail
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Regressions diff and postgresql log
|
name: Regressions diff and postgresql log
|
||||||
path: |
|
path: |
|
||||||
src/pg_stat_monitor/regression.diffs
|
src/pg_stat_monitor/regression.diffs
|
||||||
|
src/pg_stat_monitor/regression.out
|
||||||
src/pg_stat_monitor/logfile
|
src/pg_stat_monitor/logfile
|
||||||
|
src/pg_stat_monitor/t/results/
|
||||||
|
src/pg_stat_monitor/tmp_check/log/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/*
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/archives/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/backup/
|
||||||
|
!src/pg_stat_monitor/tmp_check/**/pgdata/
|
||||||
|
if-no-files-found: warn
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -29,6 +29,7 @@ ifneq (,$(findstring PostgreSQL14,$(MAJOR)))
|
||||||
ifneq (,$(wildcard pg_stat_monitor--1.0.14.sql.in))
|
ifneq (,$(wildcard pg_stat_monitor--1.0.14.sql.in))
|
||||||
CP := $(shell cp pg_stat_monitor--1.0.14.sql.in pg_stat_monitor--1.0.sql)
|
CP := $(shell cp pg_stat_monitor--1.0.14.sql.in pg_stat_monitor--1.0.sql)
|
||||||
endif
|
endif
|
||||||
|
TAP_TESTS = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(findstring PostgreSQL13,$(MAJOR)))
|
ifneq (,$(findstring PostgreSQL13,$(MAJOR)))
|
||||||
|
@ -38,6 +39,7 @@ ifneq (,$(findstring PostgreSQL13,$(MAJOR)))
|
||||||
ifneq (,$(wildcard pg_stat_monitor--1.0.13.sql.in))
|
ifneq (,$(wildcard pg_stat_monitor--1.0.13.sql.in))
|
||||||
CP := $(shell cp pg_stat_monitor--1.0.13.sql.in pg_stat_monitor--1.0.sql)
|
CP := $(shell cp pg_stat_monitor--1.0.13.sql.in pg_stat_monitor--1.0.sql)
|
||||||
endif
|
endif
|
||||||
|
TAP_TESTS = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(findstring PostgreSQL12,$(MAJOR)))
|
ifneq (,$(findstring PostgreSQL12,$(MAJOR)))
|
||||||
|
@ -67,3 +69,9 @@ top_builddir = ../..
|
||||||
include $(top_builddir)/src/Makefile.global
|
include $(top_builddir)/src/Makefile.global
|
||||||
include $(top_srcdir)/contrib/contrib-global.mk
|
include $(top_srcdir)/contrib/contrib-global.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
#NEEDTARGET = $(shell test $(VERSION_NUM) -lt 120000 && echo yes)
|
||||||
|
#ifeq ($(NEEDTARGET),yes)
|
||||||
|
#installcheck:
|
||||||
|
# $(prove_installcheck)
|
||||||
|
#endif
|
|
@ -53,7 +53,6 @@ void psgm_errors_init(void)
|
||||||
int flags = HASH_ELEM | HASH_BLOBS;
|
int flags = HASH_ELEM | HASH_BLOBS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
memset(&info, 0, sizeof(info));
|
memset(&info, 0, sizeof(info));
|
||||||
info.keysize = ERROR_MSG_MAX_LEN;
|
info.keysize = ERROR_MSG_MAX_LEN;
|
||||||
info.entrysize = sizeof(ErrorEntry);
|
info.entrysize = sizeof(ErrorEntry);
|
||||||
|
@ -82,6 +81,10 @@ void pgsm_log(PgsmLogSeverity severity, const char *format, ...)
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
n = vsnprintf(key, ERROR_MSG_MAX_LEN, format, ap);
|
n = vsnprintf(key, ERROR_MSG_MAX_LEN, format, ap);
|
||||||
|
#if PG_VERSION_NUM < 140000
|
||||||
|
if (n > 0 && n < ERROR_MSG_MAX_LEN)
|
||||||
|
memset(key + n, 0, ERROR_MSG_MAX_LEN - n);
|
||||||
|
#endif
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 1/0; -- divide by zero
|
||||||
|
ERROR: division by zero
|
||||||
|
SELECT * FROM unknown; -- unknown table
|
||||||
|
ERROR: relation "unknown" does not exist
|
||||||
|
LINE 1: SELECT * FROM unknown;
|
||||||
|
^
|
||||||
|
ELECET * FROM unknown; -- syntax error
|
||||||
|
ERROR: syntax error at or near "ELECET"
|
||||||
|
LINE 1: ELECET * FROM unknown;
|
||||||
|
^
|
||||||
|
do $$
|
||||||
|
BEGIN
|
||||||
|
RAISE WARNING 'warning message';
|
||||||
|
END $$;
|
||||||
|
WARNING: warning message
|
||||||
|
SELECT query, elevel, sqlcode, message FROM pg_stat_monitor ORDER BY query COLLATE "C",elevel;
|
||||||
|
query | elevel | sqlcode | message
|
||||||
|
----------------------------------+--------+---------+-----------------------------------
|
||||||
|
ELECET * FROM unknown; | 20 | 42601 | syntax error at or near "ELECET"
|
||||||
|
SELECT * FROM unknown; | 20 | 42P01 | relation "unknown" does not exist
|
||||||
|
SELECT pg_stat_monitor_reset() | 0 | |
|
||||||
|
do $$ +| 0 | |
|
||||||
|
BEGIN +| | |
|
||||||
|
RAISE WARNING 'warning message';+| | |
|
||||||
|
END $$ | | |
|
||||||
|
do $$ +| 19 | 01000 | warning message
|
||||||
|
BEGIN +| | |
|
||||||
|
RAISE WARNING 'warning message';+| | |
|
||||||
|
END $$; | | |
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP EXTENSION pg_stat_monitor;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,124 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
my($filename,$extension) = split('.', $perlfilename);
|
||||||
|
print '$filename';
|
||||||
|
print '$extension';
|
||||||
|
|
||||||
|
$perlfilename =~ s/.pl//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Create example database and run pgbench init
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE database example;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create Database example");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
my $port = $node->port;
|
||||||
|
|
||||||
|
my $out = system ("pgbench -i -s 10 -p $port example");
|
||||||
|
ok($cmdret == 0, "Perform pgbench init");
|
||||||
|
|
||||||
|
$out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example");
|
||||||
|
ok($cmdret == 0, "Run pgbench");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,206 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
my $dynamic_out_filename_with_path = "${results_folder}/${out_filename}.dynamic" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_track_planning = 'yes'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select from PGSM view");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Test: total_plan_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (total_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: total_plan_time is not 0).");
|
||||||
|
|
||||||
|
# Test: min_plan_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (min_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: min_plan_time is not 0).");
|
||||||
|
|
||||||
|
# Test: max_plan_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (max_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: max_plan_time is not 0).");
|
||||||
|
|
||||||
|
# Test: mean_plan_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (mean_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: mean_plan_time is not 0).");
|
||||||
|
|
||||||
|
# Test: stddev_plan_time is not 0
|
||||||
|
#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (stddev_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
#trim($stdout);
|
||||||
|
#is($stdout,'f',"Compare: stddev_plan_time is not 0).");
|
||||||
|
|
||||||
|
# Test: total_plan_time = min_plan_time + max_plan_time
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(total_plan_time::numeric,3) = round(min_plan_time::numeric + max_plan_time::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: (round(total_plan_time::numeric,3) = round(min_plan_time::numeric + max_plan_time::numeric,3)).");
|
||||||
|
|
||||||
|
# Test: mean_plan_time = total_plan_time/2
|
||||||
|
#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(mean_plan_time::numeric,3) = round((total_plan_time/2)::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
#trim($stdout);
|
||||||
|
#is($stdout,'t',"Test mean_plan_time: (round(mean_plan_time::numeric,3) = round((total_plan_time/2)::numeric,3)).");
|
||||||
|
|
||||||
|
# Test: stddev_plan_time = mean_plan_time - min_plan_time
|
||||||
|
#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(stddev_plan_time::numeric,3) = round(mean_plan_time::numeric - min_plan_time::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
#trim($stdout);
|
||||||
|
#is($stdout,'t',"Compare mean_plan_time: (round(stddev_plan_time::numeric,3) = round(mean_plan_time::numeric - min_plan_time::numeric,3)).");
|
||||||
|
|
||||||
|
# Dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan_time,stddev_plan_time from pg_stat_monitor order by query;', extra_params => ['-a','-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($dynamic_out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Disable pgsm_track_planning
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_planning = 'no'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
# Dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, calls, total_plan_time, min_plan_time, max_plan_time, mean_plan_time, stddev_plan_time from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select from PGSM view");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Test: total_plan_time is 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (total_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: total_plan_time is 0).");
|
||||||
|
|
||||||
|
# Test: min_plan_time is 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (min_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: min_plan_time is 0).");
|
||||||
|
|
||||||
|
# Test: max_plan_time is 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (max_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: max_plan_time is 0).");
|
||||||
|
|
||||||
|
# Test: mean_plan_time is 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (mean_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: mean_plan_time is 0).");
|
||||||
|
|
||||||
|
# Test: stddev_plan_time is 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (stddev_plan_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: stddev_plan_time is 0).");
|
||||||
|
|
||||||
|
# Dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan_time,stddev_plan_time from pg_stat_monitor order by query;', extra_params => ['-a','-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
#my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
#is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.extract_comments = 'yes'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.extract_comments = 'no'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.track = 'none'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.track = 'all'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.track = 'top'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_enable_query_plan = 'yes'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'UPDATE TBL_0 SET value_0 = 1681692777;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select substr(query, 0,30) as query, calls, query_plan from pg_stat_monitor order by query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Test: planid is not 0 or empty
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select planid from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
isnt($stdout,'',"Test: planid should not be empty");
|
||||||
|
ok(length($stdout) == 16, 'Length of planid is 16');
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_enable_query_plan = 'no'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'Drop TABLE TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'UPDATE TBL_0 SET value_0 = 1681692777;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select substr(query, 0,30) as query, calls, query_plan from pg_stat_monitor order by query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Test: planid is empty
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select planid from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'',"Test: planid should be empty");
|
||||||
|
ok(length($stdout) == 0, 'Length of planid is 0');
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,107 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_overflow_target = 0\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_overflow_target = 1\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,141 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Create example database and run pgbench init
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE database example;', extra_params => ['-a']);
|
||||||
|
print "cmdret $cmdret\n";
|
||||||
|
ok($cmdret == 0, "Create Database example");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
my $port = $node->port;
|
||||||
|
print "port $port \n";
|
||||||
|
|
||||||
|
my $out = system ("pgbench -i -s 10 -p $port example");
|
||||||
|
print " out: $out \n" ;
|
||||||
|
ok($cmdret == 0, "Perform pgbench init");
|
||||||
|
|
||||||
|
$out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example");
|
||||||
|
print " out: $out \n" ;
|
||||||
|
ok($cmdret == 0, "Run pgbench");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
print "cmdret $cmdret\n";
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_shared_buffer = 100\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_shared_buffer = 20\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_histogram_buckets = 10000\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_buckets = 1000\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_buckets = 100\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_buckets = 10\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_buckets = 1\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_histogram_max = 1\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_max = 10\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_max = 100\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_max = 1000\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_histogram_min = 1\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_min = 1000\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_min = 10000\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_min = 1000001\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_bucket_time = 10000\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1000\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 100\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 60\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 0\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max_buckets = 1\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 2\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 5\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 10\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 11\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 0\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_normalized_query = 'no'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'UPDATE TBL_0 SET value_0 = 1681692777;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = 'yes'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'Drop TABLE TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'UPDATE TBL_0 SET value_0 = 1681692777;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,158 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_track_utility = 'no'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'UPDATE TBL_0 SET value_0 = 1681692777;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'Analyze TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'DROP TABLE TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = 'yes'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', "INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT key, txt_0, value_0 FROM TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'UPDATE TBL_0 SET value_0 = 1681692777;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'Analyze TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'DROP TABLE TBL_0;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_max_len = 10240\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_max_len = 1024\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_max_len = 100\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_max_len = 10\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_max_len = 0\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max = 1000\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 500\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 100\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 10\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 0\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
my $dynamic_out_filename_with_path = "${results_folder}/${out_filename}.dynamic" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Run 'SELECT * from pg_stat_monitor_settings;' two times and dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT query, calls, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select from PGSM view");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Test: total_exec_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (total_exec_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: total_exec_time is not 0).");
|
||||||
|
|
||||||
|
# Test: min_exec_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (min_exec_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: min_exec_time is not 0).");
|
||||||
|
|
||||||
|
# Test: max_exec_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (max_exec_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: max_exec_time is not 0).");
|
||||||
|
|
||||||
|
# Test: mean_exec_time is not 0
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (mean_exec_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'f',"Compare: mean_exec_time is not 0).");
|
||||||
|
|
||||||
|
# Test: stddev_exec_time is not 0
|
||||||
|
#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (stddev_exec_time = 0) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
#trim($stdout);
|
||||||
|
#is($stdout,'f',"Test: stddev_exec_time should not be 0).");
|
||||||
|
|
||||||
|
# Test: total_exec_time = min_exec_time + max_exec_time
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(total_exec_time::numeric,3) = round(min_exec_time::numeric + max_exec_time::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t',"Compare: (round(total_exec_time::numeric,3) = round(min_exec_time::numeric + max_exec_time::numeric,3)).");
|
||||||
|
|
||||||
|
# Test: mean_exec_time = total_exec_time/2
|
||||||
|
#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(mean_exec_time::numeric,3) = round((total_exec_time/2)::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
#trim($stdout);
|
||||||
|
#is($stdout,'t',"Compare mean_exec_time: (round(mean_exec_time::numeric,3) = round((total_exec_time/2)::numeric,3)).");
|
||||||
|
|
||||||
|
# Test: stddev_exec_time = mean_exec_time - min_exec_time
|
||||||
|
#($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select (round(stddev_exec_time::numeric,3) = round(mean_exec_time::numeric - min_exec_time::numeric,3)) from pg_stat_monitor where calls = 2 ;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
#trim($stdout);
|
||||||
|
#is($stdout,'t',"Compare mean_exec_time: (round(stddev_exec_time::numeric,3) = round(mean_exec_time::numeric - min_exec_time::numeric,3)).");
|
||||||
|
|
||||||
|
# Dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select substr(query, 0,100) as query, calls, total_exec_time, min_exec_time,max_exec_time,mean_exec_time,stddev_exec_time from pg_stat_monitor order by query;', extra_params => ['-a','-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
TestLib::append_to_file($dynamic_out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Dump output to out file
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
#my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
#is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,146 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
my($filename,$extension) = split('.', $perlfilename);
|
||||||
|
print '$filename';
|
||||||
|
print '$extension';
|
||||||
|
|
||||||
|
$perlfilename =~ s/.pl//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM View");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset_errors();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Errors View");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_version();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Version");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Errors View data");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Create example database and run pgbench init
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE database example;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create Database example");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
my $port = $node->port;
|
||||||
|
|
||||||
|
my $out = system ("pgbench -i -s 50 -p $port example");
|
||||||
|
ok($cmdret == 0, "Perform pgbench init");
|
||||||
|
|
||||||
|
$out = system ("pgbench -c 10 -j 2 -t 1000 -p $port example");
|
||||||
|
ok($cmdret == 0, "Run pgbench");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Select XXX from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM View");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset_errors();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Errors View");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_version();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Version");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Errors View data");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# compare the expected and out file
|
||||||
|
my $compare = compare($expected_filename_with_path, $out_filename_with_path);
|
||||||
|
|
||||||
|
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||||
|
is($compare,0,"Compare Files: $expected_filename_with_path and $out_filename_with_path match.");
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
|
@ -0,0 +1,150 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_overflow_target = 0\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'create table foo (id int generated by default as identity,col1 varchar(100) not null,primary key(id));', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Create Table foo");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_1.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 2) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 2) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_overflow_target = 1\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_2.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data2.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 3) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 3) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_overflow_target = 0\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_bucket_time = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max_buckets = 2\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'create table foo (id int generated by default as identity,col1 varchar(100) not null,primary key(id));', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Create Table foo");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_1.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 3) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 3) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_overflow_target = 1\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_2.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data2.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 1) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 1) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_overflow_target = 0\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_max_len =10000\n";
|
||||||
|
print $conf " pg_stat_monitor.pgsm_enable_query_plan = 'yes'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_track_planning = 'yes'\n";
|
||||||
|
print $conf "pg_stat_monitor.track = 'all'\n";
|
||||||
|
print $conf "pg_stat_monitor.extract_comments = 'yes'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'create table foo (id int generated by default as identity,col1 varchar(100) not null,primary key(id));', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Create Table foo");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_1.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 2) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 2) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_overflow_target = 1\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_2.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data2.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 3) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 3) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use String::Util qw(trim);
|
||||||
|
use File::Basename;
|
||||||
|
use File::Compare;
|
||||||
|
use PostgresNode;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# Expected folder where expected output will be present
|
||||||
|
my $expected_folder = "t/expected";
|
||||||
|
|
||||||
|
# Results/out folder where generated results files will be placed
|
||||||
|
my $results_folder = "t/results";
|
||||||
|
|
||||||
|
# Check if results folder exists or not, create if it doesn't
|
||||||
|
unless (-d $results_folder)
|
||||||
|
{
|
||||||
|
mkdir $results_folder or die "Can't create folder $results_folder: $!\n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if expected folder exists or not, bail out if it doesn't
|
||||||
|
unless (-d $expected_folder)
|
||||||
|
{
|
||||||
|
BAIL_OUT "Expected files folder $expected_folder doesn't exist: \n";;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get filename of the this perl file
|
||||||
|
my $perlfilename = basename($0);
|
||||||
|
|
||||||
|
#Remove .pl from filename and store in a variable
|
||||||
|
$perlfilename =~ s/\.[^.]+$//;
|
||||||
|
my $filename_without_extension = $perlfilename;
|
||||||
|
|
||||||
|
# Create expected filename with path
|
||||||
|
my $expected_filename = "${filename_without_extension}.out";
|
||||||
|
my $expected_filename_with_path = "${expected_folder}/${expected_filename}" ;
|
||||||
|
|
||||||
|
# Create results filename with path
|
||||||
|
my $out_filename = "${filename_without_extension}.out";
|
||||||
|
my $out_filename_with_path = "${results_folder}/${out_filename}" ;
|
||||||
|
|
||||||
|
# Delete already existing result out file, if it exists.
|
||||||
|
if ( -f $out_filename_with_path)
|
||||||
|
{
|
||||||
|
unlink($out_filename_with_path) or die "Can't delete already existing $out_filename_with_path: $!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create new PostgreSQL node and do initdb
|
||||||
|
my $node = PostgresNode->get_new_node('test');
|
||||||
|
my $pgdata = $node->data_dir;
|
||||||
|
$node->dump_info;
|
||||||
|
$node->init;
|
||||||
|
|
||||||
|
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||||
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
|
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_overflow_target = 0\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_max = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_query_max_len =10000\n";
|
||||||
|
print $conf " pg_stat_monitor.pgsm_enable_query_plan = 'yes'\n";
|
||||||
|
print $conf "pg_stat_monitor.pgsm_track_planning = 'yes'\n";
|
||||||
|
print $conf "pg_stat_monitor.track = 'top'\n";
|
||||||
|
print $conf "pg_stat_monitor.extract_comments = 'no'\n";
|
||||||
|
close $conf;
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
my $rt_value = $node->start;
|
||||||
|
ok($rt_value == 1, "Start Server");
|
||||||
|
|
||||||
|
# Create extension and change out file permissions
|
||||||
|
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Create PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
chmod(0640 , $out_filename_with_path)
|
||||||
|
or die("unable to set permissions for $out_filename_with_path");
|
||||||
|
|
||||||
|
# Run required commands/queries and dump output to out file.
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'create table foo (id int generated by default as identity,col1 varchar(100) not null,primary key(id));', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Create Table foo");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_1.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 2) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 2) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 100\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_max_len = 1024\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_utility = 'yes'\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = 'yes'\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 10\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 60\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_min = 0\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_max = 100000\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_histogram_buckets = 10\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_shared_buffer = 20\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_overflow_target = 1\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_enable_query_plan = 'no'\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.track = 'top'\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.extract_comments = 'no'\n");
|
||||||
|
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track_planning = 'no'\n");
|
||||||
|
$node->restart();
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Reset PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', '\i scripts/data_2.sql' , extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Run sql file: scripts/data2.sql");
|
||||||
|
#TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query, 0, 50), length(query), bucket, queryid, calls, elevel, sqlcode, message from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT substr(query, 0, 50), calls, message from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT count(queryid) from pg_stat_monitor;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT count(queryid) from pg_stat_monitor");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_errors;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "SELECT * from pg_stat_monitor_errors");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT (count(message) = 1) from pg_stat_monitor_errors;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||||
|
trim($stdout);
|
||||||
|
is($stdout,'t', "SELECT (count(message) = 1) from pg_stat_monitor_errors");
|
||||||
|
|
||||||
|
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT * from pg_stat_monitor_settings;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||||
|
ok($cmdret == 0, "Print PGSM Extension Settings");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Drop extension
|
||||||
|
$stdout = $node->safe_psql('postgres', 'Drop extension pg_stat_monitor;', extra_params => ['-a']);
|
||||||
|
ok($cmdret == 0, "Drop PGSM Extension");
|
||||||
|
TestLib::append_to_file($out_filename_with_path, $stdout . "\n");
|
||||||
|
|
||||||
|
# Stop the server
|
||||||
|
$node->stop;
|
||||||
|
|
||||||
|
# Done testing for this testcase file.
|
||||||
|
done_testing();
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE database example;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor 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 | 1
|
||||||
|
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillf | 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 (fillfacto | 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
|
||||||
|
(20 rows)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,112 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | yes | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | yes | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
select substr(query, 0,100) as query, calls, total_plan_time, min_plan_time,max_plan_time,mean_plan_time,stddev_plan_time from pg_stat_monitor order by query;
|
||||||
|
query | calls | total_plan_time | min_plan_time | max_plan_time | mean_plan_time | stddev_plan_time
|
||||||
|
----------------------------------------------------------------------+-------+-----------------+---------------+---------------+----------------+------------------
|
||||||
|
SELECT * from pg_stat_monitor_settings | 2 | 0 | 0 | 0 | 0 | 0
|
||||||
|
SELECT pg_stat_monitor_reset() | 1 | 0 | 0 | 0 | 0 | 0
|
||||||
|
select (max_plan_time = $1) from pg_stat_monitor where calls = $2 | 1 | 0 | 0 | 0 | 0 | 0
|
||||||
|
select (mean_plan_time = $1) from pg_stat_monitor where calls = $2 | 1 | 0 | 0 | 0 | 0 | 0
|
||||||
|
select (min_plan_time = $1) from pg_stat_monitor where calls = $2 | 1 | 0 | 0 | 0 | 0 | 0
|
||||||
|
select (stddev_plan_time = $1) from pg_stat_monitor where calls = $2 | 1 | 0 | 0 | 0 | 0 | 0
|
||||||
|
select (total_plan_time = $1) from pg_stat_monitor where calls = $2 | 1 | 0 | 0 | 0 | 0 | 0
|
||||||
|
(7 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,82 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | yes | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/;
|
||||||
|
num | name
|
||||||
|
-----+------
|
||||||
|
1 | John
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
|
query | comments
|
||||||
|
----------------------------------------------------------------------+------------------------------------------
|
||||||
|
SELECT $1 AS num /* First comment */, $2 as Name /* Second comment*/ | /* First comment */, /* Second comment*/
|
||||||
|
SELECT * from pg_stat_monitor_settings |
|
||||||
|
SELECT pg_stat_monitor_reset() |
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT 1 AS num /* First comment */, 'John' as Name /* Second comment*/;
|
||||||
|
num | name
|
||||||
|
-----+------
|
||||||
|
1 | John
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
|
query | comments
|
||||||
|
----------------------------------------------------------------------+----------
|
||||||
|
SELECT $1 AS num /* First comment */, $2 as Name /* Second comment*/ |
|
||||||
|
SELECT * from pg_stat_monitor_settings |
|
||||||
|
SELECT pg_stat_monitor_reset() |
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,80 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | none | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | all | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,107 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | yes | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);
|
||||||
|
INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
|
select substr(query, 0,30) as query, calls, query_plan from pg_stat_monitor order by query,calls;
|
||||||
|
query | calls | query_plan
|
||||||
|
-------------------------------+-------+-------------------------------------------
|
||||||
|
CREATE TABLE TBL_0(key text p | 1 |
|
||||||
|
INSERT INTO TBL_0(key, txt_0, | 1 |
|
||||||
|
SELECT * from pg_stat_monitor | 1 | Function Scan on pg_stat_monitor_settings
|
||||||
|
SELECT key, txt_0, value_0 FR | 2 | Seq Scan on tbl_0
|
||||||
|
SELECT pg_stat_monitor_reset( | 1 | Result
|
||||||
|
UPDATE TBL_0 SET value_0 = $1 | 1 |
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
Drop TABLE TBL_0;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);
|
||||||
|
INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
|
select substr(query, 0,30) as query, calls, query_plan from pg_stat_monitor order by query,calls;
|
||||||
|
query | calls | query_plan
|
||||||
|
-------------------------------+-------+------------
|
||||||
|
CREATE TABLE TBL_0(key text p | 1 |
|
||||||
|
INSERT INTO TBL_0(key, txt_0, | 1 |
|
||||||
|
SELECT * from pg_stat_monitor | 1 |
|
||||||
|
SELECT key, txt_0, value_0 FR | 2 |
|
||||||
|
SELECT pg_stat_monitor_reset( | 1 |
|
||||||
|
UPDATE TBL_0 SET value_0 = $1 | 1 |
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,54 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 0 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,106 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_query_shared_buffer | 1 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE database example;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor 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 | 1
|
||||||
|
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillf | 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 (fillfacto | 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
|
||||||
|
(20 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_query_shared_buffer | 100 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,132 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10000 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 1000 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 100 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,106 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+-------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 10 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+-------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+-------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 1000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,106 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 1 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 1000 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 10000 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+---------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 1000001 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,158 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 10000 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 1000 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 100 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 1 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,158 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 1 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 2 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 5 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,107 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | no | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);
|
||||||
|
INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
|
datname | query | calls
|
||||||
|
----------+----------------------------------------------------------------------------------+-------
|
||||||
|
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
||||||
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383) | 1
|
||||||
|
postgres | SELECT * from pg_stat_monitor_settings | 1
|
||||||
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
|
postgres | UPDATE TBL_0 SET value_0 = 1681692777 | 1
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
Drop TABLE TBL_0;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);
|
||||||
|
INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
|
datname | query | calls
|
||||||
|
----------+-------------------------------------------------------------------+-------
|
||||||
|
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
||||||
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES($1, $2, $3) | 1
|
||||||
|
postgres | SELECT * from pg_stat_monitor_settings | 1
|
||||||
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
|
postgres | UPDATE TBL_0 SET value_0 = $1 | 1
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,111 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | no | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);
|
||||||
|
INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
|
Analyze TBL_0;
|
||||||
|
DROP TABLE TBL_0;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
|
datname | query | calls
|
||||||
|
----------+-----------------------------------------------------------+-------
|
||||||
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES($1, $2, $3) | 1
|
||||||
|
postgres | SELECT * from pg_stat_monitor_settings | 1
|
||||||
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
|
postgres | UPDATE TBL_0 SET value_0 = $1 | 1
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int);
|
||||||
|
INSERT INTO TBL_0(key, txt_0, value_0) VALUES('000000', '846930886', 1804289383);
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT key, txt_0, value_0 FROM TBL_0;
|
||||||
|
key | txt_0 | value_0
|
||||||
|
--------+-----------+------------
|
||||||
|
000000 | 846930886 | 1804289383
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
UPDATE TBL_0 SET value_0 = 1681692777;
|
||||||
|
Analyze TBL_0;
|
||||||
|
DROP TABLE TBL_0;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor order by datname, query, calls desc Limit 20;
|
||||||
|
datname | query | calls
|
||||||
|
----------+-------------------------------------------------------------------+-------
|
||||||
|
postgres | Analyze TBL_0 | 1
|
||||||
|
postgres | CREATE TABLE TBL_0(key text primary key, txt_0 text, value_0 int) | 1
|
||||||
|
postgres | DROP TABLE TBL_0 | 1
|
||||||
|
postgres | INSERT INTO TBL_0(key, txt_0, value_0) VALUES($1, $2, $3) | 1
|
||||||
|
postgres | SELECT * from pg_stat_monitor_settings | 1
|
||||||
|
postgres | SELECT key, txt_0, value_0 FROM TBL_0 | 2
|
||||||
|
postgres | SELECT pg_stat_monitor_reset() | 1
|
||||||
|
postgres | UPDATE TBL_0 SET value_0 = $1 | 1
|
||||||
|
(8 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,132 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 10240 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,132 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
pg_stat_monitor.pgsm_max | 1000 | 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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
pg_stat_monitor.pgsm_max | 500 | 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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
pg_stat_monitor.pgsm_max | 10 | 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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,54 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
|
@ -0,0 +1,102 @@
|
||||||
|
CREATE EXTENSION pg_stat_monitor;
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset_errors();
|
||||||
|
pg_stat_monitor_reset_errors
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_errors;
|
||||||
|
severity | message | msgtime | calls
|
||||||
|
----------+---------+---------+-------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
CREATE database example;
|
||||||
|
select datname, substr(query,0,100) as query, calls from pg_stat_monitor 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 | 1
|
||||||
|
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillf | 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 (fillfacto | 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) | 50
|
||||||
|
example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 500
|
||||||
|
(20 rows)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_settings;
|
||||||
|
name | value | default_value | description | minimum | maximum | options | restart
|
||||||
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+---------
|
||||||
|
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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes
|
||||||
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes
|
||||||
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 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_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no
|
||||||
|
pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no
|
||||||
|
pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no
|
||||||
|
pg_stat_monitor.pgsm_track_planning | no | no | Selects whether planning statistics are tracked. | | | yes, no | no
|
||||||
|
(15 rows)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT pg_stat_monitor_reset_errors();
|
||||||
|
pg_stat_monitor_reset_errors
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * from pg_stat_monitor_errors;
|
||||||
|
severity | message | msgtime | calls
|
||||||
|
----------+---------+---------+-------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
Drop extension pg_stat_monitor;
|
Loading…
Reference in New Issue