Compare commits
162 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
f813a1ec74 | |
|
|
55b6a3de88 | |
|
|
71b045b3a4 | |
|
|
133432ed92 | |
|
|
ff4c134e2a | |
|
|
e01e159a7d | |
|
|
bcd345a873 | |
|
|
2235e8bf44 | |
|
|
d2c1842fde | |
|
|
b00caafb68 | |
|
|
4aa3751e6a | |
|
|
5f8b716ef6 | |
|
|
aa24b90c66 | |
|
|
4ac02b2443 | |
|
|
7aeb2508d1 | |
|
|
58c9e734d8 | |
|
|
2c2c1f518d | |
|
|
10418688cd | |
|
|
6d58b1e1d7 | |
|
|
0780b675bb | |
|
|
830e06d13d | |
|
|
cd0feaf215 | |
|
|
57529ecfa7 | |
|
|
4a7f1b73e4 | |
|
|
8f7868f73e | |
|
|
bd0546b7c9 | |
|
|
9496937c9f | |
|
|
9dad93b770 | |
|
|
bdd3329298 | |
|
|
874a3b438a | |
|
|
ba02dc1f64 | |
|
|
f5003d3000 | |
|
|
e032dfaa6d | |
|
|
d16d7fe6dd | |
|
|
182bf40c34 | |
|
|
d74e927adb | |
|
|
9ea39fcb52 | |
|
|
f491096189 | |
|
|
642a2e1c7c | |
|
|
1e32b52a3f | |
|
|
2ec31f69ee | |
|
|
d0f1172476 | |
|
|
2cc0b576bd | |
|
|
c204fb0a12 | |
|
|
5e36a66d80 | |
|
|
f88167d569 | |
|
|
db4b6c6e07 | |
|
|
f774d5acbd | |
|
|
f61935cacb | |
|
|
7d3d5afbbc | |
|
|
ce21b22bf2 | |
|
|
c613f071b1 | |
|
|
f334af03a6 | |
|
|
804059ce75 | |
|
|
65d65ccd05 | |
|
|
298a8e08a2 | |
|
|
1f3754f046 | |
|
|
660190b2a0 | |
|
|
9e0a252873 | |
|
|
3653dd6041 | |
|
|
76b0802142 | |
|
|
61662cc58f | |
|
|
f7dc7fb5fe | |
|
|
38f13e893f | |
|
|
9d2f2cd8cc | |
|
|
d0237f8d83 | |
|
|
d116dd47fe | |
|
|
9c72c2e73d | |
|
|
76424b6c64 | |
|
|
f76b1860e3 | |
|
|
a7edd766e3 | |
|
|
24c1c59416 | |
|
|
b860effd97 | |
|
|
64b08e422c | |
|
|
acd559842f | |
|
|
8bbb49e409 | |
|
|
7bddd5a033 | |
|
|
5312f6f8a7 | |
|
|
c305b8a086 | |
|
|
8dcf24a879 | |
|
|
32b1beb6ff | |
|
|
9333608c3a | |
|
|
4ebb3d1f36 | |
|
|
fd43b75153 | |
|
|
c949d21656 | |
|
|
fbdff8b444 | |
|
|
e099628e18 | |
|
|
d2b2eafc85 | |
|
|
ba8d7bd83b | |
|
|
b47ae95fa8 | |
|
|
980116acea | |
|
|
ef9518c98e | |
|
|
2769e6dcb2 | |
|
|
d0b67ef32a | |
|
|
d008bbbfa7 | |
|
|
971c62025e | |
|
|
8ed7f1dbb7 | |
|
|
2a5a2f07c4 | |
|
|
7d57e2476f | |
|
|
6c7512afa5 | |
|
|
ee7f6d071f | |
|
|
7f1344e12d | |
|
|
85f0401b96 | |
|
|
df65136090 | |
|
|
534790f39b | |
|
|
646f01420f | |
|
|
c63e172100 | |
|
|
091b5866d4 | |
|
|
186c2e4795 | |
|
|
c921d483a8 | |
|
|
467394fb6e | |
|
|
bcf7bed60b | |
|
|
0c50b23d6f | |
|
|
3bb65798fd | |
|
|
130d6b5fce | |
|
|
1aa3081eaf | |
|
|
7680ceafd6 | |
|
|
778043a5db | |
|
|
d7999f1acf | |
|
|
16ec8362e2 | |
|
|
dacb41f9e4 | |
|
|
c796995e0c | |
|
|
fdec44af94 | |
|
|
0db7f70028 | |
|
|
d83d202b9c | |
|
|
74d98475a8 | |
|
|
508e35943e | |
|
|
8d974c958f | |
|
|
a88c23a626 | |
|
|
288ec6325f | |
|
|
61256faf83 | |
|
|
2b9817d3ba | |
|
|
0ba80547e6 | |
|
|
5d7c424fdc | |
|
|
c2923b4d61 | |
|
|
dce1913154 | |
|
|
2ebd163225 | |
|
|
e3d6dc4af7 | |
|
|
0275fc742e | |
|
|
f72b8a9537 | |
|
|
175e568515 | |
|
|
0bf2846748 | |
|
|
e303899652 | |
|
|
43f3c27141 | |
|
|
e1ad88a580 | |
|
|
7829869dc7 | |
|
|
684e6483b5 | |
|
|
c89879e372 | |
|
|
64c71f98de | |
|
|
7ea569e6bc | |
|
|
3d846105c5 | |
|
|
7ecd10a7de | |
|
|
5bb67963e7 | |
|
|
75f86f54b1 | |
|
|
4863020ccd | |
|
|
0a8ac38de9 | |
|
|
a35689bd36 | |
|
|
3ed25d5511 | |
|
|
ddc5a1745b | |
|
|
823bfb9aa7 | |
|
|
67493acda4 | |
|
|
715a4ceb82 |
|
|
@ -0,0 +1,4 @@
|
|||
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
|
||||
# Order is important; the last matching pattern takes the most precedence.
|
||||
|
||||
* @artemgavrilov @dutow
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
name: Bug Report
|
||||
description: File a bug report
|
||||
labels: ["bug"]
|
||||
assignees:
|
||||
- artemgavrilov
|
||||
- dutow
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report! Please provide as much information as possible, it will help us to address this problem faster.
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Please describe the problem.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected Results
|
||||
description: What did you expect to happen?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Actual Results
|
||||
description: What actually happened?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: What version of PostgreSQL and pg_stat_monitor are you running?
|
||||
placeholder: PostgreSQL 16.2, pg_stat_monitor v2.0.4
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Which steps do we need to take to reproduce this error?
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant logs
|
||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||
render: Shell
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Code of Conduct
|
||||
description: By submitting this issue, you agree to follow [Percona Community Code of Conduct](https://github.com/percona/community/blob/main/content/contribute/coc.md)
|
||||
options:
|
||||
- label: I agree to follow Percona Community Code of Conduct
|
||||
required: true
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Forum
|
||||
url: https://forums.percona.com/
|
||||
about: Please join our forums for general questions ans discussions.
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
name: Feature Request
|
||||
description: Suggest an idea for this project
|
||||
labels: ["feature"]
|
||||
assignees:
|
||||
- artemgavrilov
|
||||
- dutow
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for suggesting an idea to make pg_stat_monitor better! Please complete the below form to ensure we have all the details to get things started.
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Description of the feature and of the problem it solves.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Suggested solution
|
||||
description: A concise description of your preferred solution.
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Any information that may help.
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Code of Conduct
|
||||
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/percona/community/blob/main/content/contribute/coc.md)
|
||||
options:
|
||||
- label: I agree to follow this project's Code of Conduct
|
||||
required: true
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
PG-0
|
||||
|
||||
### Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
|
||||
### Links
|
||||
<!--- Please provide links to any related PRs in this or other repositories --->
|
||||
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
name: Checks
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
cppcheck:
|
||||
name: Cppcheck
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: src/pg_stat_monitor
|
||||
|
||||
- name: Checkout cppcheck sources
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: "danmar/cppcheck"
|
||||
ref: "2.13.4"
|
||||
path: src/cppcheck
|
||||
|
||||
- name: Build and install cppcheck
|
||||
working-directory: src/cppcheck
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
sudo cmake --install .
|
||||
|
||||
- name: Execute linter check with cppcheck
|
||||
working-directory: src/pg_stat_monitor
|
||||
run: |
|
||||
set -x
|
||||
cppcheck --enable=all --inline-suppr --template='{file}:{line},{severity},{id},{message}' --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unmatchedSuppression:pg_stat_monitor.c --check-config .
|
||||
|
||||
format:
|
||||
name: Format
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_17_STABLE'
|
||||
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'contrib/pg_stat_monitor'
|
||||
|
||||
- name: Configure postgres
|
||||
run: ./configure
|
||||
|
||||
- name: Install perltidy
|
||||
run: sudo cpan -T SHANCOCK/Perl-Tidy-20230309.tar.gz
|
||||
|
||||
- name: Install pg_bsd_indent
|
||||
working-directory: src/tools/pg_bsd_indent
|
||||
run: sudo make install
|
||||
|
||||
- name: Add pg_bsd_indent and pgindent to path
|
||||
run: |
|
||||
echo "/usr/local/pgsql/bin" >> $GITHUB_PATH
|
||||
echo "${{ github.workspace }}/src/tools/pgindent" >> $GITHUB_PATH
|
||||
|
||||
- name: Format sources
|
||||
working-directory: contrib/pg_stat_monitor
|
||||
run: |
|
||||
make update-typedefs
|
||||
make indent
|
||||
|
||||
- name: Check files are formatted and no source code changes
|
||||
working-directory: contrib/pg_stat_monitor
|
||||
run: |
|
||||
git status
|
||||
git diff --exit-code
|
||||
|
||||
license:
|
||||
name: License
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Check license headers
|
||||
uses: apache/skywalking-eyes/header@61275cc80d0798a405cb070f7d3a8aaf7cf2c2c1 # v0.8.0
|
||||
with:
|
||||
token: "" # Prevent comments
|
||||
|
|
@ -1,13 +1,22 @@
|
|||
name: code-coverage-test
|
||||
on: [pull_request]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: coverage-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_15_STABLE'
|
||||
|
|
@ -28,7 +37,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
|
|
@ -74,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -104,9 +113,10 @@ jobs:
|
|||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Upload
|
||||
uses: codecov/codecov-action@v2
|
||||
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
||||
with:
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
working-directory: ./src/pg_stat_monitor
|
||||
files: ./pg_stat_monitor.c.gcov,./hash_query.c.gcov,./guc.c.gcov
|
||||
|
||||
|
|
@ -120,7 +130,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
name: cppcheck-action-test
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: cppcheck-test
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install cppcheck
|
||||
run: sudo apt-get install cppcheck
|
||||
|
||||
- name: Execute linter check with cppcheck
|
||||
run: |
|
||||
set -x
|
||||
cppcheck --enable=all --inline-suppr --template='{file}:{line},{severity},{id},{message}' --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unmatchedSuppression:pg_stat_monitor.c --check-config .
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
name: PGXN
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to release'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 10
|
||||
container: pgxn/pgxn-tools
|
||||
steps:
|
||||
- name: Validate version tag
|
||||
run: '[[ ${{ inputs.version }} =~ ^[0-9]+.[0-9]+.[0-9]+ ]]'
|
||||
shell: bash
|
||||
|
||||
- name: Check out
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: '${{ inputs.version }}'
|
||||
|
||||
- name: Bundle
|
||||
id: bundle
|
||||
run: pgxn-bundle
|
||||
|
||||
- name: Upload
|
||||
env:
|
||||
PGXN_USERNAME: percona
|
||||
PGXN_PASSWORD: ${{ secrets.PGXN_PERCONA }}
|
||||
run: pgxn-release
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
name: postgresql-11-build
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-11-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_11_STABLE'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex \
|
||||
libipc-run-perl -y docbook-xsl docbook-xsl libxml2 libxml2-utils \
|
||||
libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \
|
||||
libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \
|
||||
llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
|
||||
- name: Create pgsql dir
|
||||
run: mkdir -p /opt/pgsql
|
||||
|
||||
- name: Build postgres
|
||||
run: |
|
||||
export PATH="/opt/pgsql/bin:$PATH"
|
||||
./configure '--build=x86_64-linux-gnu' '--prefix=/usr' \
|
||||
'--includedir=/usr/include' '--mandir=/usr/share/man' \
|
||||
'--infodir=/usr/share/info' '--sysconfdir=/etc' '--enable-nls' \
|
||||
'--localstatedir=/var' '--libdir=/usr/lib/x86_64-linux-gnu' \
|
||||
'runstatedir=/run' '--with-icu' '--with-tcl' '--with-perl' \
|
||||
'--with-python' '--with-pam' '--with-openssl' '--with-libxml' \
|
||||
'--with-libxslt' 'PYTHON=/usr/bin/python3' 'MKDIR_P=/bin/mkdir -p' \
|
||||
'--mandir=/usr/share/postgresql/11/man' '--enable-dtrace' \
|
||||
'--docdir=/usr/share/doc/postgresql-doc-11' '--enable-debug' \
|
||||
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share' \
|
||||
'--datadir=/usr/share/postgresql/11' '--enable-thread-safety' \
|
||||
'--bindir=/usr/lib/postgresql/11/bin' '--enable-tap-tests' \
|
||||
'--libdir=/usr/lib/x86_64-linux-gnu' '--disable-rpath' \
|
||||
'--libexecdir=/usr/lib/postgresql' '--with-uuid=e2fs' \
|
||||
'--includedir=/usr/include/postgresql' '--with-gnu-ld' \
|
||||
'--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' \
|
||||
'--with-llvm' 'LLVM_CONFIG=/usr/bin/llvm-config-11' \
|
||||
'CLANG=/usr/bin/clang-11' '--with-systemd' '--with-selinux' \
|
||||
'PROVE=/usr/bin/prove' 'TAR=/bin/tar' '--with-gssapi' '--with-ldap' \
|
||||
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' \
|
||||
'--with-includes=/usr/include/mit-krb5' '--with-libs=/usr/lib/mit-krb5' \
|
||||
'--with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5' \
|
||||
'build_alias=x86_64-linux-gnu' \
|
||||
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' \
|
||||
'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' \
|
||||
'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
|
||||
make world
|
||||
sudo make install-world
|
||||
|
||||
- name: Start postgresql cluster
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/11/bin:$PATH"
|
||||
sudo cp /usr/lib/postgresql/11/bin/pg_config /usr/bin
|
||||
initdb -D /opt/pgsql/data
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
make USE_PGXS=1
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor/
|
||||
|
||||
- name: Load pg_stat_monitor library and Restart Server
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/11/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> \
|
||||
/opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
make installcheck
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Report on pg_stat_monitor test fail
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
src/pg_stat_monitor/regression.diffs
|
||||
src/pg_stat_monitor/logfile
|
||||
retention-days: 1
|
||||
|
||||
- name: Start Server installcheck-world tests
|
||||
run: |
|
||||
make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
path: |
|
||||
**/regression.diffs
|
||||
**/regression.out
|
||||
src/pg_stat_monitor/logfile
|
||||
retention-days: 3
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
name: postgresql-11-pgdg-package
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-11-pgdg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Delete old postgresql files
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
|
||||
- name: Install PG Distribution Postgresql 11
|
||||
run: |
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt \
|
||||
$(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo wget --quiet -O - \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc |
|
||||
sudo apt-key add -
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install postgresql-11 postgresql-server-dev-11
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
sudo -u postgres bash -c 'make USE_PGXS=1'
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
sudo service postgresql stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" |
|
||||
sudo tee -a /etc/postgresql/11/main/postgresql.conf
|
||||
sudo service postgresql start
|
||||
sudo psql -V
|
||||
export PG_TEST_PORT_DIR=/home/postgres
|
||||
sudo -u postgres bash -c 'make installcheck USE_PGXS=1'
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Report on test fail
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
src/pg_stat_monitor/regression.diffs
|
||||
src/pg_stat_monitor/logfile
|
||||
retention-days: 3
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
name: postgresql-11-pmm-integration
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-11-pgsm-pmm-integration-test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
||||
# print branch and Repo name
|
||||
- name: Get branch and Repo Name
|
||||
run: echo 'The branch and Repo Name is' ${{ github.head_ref }} ${{ github.actor }}/pg_stat_monitor
|
||||
|
||||
- name: "Set TARGET_BRANCH variable for a PR run"
|
||||
if: github.event_name == 'pull_request'
|
||||
run: echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
|
||||
|
||||
- name: "Set TARGET_BRANCH variable for a PUSH run"
|
||||
if: github.event_name == 'push'
|
||||
run: echo "TARGET_BRANCH=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Run PMM & PGSM Setup, E2E Tests
|
||||
run: bash -xe ./pmm_pgsm_setup/pmm_pgsm_setup.sh --pgsql-version=11 --pgstat-monitor-branch=${{ env.TARGET_BRANCH }}
|
||||
|
||||
- name: Get PMM-Agent Logs from the Container
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
run: docker exec pgsql_pgsm_11 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
|
||||
|
||||
- name: Upload Tests Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
path: ./pmm-ui-tests/tests/output/
|
||||
if-no-files-found: ignore # 'warn' or 'ignore' are also available, defaults to `warn`
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
name: postgresql-11-ppg-package
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-11-ppg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \
|
||||
libipc-run-perl wget
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
|
||||
- name: Install percona-release script
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y upgrade
|
||||
sudo apt-get install -y wget gnupg2 curl lsb-release
|
||||
sudo wget \
|
||||
https://repo.percona.com/apt/percona-release_latest.generic_all.deb
|
||||
sudo dpkg -i percona-release_latest.generic_all.deb
|
||||
|
||||
- name: Install Percona Distribution Postgresql 11
|
||||
run: |
|
||||
sudo percona-release setup ppg-11
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y percona-postgresql-11 \
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
sudo -u postgres bash -c 'make USE_PGXS=1'
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
sudo service postgresql stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" |
|
||||
sudo tee -a /etc/postgresql/11/main/postgresql.conf
|
||||
sudo service postgresql start
|
||||
sudo psql -V
|
||||
export PG_TEST_PORT_DIR=/home/postgres
|
||||
sudo -u postgres bash -c 'make installcheck USE_PGXS=1'
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Report on test fail
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
src/pg_stat_monitor/regression.diffs
|
||||
src/pg_stat_monitor/logfile
|
||||
retention-days: 3
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
name: postgresql-12-pmm-integration
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-pgsm-pmm-integration-test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
||||
# print branch and Repo name
|
||||
- name: Get branch and Repo Name
|
||||
run: echo 'The branch and Repo Name is' ${{ github.head_ref }} ${{ github.actor }}/pg_stat_monitor
|
||||
|
||||
- name: "Set TARGET_BRANCH variable for a PR run"
|
||||
if: github.event_name == 'pull_request'
|
||||
run: echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
|
||||
|
||||
- name: "Set TARGET_BRANCH variable for a PUSH run"
|
||||
if: github.event_name == 'push'
|
||||
run: echo "TARGET_BRANCH=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Run PMM & PGSM Setup, E2E Tests
|
||||
run: bash -xe ./pmm_pgsm_setup/pmm_pgsm_setup.sh --pgsql-version=12 --pgstat-monitor-branch=${{ env.TARGET_BRANCH }}
|
||||
|
||||
- name: Get PMM-Agent Logs from the Container
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
run: docker exec pgsql_pgsm_12 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
|
||||
|
||||
- name: Upload Tests Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
path: ./pmm-ui-tests/tests/output/
|
||||
if-no-files-found: ignore # 'warn' or 'ignore' are also available, defaults to `warn`
|
||||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-13-build
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-13-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_13_STABLE'
|
||||
|
|
@ -27,7 +37,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
|
|
@ -73,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -107,7 +117,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
@ -130,7 +140,7 @@ jobs:
|
|||
make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-13-pgdg-package
|
||||
on: [pull_request]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-13-pgdg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -23,7 +33,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install PG Distribution Postgresql 13
|
||||
|
|
@ -38,6 +48,7 @@ jobs:
|
|||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
|
|
@ -68,7 +79,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
name: postgresql-13-pmm-integration
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -8,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
|
@ -33,7 +42,7 @@ jobs:
|
|||
run: docker exec pgsql_pgsm_13 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
|
||||
|
||||
- name: Upload Tests Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-13-ppg-package
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-13-ppg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -23,7 +33,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install percona-release script
|
||||
|
|
@ -35,15 +45,23 @@ jobs:
|
|||
https://repo.percona.com/apt/percona-release_latest.generic_all.deb
|
||||
sudo dpkg -i percona-release_latest.generic_all.deb
|
||||
|
||||
- name: Install Percona Distribution Postgresql 13
|
||||
- name: Install Percona Distribution Postgresql 13 & Extensions
|
||||
run: |
|
||||
sudo percona-release setup ppg-13
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y percona-postgresql-13 \
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all \
|
||||
percona-pgpool2 libpgpool2 percona-postgresql-13-pgaudit \
|
||||
percona-postgresql-13-pgaudit-dbgsym percona-postgresql-13-repack \
|
||||
percona-postgresql-13-repack-dbgsym percona-pgaudit13-set-user \
|
||||
percona-pgaudit13-set-user-dbgsym percona-postgresql-13-postgis-3 \
|
||||
percona-postgresql-13-postgis-3-scripts \
|
||||
percona-postgresql-postgis-scripts percona-postgresql-postgis \
|
||||
percona-postgis
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
|
|
@ -74,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-14-build
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-14-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_14_STABLE'
|
||||
|
|
@ -28,7 +38,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
|
|
@ -73,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -83,12 +93,13 @@ jobs:
|
|||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Load pg_stat_monitor library and Restart Server
|
||||
- name: Configure and Restart Server
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/14/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> \
|
||||
/opt/pgsql/data/postgresql.conf
|
||||
echo "compute_query_id = regress" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
|
|
@ -107,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
@ -126,15 +137,10 @@ jobs:
|
|||
retention-days: 3
|
||||
|
||||
- name: Start Server installcheck-world tests
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/14/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "compute_query_id = off" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
make installcheck-world
|
||||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-14-pgdg-package
|
||||
on: [pull_request]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-14-pgdg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -22,7 +32,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install PG Distribution Postgresql 14
|
||||
|
|
@ -37,6 +47,7 @@ jobs:
|
|||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
|
|
@ -67,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
name: postgresql-14-pmm-integration
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -8,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
|
@ -33,7 +42,7 @@ jobs:
|
|||
run: docker exec pgsql_pgsm_14 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
|
||||
|
||||
- name: Upload Tests Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-14-ppg-package
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-14-ppg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -23,7 +33,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install percona-release script
|
||||
|
|
@ -35,15 +45,23 @@ jobs:
|
|||
https://repo.percona.com/apt/percona-release_latest.generic_all.deb
|
||||
sudo dpkg -i percona-release_latest.generic_all.deb
|
||||
|
||||
- name: Install Percona Distribution Postgresql 14
|
||||
- name: Install Percona Distribution Postgresql 14 & Extensions
|
||||
run: |
|
||||
sudo percona-release setup ppg-14
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y percona-postgresql-14 \
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all \
|
||||
percona-pgpool2 libpgpool2 percona-postgresql-14-pgaudit \
|
||||
percona-postgresql-14-pgaudit-dbgsym percona-postgresql-14-repack \
|
||||
percona-postgresql-14-repack-dbgsym percona-pgaudit14-set-user \
|
||||
percona-pgaudit14-set-user-dbgsym percona-postgresql-14-postgis-3 \
|
||||
percona-postgresql-14-postgis-3-scripts \
|
||||
percona-postgresql-postgis-scripts percona-postgresql-postgis \
|
||||
percona-postgis
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
|
|
@ -74,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-15-build
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-15-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_15_STABLE'
|
||||
|
|
@ -28,7 +38,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
|
|
@ -73,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -83,12 +93,13 @@ jobs:
|
|||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Load pg_stat_monitor library and Restart Server
|
||||
- name: Configure and Restart Server
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/15/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> \
|
||||
/opt/pgsql/data/postgresql.conf
|
||||
echo "compute_query_id = regress" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
|
|
@ -107,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
@ -126,15 +137,10 @@ jobs:
|
|||
retention-days: 3
|
||||
|
||||
- name: Start Server installcheck-world tests
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/15/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "compute_query_id = off" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
make installcheck-world
|
||||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-15-pgdg-package
|
||||
on: [pull_request]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-15-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -22,7 +32,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install PG Distribution Postgresql 15
|
||||
|
|
@ -68,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
name: postgresql-15-pmm-integration
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -8,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
|
@ -33,7 +42,7 @@ jobs:
|
|||
run: docker exec pgsql_pgsm_15 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
|
||||
|
||||
- name: Upload Tests Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-15-ppg-package
|
||||
on: [push]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-15-ppg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -23,7 +33,7 @@ jobs:
|
|||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install percona-release script
|
||||
|
|
@ -35,12 +45,19 @@ jobs:
|
|||
https://repo.percona.com/apt/percona-release_latest.generic_all.deb
|
||||
sudo dpkg -i percona-release_latest.generic_all.deb
|
||||
|
||||
- name: Install Percona Distribution Postgresql 15
|
||||
- name: Install Percona Distribution Postgresql 15 & Extensions
|
||||
run: |
|
||||
sudo percona-release setup ppg-15
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y percona-postgresql-15 \
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all \
|
||||
percona-pgpool2 libpgpool2 percona-postgresql-15-pgaudit \
|
||||
percona-postgresql-15-pgaudit-dbgsym percona-postgresql-15-repack \
|
||||
percona-postgresql-15-repack-dbgsym percona-pgaudit15-set-user \
|
||||
percona-pgaudit15-set-user-dbgsym percona-postgresql-15-postgis-3 \
|
||||
percona-postgresql-15-postgis-3-scripts \
|
||||
percona-postgresql-postgis-scripts percona-postgresql-postgis \
|
||||
percona-postgis
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
|
|
@ -75,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
|||
|
|
@ -1,16 +1,26 @@
|
|||
name: postgresql-12-build
|
||||
on: [push]
|
||||
name: postgresql-16-build
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-build-test
|
||||
name: pg-16-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_12_STABLE'
|
||||
ref: 'REL_16_STABLE'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
|
@ -19,15 +29,16 @@ jobs:
|
|||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex \
|
||||
libipc-run-perl docbook-xsl docbook-xsl libxml2 libxml2-utils \
|
||||
libipc-run-perl -y docbook-xsl docbook-xsl libxml2 libxml2-utils \
|
||||
libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \
|
||||
libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \
|
||||
llvm-11 llvm-11-dev libselinux1-dev python3-dev uuid-dev liblz4-dev
|
||||
llvm-11 llvm-11-dev libselinux1-dev python3-dev \
|
||||
uuid-dev liblz4-dev
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
|
|
@ -37,29 +48,28 @@ jobs:
|
|||
run: |
|
||||
export PATH="/opt/pgsql/bin:$PATH"
|
||||
./configure '--build=x86_64-linux-gnu' '--prefix=/usr' \
|
||||
'--includedir=/usr/include' '--mandir=/usr/share/man' \
|
||||
'--infodir=/usr/share/info' '--sysconfdir=/etc' '--with-gnu-ld' \
|
||||
'--localstatedir=/var' '--libdir=/usr/lib/x86_64-linux-gnu' \
|
||||
'runstatedir=/run' '--with-icu' '--with-tcl' '--with-perl' \
|
||||
'--with-python' '--with-pam' '--with-openssl' '--with-libxml' \
|
||||
'--with-libxslt' 'PYTHON=/usr/bin/python3' '--enable-tap-tests' \
|
||||
'--mandir=/usr/share/postgresql/12/man' '--enable-thread-safety' \
|
||||
'--docdir=/usr/share/doc/postgresql-doc-12' '--enable-debug' \
|
||||
'--includedir=${prefix}/include' '--mandir=${prefix}/share/man' \
|
||||
'--infodir=${prefix}/share/info' '--sysconfdir=/etc' \
|
||||
'--localstatedir=/var' '--libdir=${prefix}/lib/x86_64-linux-gnu' \
|
||||
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--with-icu' \
|
||||
'--with-tcl' '--with-perl' '--with-python' '--with-pam' \
|
||||
'--with-openssl' '--with-libxml' '--with-libxslt' '--with-ldap' \
|
||||
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/16/man' \
|
||||
'--docdir=/usr/share/doc/postgresql-doc-16' '--with-pgport=5432' \
|
||||
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share' \
|
||||
'--datadir=/usr/share/postgresql/12' '--enable-dtrace' \
|
||||
'--bindir=/usr/lib/postgresql/12/bin' '--disable-rpath' \
|
||||
'--libdir=/usr/lib/x86_64-linux-gnu' '--with-pgport=5432' \
|
||||
'--libexecdir=/usr/lib/postgresql' '--with-uuid=e2fs' \
|
||||
'--includedir=/usr/include/postgresql' 'TAR=/bin/tar' \
|
||||
'--datadir=/usr/share/postgresql/16' '--with-uuid=e2fs' \
|
||||
'--bindir=/usr/lib/postgresql/16/bin' '--enable-tap-tests' \
|
||||
'--libdir=/usr/lib/x86_64-linux-gnu' '--enable-debug' \
|
||||
'--libexecdir=/usr/lib/postgresql' '--with-gnu-ld' \
|
||||
'--includedir=/usr/include/postgresql' '--enable-dtrace' \
|
||||
'--enable-nls' '--enable-thread-safety' '--disable-rpath' \
|
||||
'--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
||||
'LLVM_CONFIG=/usr/bin/llvm-config-11' 'CLANG=/usr/bin/clang-11' \
|
||||
'--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' \
|
||||
'PROVE=/usr/bin/prove' '--with-gssapi' '--with-ldap' \
|
||||
'PROVE=/usr/bin/prove' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' \
|
||||
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' \
|
||||
'--with-includes=/usr/include/mit-krb5' '--with-libs=/usr/lib/mit-krb5' \
|
||||
'--with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5' \
|
||||
'build_alias=x86_64-linux-gnu' \
|
||||
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' '--enable-nls' \
|
||||
'build_alias=x86_64-linux-gnu' '--with-gssapi' \
|
||||
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' \
|
||||
'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' \
|
||||
'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
|
||||
make world
|
||||
|
|
@ -67,13 +77,13 @@ jobs:
|
|||
|
||||
- name: Start postgresql cluster
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/12/bin:$PATH"
|
||||
sudo cp /usr/lib/postgresql/12/bin/pg_config /usr/bin
|
||||
export PATH="/usr/lib/postgresql/16/bin:$PATH"
|
||||
sudo cp /usr/lib/postgresql/16/bin/pg_config /usr/bin
|
||||
initdb -D /opt/pgsql/data
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -83,19 +93,20 @@ jobs:
|
|||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Load pg_stat_monitor library and Restart Server
|
||||
- name: Configure and Restart Server
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/12/bin:$PATH"
|
||||
export PATH="/usr/lib/postgresql/16/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> \
|
||||
/opt/pgsql/data/postgresql.conf
|
||||
echo "compute_query_id = regress" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
make installcheck
|
||||
working-directory: src/pg_stat_monitor
|
||||
working-directory: src/pg_stat_monitor/
|
||||
|
||||
- name: Change dir permissions on fail
|
||||
if: ${{ failure() }}
|
||||
|
|
@ -107,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
@ -126,11 +137,10 @@ jobs:
|
|||
retention-days: 3
|
||||
|
||||
- name: Start Server installcheck-world tests
|
||||
run: |
|
||||
make installcheck-world
|
||||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
@ -1,13 +1,23 @@
|
|||
name: postgresql-12-pgdg-package
|
||||
on: [pull_request]
|
||||
name: postgresql-16-pgdg-package
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-pgdg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
name: pg-16-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
|
@ -16,28 +26,28 @@ jobs:
|
|||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \
|
||||
libipc-run-perl wget -y
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev wget \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install PG Distribution Postgresql 12
|
||||
- name: Install PG Distribution Postgresql 16
|
||||
run: |
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt \
|
||||
$(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo wget --quiet -O - \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc |
|
||||
sudo apt-key add -
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install postgresql-12 postgresql-server-dev-12
|
||||
sudo apt update
|
||||
sudo apt -y install postgresql-16 postgresql-server-dev-16
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
|
|
@ -50,7 +60,7 @@ jobs:
|
|||
run: |
|
||||
sudo service postgresql stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" |
|
||||
sudo tee -a /etc/postgresql/12/main/postgresql.conf
|
||||
sudo tee -a /etc/postgresql/16/main/postgresql.conf
|
||||
sudo service postgresql start
|
||||
sudo psql -V
|
||||
export PG_TEST_PORT_DIR=${GITHUB_WORKSPACE}/src/pg_stat_monitor
|
||||
|
|
@ -68,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
@ -1,17 +1,27 @@
|
|||
name: postgresql-12-ppg-package
|
||||
on: [push]
|
||||
name: postgresql-16-ppg-package
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-ppg-package-test
|
||||
runs-on: ubuntu-20.04
|
||||
name: pg-16-ppg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Delete old postgresql files
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
|
|
@ -19,14 +29,11 @@ jobs:
|
|||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \
|
||||
libipc-run-perl wget
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev python3-dev bison flex \
|
||||
libipc-run-perl wget
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::RUN'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install percona-release script
|
||||
|
|
@ -38,15 +45,23 @@ jobs:
|
|||
https://repo.percona.com/apt/percona-release_latest.generic_all.deb
|
||||
sudo dpkg -i percona-release_latest.generic_all.deb
|
||||
|
||||
- name: Install Percona Distribution Postgresql 12
|
||||
- name: Install Percona Distribution Postgresql 16 & Extensions
|
||||
run: |
|
||||
sudo percona-release setup ppg-12
|
||||
sudo percona-release setup ppg-16
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y percona-postgresql-12 \
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all
|
||||
sudo apt-get install -y percona-postgresql-16 \
|
||||
percona-postgresql-contrib percona-postgresql-server-dev-all \
|
||||
percona-pgpool2 libpgpool2 percona-postgresql-16-pgaudit \
|
||||
percona-postgresql-16-pgaudit-dbgsym percona-postgresql-16-repack \
|
||||
percona-postgresql-16-repack-dbgsym percona-pgaudit16-set-user \
|
||||
percona-pgaudit16-set-user-dbgsym percona-postgresql-16-postgis-3 \
|
||||
percona-postgresql-16-postgis-3-scripts \
|
||||
percona-postgresql-postgis-scripts percona-postgresql-postgis \
|
||||
percona-postgis
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
|
|
@ -59,7 +74,7 @@ jobs:
|
|||
run: |
|
||||
sudo service postgresql stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" |
|
||||
sudo tee -a /etc/postgresql/12/main/postgresql.conf
|
||||
sudo tee -a /etc/postgresql/16/main/postgresql.conf
|
||||
sudo service postgresql start
|
||||
sudo psql -V
|
||||
export PG_TEST_PORT_DIR=${GITHUB_WORKSPACE}/src/pg_stat_monitor
|
||||
|
|
@ -77,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
name: postgresql-17-build
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-17-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_17_STABLE'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex \
|
||||
libipc-run-perl -y docbook-xsl docbook-xsl libxml2 libxml2-utils \
|
||||
libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \
|
||||
libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-11 \
|
||||
llvm-11 llvm-11-dev libselinux1-dev python3-dev \
|
||||
uuid-dev liblz4-dev
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
run: mkdir -p /opt/pgsql
|
||||
|
||||
- name: Build postgres
|
||||
run: |
|
||||
export PATH="/opt/pgsql/bin:$PATH"
|
||||
./configure '--build=x86_64-linux-gnu' '--prefix=/usr' \
|
||||
'--includedir=${prefix}/include' '--mandir=${prefix}/share/man' \
|
||||
'--infodir=${prefix}/share/info' '--sysconfdir=/etc' \
|
||||
'--localstatedir=/var' '--libdir=${prefix}/lib/x86_64-linux-gnu' \
|
||||
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--with-icu' \
|
||||
'--with-tcl' '--with-perl' '--with-python' '--with-pam' \
|
||||
'--with-openssl' '--with-libxml' '--with-libxslt' '--with-ldap' \
|
||||
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/17/man' \
|
||||
'--docdir=/usr/share/doc/postgresql-doc-17' '--with-pgport=5432' \
|
||||
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share' \
|
||||
'--datadir=/usr/share/postgresql/17' '--with-uuid=e2fs' \
|
||||
'--bindir=/usr/lib/postgresql/17/bin' '--enable-tap-tests' \
|
||||
'--libdir=/usr/lib/x86_64-linux-gnu' '--enable-debug' \
|
||||
'--libexecdir=/usr/lib/postgresql' '--with-gnu-ld' \
|
||||
'--includedir=/usr/include/postgresql' '--enable-dtrace' \
|
||||
'--enable-nls' '--enable-thread-safety' '--disable-rpath' \
|
||||
'--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
||||
'LLVM_CONFIG=/usr/bin/llvm-config-11' 'CLANG=/usr/bin/clang-11' \
|
||||
'--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' \
|
||||
'PROVE=/usr/bin/prove' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' \
|
||||
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' \
|
||||
'build_alias=x86_64-linux-gnu' '--with-gssapi' \
|
||||
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' \
|
||||
'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' \
|
||||
'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
|
||||
make world
|
||||
sudo make install-world
|
||||
|
||||
- name: Start postgresql cluster
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/17/bin:$PATH"
|
||||
sudo cp /usr/lib/postgresql/17/bin/pg_config /usr/bin
|
||||
initdb -D /opt/pgsql/data
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
make USE_PGXS=1
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Configure and Restart Server
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/17/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> \
|
||||
/opt/pgsql/data/postgresql.conf
|
||||
echo "compute_query_id = regress" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
make installcheck
|
||||
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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
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: 3
|
||||
|
||||
- name: Start Server installcheck-world tests
|
||||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
path: |
|
||||
**/regression.diffs
|
||||
**/regression.out
|
||||
src/pg_stat_monitor/logfile
|
||||
retention-days: 3
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
name: postgresql-17-pgdg-package
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-17-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Delete old postgresql files
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev wget \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install PG Distribution Postgresql 17
|
||||
run: |
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt \
|
||||
$(lsb_release -cs)-pgdg main 17" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo wget --quiet -O - \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc |
|
||||
sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt -y install postgresql-17 postgresql-server-dev-17
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
sudo -u postgres bash -c 'make USE_PGXS=1'
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
sudo service postgresql stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" |
|
||||
sudo tee -a /etc/postgresql/17/main/postgresql.conf
|
||||
sudo service postgresql start
|
||||
sudo psql -V
|
||||
export PG_TEST_PORT_DIR=${GITHUB_WORKSPACE}/src/pg_stat_monitor
|
||||
echo $PG_TEST_PORT_DIR
|
||||
sudo -E -u postgres bash -c 'make installcheck USE_PGXS=1'
|
||||
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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
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: 3
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
name: postgresql-18-build
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-18-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_18_STABLE'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex \
|
||||
libipc-run-perl -y docbook-xsl docbook-xsl libxml2 libxml2-utils \
|
||||
libxml2-dev libxslt-dev xsltproc libkrb5-dev libldap2-dev \
|
||||
libsystemd-dev gettext tcl-dev libperl-dev pkg-config clang-14 \
|
||||
llvm-14 llvm-14-dev libselinux1-dev python3-dev \
|
||||
uuid-dev liblz4-dev
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Create pgsql dir
|
||||
run: mkdir -p /opt/pgsql
|
||||
|
||||
- name: Build postgres
|
||||
run: |
|
||||
export PATH="/opt/pgsql/bin:$PATH"
|
||||
./configure '--build=x86_64-linux-gnu' '--prefix=/usr' \
|
||||
'--includedir=${prefix}/include' '--mandir=${prefix}/share/man' \
|
||||
'--infodir=${prefix}/share/info' '--sysconfdir=/etc' \
|
||||
'--localstatedir=/var' '--libdir=${prefix}/lib/x86_64-linux-gnu' \
|
||||
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--with-icu' \
|
||||
'--with-tcl' '--with-perl' '--with-python' '--with-pam' \
|
||||
'--with-openssl' '--with-libxml' '--with-libxslt' '--with-ldap' \
|
||||
'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/18/man' \
|
||||
'--docdir=/usr/share/doc/postgresql-doc-18' '--with-pgport=5432' \
|
||||
'--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share' \
|
||||
'--datadir=/usr/share/postgresql/18' '--with-uuid=e2fs' \
|
||||
'--bindir=/usr/lib/postgresql/18/bin' '--enable-tap-tests' \
|
||||
'--libdir=/usr/lib/x86_64-linux-gnu' '--enable-debug' \
|
||||
'--libexecdir=/usr/lib/postgresql' '--with-gnu-ld' \
|
||||
'--includedir=/usr/include/postgresql' '--enable-dtrace' \
|
||||
'--enable-nls' '--enable-thread-safety' '--disable-rpath' \
|
||||
'--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' \
|
||||
'LLVM_CONFIG=/usr/bin/llvm-config-14' 'CLANG=/usr/bin/clang-14' \
|
||||
'--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' \
|
||||
'PROVE=/usr/bin/prove' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' \
|
||||
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' \
|
||||
'build_alias=x86_64-linux-gnu' '--with-gssapi' \
|
||||
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' \
|
||||
'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' \
|
||||
'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
|
||||
make world
|
||||
sudo make install-world
|
||||
|
||||
- name: Start postgresql cluster
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/18/bin:$PATH"
|
||||
sudo cp /usr/lib/postgresql/18/bin/pg_config /usr/bin
|
||||
initdb -D /opt/pgsql/data
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
make USE_PGXS=1
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Configure and Restart Server
|
||||
run: |
|
||||
export PATH="/usr/lib/postgresql/18/bin:$PATH"
|
||||
pg_ctl -D /opt/pgsql/data -l logfile stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" >> \
|
||||
/opt/pgsql/data/postgresql.conf
|
||||
echo "compute_query_id = regress" >> /opt/pgsql/data/postgresql.conf
|
||||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
make installcheck
|
||||
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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
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: 3
|
||||
|
||||
- name: Start Server installcheck-world tests
|
||||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
path: |
|
||||
**/regression.diffs
|
||||
**/regression.out
|
||||
src/pg_stat_monitor/logfile
|
||||
retention-days: 3
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
name: postgresql-18-pgdg-package
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-18-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
- name: Delete old postgresql files
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt purge postgresql-client-common postgresql-common \
|
||||
postgresql postgresql*
|
||||
sudo apt-get install -y libreadline6-dev systemtap-sdt-dev wget \
|
||||
zlib1g-dev libssl-dev libpam0g-dev bison flex libipc-run-perl
|
||||
sudo rm -rf /var/lib/postgresql /var/log/postgresql /etc/postgresql \
|
||||
/usr/lib/postgresql /usr/include/postgresql /usr/share/postgresql \
|
||||
/etc/postgresql
|
||||
sudo rm -f /usr/bin/pg_config
|
||||
sudo /usr/bin/perl -MCPAN -e 'install IPC::Run'
|
||||
sudo /usr/bin/perl -MCPAN -e 'install Text::Trim'
|
||||
|
||||
- name: Install PG Distribution Postgresql 18
|
||||
run: |
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt \
|
||||
$(lsb_release -cs)-pgdg main 18" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo wget --quiet -O - \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc |
|
||||
sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt -y install postgresql-18 postgresql-server-dev-18
|
||||
|
||||
- name: Change src owner to postgres
|
||||
run: |
|
||||
sudo chmod o+rx ~
|
||||
sudo chown -R postgres:postgres src
|
||||
|
||||
- name: Build pg_stat_monitor
|
||||
run: |
|
||||
sudo -u postgres bash -c 'make USE_PGXS=1'
|
||||
sudo make USE_PGXS=1 install
|
||||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Start pg_stat_monitor_tests
|
||||
run: |
|
||||
sudo service postgresql stop
|
||||
echo "shared_preload_libraries = 'pg_stat_monitor'" |
|
||||
sudo tee -a /etc/postgresql/18/main/postgresql.conf
|
||||
sudo service postgresql start
|
||||
sudo psql -V
|
||||
export PG_TEST_PORT_DIR=${GITHUB_WORKSPACE}/src/pg_stat_monitor
|
||||
echo $PG_TEST_PORT_DIR
|
||||
sudo -E -u postgres bash -c 'make installcheck USE_PGXS=1'
|
||||
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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
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: 3
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
name: Scorecard
|
||||
on:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: "24 3 * * 1"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run analysis
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
publish_results: true
|
||||
|
||||
- name: Upload results
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard (optional).
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
|
@ -45,6 +45,7 @@
|
|||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
.deps/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
|
|
@ -59,3 +60,6 @@ dkms.conf
|
|||
## .vscode
|
||||
.vscode/
|
||||
.vscode/*
|
||||
|
||||
# tools files
|
||||
typedefs-full.list
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
header:
|
||||
paths:
|
||||
- "**/*.c"
|
||||
- "**/*.h"
|
||||
license:
|
||||
pattern: |
|
||||
.*\.(c|h)
|
||||
.*
|
||||
|
||||
Portions Copyright © 2018-2025, Percona LLC and/or its affiliates
|
||||
|
||||
Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
|
||||
Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
||||
IDENTIFICATION
|
||||
contrib/pg_stat_monitor/.*\.(c|h)
|
||||
|
||||
comment: never
|
||||
20
ADOPTERS.md
20
ADOPTERS.md
|
|
@ -1,20 +0,0 @@
|
|||
# List of pg_stat_monitor Adopters
|
||||
|
||||
This is the list of organizations and users that publicly shared details of how
|
||||
they are using pg_stat_monitor.
|
||||
|
||||
Please send us a pull request if you want to be added or removed from this
|
||||
list.
|
||||
|
||||
The list of organizations that have publicly shared the usage of
|
||||
pg_stat_monitor:
|
||||
|
||||
| Organization | Description | Success Story |
|
||||
| :--- | :--- | :--- |
|
||||
| [Example](https://example.com/) | Example company running pg_stat_monitor for dev and production for core application | [English](./adopters/example/README.md) |
|
||||
|
||||
The list of users that have publicly shared the usage of pg_stat_monitor.
|
||||
|
||||
| User | Description | Success Story |
|
||||
| :--- | :--- | :--- |
|
||||
| [Example User](https://github.com/username) | Personal tests of pg_stat_monitor | [English](./adopters/users/username/README.md) |
|
||||
21
META.json
21
META.json
|
|
@ -2,30 +2,33 @@
|
|||
"name": "pg_stat_monitor",
|
||||
"abstract": "PostgreSQL Query Performance Monitoring Tool",
|
||||
"description": "pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL's contrib module pg_stat_statements. PostgreSQL’s pg_stat_statements provides the basic statistics, which is sometimes not enough. The major shortcoming in pg_stat_statements is that it accumulates all the queries and their statistics and does not provide aggregated statistics nor histogram information. In this case, a user would need to calculate the aggregates, which is quite an expensive operation.",
|
||||
"version": "2.0.2",
|
||||
"version": "2.3.1",
|
||||
"maintainer": [
|
||||
"ibrar.ahmed@percona.com"
|
||||
"Artem Gavrilov <artem.gavrilov@percona.com>",
|
||||
"Diego dos Santos Fronza <diego.fronza@percona.com>"
|
||||
],
|
||||
"license": "postgresql",
|
||||
"license": {
|
||||
"PostgreSQL": "https://www.postgresql.org/about/licence"
|
||||
},
|
||||
"provides": {
|
||||
"pg_stat_monitor": {
|
||||
"abstract": "PostgreSQL Query Performance Monitoring Tool",
|
||||
"file": "pg_stat_monitor--2.0.sql",
|
||||
"file": "pg_stat_monitor--2.2--2.3.sql",
|
||||
"docfile": "README.md",
|
||||
"version": "2.0.2"
|
||||
"version": "2.3.1"
|
||||
}
|
||||
},
|
||||
"prereqs": {
|
||||
"runtime": {
|
||||
"requires": {
|
||||
"PostgreSQL": "11.0.0"
|
||||
"PostgreSQL": "12.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"homepage": "https://percona.github.io/pg_stat_monitor/",
|
||||
"homepage": "https://github.com/percona/pg_stat_monitor",
|
||||
"bugtracker": {
|
||||
"web": "https://jira.percona.com/projects/PG/issues"
|
||||
"web": "https://perconadev.atlassian.net/jira/software/c/projects/PG/issues"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://github.com/percona/pg_stat_monitor.git",
|
||||
|
|
@ -33,7 +36,7 @@
|
|||
"type": "git"
|
||||
}
|
||||
},
|
||||
"generated_by": "ibrar.ahmed@percona.com",
|
||||
"generated_by": "Artem Gavrilov",
|
||||
"meta-spec": {
|
||||
"version": "1.0.0",
|
||||
"url": "http://pgxn.org/meta/spec.txt"
|
||||
|
|
|
|||
36
Makefile
36
Makefile
|
|
@ -4,7 +4,7 @@ MODULE_big = pg_stat_monitor
|
|||
OBJS = hash_query.o guc.o pg_stat_monitor.o $(WIN32RES)
|
||||
|
||||
EXTENSION = pg_stat_monitor
|
||||
DATA = pg_stat_monitor--2.0.sql pg_stat_monitor--1.0--2.0.sql
|
||||
DATA = pg_stat_monitor--2.0.sql pg_stat_monitor--1.0--2.0.sql pg_stat_monitor--2.0--2.1.sql pg_stat_monitor--2.1--2.2.sql pg_stat_monitor--2.2--2.3.sql
|
||||
|
||||
PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements"
|
||||
|
||||
|
|
@ -12,7 +12,28 @@ LDFLAGS_SL += $(filter -lm, $(LIBS))
|
|||
|
||||
TAP_TESTS = 1
|
||||
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression
|
||||
REGRESS = basic version guc pgsm_query_id functions counters relations database error_insert application_name application_name_unique top_query cmd_type error rows tags user
|
||||
REGRESS = basic \
|
||||
version \
|
||||
guc \
|
||||
pgsm_query_id \
|
||||
functions \
|
||||
counters \
|
||||
relations \
|
||||
database \
|
||||
error_insert \
|
||||
application_name \
|
||||
application_name_unique \
|
||||
top_query \
|
||||
different_parent_queries \
|
||||
cmd_type \
|
||||
error \
|
||||
rows \
|
||||
squashing \
|
||||
tags \
|
||||
user \
|
||||
level_tracking \
|
||||
decode_error_level \
|
||||
parallel
|
||||
|
||||
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
|
||||
# which typical installcheck users do not have (e.g. buildfarm clients).
|
||||
|
|
@ -30,3 +51,14 @@ top_builddir = ../..
|
|||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
|
||||
# Fetches typedefs list for PostgreSQL core and merges it with typedefs defined in this project.
|
||||
# https://wiki.postgresql.org/wiki/Running_pgindent_on_non-core_code_or_development_code
|
||||
update-typedefs:
|
||||
wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_17_STABLE" | cat - typedefs.list | sort | uniq > typedefs-full.list
|
||||
|
||||
# Indents projects sources.
|
||||
indent:
|
||||
pgindent --typedefs=typedefs-full.list .
|
||||
|
||||
.PHONY: update-typedefs indent
|
||||
66
README.md
66
README.md
|
|
@ -1,6 +1,15 @@
|
|||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-11-pgdg-package.yml) [](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-12-pgdg-package.yml) [](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-13-pgdg-package.yml) [](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-14-pgdg-package.yml) [](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-15-pgdg-package.yml)
|
||||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-13-pgdg-package.yml)
|
||||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-14-pgdg-package.yml)
|
||||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-15-pgdg-package.yml)
|
||||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-16-pgdg-package.yml)
|
||||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-17-pgdg-package.yml)
|
||||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-18-pgdg-package.yml)
|
||||
|
||||
[](https://badge.fury.io/pg/pg_stat_monitor)
|
||||
[](https://scorecard.dev/viewer/?uri=github.com/percona/pg_stat_monitor)
|
||||
[](https://www.bestpractices.dev/projects/9703)
|
||||
[](https://codecov.io/gh/percona/pg_stat_monitor)
|
||||
[](https://forums.percona.com/)
|
||||
# pg_stat_monitor: Query Performance Monitoring Tool for PostgreSQL
|
||||
|
||||
## Table of Contents
|
||||
|
|
@ -16,6 +25,7 @@
|
|||
- [Installing from Percona repositories](#installing-from-percona-repositories)
|
||||
- [Installing from PostgreSQL `yum` repositories](#installing-from-postgresql-yum-repositories)
|
||||
- [Installing from PGXN](#installing-from-pgxn)
|
||||
- [Installing from sources](#building-from-source)
|
||||
- [Configuration](#configuration)
|
||||
- [Setup](#setup)
|
||||
- [Building from source](#building-from-source)
|
||||
|
|
@ -41,9 +51,9 @@ While `pg_stat_statements` provides ever-increasing metrics, `pg_stat_monitor` a
|
|||
|
||||
To learn about other features, available in `pg_stat_monitor`, see the [Features](#pg_stat_monitor-features) section and the [User Guide](https://docs.percona.com/pg-stat-monitor/user_guide.html).
|
||||
|
||||
`pg_stat_monitor` supports PostgreSQL versions 11 and above. It is compatible with both PostgreSQL provided by PostgreSQL Global Development Group (PGDG) and [Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution).
|
||||
`pg_stat_monitor` supports PostgreSQL versions 13 and above. It is compatible with both PostgreSQL provided by PostgreSQL Global Development Group (PGDG) and [Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution).
|
||||
|
||||
The `RPM` (for RHEL and CentOS) and the `DEB` (for Debian and Ubuntu) packages are available from Percona repositories for PostgreSQL versions [11](https://www.percona.com/downloads/percona-postgresql-11/LATEST/), [12](https://www.percona.com/downloads/postgresql-distribution-12/LATEST/), [13](https://www.percona.com/downloads/postgresql-distribution-13/LATEST/), [14](https://www.percona.com/downloads/postgresql-distribution-14/LATEST/) and [15](https://www.percona.com/downloads/postgresql-distribution-15/LATEST/).
|
||||
The `RPM` (for RHEL and CentOS) and the `DEB` (for Debian and Ubuntu) packages are available from Percona repositories for PostgreSQL versions [13](https://www.percona.com/downloads/postgresql-distribution-13/LATEST/), [14](https://www.percona.com/downloads/postgresql-distribution-14/LATEST/), [15](https://www.percona.com/downloads/postgresql-distribution-15/LATEST/), [16](https://www.percona.com/downloads/postgresql-distribution-16/LATEST/), [17](https://www.percona.com/downloads/postgresql-distribution-17/LATEST/) and [18](https://www.percona.com/downloads/postgresql-distribution-18/LATEST/).
|
||||
|
||||
The RPM packages are also available in the official PostgreSQL (PGDG) yum repositories.
|
||||
|
||||
|
|
@ -53,8 +63,8 @@ The `pg_stat_monitor` should work on the latest version of both [Percona Distrib
|
|||
|
||||
| **Distribution** | **Version** | **Provider** |
|
||||
| ---------------- | --------------- | ------------ |
|
||||
|[Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution)| [11](https://www.percona.com/downloads/percona-postgresql-11/LATEST/), [12](https://www.percona.com/downloads/postgresql-distribution-12/LATEST/), [13](https://www.percona.com/downloads/postgresql-distribution-13/LATEST/), [14](https://www.percona.com/downloads/postgresql-distribution-14/LATEST/) and [15](https://www.percona.com/downloads/postgresql-distribution-15/LATEST/)| Percona|
|
||||
| PostgreSQL | 11, 12, 13, 14 and 15 | PostgreSQL Global Development Group (PGDG) |
|
||||
|[Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution)| [13](https://www.percona.com/downloads/postgresql-distribution-13/LATEST/), [14](https://www.percona.com/downloads/postgresql-distribution-14/LATEST/), [15](https://www.percona.com/downloads/postgresql-distribution-15/LATEST/), [16](https://www.percona.com/downloads/postgresql-distribution-16/LATEST/), [17](https://www.percona.com/downloads/postgresql-distribution-17/LATEST/) and [18](https://www.percona.com/downloads/postgresql-distribution-18/LATEST/)| Percona|
|
||||
| PostgreSQL | 13, 14, 15, 16, 17 and 18 | PostgreSQL Global Development Group (PGDG) |
|
||||
|
||||
|
||||
### Features
|
||||
|
|
@ -85,7 +95,7 @@ The following are useful links in [`pg_stat_monitor` documentation](https://docs
|
|||
|
||||
The PostgreSQL YUM repository supports `pg_stat_monitor` for all [supported versions](#supported-versions) for the following platforms:
|
||||
|
||||
* Red Hat Enterprise/Rocky/CentOS/Oracle Linux 7 and 8
|
||||
* Red Hat Enterprise/Rocky/CentOS/Oracle Linux 7, 8 and 9
|
||||
* Fedora 33 and 34
|
||||
|
||||
Find the list of supported platforms for `pg_stat_monitor` within [Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution) on the [Percona Release Lifecycle Overview](https://www.percona.com/services/policies/percona-software-support-lifecycle#pgsql) page.
|
||||
|
|
@ -95,10 +105,10 @@ Find the list of supported platforms for `pg_stat_monitor` within [Percona Distr
|
|||
|
||||
You can install `pg_stat_monitor` from the following sources:
|
||||
|
||||
* [Percona repositories](#installing-from-percona-repositories),
|
||||
* [PostgreSQL PGDG yum repositories](#installing-from-postgresql-yum-repositories),
|
||||
* [PGXN](#installing-from-pgxn) and
|
||||
* [source code](#building-from-source).
|
||||
* [Percona repositories](#installing-from-percona-repositories)
|
||||
* [PostgreSQL PGDG yum repositories](#installing-from-postgresql-yum-repositories)
|
||||
* [PGXN](#installing-from-pgxn)
|
||||
* [source code](#building-from-source)
|
||||
|
||||
|
||||
#### Installing from Percona repositories
|
||||
|
|
@ -109,19 +119,19 @@ To install `pg_stat_monitor` from Percona repositories, you need to use the `per
|
|||
2. Enable Percona repository:
|
||||
|
||||
``` sh
|
||||
percona-release setup ppgXX
|
||||
percona-release setup ppg-XX
|
||||
```
|
||||
|
||||
Replace XX with the desired PostgreSQL version. For example, to install `pg_stat_monitor ` for PostgreSQL 15, specify `ppg15`.
|
||||
Replace XX with the desired PostgreSQL version. For example, to install `pg_stat_monitor ` for PostgreSQL 17, specify `ppg-17`.
|
||||
|
||||
3. Install `pg_stat_monitor` package
|
||||
* For Debian and Ubuntu:
|
||||
``` sh
|
||||
apt-get install percona-pg-stat-monitor15
|
||||
apt-get install percona-pg-stat-monitor17
|
||||
```
|
||||
* For RHEL and CentOS:
|
||||
``` sh
|
||||
yum install percona-pg-stat-monitor15
|
||||
yum install percona-pg-stat-monitor17
|
||||
```
|
||||
|
||||
#### Installing from PostgreSQL `yum` repositories
|
||||
|
|
@ -134,12 +144,12 @@ Install `pg_stat_monitor`:
|
|||
dnf install -y pg_stat_monitor_<VERSION>
|
||||
```
|
||||
|
||||
Replace the `VERSION` variable with the PostgreSQL version you are using (e.g. specify `pg_stat_monitor_15` for PostgreSQL 15)
|
||||
Replace the `VERSION` variable with the PostgreSQL version you are using (e.g. specify `pg_stat_monitor_17` for PostgreSQL 17)
|
||||
|
||||
|
||||
#### Installing from PGXN
|
||||
|
||||
You can install `pg_stat_monitor` from PGXN (PostgreSQL Extensions Network) using the [PGXN client](https://pgxn.github.io/pgxnclient/).
|
||||
You can install `pg_stat_monitor` from [PGXN (PostgreSQL Extensions Network)](https://pgxn.org/) using the [PGXN client](https://pgxn.github.io/pgxnclient/).
|
||||
|
||||
Use the following command:
|
||||
|
||||
|
|
@ -149,7 +159,7 @@ pgxn install pg_stat_monitor
|
|||
|
||||
### Configuration
|
||||
|
||||
You can find the configuration parameters of the `pg_stat_monitor` extension in the `pg_stat_monitor_settings` view. To change the default configuration, specify new values for the desired parameters using the GUC (Grant Unified Configuration) system. To learn more, refer to the [Configuration parameters](https://docs.percona.com/pg-stat-monitor/configuration.html) section of the documentation.
|
||||
You can find the configuration parameters of the `pg_stat_monitor` extension in the `pg_settings` view. To change the default configuration, specify new values for the desired parameters using the GUC (Grant Unified Configuration) system. To learn more, refer to the [Configuration parameters](https://docs.percona.com/pg-stat-monitor/configuration.html) section of the documentation.
|
||||
|
||||
|
||||
### Setup
|
||||
|
|
@ -166,7 +176,7 @@ ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_monitor';
|
|||
|
||||
> **NOTE**: If you’ve added other modules to the `shared_preload_libraries` parameter (for example, `pg_stat_statements`), list all of them separated by commas for the `ALTER SYSTEM` command.
|
||||
>
|
||||
>:warning: For PostgreSQL 13 and earlier versions,`pg_stat_monitor` **must** follow `pg_stat_statements`. For example, `ALTER SYSTEM SET shared_preload_libraries = 'foo, pg_stat_statements, pg_stat_monitor'`.
|
||||
>:warning: For PostgreSQL 13 `pg_stat_monitor` **must** follow `pg_stat_statements`. For example, `ALTER SYSTEM SET shared_preload_libraries = 'foo, pg_stat_statements, pg_stat_monitor'`.
|
||||
>
|
||||
>In PostgreSQL 14, you can specify `pg_stat_statements` and `pg_stat_monitor` in any order. However, due to the extensions' architecture, if both `pg_stat_statements` and `pg_stat_monitor` are loaded, only the last listed extension captures utility queries, CREATE TABLE, Analyze, etc. The first listed extension captures most common queries like SELECT, UPDATE, INSERT, but does not capture utility queries.
|
||||
>
|
||||
|
|
@ -185,7 +195,7 @@ sudo systemctl restart postgresql.service
|
|||
|
||||
|
||||
```sh
|
||||
sudo systemctl restart postgresql-15
|
||||
sudo systemctl restart postgresql-17
|
||||
```
|
||||
|
||||
Create the extension using the [CREATE EXTENSION](https://www.postgresql.org/docs/current/sql-createextension.html) command. Using this command requires the privileges of a superuser or a database owner. Connect to `psql` as a superuser for a database and run the following command:
|
||||
|
|
@ -247,19 +257,13 @@ make USE_PGXS=1 install
|
|||
|
||||
To uninstall `pg_stat_monitor`, do the following:
|
||||
|
||||
1. Disable statistics collection. From the `psql` terminal, run the following command:
|
||||
|
||||
```sql
|
||||
ALTER SYSTEM SET pg_stat_monitor.pgsm_enable = 0;
|
||||
```
|
||||
|
||||
2. Drop `pg_stat_monitor` extension:
|
||||
1. Drop `pg_stat_monitor` extension:
|
||||
|
||||
```sql
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
```
|
||||
|
||||
3. Remove `pg_stat_monitor` from the `shared_preload_libraries` configuration parameter:
|
||||
2. Remove `pg_stat_monitor` from the `shared_preload_libraries` configuration parameter:
|
||||
|
||||
```sql
|
||||
ALTER SYSTEM SET shared_preload_libraries = '';
|
||||
|
|
@ -267,7 +271,7 @@ To uninstall `pg_stat_monitor`, do the following:
|
|||
|
||||
**Important**: If the `shared_preload_libraries` parameter includes other modules, specify them all for the `ALTER SYSTEM SET` command to keep using them.
|
||||
|
||||
4. Restart the `postgresql` instance to apply the changes. The following command restarts PostgreSQL 15. Replace the version value with the one you are using.
|
||||
3. Restart the `postgresql` instance to apply the changes. The following command restarts PostgreSQL 17. Replace the version value with the one you are using.
|
||||
|
||||
* On Debian and Ubuntu:
|
||||
|
||||
|
|
@ -279,7 +283,7 @@ To uninstall `pg_stat_monitor`, do the following:
|
|||
|
||||
|
||||
```sh
|
||||
sudo systemctl restart postgresql-15
|
||||
sudo systemctl restart postgresql-17
|
||||
```
|
||||
|
||||
### How we work
|
||||
|
|
@ -319,6 +323,6 @@ This project is licensed under the same open liberal terms and conditions as the
|
|||
|
||||
### Copyright notice
|
||||
|
||||
* Portions Copyright © 2018-2023, Percona LLC and/or its affiliates
|
||||
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
|
||||
* Portions Copyright © 2018-2025, Percona LLC and/or its affiliates
|
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
|
|
|||
304
RELEASE_NOTES.md
304
RELEASE_NOTES.md
|
|
@ -1,304 +0,0 @@
|
|||
# Release Notes
|
||||
|
||||
Below is the complete list of release notes for every version of ``pg_stat_monitor``.
|
||||
|
||||
## 2.0.2
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
[GH-418](https://github.com/percona/pg_stat_monitor/issues/418) - Fixed compilation issue with PG16 and added meson.build file.
|
||||
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
[PG-613](https://jira.percona.com/browse/PG-613) - Fixed the issue with segmentation fault error when the query plan is enabled on large queries.
|
||||
|
||||
[PG-624](https://jira.percona.com/browse/PG-624) - Fixed the server crash when running pgbench with pg_stat_monitor loaded by improving the handling of the dynamic number of buckets.
|
||||
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-310](https://jira.percona.com/browse/PG-310): Bucket is “Done” vs still being current/last
|
||||
|
||||
[PG-400](https://jira.percona.com/browse/PG-400): Add timezone in datetime columns in pg_stat_monitor view.
|
||||
|
||||
[PG-435](https://jira.percona.com/browse/PG-435): PostgreSQL 15 Support by adding newly introduced columns
|
||||
|
||||
[PG-488](https://jira.percona.com/browse/PG-488): Update query buffer overflow management to use dynamic shared memory
|
||||
|
||||
[PG-543](https://jira.percona.com/browse/PG-543): PostgreSQL's pg_stat_statements compatible view.
|
||||
|
||||
[PG-545](https://jira.percona.com/browse/PG-545): Same query text should generate same queryid
|
||||
|
||||
[PG-569](https://jira.percona.com/browse/PG-569): Make all data types of pg_stat_monitor view compatible with pg_stat_statements
|
||||
|
||||
[PG-586](https://jira.percona.com/browse/PG-586): CPU and user timing should be captured for utility statements as well
|
||||
|
||||
[PG-588](https://jira.percona.com/browse/PG-588): Fix missing query and query normalization issue; rearchitect pg_stat_monitor
|
||||
|
||||
[PG-606](https://jira.percona.com/browse/PG-606): New GUC required for enabling/disabling of pgsm_query_id calculation
|
||||
|
||||
[PG-607](https://jira.percona.com/browse/PG-607): Allow histogram to track queries in sub-ms time brackets
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
[PG-306](https://jira.percona.com/browse/PG-306): bucket_start_time - TEXT vs TIMESTAMP?
|
||||
|
||||
[PG-320](https://jira.percona.com/browse/PG-320): Remove state/state_code fields from pg_stat_monitor_view.
|
||||
|
||||
[PG-321](https://jira.percona.com/browse/PG-321): Remove redundant `cmd_type`/`cmd_type_text` columns in `pg_stat_monitor` view.
|
||||
|
||||
[PG-354](https://jira.percona.com/browse/PG-354): Remove pg_stat_monitor_settings view
|
||||
|
||||
[PG-373](https://jira.percona.com/browse/PG-373): Remove wal fields for PG12 and below
|
||||
|
||||
[PG-518](https://jira.percona.com/browse/PG-518): Internal Functions should NOT be visible in PGSM API.
|
||||
|
||||
[PG-579](https://jira.percona.com/browse/PG-579): Querying pg_stat_monitor view crashes the server when pg_stat_monitor.so is not configured in shared_preload_libraries
|
||||
|
||||
[PG-582](https://jira.percona.com/browse/PG-582): blk_read_time and blk_write_time are not being rounded.
|
||||
|
||||
[PG-583](https://jira.percona.com/browse/PG-583): Rounded time based values are not consistent
|
||||
|
||||
[PG-597](https://jira.percona.com/browse/PG-597): Remove rounding off for floating point values
|
||||
|
||||
[PG-569](https://jira.percona.com/browse/PG-569): Make all data types of pg_stat_monitor view compatible with pg_stat_statements
|
||||
|
||||
## 1.1.1
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-462](https://jira.percona.com/browse/PG-462): Initial Support for PostgreSQL15 was added
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-474](https://jira.percona.com/browse/PG-474): Make pg_stat_monitor compiled with CLANG
|
||||
|
||||
[PG-159](https://jira.percona.com/browse/PG-159): Change the bucket start time scheme to align with the bucket time size
|
||||
|
||||
[PG-293](https://jira.percona.com/browse/PG-293): Add the ability to control features added on top of `pg_stat_monitor` using GUC (Grand Unified Configuration) parameters
|
||||
|
||||
[PG-300](https://jira.percona.com/browse/PG-300): Improve compatibility with PMM by making QueryIDs persistent for the same queries across different buckets and regardless of the node / client a query is executed on.
|
||||
|
||||
[PG-362](https://jira.percona.com/browse/PG-362): Fix the `pgsm_normalized_query` default value to provide query examples in the `pg_stat_monitor` view by default.
|
||||
|
||||
[PG-439](https://jira.percona.com/browse/PG-439): Remove warning of comparison of unsigned enum expression
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-221](https://jira.percona.com/browse/PG-221): Fixed the issue with pg_stat_monitor crashing when querying JSON with parallel workers enabled
|
||||
|
||||
[PG-289](https://jira.percona.com/browse/PG-289): Fixed the issue with pg_stat_monitor failing to build on C11 compilers by removing 'for' loop initial declarations
|
||||
|
||||
[PG-449](https://jira.percona.com/browse/PG-449): Fix comments visibility by correcting the behavior of the `pgsm_extract_comments` parameter
|
||||
|
||||
[PG-453](https://jira.percona.com/browse/PG-453): Fixed query normalization for INSERT statements in PostgreSQL 13 and earlier versions
|
||||
|
||||
[PG-455](https://jira.percona.com/browse/PG-455): Fixed the issue with data collection for any value specified for `pgsm_bucket_time` parameter within the min / max range
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-382](https://jira.percona.com/browse/PG-382): Histogram default settings changed to prevent the PostgreSQL server to crash
|
||||
|
||||
[PG-417](https://jira.percona.com/browse/PG-417): Addressed security vulnerabilities to prevent an attacker from precreating functions
|
||||
|
||||
[DISTPG-427](https://jira.percona.com/browse/DISTPG-427): Fixed the issue with the extensions not working when pg_stat_monitor is enabled by replacing the `return` with `goto exit` for the `pgsm_emit_log_hook` function
|
||||
|
||||
## 1.0.0
|
||||
|
||||
Bump version from 1.0.0-rc.2 to 1.0.0.
|
||||
|
||||
## 1.0.0-rc.2
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-331](https://jira.percona.com/browse/PG-331): Changed the default value for the `pg_stat_monitor.pgsm_query_max_len` parameter from 1024 to 2048 for better data presentation in PMM
|
||||
|
||||
[PG-355](https://jira.percona.com/browse/PG-355): Changed the collection of `sys_time` and `user_time` metrics so that they are now presented as an accumulative value
|
||||
|
||||
[PG-286](https://jira.percona.com/browse/PG-286): Improved pg_stat_monitor performance by decreasing the overhead by more than 50%.
|
||||
|
||||
[PG-267](https://jira.percona.com/browse/PG-267): Added test case to verify histogram feature
|
||||
|
||||
[PG-359](https://jira.percona.com/browse/PG-359): Documentation: updated the `pg_stat_monitor_settings` view reference.
|
||||
|
||||
[PG-344](https://jira.percona.com/browse/PG-344): Documentation: Updated the extensions order and behavior with data collection for PostgreSQL 14.
|
||||
|
||||
[PG-358](https://jira.percona.com/browse/PG-358): Documentation: data display of `** blk **` and `** wal **` columns when both `pg_stat_monitor` and `pg_stat_statements` are loaded together.
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-350](https://jira.percona.com/browse/PG-350): Fixed bucket time overflow
|
||||
|
||||
[PG-338](https://jira.percona.com/browse/PG-338): Fixed query calls count by setting the default value for `pg_stat_monitor.pgsm_track` to `top`.
|
||||
|
||||
[PG-291](https://jira.percona.com/browse/PG-338): Fixed calls count.
|
||||
|
||||
[PG-325](https://jira.percona.com/browse/PG-325): Fixed deadlock that occurred when the query length exceeded the `pgsm_query_max_len` value.
|
||||
|
||||
[PG-326](https://jira.percona.com/browse/PG-326): Added validation for `pgsm_histogram_min` and `pgsm_histogram_max` ranges
|
||||
|
||||
[PG-329](https://jira.percona.com/browse/PG-329): Fixed creation of `pg_stat_monitor_errors` view on SQL files.
|
||||
|
||||
[PG-296](https://jira.percona.com/browse/PG-296): Fixed issue with the application name not displaying in the view when changed.
|
||||
|
||||
[PG-290](https://jira.percona.com/browse/PG-290): Fixed issue with PostgreSQL crashing after enabling debug log level and when `pg_stat_monitor` is enabled.
|
||||
|
||||
[PG-166](https://jira.percona.com/browse/PG-166): Fixed issue with displaying the actual system time values instead of `NULL`
|
||||
|
||||
[PG-369](https://jira.percona.com/browse/PG-358): Fixed issue with incorrect `wal_bytes` values for PostgreSQL 11 and 12 that caused Query Analytics failure in PMM by ignoring the `WalUsage` variable value for these versions.
|
||||
|
||||
## 1.0.0-rc.1
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-165](https://jira.percona.com/browse/PG-165): Recycle expired buckets
|
||||
|
||||
[PG-167](https://jira.percona.com/browse/PG-167): Make SQL error codes readable by updating their data types
|
||||
|
||||
[PG-193](https://jira.percona.com/browse/PG-193): Create a comment based tags to identify different parameters
|
||||
|
||||
[PG-199](https://jira.percona.com/browse/PG-199): Documentation: Add the integration with PMM section in User Guide
|
||||
|
||||
[PG-210](https://jira.percona.com/browse/PG-210): Documentation: Update column names per POstgreSQL version to match the upstream ones
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-177](https://jira.percona.com/browse/PG-177): Fixed the error in histogram ranges
|
||||
|
||||
[PG-214](https://jira.percona.com/browse/PG-214): Fixed the issue with the display of the error message as part of the query column in `pg_stat_monitor` view
|
||||
|
||||
[PG-246](https://jira.percona.com/browse/PG-246): Fixed the issue with significant CPU and memory resource usage when `pg_stat_monitor.pgsm_enable_query_plan` parameter is enabled
|
||||
|
||||
[PG-262](https://jira.percona.com/browse/PG-262): Fixed the way the comments are extracted in pg_stat_monitor view
|
||||
|
||||
[PG-271](https://jira.percona.com/browse/PG-271): Fixed the issue with enabling the ``pg_stat_monitor.pgsm_overflow_target`` configuration parameter.
|
||||
|
||||
[PG-272](https://jira.percona.com/browse/PG-272): Fixed the server crash when calling the `pg_stat_monitor_reset()` function by using the correct `PGSM_MAX_BUCKETS` GUC as the limit to the loop
|
||||
|
||||
## REL0_9_0_STABLE
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-186](https://jira.percona.com/browse/PG-186): Add support to monitor query execution plan
|
||||
|
||||
[PG-147](https://jira.percona.com/browse/PG-147): Store top query, instead of parent query.
|
||||
|
||||
[PG-188](https://jira.percona.com/browse/PG-188): Added a new column to monitor the query state i.e PARSING/PLANNING/ACTIVE/FINISHED.
|
||||
|
||||
[PG-180](https://jira.percona.com/browse/PG-180): Schema Qualified table/relations names.
|
||||
|
||||
Regression Test Suite.
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-189](https://jira.percona.com/browse/PG-189): Regression crash in case of PostgreSQL 11.
|
||||
|
||||
[PG-187](https://jira.percona.com/browse/PG-187): Compilation Error for PostgreSQL 11 and PostgreSQL 12.
|
||||
|
||||
[PG-186](https://jira.percona.com/browse/PG-186): Add support to monitor query execution plan.
|
||||
|
||||
[PG-182](https://jira.percona.com/browse/PG-182): Added a new option for the query buffer overflow.
|
||||
|
||||
[PG-181](https://jira.percona.com/browse/PG-181): Segmentation fault in case of track_utility is ON.
|
||||
|
||||
Some Code refactoring.
|
||||
|
||||
## REL0_8_1
|
||||
|
||||
[PG-147](https://jira.percona.com/browse/PG-147): Stored Procedure Support add parentid to track caller.
|
||||
|
||||
[PG-177](https://jira.percona.com/browse/PG-177): Error in Histogram ranges.
|
||||
|
||||
## REL0_8_0_STABLE
|
||||
### Improvements
|
||||
|
||||
Column userid (int64) was removed.
|
||||
Column dbid (int64) was removed.
|
||||
|
||||
Column user (string) was added (replacement for userid).
|
||||
Column datname (string) was added (replacement for dbid).
|
||||
|
||||
[PG-176](https://jira.percona.com/browse/PG-176): Extract fully qualified relations name.
|
||||
|
||||
[PG-175](https://jira.percona.com/browse/PG-175): Only Superuser / Privileged user can view IP address.
|
||||
|
||||
[PG-174](https://jira.percona.com/browse/PG-174): Code cleanup.
|
||||
|
||||
[PG-173](https://jira.percona.com/browse/PG-173): Added new WAL usage statistics.
|
||||
|
||||
[PG-172](https://jira.percona.com/browse/PG-172): Exponential histogram for time buckets.
|
||||
|
||||
[PG-164](https://jira.percona.com/browse/PG-164): Query timing will be four decimal places instead of two.
|
||||
|
||||
[PG-167](https://jira.percona.com/browse/PG-167): SQLERRCODE must be in readable format.
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-169](https://jira.percona.com/browse/PG-169): Fixing message buffer overrun and incorrect index access to fix the server crash.
|
||||
|
||||
[PG-168](https://jira.percona.com/browse/PG-168): "calls" and histogram parameter does not match.
|
||||
|
||||
[PG-166](https://jira.percona.com/browse/PG-166): Display actual system time instead of null.
|
||||
|
||||
[PG-165](https://jira.percona.com/browse/PG-165): Recycle expired buckets.
|
||||
|
||||
[PG-150](https://jira.percona.com/browse/PG-150): Error while logging CMD Type like SELECT, UPDATE, INSERT, DELETE.
|
||||
|
||||
|
||||
## REL0_7_2
|
||||
|
||||
[PG-165](https://jira.percona.com/browse/PG-165): Recycle expired buckets.
|
||||
|
||||
[PG-164](https://jira.percona.com/browse/PG-164): Query timing will be four decimal places instead of two.
|
||||
|
||||
[PG-161](https://jira.percona.com/browse/PG-161): Miscellaneous small issues.
|
||||
|
||||
## REL0_7_1
|
||||
|
||||
[PG-158](https://jira.percona.com/browse/PG-158): Segmentation fault while using pgbench with clients > 1.
|
||||
|
||||
[PG-159](https://jira.percona.com/browse/PG-159): Bucket start time (bucket_start_time) should be aligned with bucket_time.
|
||||
|
||||
[PG-160](https://jira.percona.com/browse/PG-160): Integration with PGXN.
|
||||
|
||||
|
||||
|
||||
## REL0_7_0_STABLE
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-153](https://jira.percona.com/browse/PG-153): Capture and record the application_name executing the query.
|
||||
|
||||
[PG-145](https://jira.percona.com/browse/PG-143): Add a new View/Query to show the actual Database name and Username.
|
||||
|
||||
[PG-110](https://jira.percona.com/browse/PG-110); Aggregate the number of warnings.
|
||||
|
||||
[PG-109](https://jira.percona.com/browse/PG-109): Log failed queries or queries with warning messages.
|
||||
|
||||
[PG-150](https://jira.percona.com/browse/PG-150): Differentiate different types of queries such as SELECT, UPDATE, INSERT or DELETE.
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
[PG-111](https://jira.percona.com/browse/PG-111) Show information for incomplete buckets.
|
||||
|
||||
[PG-148](https://jira.percona.com/browse/PG-148) Loss of query statistics/monitoring due to not enough “slots” available.
|
||||
|
||||
## v0.6.0
|
||||
Initial Release.
|
||||
|
||||
|
||||
## Master
|
||||
|
||||
### Improvements
|
||||
|
||||
[PG-156](https://jira.percona.com/browse/PG-156): Adding a placeholder replacement function for the prepared statement
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
pg_stat_monitor project follows rolling release strategy. So all security updates go to new versions.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please report any vulnerabilities to our project in [Jira](https://perconadev.atlassian.net/jira/software/c/projects/PG/issues).
|
||||
|
||||
If the vulnerability is accepted and confirmed by our experts, you should normally expect us to deliver
|
||||
a version with a fix according to the timelines provided below:
|
||||
|
||||
For Percona created software (our engineers wrote the code):
|
||||
|
||||
- Low/Medium: 120 days
|
||||
- High: 90 days
|
||||
- Critical: ASAP but should not exceed 30 days
|
||||
|
||||
For Non-Percona created software (upstream provided/packaged) from the time the vendor releases a patch:
|
||||
|
||||
- Low/Medium: 2nd release from current version
|
||||
- High: Next release
|
||||
- Critical: Hotfix or no later than next release (our regular release cadence is once every month)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Percona Distribution for PostgreSQL Operator Code of Conduct
|
||||
# Percona Code of Conduct
|
||||
|
||||
All Percona Products follow the [Percona Community Code of Conduct](https://github.com/percona/community/blob/main/content/contribute/coc.md).
|
||||
|
||||
|
|
|
|||
23
guc.c
23
guc.c
|
|
@ -1,14 +1,14 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* guc.c: guc variable handling of pg_stat_monitor
|
||||
* guc.c
|
||||
* guc variable handling of pg_stat_monitor
|
||||
*
|
||||
* Portions Copyright © 2018-2020, Percona LLC and/or its affiliates
|
||||
* Portions Copyright © 2018-2025, Percona LLC and/or its affiliates
|
||||
*
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
*
|
||||
* Portions Copyright (c) 1994, The Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/pg_stat_monitor/guc.c
|
||||
*
|
||||
|
|
@ -33,6 +33,7 @@ bool pgsm_enable_query_plan;
|
|||
bool pgsm_enable_overflow;
|
||||
bool pgsm_normalized_query;
|
||||
bool pgsm_track_utility;
|
||||
bool pgsm_track_application_names;
|
||||
bool pgsm_enable_pgsm_query_id;
|
||||
int pgsm_track;
|
||||
static int pgsm_overflow_target; /* Not used since 2.0 */
|
||||
|
|
@ -190,6 +191,18 @@ init_guc(void)
|
|||
NULL /* show_hook */
|
||||
);
|
||||
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_track_application_names", /* name */
|
||||
"Enable/Disable application names tracking.", /* short_desc */
|
||||
NULL, /* long_desc */
|
||||
&pgsm_track_application_names, /* value address */
|
||||
true, /* boot value */
|
||||
PGC_USERSET, /* context */
|
||||
0, /* flags */
|
||||
NULL, /* check_hook */
|
||||
NULL, /* assign_hook */
|
||||
NULL /* show_hook */
|
||||
);
|
||||
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_enable_pgsm_query_id", /* name */
|
||||
"Enable/disable PGSM specific query id calculation which is very useful in comparing same query across databases and clusters..", /* short_desc */
|
||||
NULL, /* long_desc */
|
||||
|
|
@ -262,7 +275,6 @@ init_guc(void)
|
|||
NULL, /* assign_hook */
|
||||
NULL /* show_hook */
|
||||
);
|
||||
#if PG_VERSION_NUM >= 130000
|
||||
DefineCustomBoolVariable("pg_stat_monitor.pgsm_track_planning", /* name */
|
||||
"Selects whether planning statistics are tracked.", /* short_desc */
|
||||
NULL, /* long_desc */
|
||||
|
|
@ -274,7 +286,6 @@ init_guc(void)
|
|||
NULL, /* assign_hook */
|
||||
NULL /* show_hook */
|
||||
);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
* hash_query.c
|
||||
* Track statement execution times across a whole database cluster.
|
||||
*
|
||||
* Portions Copyright © 2018-2020, Percona LLC and/or its affiliates
|
||||
* Portions Copyright © 2018-2025, Percona LLC and/or its affiliates
|
||||
*
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
*
|
||||
* Portions Copyright (c) 1994, The Regents of the University of California
|
||||
*
|
||||
|
|
@ -238,7 +238,8 @@ pgsm_attach_shmem(void)
|
|||
MemoryContextSwitchTo(oldcontext);
|
||||
}
|
||||
|
||||
MemoryContext GetPgsmMemoryContext(void)
|
||||
MemoryContext
|
||||
GetPgsmMemoryContext(void)
|
||||
{
|
||||
return pgsmStateLocal.pgsm_mem_cxt;
|
||||
}
|
||||
|
|
@ -303,6 +304,8 @@ hash_entry_alloc(pgsmSharedState * pgsm, pgsmHashKey * key, int encoding)
|
|||
memset(&entry->counters, 0, sizeof(Counters));
|
||||
entry->query_text.query_pos = InvalidDsaPointer;
|
||||
entry->counters.info.parent_query = InvalidDsaPointer;
|
||||
entry->stats_since = GetCurrentTimestamp();
|
||||
entry->minmax_stats_since = entry->stats_since;
|
||||
|
||||
/* set the appropriate initial usage count */
|
||||
/* re-initialize the mutex each time ... we assume no one using it */
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ install_data(
|
|||
'pg_stat_monitor.control',
|
||||
'pg_stat_monitor--2.0.sql',
|
||||
'pg_stat_monitor--1.0--2.0.sql',
|
||||
'pg_stat_monitor--2.0--2.1.sql',
|
||||
'pg_stat_monitor--2.1--2.2.sql',
|
||||
'pg_stat_monitor--2.2--2.3.sql',
|
||||
kwargs: contrib_data_args,
|
||||
)
|
||||
|
||||
|
|
@ -31,14 +34,18 @@ tests += {
|
|||
'cmd_type',
|
||||
'counters',
|
||||
'database',
|
||||
'different_parent_queries'
|
||||
'error_insert',
|
||||
'error',
|
||||
'functions',
|
||||
'guc',
|
||||
'histogram',
|
||||
'level_tracking'
|
||||
'parallel',
|
||||
'pgsqm_query_id',
|
||||
'relations',
|
||||
'rows',
|
||||
'squashing',
|
||||
'state',
|
||||
'tags',
|
||||
'top_query',
|
||||
|
|
|
|||
101
mkdocs.yml
101
mkdocs.yml
|
|
@ -1,101 +0,0 @@
|
|||
# MkDocs configuration for Netlify builds
|
||||
|
||||
site_name: pg_stat_monitor Documentation
|
||||
site_description: Documentation
|
||||
site_author: Percona LLC
|
||||
copyright: Percona LLC, © 2022
|
||||
|
||||
repo_name: percona/pg_stat_monitor
|
||||
repo_url: https://github.com/percona/pg_stat_monitor
|
||||
edit_uri: edit/master/docs/
|
||||
|
||||
use_directory_urls: false
|
||||
|
||||
# Theme for netlify testing
|
||||
theme:
|
||||
name: material
|
||||
logo: _images/percona-logo.svg
|
||||
favicon: _images/percona-favicon.ico
|
||||
custom_dir: docs/overrides
|
||||
|
||||
palette:
|
||||
|
||||
# Light mode
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: percona-light
|
||||
toggle:
|
||||
icon: material/toggle-switch-off-outline
|
||||
name: Switch to dark mode
|
||||
|
||||
# Dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
toggle:
|
||||
icon: material/toggle-switch
|
||||
name: Switch to light mode
|
||||
|
||||
# Theme features
|
||||
|
||||
features:
|
||||
- search.highlight
|
||||
- navigation.top
|
||||
|
||||
|
||||
extra_css:
|
||||
- https://unicons.iconscout.com/release/v3.0.3/css/line.css
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css
|
||||
- css/version-select.css
|
||||
- css/toctree.css
|
||||
- css/percona.css
|
||||
|
||||
extra_javascript:
|
||||
- js/version-select.js
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
- toc:
|
||||
permalink: True
|
||||
- admonition
|
||||
- footnotes
|
||||
- def_list # https://michelf.ca/projects/php-markdown/extra/#def-list
|
||||
- meta
|
||||
- smarty:
|
||||
smart_angled_quotes: true
|
||||
- pymdownx.mark
|
||||
- pymdownx.smartsymbols
|
||||
- pymdownx.tabbed
|
||||
- pymdownx.tilde
|
||||
- pymdownx.superfences
|
||||
- pymdownx.highlight:
|
||||
linenums: false
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
#- plantuml_markdown
|
||||
|
||||
plugins:
|
||||
- search
|
||||
- git-revision-date
|
||||
- section-index # Adds links to nodes - comment out when creating PDF
|
||||
# - htmlproofer # Uncomment to check links - but extends build time significantly
|
||||
- mike:
|
||||
version_selector: true
|
||||
css_dir: css
|
||||
javascript_dir: js
|
||||
canonical_version: null
|
||||
|
||||
|
||||
extra:
|
||||
version:
|
||||
provider: mike
|
||||
|
||||
nav:
|
||||
- index.md
|
||||
- setup.md
|
||||
- User guide:
|
||||
- USER_GUIDE.md
|
||||
- REFERENCE.md
|
||||
- COMPARISON.md
|
||||
- Release notes:
|
||||
- RELEASE_NOTES.md
|
||||
# - Version Selector: "../"
|
||||
|
|
@ -21,6 +21,7 @@ Usage: $0 [OPTIONS]
|
|||
--rpm_release RPM version( default = 1)
|
||||
--deb_release DEB version( default = 1)
|
||||
--pg_release PPG version build on( default = 11)
|
||||
--ppg_repo_name PPG repo name (default ppg-11.18)
|
||||
--version product version
|
||||
--help) usage ;;
|
||||
Example $0 --builddir=/tmp/test --get_sources=1 --build_src_rpm=1 --build_rpm=1
|
||||
|
|
@ -57,6 +58,7 @@ append_arg_to_args () {
|
|||
--rpm_release=*) RPM_RELEASE="$val" ;;
|
||||
--deb_release=*) DEB_RELEASE="$val" ;;
|
||||
--pg_release=*) PG_RELEASE="$val" ;;
|
||||
--ppg_repo_name=*) PPG_REPO_NAME="$val";;
|
||||
--version=*) VERSION="$val" ;;
|
||||
--help) usage ;;
|
||||
*)
|
||||
|
|
@ -115,6 +117,10 @@ get_sources(){
|
|||
echo "Sources will not be downloaded"
|
||||
return 0
|
||||
fi
|
||||
IS_RELEASE_BRANCH=$(echo ${VERSION} | grep -c release)
|
||||
if [ ${IS_RELEASE_BRANCH} != 0 ]; then
|
||||
VERSION=$(echo $VERSION | awk -F'-' '{print $2}')
|
||||
fi
|
||||
PRODUCT=percona-pg-stat-monitor${PG_RELEASE}
|
||||
PRODUCT_FULL=${PRODUCT}-${VERSION}
|
||||
|
||||
|
|
@ -160,7 +166,8 @@ get_sources(){
|
|||
source pg-stat-monitor.properties
|
||||
#
|
||||
tar --owner=0 --group=0 --exclude=.* -czf ${PRODUCT_FULL}.tar.gz ${PRODUCT_FULL}
|
||||
echo "UPLOAD=UPLOAD/experimental/BUILDS/${PRODUCT}/${PRODUCT_FULL}/${BRANCH}/${REVISION}/${BUILD_ID}" >> pg-stat-monitor.properties
|
||||
DATE_TIMESTAMP=$(date +%F_%H-%M-%S)
|
||||
echo "UPLOAD=UPLOAD/experimental/BUILDS/${PRODUCT}/${PRODUCT_FULL}/${BRANCH}/${REVISION}/${DATE_TIMESTAMP}/${BUILD_ID}" >> pg-stat-monitor.properties
|
||||
mkdir $WORKDIR/source_tarball
|
||||
mkdir $CURDIR/source_tarball
|
||||
cp ${PRODUCT_FULL}.tar.gz $WORKDIR/source_tarball
|
||||
|
|
@ -200,18 +207,26 @@ install_deps() {
|
|||
CURPLACE=$(pwd)
|
||||
if [ "$OS" == "rpm" ]
|
||||
then
|
||||
yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
|
||||
if [[ ${PG_RELEASE} == "11" ]]; then
|
||||
percona-release enable ppg-11 release
|
||||
elif [[ $PG_RELEASE == "12" ]]; then
|
||||
percona-release enable ppg-12 release
|
||||
fi
|
||||
yum -y install git wget
|
||||
yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
|
||||
percona-release enable ${PPG_REPO_NAME} testing
|
||||
|
||||
if [ x"$RHEL" = x8 ];
|
||||
then
|
||||
clang_version=$(yum list --showduplicates clang-devel | grep "20.1" | grep clang | awk '{print $2}' | head -n 1)
|
||||
llvm_version=$(yum list --showduplicates llvm-devel | grep "20.1" | grep llvm | awk '{print $2}' | head -n 1)
|
||||
yum install -y clang-devel-${clang_version} clang-${clang_version} llvm-devel-${llvm_version}
|
||||
dnf module disable -y rust-toolset llvm-toolset
|
||||
else
|
||||
yum install -y clang-devel clang llvm-devel
|
||||
fi
|
||||
|
||||
PKGLIST="percona-postgresql${PG_RELEASE}-devel"
|
||||
PKGLIST+=" clang-devel git clang llvm-devel rpmdevtools vim wget"
|
||||
PKGLIST+=" git rpmdevtools vim wget"
|
||||
PKGLIST+=" perl binutils gcc gcc-c++"
|
||||
PKGLIST+=" clang-devel llvm-devel git rpm-build rpmdevtools wget gcc make autoconf"
|
||||
PKGLIST+=" git rpm-build rpmdevtools wget gcc make autoconf"
|
||||
if [[ "${RHEL}" -ge 8 ]]; then
|
||||
dnf config-manager --set-enabled ol${RHEL}_codeready_builder
|
||||
dnf -y module disable postgresql || true
|
||||
elif [[ "${RHEL}" -eq 7 ]]; then
|
||||
PKGLIST+=" llvm-toolset-7-clang llvm-toolset-7-llvm-devel llvm5.0-devel"
|
||||
|
|
@ -232,37 +247,29 @@ install_deps() {
|
|||
done
|
||||
else
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install lsb-release gnupg git wget
|
||||
|
||||
wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb && dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb
|
||||
if [[ "${PG_RELEASE}" == "11" ]]; then
|
||||
percona-release enable ppg-11 release
|
||||
elif [[ "${PG_RELEASE}" == "12" ]]; then
|
||||
percona-release enable ppg-12 release
|
||||
fi
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install lsb-release gnupg git wget curl
|
||||
export DEBIAN=$(lsb_release -sc)
|
||||
|
||||
wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb
|
||||
dpkg -i percona-release_latest.generic_all.deb
|
||||
rm -f percona-release_latest.generic_all.deb
|
||||
percona-release enable ${PPG_REPO_NAME} testing
|
||||
|
||||
PKGLIST="percona-postgresql-${PG_RELEASE} percona-postgresql-common percona-postgresql-server-dev-all"
|
||||
|
||||
# ---- using a community version of postgresql
|
||||
#wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
#echo "deb http://apt.postgresql.org/pub/repos/apt/ ${PG_RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
|
||||
#PKGLIST="postgresql-${PG_RELEASE} postgresql-common postgresql-server-dev-all"
|
||||
|
||||
apt-get update
|
||||
|
||||
if [[ "${OS_NAME}" != "focal" ]]; then
|
||||
LLVM_EXISTS=$(grep -c "apt.llvm.org" /etc/apt/sources.list)
|
||||
if [ "${LLVM_EXISTS}" == 0 ]; then
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
|
||||
echo "deb http://apt.llvm.org/${OS_NAME}/ llvm-toolchain-${OS_NAME}-7 main" >> /etc/apt/sources.list
|
||||
echo "deb-src http://apt.llvm.org/${OS_NAME}/ llvm-toolchain-${OS_NAME}-7 main" >> /etc/apt/sources.list
|
||||
apt-get update
|
||||
fi
|
||||
if [[ "x${DEBIAN}" == "xbullseye" ]]; then
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
./llvm.sh 14 bullseye
|
||||
else
|
||||
wget http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb
|
||||
apt install ./libllvm7_7.0.1-12_amd64.deb ./llvm-7_7.0.1-12_amd64.deb ./llvm-7-runtime_7.0.1-12_amd64.deb
|
||||
fi
|
||||
|
||||
PKGLIST+=" debconf debhelper clang-7 devscripts dh-exec dh-systemd git wget libkrb5-dev libssl-dev"
|
||||
PKGLIST+=" build-essential debconf debhelper devscripts dh-exec dh-systemd git wget libxml-checker-perl"
|
||||
PKGLIST+=" debconf debhelper clang devscripts dh-exec git wget libkrb5-dev libssl-dev"
|
||||
PKGLIST+=" build-essential debconf debhelper devscripts dh-exec git wget libxml-checker-perl"
|
||||
PKGLIST+=" libxml-libxml-perl libio-socket-ssl-perl libperl-dev libssl-dev libxml2-dev txt2man zlib1g-dev libpq-dev"
|
||||
|
||||
until DEBIAN_FRONTEND=noninteractive apt-get -y install ${PKGLIST}; do
|
||||
|
|
@ -389,6 +396,9 @@ build_rpm(){
|
|||
fi
|
||||
export LIBPQ_DIR=/usr/pgsql-${PG_RELEASE}/
|
||||
export LIBRARY_PATH=/usr/pgsql-${PG_RELEASE}/lib/:/usr/pgsql-${PG_RELEASE}/include/
|
||||
if [[ "${RHEL}" -eq 10 ]]; then
|
||||
export QA_RPATHS=0x0002
|
||||
fi
|
||||
rpmbuild --define "_topdir ${WORKDIR}/rpmbuild" --define "dist .$OS_NAME" --define "version ${VERSION}" --rebuild rpmbuild/SRPMS/$SRC_RPM
|
||||
|
||||
return_code=$?
|
||||
|
|
@ -442,6 +452,19 @@ build_source_deb(){
|
|||
cp *.orig.tar.gz $CURDIR/source_deb
|
||||
}
|
||||
|
||||
change_ddeb_package_to_deb(){
|
||||
|
||||
directory=$1
|
||||
|
||||
for file in "$directory"/*.ddeb; do
|
||||
if [ -e "$file" ]; then
|
||||
# Change extension to .deb
|
||||
mv "$file" "${file%.ddeb}.deb"
|
||||
echo "Changed extension of $file to ${file%.ddeb}.deb"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
build_deb(){
|
||||
if [ $DEB = 0 ]
|
||||
then
|
||||
|
|
@ -479,6 +502,7 @@ build_deb(){
|
|||
mkdir -p $WORKDIR/deb
|
||||
cp $WORKDIR/*.*deb $WORKDIR/deb
|
||||
cp $WORKDIR/*.*deb $CURDIR/deb
|
||||
change_ddeb_package_to_deb "$CURDIR/deb"
|
||||
}
|
||||
|
||||
CURDIR=$(pwd)
|
||||
|
|
@ -502,6 +526,7 @@ DEB_RELEASE=1
|
|||
REPO="https://github.com/Percona/pg_stat_monitor.git"
|
||||
VERSION="1.0.0"
|
||||
PG_RELEASE=11
|
||||
PPG_REPO_NAME=ppg-11
|
||||
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
||||
|
||||
check_workdir
|
||||
|
|
|
|||
|
|
@ -0,0 +1,497 @@
|
|||
/* contrib/pg_stat_monitor/pg_stat_monitor--2.0--2.1.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "ALTER EXTENSION pg_stat_monitor" to load this file. \quit
|
||||
|
||||
DROP FUNCTION pg_stat_monitor_internal CASCADE;
|
||||
DROP FUNCTION pgsm_create_view CASCADE;
|
||||
DROP FUNCTION pgsm_create_11_view();
|
||||
DROP FUNCTION pgsm_create_13_view();
|
||||
DROP FUNCTION pgsm_create_14_view();
|
||||
DROP FUNCTION pgsm_create_15_view();
|
||||
|
||||
CREATE FUNCTION pg_stat_monitor_internal(
|
||||
IN showtext boolean,
|
||||
OUT bucket int8, -- 0
|
||||
OUT userid oid,
|
||||
OUT username text,
|
||||
OUT dbid oid,
|
||||
OUT datname text,
|
||||
OUT client_ip int8,
|
||||
|
||||
OUT queryid int8, -- 6
|
||||
OUT planid int8,
|
||||
OUT query text,
|
||||
OUT query_plan text,
|
||||
OUT pgsm_query_id int8,
|
||||
OUT top_queryid int8,
|
||||
OUT top_query text,
|
||||
OUT application_name text,
|
||||
|
||||
OUT relations text, -- 14
|
||||
OUT cmd_type int,
|
||||
OUT elevel int,
|
||||
OUT sqlcode TEXT,
|
||||
OUT message text,
|
||||
OUT bucket_start_time timestamptz,
|
||||
|
||||
OUT calls int8, -- 20
|
||||
|
||||
OUT total_exec_time float8, -- 21
|
||||
OUT min_exec_time float8,
|
||||
OUT max_exec_time float8,
|
||||
OUT mean_exec_time float8,
|
||||
OUT stddev_exec_time float8,
|
||||
|
||||
OUT rows int8, -- 26
|
||||
|
||||
OUT plans int8, -- 27
|
||||
|
||||
OUT total_plan_time float8, -- 28
|
||||
OUT min_plan_time float8,
|
||||
OUT max_plan_time float8,
|
||||
OUT mean_plan_time float8,
|
||||
OUT stddev_plan_time float8,
|
||||
|
||||
OUT shared_blks_hit int8, -- 33
|
||||
OUT shared_blks_read int8,
|
||||
OUT shared_blks_dirtied int8,
|
||||
OUT shared_blks_written int8,
|
||||
OUT local_blks_hit int8,
|
||||
OUT local_blks_read int8,
|
||||
OUT local_blks_dirtied int8,
|
||||
OUT local_blks_written int8,
|
||||
OUT temp_blks_read int8,
|
||||
OUT temp_blks_written int8,
|
||||
OUT shared_blk_read_time float8,
|
||||
OUT shared_blk_write_time float8,
|
||||
OUT local_blk_read_time float8,
|
||||
OUT local_blk_write_time float8,
|
||||
OUT temp_blk_read_time float8,
|
||||
OUT temp_blk_write_time float8,
|
||||
|
||||
OUT resp_calls text, -- 49
|
||||
OUT cpu_user_time float8,
|
||||
OUT cpu_sys_time float8,
|
||||
OUT wal_records int8,
|
||||
OUT wal_fpi int8,
|
||||
OUT wal_bytes numeric,
|
||||
OUT comments TEXT,
|
||||
|
||||
OUT jit_functions int8, -- 56
|
||||
OUT jit_generation_time float8,
|
||||
OUT jit_inlining_count int8,
|
||||
OUT jit_inlining_time float8,
|
||||
OUT jit_optimization_count int8,
|
||||
OUT jit_optimization_time float8,
|
||||
OUT jit_emission_count int8,
|
||||
OUT jit_emission_time float8,
|
||||
OUT jit_deform_count int8,
|
||||
OUT jit_deform_time float8,
|
||||
|
||||
OUT stats_since timestamp with time zone, -- 66
|
||||
OUT minmax_stats_since timestamp with time zone,
|
||||
|
||||
OUT toplevel BOOLEAN, -- 68
|
||||
OUT bucket_done BOOLEAN
|
||||
)
|
||||
RETURNS SETOF record
|
||||
AS 'MODULE_PATHNAME', 'pg_stat_monitor_2_1'
|
||||
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;
|
||||
|
||||
-- Register a view on the function for ease of use.
|
||||
CREATE FUNCTION pgsm_create_11_view() RETURNS INT AS
|
||||
$$
|
||||
BEGIN
|
||||
CREATE VIEW pg_stat_monitor AS SELECT
|
||||
bucket,
|
||||
bucket_start_time AS bucket_start_time,
|
||||
userid,
|
||||
username,
|
||||
dbid,
|
||||
datname,
|
||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||
pgsm_query_id,
|
||||
queryid,
|
||||
top_queryid,
|
||||
query,
|
||||
comments,
|
||||
planid,
|
||||
query_plan,
|
||||
top_query,
|
||||
application_name,
|
||||
string_to_array(relations, ',') AS relations,
|
||||
cmd_type,
|
||||
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||
elevel,
|
||||
sqlcode,
|
||||
message,
|
||||
calls,
|
||||
total_exec_time AS total_time,
|
||||
min_exec_time AS min_time,
|
||||
max_exec_time AS max_time,
|
||||
mean_exec_time AS mean_time,
|
||||
stddev_exec_time AS stddev_time,
|
||||
rows,
|
||||
shared_blks_hit,
|
||||
shared_blks_read,
|
||||
shared_blks_dirtied,
|
||||
shared_blks_written,
|
||||
local_blks_hit,
|
||||
local_blks_read,
|
||||
local_blks_dirtied,
|
||||
local_blks_written,
|
||||
temp_blks_read,
|
||||
temp_blks_written,
|
||||
shared_blk_read_time AS blk_read_time,
|
||||
shared_blk_write_time AS blk_write_time,
|
||||
(string_to_array(resp_calls, ',')) resp_calls,
|
||||
cpu_user_time,
|
||||
cpu_sys_time,
|
||||
bucket_done
|
||||
FROM pg_stat_monitor_internal(TRUE)
|
||||
ORDER BY bucket_start_time;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
CREATE FUNCTION pgsm_create_13_view() RETURNS INT AS
|
||||
$$
|
||||
BEGIN
|
||||
CREATE VIEW pg_stat_monitor AS SELECT
|
||||
bucket,
|
||||
bucket_start_time AS bucket_start_time,
|
||||
userid,
|
||||
username,
|
||||
dbid,
|
||||
datname,
|
||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||
pgsm_query_id,
|
||||
queryid,
|
||||
toplevel,
|
||||
top_queryid,
|
||||
query,
|
||||
comments,
|
||||
planid,
|
||||
query_plan,
|
||||
top_query,
|
||||
application_name,
|
||||
string_to_array(relations, ',') AS relations,
|
||||
cmd_type,
|
||||
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||
elevel,
|
||||
sqlcode,
|
||||
message,
|
||||
calls,
|
||||
total_exec_time,
|
||||
min_exec_time,
|
||||
max_exec_time,
|
||||
mean_exec_time,
|
||||
stddev_exec_time,
|
||||
rows,
|
||||
shared_blks_hit,
|
||||
shared_blks_read,
|
||||
shared_blks_dirtied,
|
||||
shared_blks_written,
|
||||
local_blks_hit,
|
||||
local_blks_read,
|
||||
local_blks_dirtied,
|
||||
local_blks_written,
|
||||
temp_blks_read,
|
||||
temp_blks_written,
|
||||
shared_blk_read_time AS blk_read_time,
|
||||
shared_blk_write_time AS blk_write_time,
|
||||
(string_to_array(resp_calls, ',')) resp_calls,
|
||||
cpu_user_time,
|
||||
cpu_sys_time,
|
||||
wal_records,
|
||||
wal_fpi,
|
||||
wal_bytes,
|
||||
bucket_done,
|
||||
-- PostgreSQL-13 Specific Coulumns
|
||||
plans,
|
||||
total_plan_time,
|
||||
min_plan_time,
|
||||
max_plan_time,
|
||||
mean_plan_time,
|
||||
stddev_plan_time
|
||||
FROM pg_stat_monitor_internal(TRUE)
|
||||
ORDER BY bucket_start_time;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE FUNCTION pgsm_create_14_view() RETURNS INT AS
|
||||
$$
|
||||
BEGIN
|
||||
CREATE VIEW pg_stat_monitor AS SELECT
|
||||
bucket,
|
||||
bucket_start_time AS bucket_start_time,
|
||||
userid,
|
||||
username,
|
||||
dbid,
|
||||
datname,
|
||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||
pgsm_query_id,
|
||||
queryid,
|
||||
toplevel,
|
||||
top_queryid,
|
||||
query,
|
||||
comments,
|
||||
planid,
|
||||
query_plan,
|
||||
top_query,
|
||||
application_name,
|
||||
string_to_array(relations, ',') AS relations,
|
||||
cmd_type,
|
||||
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||
elevel,
|
||||
sqlcode,
|
||||
message,
|
||||
calls,
|
||||
total_exec_time,
|
||||
min_exec_time,
|
||||
max_exec_time,
|
||||
mean_exec_time,
|
||||
stddev_exec_time,
|
||||
rows,
|
||||
shared_blks_hit,
|
||||
shared_blks_read,
|
||||
shared_blks_dirtied,
|
||||
shared_blks_written,
|
||||
local_blks_hit,
|
||||
local_blks_read,
|
||||
local_blks_dirtied,
|
||||
local_blks_written,
|
||||
temp_blks_read,
|
||||
temp_blks_written,
|
||||
shared_blk_read_time AS blk_read_time,
|
||||
shared_blk_write_time AS blk_write_time,
|
||||
(string_to_array(resp_calls, ',')) resp_calls,
|
||||
cpu_user_time,
|
||||
cpu_sys_time,
|
||||
wal_records,
|
||||
wal_fpi,
|
||||
wal_bytes,
|
||||
bucket_done,
|
||||
|
||||
plans,
|
||||
total_plan_time,
|
||||
min_plan_time,
|
||||
max_plan_time,
|
||||
mean_plan_time,
|
||||
stddev_plan_time
|
||||
FROM pg_stat_monitor_internal(TRUE)
|
||||
ORDER BY bucket_start_time;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE FUNCTION pgsm_create_15_view() RETURNS INT AS
|
||||
$$
|
||||
BEGIN
|
||||
CREATE VIEW pg_stat_monitor AS SELECT
|
||||
bucket,
|
||||
bucket_start_time AS bucket_start_time,
|
||||
userid,
|
||||
username,
|
||||
dbid,
|
||||
datname,
|
||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||
pgsm_query_id,
|
||||
queryid,
|
||||
toplevel,
|
||||
top_queryid,
|
||||
query,
|
||||
comments,
|
||||
planid,
|
||||
query_plan,
|
||||
top_query,
|
||||
application_name,
|
||||
string_to_array(relations, ',') AS relations,
|
||||
cmd_type,
|
||||
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||
elevel,
|
||||
sqlcode,
|
||||
message,
|
||||
calls,
|
||||
total_exec_time,
|
||||
min_exec_time,
|
||||
max_exec_time,
|
||||
mean_exec_time,
|
||||
stddev_exec_time,
|
||||
rows,
|
||||
shared_blks_hit,
|
||||
shared_blks_read,
|
||||
shared_blks_dirtied,
|
||||
shared_blks_written,
|
||||
local_blks_hit,
|
||||
local_blks_read,
|
||||
local_blks_dirtied,
|
||||
local_blks_written,
|
||||
temp_blks_read,
|
||||
temp_blks_written,
|
||||
shared_blk_read_time AS blk_read_time,
|
||||
shared_blk_write_time AS blk_write_time,
|
||||
temp_blk_read_time,
|
||||
temp_blk_write_time,
|
||||
|
||||
(string_to_array(resp_calls, ',')) resp_calls,
|
||||
cpu_user_time,
|
||||
cpu_sys_time,
|
||||
wal_records,
|
||||
wal_fpi,
|
||||
wal_bytes,
|
||||
bucket_done,
|
||||
|
||||
plans,
|
||||
total_plan_time,
|
||||
min_plan_time,
|
||||
max_plan_time,
|
||||
mean_plan_time,
|
||||
stddev_plan_time,
|
||||
|
||||
jit_functions,
|
||||
jit_generation_time,
|
||||
jit_inlining_count,
|
||||
jit_inlining_time,
|
||||
jit_optimization_count,
|
||||
jit_optimization_time,
|
||||
jit_emission_count,
|
||||
jit_emission_time
|
||||
|
||||
FROM pg_stat_monitor_internal(TRUE)
|
||||
ORDER BY bucket_start_time;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE FUNCTION pgsm_create_17_view() RETURNS INT AS
|
||||
$$
|
||||
BEGIN
|
||||
CREATE VIEW pg_stat_monitor AS SELECT
|
||||
bucket,
|
||||
bucket_start_time,
|
||||
userid,
|
||||
username,
|
||||
dbid,
|
||||
datname,
|
||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||
pgsm_query_id,
|
||||
queryid,
|
||||
toplevel,
|
||||
top_queryid,
|
||||
query,
|
||||
comments,
|
||||
planid,
|
||||
query_plan,
|
||||
top_query,
|
||||
application_name,
|
||||
string_to_array(relations, ',') AS relations,
|
||||
cmd_type,
|
||||
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||
elevel,
|
||||
sqlcode,
|
||||
message,
|
||||
calls,
|
||||
total_exec_time,
|
||||
min_exec_time,
|
||||
max_exec_time,
|
||||
mean_exec_time,
|
||||
stddev_exec_time,
|
||||
rows,
|
||||
shared_blks_hit,
|
||||
shared_blks_read,
|
||||
shared_blks_dirtied,
|
||||
shared_blks_written,
|
||||
local_blks_hit,
|
||||
local_blks_read,
|
||||
local_blks_dirtied,
|
||||
local_blks_written,
|
||||
temp_blks_read,
|
||||
temp_blks_written,
|
||||
shared_blk_read_time,
|
||||
shared_blk_write_time,
|
||||
local_blk_read_time,
|
||||
local_blk_write_time,
|
||||
temp_blk_read_time,
|
||||
temp_blk_write_time,
|
||||
|
||||
(string_to_array(resp_calls, ',')) resp_calls,
|
||||
cpu_user_time,
|
||||
cpu_sys_time,
|
||||
wal_records,
|
||||
wal_fpi,
|
||||
wal_bytes,
|
||||
bucket_done,
|
||||
|
||||
plans,
|
||||
total_plan_time,
|
||||
min_plan_time,
|
||||
max_plan_time,
|
||||
mean_plan_time,
|
||||
stddev_plan_time,
|
||||
|
||||
jit_functions,
|
||||
jit_generation_time,
|
||||
jit_inlining_count,
|
||||
jit_inlining_time,
|
||||
jit_optimization_count,
|
||||
jit_optimization_time,
|
||||
jit_emission_count,
|
||||
jit_emission_time,
|
||||
jit_deform_count,
|
||||
jit_deform_time,
|
||||
|
||||
stats_since,
|
||||
minmax_stats_since
|
||||
|
||||
FROM pg_stat_monitor_internal(TRUE)
|
||||
ORDER BY bucket_start_time;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE FUNCTION pgsm_create_view() RETURNS INT AS
|
||||
$$
|
||||
DECLARE ver integer;
|
||||
BEGIN
|
||||
SELECT current_setting('server_version_num') INTO ver;
|
||||
IF (ver >= 170000) THEN
|
||||
return pgsm_create_17_view();
|
||||
END IF;
|
||||
IF (ver >= 150000) THEN
|
||||
return pgsm_create_15_view();
|
||||
END IF;
|
||||
IF (ver >= 140000) THEN
|
||||
return pgsm_create_14_view();
|
||||
END IF;
|
||||
IF (ver >= 130000) THEN
|
||||
return pgsm_create_13_view();
|
||||
END IF;
|
||||
IF (ver >= 110000) THEN
|
||||
return pgsm_create_11_view();
|
||||
END IF;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT pgsm_create_view();
|
||||
REVOKE ALL ON FUNCTION pgsm_create_view FROM PUBLIC;
|
||||
REVOKE ALL ON FUNCTION pgsm_create_11_view FROM PUBLIC;
|
||||
REVOKE ALL ON FUNCTION pgsm_create_13_view FROM PUBLIC;
|
||||
REVOKE ALL ON FUNCTION pgsm_create_14_view FROM PUBLIC;
|
||||
REVOKE ALL ON FUNCTION pgsm_create_15_view FROM PUBLIC;
|
||||
REVOKE ALL ON FUNCTION pgsm_create_17_view FROM PUBLIC;
|
||||
|
||||
GRANT EXECUTE ON FUNCTION range TO PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION decode_error_level TO PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION get_histogram_timings TO PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION get_cmd_type TO PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION pg_stat_monitor_internal TO PUBLIC;
|
||||
|
||||
GRANT SELECT ON pg_stat_monitor TO PUBLIC;
|
||||
|
||||
-- Reset is only available to super user
|
||||
REVOKE ALL ON FUNCTION pg_stat_monitor_reset FROM PUBLIC;
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/* contrib/pg_stat_monitor/pg_stat_monitor--2.1--2.2.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "ALTER EXTENSION pg_stat_monitor" to load this file. \quit
|
||||
|
||||
CREATE OR REPLACE FUNCTION get_cmd_type (cmd_type INTEGER) RETURNS TEXT AS
|
||||
$$
|
||||
SELECT
|
||||
CASE
|
||||
WHEN cmd_type = 0 THEN ''
|
||||
WHEN cmd_type = 1 THEN 'SELECT'
|
||||
WHEN cmd_type = 2 THEN 'UPDATE'
|
||||
WHEN cmd_type = 3 THEN 'INSERT'
|
||||
WHEN cmd_type = 4 THEN 'DELETE'
|
||||
WHEN cmd_type = 5 AND current_setting('server_version_num')::int >= 150000 THEN 'MERGE'
|
||||
WHEN cmd_type = 5 AND current_setting('server_version_num')::int < 150000 THEN 'UTILITY'
|
||||
WHEN cmd_type = 6 AND current_setting('server_version_num')::int >= 150000 THEN 'UTILITY'
|
||||
WHEN cmd_type = 6 AND current_setting('server_version_num')::int < 150000 THEN 'NOTHING'
|
||||
WHEN cmd_type = 7 THEN 'NOTHING'
|
||||
END
|
||||
$$
|
||||
LANGUAGE SQL PARALLEL SAFE;
|
||||
|
||||
-- Create new function that handles error levels across PostgreSQL versions 12-17
|
||||
CREATE OR REPLACE FUNCTION decode_error_level(elevel int)
|
||||
RETURNS text
|
||||
AS $$
|
||||
SELECT CASE
|
||||
WHEN elevel = 0 THEN ''
|
||||
WHEN elevel = 10 THEN 'DEBUG5'
|
||||
WHEN elevel = 11 THEN 'DEBUG4'
|
||||
WHEN elevel = 12 THEN 'DEBUG3'
|
||||
WHEN elevel = 13 THEN 'DEBUG2'
|
||||
WHEN elevel = 14 THEN 'DEBUG1'
|
||||
WHEN elevel = 15 THEN 'LOG'
|
||||
WHEN elevel = 16 THEN 'LOG_SERVER_ONLY'
|
||||
WHEN elevel = 17 THEN 'INFO'
|
||||
WHEN elevel = 18 THEN 'NOTICE'
|
||||
WHEN elevel = 19 THEN 'WARNING'
|
||||
WHEN elevel = 20 AND current_setting('server_version_num')::int < 140000 THEN 'ERROR'
|
||||
WHEN elevel = 20 AND current_setting('server_version_num')::int >= 140000 THEN 'WARNING_CLIENT_ONLY'
|
||||
WHEN elevel = 21 AND current_setting('server_version_num')::int < 140000 THEN 'FATAL'
|
||||
WHEN elevel = 21 AND current_setting('server_version_num')::int >= 140000 THEN 'ERROR'
|
||||
WHEN elevel = 22 AND current_setting('server_version_num')::int < 140000 THEN 'PANIC'
|
||||
WHEN elevel = 22 AND current_setting('server_version_num')::int >= 140000 THEN 'FATAL'
|
||||
WHEN elevel = 23 AND current_setting('server_version_num')::int >= 140000 THEN 'PANIC'
|
||||
END;
|
||||
$$ LANGUAGE SQL PARALLEL SAFE;
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
/* contrib/pg_stat_monitor/pg_stat_monitor--2.2--2.3.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "ALTER EXTENSION pg_stat_monitor" to load this file. \quit
|
||||
|
||||
DROP FUNCTION pgsm_create_11_view();
|
||||
DROP VIEW pg_stat_monitor;
|
||||
DROP FUNCTION pg_stat_monitor_internal;
|
||||
|
||||
CREATE FUNCTION pg_stat_monitor_internal(
|
||||
IN showtext boolean,
|
||||
OUT bucket int8, -- 0
|
||||
OUT userid oid,
|
||||
OUT username text,
|
||||
OUT dbid oid,
|
||||
OUT datname text,
|
||||
OUT client_ip int8,
|
||||
|
||||
OUT queryid int8, -- 6
|
||||
OUT planid int8,
|
||||
OUT query text,
|
||||
OUT query_plan text,
|
||||
OUT pgsm_query_id int8,
|
||||
OUT top_queryid int8,
|
||||
OUT top_query text,
|
||||
OUT application_name text,
|
||||
|
||||
OUT relations text, -- 14
|
||||
OUT cmd_type int,
|
||||
OUT elevel int,
|
||||
OUT sqlcode TEXT,
|
||||
OUT message text,
|
||||
OUT bucket_start_time timestamptz,
|
||||
|
||||
OUT calls int8, -- 20
|
||||
|
||||
OUT total_exec_time float8, -- 21
|
||||
OUT min_exec_time float8,
|
||||
OUT max_exec_time float8,
|
||||
OUT mean_exec_time float8,
|
||||
OUT stddev_exec_time float8,
|
||||
|
||||
OUT rows int8, -- 26
|
||||
|
||||
OUT plans int8, -- 27
|
||||
|
||||
OUT total_plan_time float8, -- 28
|
||||
OUT min_plan_time float8,
|
||||
OUT max_plan_time float8,
|
||||
OUT mean_plan_time float8,
|
||||
OUT stddev_plan_time float8,
|
||||
|
||||
OUT shared_blks_hit int8, -- 33
|
||||
OUT shared_blks_read int8,
|
||||
OUT shared_blks_dirtied int8,
|
||||
OUT shared_blks_written int8,
|
||||
OUT local_blks_hit int8,
|
||||
OUT local_blks_read int8,
|
||||
OUT local_blks_dirtied int8,
|
||||
OUT local_blks_written int8,
|
||||
OUT temp_blks_read int8,
|
||||
OUT temp_blks_written int8,
|
||||
OUT shared_blk_read_time float8,
|
||||
OUT shared_blk_write_time float8,
|
||||
OUT local_blk_read_time float8,
|
||||
OUT local_blk_write_time float8,
|
||||
OUT temp_blk_read_time float8,
|
||||
OUT temp_blk_write_time float8,
|
||||
|
||||
OUT resp_calls text, -- 49
|
||||
OUT cpu_user_time float8,
|
||||
OUT cpu_sys_time float8,
|
||||
OUT wal_records int8,
|
||||
OUT wal_fpi int8,
|
||||
OUT wal_bytes numeric,
|
||||
OUT wal_buffers_full int8,
|
||||
OUT comments TEXT,
|
||||
|
||||
OUT jit_functions int8, -- 57
|
||||
OUT jit_generation_time float8,
|
||||
OUT jit_inlining_count int8,
|
||||
OUT jit_inlining_time float8,
|
||||
OUT jit_optimization_count int8,
|
||||
OUT jit_optimization_time float8,
|
||||
OUT jit_emission_count int8,
|
||||
OUT jit_emission_time float8,
|
||||
OUT jit_deform_count int8,
|
||||
OUT jit_deform_time float8,
|
||||
|
||||
OUT parallel_workers_to_launch int, -- 67
|
||||
OUT parallel_workers_launched int,
|
||||
|
||||
OUT stats_since timestamp with time zone, -- 69
|
||||
OUT minmax_stats_since timestamp with time zone,
|
||||
|
||||
OUT toplevel BOOLEAN, -- 71
|
||||
OUT bucket_done BOOLEAN
|
||||
)
|
||||
RETURNS SETOF record
|
||||
AS 'MODULE_PATHNAME', 'pg_stat_monitor_2_3'
|
||||
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;
|
||||
|
||||
CREATE FUNCTION pgsm_create_18_view() RETURNS INT AS
|
||||
$$
|
||||
BEGIN
|
||||
CREATE VIEW pg_stat_monitor AS SELECT
|
||||
bucket,
|
||||
bucket_start_time,
|
||||
userid,
|
||||
username,
|
||||
dbid,
|
||||
datname,
|
||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||
pgsm_query_id,
|
||||
queryid,
|
||||
toplevel,
|
||||
top_queryid,
|
||||
query,
|
||||
comments,
|
||||
planid,
|
||||
query_plan,
|
||||
top_query,
|
||||
application_name,
|
||||
string_to_array(relations, ',') AS relations,
|
||||
cmd_type,
|
||||
get_cmd_type(cmd_type) AS cmd_type_text,
|
||||
elevel,
|
||||
sqlcode,
|
||||
message,
|
||||
calls,
|
||||
total_exec_time,
|
||||
min_exec_time,
|
||||
max_exec_time,
|
||||
mean_exec_time,
|
||||
stddev_exec_time,
|
||||
rows,
|
||||
shared_blks_hit,
|
||||
shared_blks_read,
|
||||
shared_blks_dirtied,
|
||||
shared_blks_written,
|
||||
local_blks_hit,
|
||||
local_blks_read,
|
||||
local_blks_dirtied,
|
||||
local_blks_written,
|
||||
temp_blks_read,
|
||||
temp_blks_written,
|
||||
shared_blk_read_time,
|
||||
shared_blk_write_time,
|
||||
local_blk_read_time,
|
||||
local_blk_write_time,
|
||||
temp_blk_read_time,
|
||||
temp_blk_write_time,
|
||||
|
||||
(string_to_array(resp_calls, ',')) resp_calls,
|
||||
cpu_user_time,
|
||||
cpu_sys_time,
|
||||
wal_records,
|
||||
wal_fpi,
|
||||
wal_bytes,
|
||||
wal_buffers_full,
|
||||
bucket_done,
|
||||
|
||||
plans,
|
||||
total_plan_time,
|
||||
min_plan_time,
|
||||
max_plan_time,
|
||||
mean_plan_time,
|
||||
stddev_plan_time,
|
||||
|
||||
jit_functions,
|
||||
jit_generation_time,
|
||||
jit_inlining_count,
|
||||
jit_inlining_time,
|
||||
jit_optimization_count,
|
||||
jit_optimization_time,
|
||||
jit_emission_count,
|
||||
jit_emission_time,
|
||||
jit_deform_count,
|
||||
jit_deform_time,
|
||||
|
||||
parallel_workers_to_launch,
|
||||
parallel_workers_launched,
|
||||
|
||||
stats_since,
|
||||
minmax_stats_since
|
||||
|
||||
FROM pg_stat_monitor_internal(TRUE)
|
||||
ORDER BY bucket_start_time;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION pgsm_create_view() RETURNS INT AS
|
||||
$$
|
||||
DECLARE ver integer;
|
||||
BEGIN
|
||||
SELECT current_setting('server_version_num') INTO ver;
|
||||
IF (ver >= 180000) THEN
|
||||
return pgsm_create_18_view();
|
||||
END IF;
|
||||
IF (ver >= 170000) THEN
|
||||
return pgsm_create_17_view();
|
||||
END IF;
|
||||
IF (ver >= 150000) THEN
|
||||
return pgsm_create_15_view();
|
||||
END IF;
|
||||
IF (ver >= 140000) THEN
|
||||
return pgsm_create_14_view();
|
||||
END IF;
|
||||
IF (ver >= 130000) THEN
|
||||
return pgsm_create_13_view();
|
||||
END IF;
|
||||
RETURN 0;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT pgsm_create_view();
|
||||
REVOKE ALL ON FUNCTION pgsm_create_view FROM PUBLIC;
|
||||
REVOKE ALL ON FUNCTION pgsm_create_18_view FROM PUBLIC;
|
||||
|
||||
GRANT SELECT ON pg_stat_monitor TO PUBLIC;
|
||||
1195
pg_stat_monitor.c
1195
pg_stat_monitor.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,5 +1,5 @@
|
|||
# pg_stat_monitor extension
|
||||
comment = 'The pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL contrib module pg_stat_statements. pg_stat_monitor provides aggregated statistics, client information, plan details including plan, and histogram information.'
|
||||
default_version = '2.0'
|
||||
default_version = '2.3'
|
||||
module_pathname = '$libdir/pg_stat_monitor'
|
||||
relocatable = true
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
* pg_stat_monitor.h
|
||||
* Track statement execution times across a whole database cluster.
|
||||
*
|
||||
* Portions Copyright © 2018-2020, Percona LLC and/or its affiliates
|
||||
* Portions Copyright © 2018-2025, Percona LLC and/or its affiliates
|
||||
*
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
*
|
||||
* Portions Copyright (c) 1994, The Regents of the University of California
|
||||
*
|
||||
|
|
@ -93,8 +93,8 @@
|
|||
/* the assumption of query max nested level */
|
||||
#define DEFAULT_MAX_NESTED_LEVEL 10
|
||||
|
||||
#define MAX_QUERY_BUF (pgsm_query_shared_buffer * 1024 * 1024)
|
||||
#define MAX_BUCKETS_MEM (pgsm_max * 1024 * 1024)
|
||||
#define MAX_QUERY_BUF ((int64)pgsm_query_shared_buffer * 1024 * 1024)
|
||||
#define MAX_BUCKETS_MEM ((int64)pgsm_max * 1024 * 1024)
|
||||
#define BUCKETS_MEM_OVERFLOW() ((hash_get_num_entries(pgsm_hash) * sizeof(pgsmEntry)) >= MAX_BUCKETS_MEM)
|
||||
#define MAX_BUCKET_ENTRIES (MAX_BUCKETS_MEM / sizeof(pgsmEntry))
|
||||
#define QUERY_BUFFER_OVERFLOW(x,y) ((x + y + sizeof(uint64) + sizeof(uint64)) > MAX_QUERY_BUF)
|
||||
|
|
@ -102,41 +102,11 @@
|
|||
#define MIN_QUERY_LEN 10
|
||||
#define SQLCODE_LEN 20
|
||||
#define TOTAL_RELS_LENGTH (REL_LST * REL_LEN)
|
||||
|
||||
#if PG_VERSION_NUM >= 130000
|
||||
#define MAX_SETTINGS 15
|
||||
#else
|
||||
#define MAX_SETTINGS 14
|
||||
#endif
|
||||
|
||||
/* Update this if need a enum GUC with more options. */
|
||||
#define MAX_ENUM_OPTIONS 6
|
||||
|
||||
/*
|
||||
* API for disabling error capture ereport(ERROR,..) by PGSM's error capture hook
|
||||
* pgsm_emit_log_hook()
|
||||
*
|
||||
* Use these macros as follows:
|
||||
* PGSM_DISABLE_ERROR_CAPUTRE();
|
||||
* {
|
||||
* ... code that might throw ereport(ERROR) ...
|
||||
* }PGSM_END_DISABLE_ERROR_CAPTURE();
|
||||
*
|
||||
* These macros can be used to error recursion if the error gets
|
||||
* thrown from within the function called from pgsm_emit_log_hook()
|
||||
*/
|
||||
extern volatile bool __pgsm_do_not_capture_error;
|
||||
#define PGSM_DISABLE_ERROR_CAPUTRE() \
|
||||
do { \
|
||||
__pgsm_do_not_capture_error = true
|
||||
|
||||
#define PGSM_END_DISABLE_ERROR_CAPTURE() \
|
||||
__pgsm_do_not_capture_error = false; \
|
||||
} while (0)
|
||||
|
||||
#define PGSM_ERROR_CAPTURE_ENABLED \
|
||||
__pgsm_do_not_capture_error == false
|
||||
|
||||
/*
|
||||
* pg_stat_monitor uses the hash structure to store all query statistics
|
||||
* except the query text, which gets stored out of line in the raw DSA area.
|
||||
|
|
@ -168,17 +138,6 @@ extern volatile bool __pgsm_do_not_capture_error;
|
|||
#define PGSM_HASH_SEQ_STATUS HASH_SEQ_STATUS
|
||||
#endif
|
||||
|
||||
|
||||
#if PG_VERSION_NUM < 130000
|
||||
typedef struct WalUsage
|
||||
{
|
||||
long wal_records; /* # of WAL records produced */
|
||||
long wal_fpi; /* # of WAL full page images produced */
|
||||
uint64 wal_bytes; /* size of WAL records produced */
|
||||
} WalUsage;
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum pgsmStoreKind
|
||||
{
|
||||
PGSM_INVALID = -1,
|
||||
|
|
@ -193,10 +152,10 @@ typedef enum pgsmStoreKind
|
|||
PGSM_EXEC,
|
||||
PGSM_STORE,
|
||||
PGSM_ERROR,
|
||||
|
||||
PGSM_NUMKIND /* Must be last value of this enum */
|
||||
} pgsmStoreKind;
|
||||
|
||||
#define PGSM_NUMKIND (PGSM_ERROR + 1)
|
||||
|
||||
/* the assumption of query max nested level */
|
||||
#define DEFAULT_MAX_NESTED_LEVEL 10
|
||||
|
||||
|
|
@ -225,7 +184,7 @@ typedef struct CallTime
|
|||
|
||||
typedef struct PlanInfo
|
||||
{
|
||||
uint64 planid; /* plan identifier */
|
||||
int64 planid; /* plan identifier */
|
||||
char plan_text[PLAN_TEXT_LEN]; /* plan text */
|
||||
size_t plan_len; /* strlen(plan_text) */
|
||||
} PlanInfo;
|
||||
|
|
@ -233,18 +192,18 @@ typedef struct PlanInfo
|
|||
typedef struct pgsmHashKey
|
||||
{
|
||||
uint64 bucket_id; /* bucket number */
|
||||
uint64 queryid; /* query identifier */
|
||||
uint64 planid; /* plan identifier */
|
||||
uint64 appid; /* hash of application name */
|
||||
int64 queryid; /* query identifier */
|
||||
int64 planid; /* plan identifier */
|
||||
int64 appid; /* hash of application name */
|
||||
Oid userid; /* user OID */
|
||||
Oid dbid; /* database OID */
|
||||
uint32 ip; /* client ip address */
|
||||
bool toplevel; /* query executed at top level */
|
||||
int64 parentid; /* parent queryId of current query */
|
||||
} pgsmHashKey;
|
||||
|
||||
typedef struct QueryInfo
|
||||
{
|
||||
uint64 parentid; /* parent queryid of current query */
|
||||
dsa_pointer parent_query;
|
||||
int64 type; /* type of query, options are query, info,
|
||||
* warning, error, fatal */
|
||||
|
|
@ -284,9 +243,14 @@ typedef struct Blocks
|
|||
int64 local_blks_written; /* # of local disk blocks written */
|
||||
int64 temp_blks_read; /* # of temp blocks read */
|
||||
int64 temp_blks_written; /* # of temp blocks written */
|
||||
double blk_read_time; /* time spent reading, in msec */
|
||||
double blk_write_time; /* time spent writing, in msec */
|
||||
|
||||
double shared_blk_read_time; /* time spent reading shared blocks,
|
||||
* in msec */
|
||||
double shared_blk_write_time; /* time spent writing shared blocks,
|
||||
* in msec */
|
||||
double local_blk_read_time; /* time spent reading local blocks, in
|
||||
* msec */
|
||||
double local_blk_write_time; /* time spent writing local blocks, in
|
||||
* msec */
|
||||
double temp_blk_read_time; /* time spent reading temp blocks, in msec */
|
||||
double temp_blk_write_time; /* time spent writing temp blocks, in
|
||||
* msec */
|
||||
|
|
@ -295,8 +259,12 @@ typedef struct Blocks
|
|||
* Variables for local entry. The values to be passed to pgsm_update_entry
|
||||
* from pgsm_store.
|
||||
*/
|
||||
instr_time instr_blk_read_time; /* time spent reading blocks */
|
||||
instr_time instr_blk_write_time; /* time spent writing blocks */
|
||||
instr_time instr_shared_blk_read_time; /* time spent reading shared
|
||||
* blocks */
|
||||
instr_time instr_shared_blk_write_time; /* time spent writing shared
|
||||
* blocks */
|
||||
instr_time instr_local_blk_read_time; /* time spent reading local blocks */
|
||||
instr_time instr_local_blk_write_time; /* time spent writing local blocks */
|
||||
instr_time instr_temp_blk_read_time; /* time spent reading temp blocks */
|
||||
instr_time instr_temp_blk_write_time; /* time spent writing temp blocks */
|
||||
} Blocks;
|
||||
|
|
@ -307,6 +275,9 @@ typedef struct JitInfo
|
|||
double jit_generation_time; /* total time to generate jit code */
|
||||
int64 jit_inlining_count; /* number of times inlining time has been
|
||||
* > 0 */
|
||||
double jit_deform_time; /* total time to deform tuples in jit code */
|
||||
int64 jit_deform_count; /* number of times deform time has been >
|
||||
* 0 */
|
||||
double jit_inlining_time; /* total time to inline jit code */
|
||||
int64 jit_optimization_count; /* number of times optimization time
|
||||
* has been > 0 */
|
||||
|
|
@ -321,6 +292,7 @@ typedef struct JitInfo
|
|||
*/
|
||||
instr_time instr_generation_counter; /* generation counter */
|
||||
instr_time instr_inlining_counter; /* inlining counter */
|
||||
instr_time instr_deform_counter; /* deform counter */
|
||||
instr_time instr_optimization_counter; /* optimization counter */
|
||||
instr_time instr_emission_counter; /* emission counter */
|
||||
} JitInfo;
|
||||
|
|
@ -336,6 +308,7 @@ typedef struct Wal_Usage
|
|||
int64 wal_records; /* # of WAL records generated */
|
||||
int64 wal_fpi; /* # of WAL full page images generated */
|
||||
uint64 wal_bytes; /* total amount of WAL bytes generated */
|
||||
int64 wal_buffers_full; /* # of times the WAL buffers became full */
|
||||
} Wal_Usage;
|
||||
|
||||
typedef struct Counters
|
||||
|
|
@ -355,6 +328,10 @@ typedef struct Counters
|
|||
Wal_Usage walusage;
|
||||
int resp_calls[MAX_RESPONSE_BUCKET]; /* execution time's in
|
||||
* msec */
|
||||
int64 parallel_workers_to_launch; /* # of parallel workers planned
|
||||
* to be launched */
|
||||
int64 parallel_workers_launched; /* # of parallel workers actually
|
||||
* launched */
|
||||
} Counters;
|
||||
|
||||
/* Some global structure to get the cpu usage, really don't like the idea of global variable */
|
||||
|
|
@ -365,11 +342,13 @@ typedef struct Counters
|
|||
typedef struct pgsmEntry
|
||||
{
|
||||
pgsmHashKey key; /* hash key of entry - MUST BE FIRST */
|
||||
uint64 pgsm_query_id; /* pgsm generate normalized query hash */
|
||||
int64 pgsm_query_id; /* pgsm generate normalized query hash */
|
||||
char datname[NAMEDATALEN]; /* database name */
|
||||
char username[NAMEDATALEN]; /* user name */
|
||||
Counters counters; /* the statistics for this query */
|
||||
int encoding; /* query text encoding */
|
||||
TimestampTz stats_since; /* timestamp of entry allocation */
|
||||
TimestampTz minmax_stats_since; /* timestamp of last min/max values reset */
|
||||
slock_t mutex; /* protects the counters only */
|
||||
union
|
||||
{
|
||||
|
|
@ -513,6 +492,7 @@ extern bool pgsm_enable_query_plan;
|
|||
extern bool pgsm_enable_overflow;
|
||||
extern bool pgsm_normalized_query;
|
||||
extern bool pgsm_track_utility;
|
||||
extern bool pgsm_track_application_names;
|
||||
extern bool pgsm_enable_pgsm_query_id;
|
||||
extern int pgsm_track;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,4 +24,32 @@ SELECT pg_stat_monitor_reset();
|
|||
|
||||
(1 row)
|
||||
|
||||
SELECT 1 AS num;
|
||||
num
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SET pg_stat_monitor.pgsm_track_application_names='no';
|
||||
SELECT 1 AS num;
|
||||
num
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT query,application_name FROM pg_stat_monitor ORDER BY query, application_name COLLATE "C";
|
||||
query | application_name
|
||||
-------------------------------------------------------+-----------------------------
|
||||
SELECT 1 AS num | pg_regress/application_name
|
||||
SELECT 1 AS num |
|
||||
SELECT pg_stat_monitor_reset() | pg_regress/application_name
|
||||
SET pg_stat_monitor.pgsm_track_application_names='no' |
|
||||
(4 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ DROP TABLE t2;
|
|||
SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | cmd_type | cmd_type_text
|
||||
--------------------------------+----------+---------------
|
||||
CREATE TABLE t1 (a INTEGER) | 0 |
|
||||
CREATE TABLE t2 (b INTEGER) | 0 |
|
||||
CREATE TABLE t1 (a INTEGER) | 5 | UTILITY
|
||||
CREATE TABLE t2 (b INTEGER) | 5 | UTILITY
|
||||
DELETE FROM t1 | 4 | DELETE
|
||||
DROP TABLE t1 | 0 |
|
||||
DROP TABLE t2 | 0 |
|
||||
DROP TABLE t1 | 5 | UTILITY
|
||||
DROP TABLE t2 | 5 | UTILITY
|
||||
INSERT INTO t1 VALUES(1) | 3 | INSERT
|
||||
SELECT a FROM t1 | 1 | SELECT
|
||||
SELECT b FROM t2 FOR UPDATE | 1 | SELECT
|
||||
SELECT pg_stat_monitor_reset() | 1 | SELECT
|
||||
TRUNCATE t1 | 0 |
|
||||
TRUNCATE t1 | 5 | UTILITY
|
||||
UPDATE t1 SET a = 2 | 2 | UPDATE
|
||||
(11 rows)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,16 +23,22 @@ SELECT b FROM t2 FOR UPDATE;
|
|||
|
||||
TRUNCATE t1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | cmd_type | cmd_type_text
|
||||
--------------------------------+----------+---------------
|
||||
CREATE TABLE t1 (a INTEGER) | 6 | UTILITY
|
||||
CREATE TABLE t2 (b INTEGER) | 6 | UTILITY
|
||||
DELETE FROM t1 | 4 | DELETE
|
||||
DROP TABLE t1 | 6 | UTILITY
|
||||
DROP TABLE t2 | 6 | UTILITY
|
||||
INSERT INTO t1 VALUES(1) | 3 | INSERT
|
||||
SELECT a FROM t1 | 1 | SELECT
|
||||
SELECT b FROM t2 FOR UPDATE | 1 | SELECT
|
||||
SELECT pg_stat_monitor_reset() | 1 | SELECT
|
||||
TRUNCATE t1 | 6 | UTILITY
|
||||
UPDATE t1 SET a = 2 | 2 | UPDATE
|
||||
(6 rows)
|
||||
(11 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
DO $$
|
||||
DECLARE
|
||||
i integer;
|
||||
BEGIN
|
||||
FOR i IN 10..24 LOOP
|
||||
RAISE NOTICE 'error_code: %, error_level: %', i, decode_error_level(i);
|
||||
END LOOP;
|
||||
END $$;
|
||||
NOTICE: error_code: 10, error_level: DEBUG5
|
||||
NOTICE: error_code: 11, error_level: DEBUG4
|
||||
NOTICE: error_code: 12, error_level: DEBUG3
|
||||
NOTICE: error_code: 13, error_level: DEBUG2
|
||||
NOTICE: error_code: 14, error_level: DEBUG1
|
||||
NOTICE: error_code: 15, error_level: LOG
|
||||
NOTICE: error_code: 16, error_level: LOG_SERVER_ONLY
|
||||
NOTICE: error_code: 17, error_level: INFO
|
||||
NOTICE: error_code: 18, error_level: NOTICE
|
||||
NOTICE: error_code: 19, error_level: WARNING
|
||||
NOTICE: error_code: 20, error_level: WARNING_CLIENT_ONLY
|
||||
NOTICE: error_code: 21, error_level: ERROR
|
||||
NOTICE: error_code: 22, error_level: FATAL
|
||||
NOTICE: error_code: 23, error_level: PANIC
|
||||
NOTICE: error_code: 24, error_level: <NULL>
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
DO $$
|
||||
DECLARE
|
||||
i integer;
|
||||
BEGIN
|
||||
FOR i IN 10..24 LOOP
|
||||
RAISE NOTICE 'error_code: %, error_level: %', i, decode_error_level(i);
|
||||
END LOOP;
|
||||
END $$;
|
||||
NOTICE: error_code: 10, error_level: DEBUG5
|
||||
NOTICE: error_code: 11, error_level: DEBUG4
|
||||
NOTICE: error_code: 12, error_level: DEBUG3
|
||||
NOTICE: error_code: 13, error_level: DEBUG2
|
||||
NOTICE: error_code: 14, error_level: DEBUG1
|
||||
NOTICE: error_code: 15, error_level: LOG
|
||||
NOTICE: error_code: 16, error_level: LOG_SERVER_ONLY
|
||||
NOTICE: error_code: 17, error_level: INFO
|
||||
NOTICE: error_code: 18, error_level: NOTICE
|
||||
NOTICE: error_code: 19, error_level: WARNING
|
||||
NOTICE: error_code: 20, error_level: ERROR
|
||||
NOTICE: error_code: 21, error_level: FATAL
|
||||
NOTICE: error_code: 22, error_level: PANIC
|
||||
NOTICE: error_code: 23, error_level: <NULL>
|
||||
NOTICE: error_code: 24, error_level: <NULL>
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_track='all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE OR REPLACE FUNCTION test() RETURNS VOID AS
|
||||
$$
|
||||
BEGIN
|
||||
PERFORM 1 + 2;
|
||||
END; $$ language plpgsql;
|
||||
CREATE OR REPLACE FUNCTION test2() RETURNS VOID AS
|
||||
$$
|
||||
BEGIN
|
||||
PERFORM 1 + 2;
|
||||
END; $$ language plpgsql;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT test();
|
||||
test
|
||||
------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT test2();
|
||||
test2
|
||||
-------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 2;
|
||||
?column?
|
||||
----------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT left(query, 15) as query, calls, top_query, pgsm_query_id FROM pg_stat_monitor ORDER BY query, top_query COLLATE "C";
|
||||
query | calls | top_query | pgsm_query_id
|
||||
-----------------+-------+-----------------+----------------------
|
||||
SELECT 1 + 2 | 1 | SELECT test(); | 5193804135051352284
|
||||
SELECT 1 + 2 | 1 | SELECT test2(); | 5193804135051352284
|
||||
SELECT 1 + 2 | 1 | | 5193804135051352284
|
||||
SELECT pg_stat_ | 1 | | 689150021118383254
|
||||
SELECT test() | 1 | | -6801876889834540522
|
||||
SELECT test2() | 1 | | 369102705908374543
|
||||
(6 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -20,13 +20,14 @@ SELECT routine_schema, routine_name, routine_type, data_type FROM information_sc
|
|||
public | pg_stat_monitor_internal | FUNCTION | record
|
||||
public | pg_stat_monitor_reset | FUNCTION | void
|
||||
public | pg_stat_monitor_version | FUNCTION | text
|
||||
public | pgsm_create_11_view | FUNCTION | integer
|
||||
public | pgsm_create_13_view | FUNCTION | integer
|
||||
public | pgsm_create_14_view | FUNCTION | integer
|
||||
public | pgsm_create_15_view | FUNCTION | integer
|
||||
public | pgsm_create_17_view | FUNCTION | integer
|
||||
public | pgsm_create_18_view | FUNCTION | integer
|
||||
public | pgsm_create_view | FUNCTION | integer
|
||||
public | range | FUNCTION | ARRAY
|
||||
(13 rows)
|
||||
(14 rows)
|
||||
|
||||
SET ROLE u1;
|
||||
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@ SELECT routine_schema, routine_name, routine_type, data_type FROM information_sc
|
|||
public | pg_stat_monitor_internal | FUNCTION | record
|
||||
public | pg_stat_monitor_reset | FUNCTION | void
|
||||
public | pg_stat_monitor_version | FUNCTION | text
|
||||
public | pgsm_create_11_view | FUNCTION | integer
|
||||
public | pgsm_create_13_view | FUNCTION | integer
|
||||
public | pgsm_create_14_view | FUNCTION | integer
|
||||
public | pgsm_create_15_view | FUNCTION | integer
|
||||
public | pgsm_create_17_view | FUNCTION | integer
|
||||
public | pgsm_create_18_view | FUNCTION | integer
|
||||
public | pgsm_create_view | FUNCTION | integer
|
||||
public | range | FUNCTION | ARRAY
|
||||
(13 rows)
|
||||
(14 rows)
|
||||
|
||||
SET ROLE u1;
|
||||
SELECT routine_schema, routine_name, routine_type, data_type FROM information_schema.routines WHERE routine_schema = 'public' ORDER BY routine_name COLLATE "C";
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ ORDER
|
|||
BY name
|
||||
COLLATE "C";
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -33,8 +33,9 @@ COLLATE "C";
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_planning | off | | user | bool | default | | | | off | off | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(17 rows)
|
||||
(18 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ ORDER
|
|||
BY name
|
||||
COLLATE "C";
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -33,7 +33,8 @@ COLLATE "C";
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(16 rows)
|
||||
(17 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ ORDER
|
|||
BY name
|
||||
COLLATE "C";
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -33,7 +33,8 @@ COLLATE "C";
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(16 rows)
|
||||
(17 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
--
|
||||
-- Statement level tracking
|
||||
--
|
||||
SELECT setting::integer < 140000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
|
|
@ -0,0 +1,326 @@
|
|||
--
|
||||
-- Statement level tracking
|
||||
--
|
||||
SELECT setting::integer < 140000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_track_utility = TRUE;
|
||||
SET pg_stat_monitor.pgsm_normalized_query = TRUE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- DO block - top-level tracking.
|
||||
CREATE TABLE stats_track_tab (x int);
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
WHERE query LIKE '%DELETE%' ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+--------------------------------
|
||||
t | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DO $$ +
|
||||
| | BEGIN +
|
||||
| | DELETE FROM stats_track_tab;+
|
||||
| | END; +
|
||||
| | $$ LANGUAGE plpgsql
|
||||
(2 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- DO block - all-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+----------------------------------------
|
||||
f | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DO $$ +
|
||||
| | BEGIN +
|
||||
| | DELETE FROM stats_track_tab; +
|
||||
| | END; $$
|
||||
t | 1 | DO LANGUAGE plpgsql $$ +
|
||||
| | BEGIN +
|
||||
| | -- this is a SELECT +
|
||||
| | PERFORM 'hello world'::TEXT; +
|
||||
| | END; $$
|
||||
f | 1 | SELECT $1::TEXT
|
||||
t | 1 | SELECT pg_stat_monitor_reset()
|
||||
t | 1 | SET pg_stat_monitor.pgsm_track = 'all'
|
||||
(7 rows)
|
||||
|
||||
-- DO block - top-level tracking without utility.
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
SET pg_stat_monitor.pgsm_track_utility = FALSE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+--------------------------------
|
||||
t | 2 | DELETE FROM stats_track_tab
|
||||
t | 1 | SELECT $1::TEXT
|
||||
t | 1 | SELECT pg_stat_monitor_reset()
|
||||
(3 rows)
|
||||
|
||||
-- DO block - all-level tracking without utility.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+--------------------------------
|
||||
t | 2 | DELETE FROM stats_track_tab
|
||||
t | 1 | SELECT $1::TEXT
|
||||
t | 1 | SELECT pg_stat_monitor_reset()
|
||||
(3 rows)
|
||||
|
||||
-- PL/pgSQL function - top-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
SET pg_stat_monitor.pgsm_track_utility = FALSE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
||||
DECLARE
|
||||
r INTEGER;
|
||||
BEGIN
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
||||
RETURN r;
|
||||
END; $$ LANGUAGE plpgsql;
|
||||
SELECT PLUS_TWO(3);
|
||||
plus_two
|
||||
----------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_TWO(7);
|
||||
plus_two
|
||||
----------
|
||||
9
|
||||
(1 row)
|
||||
|
||||
-- SQL function --- use LIMIT to keep it from being inlined
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
||||
SELECT PLUS_ONE(8);
|
||||
plus_one
|
||||
----------
|
||||
9
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_ONE(10);
|
||||
plus_one
|
||||
----------
|
||||
11
|
||||
(1 row)
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
calls | rows | query
|
||||
-------+------+--------------------------------
|
||||
2 | 2 | SELECT PLUS_ONE($1)
|
||||
2 | 2 | SELECT PLUS_TWO($1)
|
||||
1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(3 rows)
|
||||
|
||||
-- immutable SQL function --- can be executed at plan time
|
||||
CREATE FUNCTION PLUS_THREE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT i + 3 LIMIT 1 $$ IMMUTABLE LANGUAGE SQL;
|
||||
SELECT PLUS_THREE(8);
|
||||
plus_three
|
||||
------------
|
||||
11
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_THREE(10);
|
||||
plus_three
|
||||
------------
|
||||
13
|
||||
(1 row)
|
||||
|
||||
SELECT toplevel, calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
toplevel | calls | rows | query
|
||||
----------+-------+------+---------------------------------------------------------------------------
|
||||
t | 2 | 2 | SELECT PLUS_ONE($1)
|
||||
t | 2 | 2 | SELECT PLUS_THREE($1)
|
||||
t | 2 | 2 | SELECT PLUS_TWO($1)
|
||||
t | 1 | 3 | SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
||||
f | 2 | 2 | SELECT i + $2 LIMIT $3
|
||||
t | 1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(6 rows)
|
||||
|
||||
-- PL/pgSQL function - all-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- we drop and recreate the functions to avoid any caching funnies
|
||||
DROP FUNCTION PLUS_ONE(INTEGER);
|
||||
DROP FUNCTION PLUS_TWO(INTEGER);
|
||||
DROP FUNCTION PLUS_THREE(INTEGER);
|
||||
-- PL/pgSQL function
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
||||
DECLARE
|
||||
r INTEGER;
|
||||
BEGIN
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
||||
RETURN r;
|
||||
END; $$ LANGUAGE plpgsql;
|
||||
SELECT PLUS_TWO(-1);
|
||||
plus_two
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_TWO(2);
|
||||
plus_two
|
||||
----------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
-- SQL function --- use LIMIT to keep it from being inlined
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
||||
SELECT PLUS_ONE(3);
|
||||
plus_one
|
||||
----------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_ONE(1);
|
||||
plus_one
|
||||
----------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
calls | rows | query
|
||||
-------+------+-----------------------------------
|
||||
2 | 2 | SELECT (i + $2 + $3)::INTEGER
|
||||
2 | 2 | SELECT (i + $2)::INTEGER LIMIT $3
|
||||
2 | 2 | SELECT PLUS_ONE($1)
|
||||
2 | 2 | SELECT PLUS_TWO($1)
|
||||
1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(5 rows)
|
||||
|
||||
-- immutable SQL function --- can be executed at plan time
|
||||
CREATE FUNCTION PLUS_THREE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT i + 3 LIMIT 1 $$ IMMUTABLE LANGUAGE SQL;
|
||||
SELECT PLUS_THREE(8);
|
||||
plus_three
|
||||
------------
|
||||
11
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_THREE(10);
|
||||
plus_three
|
||||
------------
|
||||
13
|
||||
(1 row)
|
||||
|
||||
SELECT toplevel, calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
toplevel | calls | rows | query
|
||||
----------+-------+------+---------------------------------------------------------------------------
|
||||
f | 2 | 2 | SELECT (i + $2 + $3)::INTEGER
|
||||
f | 2 | 2 | SELECT (i + $2)::INTEGER LIMIT $3
|
||||
t | 2 | 2 | SELECT PLUS_ONE($1)
|
||||
t | 2 | 2 | SELECT PLUS_THREE($1)
|
||||
t | 2 | 2 | SELECT PLUS_TWO($1)
|
||||
t | 1 | 5 | SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
||||
f | 2 | 2 | SELECT i + $2 LIMIT $3
|
||||
t | 1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(8 rows)
|
||||
|
||||
--
|
||||
-- pg_stat_monitor.pgsm_track = none
|
||||
--
|
||||
SET pg_stat_monitor.pgsm_track = 'none';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT 1 AS "one";
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 AS "two";
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
calls | rows | query
|
||||
-------+------+-------
|
||||
(0 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,325 @@
|
|||
--
|
||||
-- Statement level tracking
|
||||
--
|
||||
SELECT setting::integer < 140000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_track_utility = TRUE;
|
||||
SET pg_stat_monitor.pgsm_normalized_query = TRUE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- DO block - top-level tracking.
|
||||
CREATE TABLE stats_track_tab (x int);
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
WHERE query LIKE '%DELETE%' ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+--------------------------------
|
||||
t | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DO $$ +
|
||||
| | BEGIN +
|
||||
| | DELETE FROM stats_track_tab;+
|
||||
| | END; +
|
||||
| | $$ LANGUAGE plpgsql
|
||||
(2 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- DO block - all-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+----------------------------------------
|
||||
f | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DO $$ +
|
||||
| | BEGIN +
|
||||
| | DELETE FROM stats_track_tab; +
|
||||
| | END; $$
|
||||
t | 1 | DO LANGUAGE plpgsql $$ +
|
||||
| | BEGIN +
|
||||
| | -- this is a SELECT +
|
||||
| | PERFORM 'hello world'::TEXT; +
|
||||
| | END; $$
|
||||
f | 1 | SELECT $1::TEXT
|
||||
t | 1 | SELECT pg_stat_monitor_reset()
|
||||
t | 1 | SET pg_stat_monitor.pgsm_track = 'all'
|
||||
(7 rows)
|
||||
|
||||
-- DO block - top-level tracking without utility.
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
SET pg_stat_monitor.pgsm_track_utility = FALSE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+--------------------------------
|
||||
t | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | SELECT pg_stat_monitor_reset()
|
||||
(2 rows)
|
||||
|
||||
-- DO block - all-level tracking without utility.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
toplevel | calls | query
|
||||
----------+-------+--------------------------------
|
||||
f | 1 | DELETE FROM stats_track_tab
|
||||
t | 1 | DELETE FROM stats_track_tab
|
||||
f | 1 | SELECT $1::TEXT
|
||||
t | 1 | SELECT pg_stat_monitor_reset()
|
||||
(4 rows)
|
||||
|
||||
-- PL/pgSQL function - top-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
SET pg_stat_monitor.pgsm_track_utility = FALSE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
||||
DECLARE
|
||||
r INTEGER;
|
||||
BEGIN
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
||||
RETURN r;
|
||||
END; $$ LANGUAGE plpgsql;
|
||||
SELECT PLUS_TWO(3);
|
||||
plus_two
|
||||
----------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_TWO(7);
|
||||
plus_two
|
||||
----------
|
||||
9
|
||||
(1 row)
|
||||
|
||||
-- SQL function --- use LIMIT to keep it from being inlined
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
||||
SELECT PLUS_ONE(8);
|
||||
plus_one
|
||||
----------
|
||||
9
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_ONE(10);
|
||||
plus_one
|
||||
----------
|
||||
11
|
||||
(1 row)
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
calls | rows | query
|
||||
-------+------+--------------------------------
|
||||
2 | 2 | SELECT PLUS_ONE($1)
|
||||
2 | 2 | SELECT PLUS_TWO($1)
|
||||
1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(3 rows)
|
||||
|
||||
-- immutable SQL function --- can be executed at plan time
|
||||
CREATE FUNCTION PLUS_THREE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT i + 3 LIMIT 1 $$ IMMUTABLE LANGUAGE SQL;
|
||||
SELECT PLUS_THREE(8);
|
||||
plus_three
|
||||
------------
|
||||
11
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_THREE(10);
|
||||
plus_three
|
||||
------------
|
||||
13
|
||||
(1 row)
|
||||
|
||||
SELECT toplevel, calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
toplevel | calls | rows | query
|
||||
----------+-------+------+---------------------------------------------------------------------------
|
||||
t | 2 | 2 | SELECT PLUS_ONE($1)
|
||||
t | 2 | 2 | SELECT PLUS_THREE($1)
|
||||
t | 2 | 2 | SELECT PLUS_TWO($1)
|
||||
t | 1 | 3 | SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
||||
t | 1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(5 rows)
|
||||
|
||||
-- PL/pgSQL function - all-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- we drop and recreate the functions to avoid any caching funnies
|
||||
DROP FUNCTION PLUS_ONE(INTEGER);
|
||||
DROP FUNCTION PLUS_TWO(INTEGER);
|
||||
DROP FUNCTION PLUS_THREE(INTEGER);
|
||||
-- PL/pgSQL function
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
||||
DECLARE
|
||||
r INTEGER;
|
||||
BEGIN
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
||||
RETURN r;
|
||||
END; $$ LANGUAGE plpgsql;
|
||||
SELECT PLUS_TWO(-1);
|
||||
plus_two
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_TWO(2);
|
||||
plus_two
|
||||
----------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
-- SQL function --- use LIMIT to keep it from being inlined
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
||||
SELECT PLUS_ONE(3);
|
||||
plus_one
|
||||
----------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_ONE(1);
|
||||
plus_one
|
||||
----------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
calls | rows | query
|
||||
-------+------+-----------------------------------
|
||||
2 | 2 | SELECT (i + $2 + $3)::INTEGER
|
||||
2 | 2 | SELECT (i + $2)::INTEGER LIMIT $3
|
||||
2 | 2 | SELECT PLUS_ONE($1)
|
||||
2 | 2 | SELECT PLUS_TWO($1)
|
||||
1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(5 rows)
|
||||
|
||||
-- immutable SQL function --- can be executed at plan time
|
||||
CREATE FUNCTION PLUS_THREE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT i + 3 LIMIT 1 $$ IMMUTABLE LANGUAGE SQL;
|
||||
SELECT PLUS_THREE(8);
|
||||
plus_three
|
||||
------------
|
||||
11
|
||||
(1 row)
|
||||
|
||||
SELECT PLUS_THREE(10);
|
||||
plus_three
|
||||
------------
|
||||
13
|
||||
(1 row)
|
||||
|
||||
SELECT toplevel, calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
toplevel | calls | rows | query
|
||||
----------+-------+------+---------------------------------------------------------------------------
|
||||
f | 2 | 2 | SELECT (i + $2 + $3)::INTEGER
|
||||
f | 2 | 2 | SELECT (i + $2)::INTEGER LIMIT $3
|
||||
t | 2 | 2 | SELECT PLUS_ONE($1)
|
||||
t | 2 | 2 | SELECT PLUS_THREE($1)
|
||||
t | 2 | 2 | SELECT PLUS_TWO($1)
|
||||
t | 1 | 5 | SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
||||
f | 2 | 2 | SELECT i + $2 LIMIT $3
|
||||
t | 1 | 1 | SELECT pg_stat_monitor_reset()
|
||||
(8 rows)
|
||||
|
||||
--
|
||||
-- pg_stat_monitor.pgsm_track = none
|
||||
--
|
||||
SET pg_stat_monitor.pgsm_track = 'none';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT 1 AS "one";
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 AS "two";
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
calls | rows | query
|
||||
-------+------+-------
|
||||
(0 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
--
|
||||
-- Tests for parallel statistics
|
||||
--
|
||||
SELECT setting::integer < 180000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
--
|
||||
-- Tests for parallel statistics
|
||||
--
|
||||
SELECT setting::integer < 180000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pgsm.track_utility = FALSE;
|
||||
-- encourage use of parallel plans
|
||||
SET parallel_setup_cost = 0;
|
||||
SET parallel_tuple_cost = 0;
|
||||
SET min_parallel_table_scan_size = 0;
|
||||
SET max_parallel_workers_per_gather = 2;
|
||||
CREATE TABLE pgsm_parallel_tab (a int);
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM pgsm_parallel_tab;
|
||||
count
|
||||
-------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT query,
|
||||
parallel_workers_to_launch > 0 AS has_workers_to_launch,
|
||||
parallel_workers_launched > 0 AS has_workers_launched
|
||||
FROM pg_stat_monitor
|
||||
WHERE query ~ 'SELECT count'
|
||||
ORDER BY query COLLATE "C";
|
||||
query | has_workers_to_launch | has_workers_launched
|
||||
----------------------------------------+-----------------------+----------------------
|
||||
SELECT count(*) FROM pgsm_parallel_tab | t | t
|
||||
(1 row)
|
||||
|
||||
DROP TABLE pgsm_parallel_tab;
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
CREATE DATABASE db1;
|
||||
CREATE DATABASE db2;
|
||||
\c db1
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
CREATE FUNCTION add(integer, integer) RETURNS integer
|
||||
AS 'select $1 + $2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
\c db2
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t3 (c int);
|
||||
CREATE FUNCTION add(integer, integer) RETURNS integer
|
||||
AS 'select $1 + $2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
\c contrib_regression
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\c db1
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT *, ADD(1, 2) FROM t1;
|
||||
a | add
|
||||
---+-----
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM t2;
|
||||
b
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
-- Check that spaces and comments do not generate a different pgsm_query_id
|
||||
SELECT * FROM t2 --WHATEVER;
|
||||
;
|
||||
b
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM t2 /* ...
|
||||
...
|
||||
More comments to check for spaces.
|
||||
*/
|
||||
;
|
||||
b
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
\c db2
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT *, ADD(1, 2) FROM t1;
|
||||
a | add
|
||||
---+-----
|
||||
(0 rows)
|
||||
|
||||
set pg_stat_monitor.pgsm_enable_pgsm_query_id = off;
|
||||
SELECT * FROM t3;
|
||||
c
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
set pg_stat_monitor.pgsm_enable_pgsm_query_id = on;
|
||||
SELECT * FROM t3 where c = 20;
|
||||
c
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
\c contrib_regression
|
||||
SELECT datname, pgsm_query_id, query, calls FROM pg_stat_monitor ORDER BY pgsm_query_id, query, datname;
|
||||
datname | pgsm_query_id | query | calls
|
||||
--------------------+---------------------+-----------------------------------------------------+-------
|
||||
contrib_regression | 689150021118383254 | SELECT pg_stat_monitor_reset() | 1
|
||||
db1 | 1897482803466821995 | SELECT * FROM t2 | 3
|
||||
db1 | 1988437669671417938 | SELECT * FROM t1 | 1
|
||||
db2 | 1988437669671417938 | SELECT * FROM t1 | 1
|
||||
db2 | 6220142855706866455 | set pg_stat_monitor.pgsm_enable_pgsm_query_id = on | 1
|
||||
db2 | 6633979598391393345 | SELECT * FROM t3 where c = 20 | 1
|
||||
db1 | 8140395000078788481 | SELECT *, ADD(1, 2) FROM t1 | 1
|
||||
db2 | 8140395000078788481 | SELECT *, ADD(1, 2) FROM t1 | 1
|
||||
db2 | | SELECT * FROM t3 | 1
|
||||
db2 | | set pg_stat_monitor.pgsm_enable_pgsm_query_id = off | 1
|
||||
(10 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\c db1
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
DROP FUNCTION ADD;
|
||||
\c db2
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t3;
|
||||
DROP FUNCTION ADD;
|
||||
\c contrib_regression
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
CREATE DATABASE db1;
|
||||
CREATE DATABASE db2;
|
||||
\c db1
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
CREATE FUNCTION add(integer, integer) RETURNS integer
|
||||
AS 'select $1 + $2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
\c db2
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t3 (c int);
|
||||
CREATE FUNCTION add(integer, integer) RETURNS integer
|
||||
AS 'select $1 + $2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
\c contrib_regression
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\c db1
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT *, ADD(1, 2) FROM t1;
|
||||
a | add
|
||||
---+-----
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM t2;
|
||||
b
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
-- Check that spaces and comments do not generate a different pgsm_query_id
|
||||
SELECT * FROM t2 --WHATEVER;
|
||||
;
|
||||
b
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM t2 /* ...
|
||||
...
|
||||
More comments to check for spaces.
|
||||
*/
|
||||
;
|
||||
b
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
\c db2
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT *, ADD(1, 2) FROM t1;
|
||||
a | add
|
||||
---+-----
|
||||
(0 rows)
|
||||
|
||||
set pg_stat_monitor.pgsm_enable_pgsm_query_id = off;
|
||||
SELECT * FROM t3;
|
||||
c
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
set pg_stat_monitor.pgsm_enable_pgsm_query_id = on;
|
||||
SELECT * FROM t3 where c = 20;
|
||||
c
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
\c contrib_regression
|
||||
SELECT datname, pgsm_query_id, query, calls FROM pg_stat_monitor ORDER BY pgsm_query_id, query, datname;
|
||||
datname | pgsm_query_id | query | calls
|
||||
--------------------+---------------------+-----------------------------------------------------+-------
|
||||
contrib_regression | 689150021118383254 | SELECT pg_stat_monitor_reset() | 1
|
||||
db1 | 1897482803466821995 | SELECT * FROM t2 | 3
|
||||
db1 | 1988437669671417938 | SELECT * FROM t1 | 1
|
||||
db2 | 1988437669671417938 | SELECT * FROM t1 | 1
|
||||
db2 | 6633979598391393345 | SELECT * FROM t3 where c = 20 | 1
|
||||
db1 | 8140395000078788481 | SELECT *, ADD(1, 2) FROM t1 | 1
|
||||
db2 | 8140395000078788481 | SELECT *, ADD(1, 2) FROM t1 | 1
|
||||
db2 | | SELECT * FROM t3 | 1
|
||||
db2 | | set pg_stat_monitor.pgsm_enable_pgsm_query_id = off | 2
|
||||
(9 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\c db1
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
DROP FUNCTION ADD;
|
||||
\c db2
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t3;
|
||||
DROP FUNCTION ADD;
|
||||
\c contrib_regression
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
--
|
||||
-- Const squashing functionality
|
||||
--
|
||||
SELECT setting::integer < 180000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
|
|
@ -0,0 +1,792 @@
|
|||
--
|
||||
-- Const squashing functionality
|
||||
--
|
||||
SELECT setting::integer < 180000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_normalized_query = TRUE;
|
||||
--
|
||||
-- Simple Lists
|
||||
--
|
||||
CREATE TABLE test_squash (id int, data int);
|
||||
-- single element will not be squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT ARRAY[1];
|
||||
array
|
||||
-------
|
||||
{1}
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT * FROM test_squash WHERE id IN ($1) | 1
|
||||
SELECT ARRAY[$1] | 1
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
-- more than 1 element in a list will be squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT ARRAY[1, 2, 3];
|
||||
array
|
||||
---------
|
||||
{1,2,3}
|
||||
(1 row)
|
||||
|
||||
SELECT ARRAY[1, 2, 3, 4];
|
||||
array
|
||||
-----------
|
||||
{1,2,3,4}
|
||||
(1 row)
|
||||
|
||||
SELECT ARRAY[1, 2, 3, 4, 5];
|
||||
array
|
||||
-------------
|
||||
{1,2,3,4,5}
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash WHERE id IN ($1 /*, ... */) | 3
|
||||
SELECT ARRAY[$1 /*, ... */] | 3
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
-- built-in functions will be squashed
|
||||
-- the IN and ARRAY forms of this statement will have the same queryId
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT WHERE 1 IN (1, int4(1), int4(2), 2);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT WHERE 1 = ANY (ARRAY[1, int4(1), int4(2), 2]);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT WHERE $1 IN ($2 /*, ... */) | 2
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- This tests are disabled due bug in PGSM, see: https://perconadev.atlassian.net/browse/PG-1936
|
||||
-- -- external parameters will be squashed
|
||||
-- SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5) \bind 1 2 3 4 5
|
||||
-- ;
|
||||
-- SELECT * FROM test_squash WHERE id::text = ANY(ARRAY[$1, $2, $3, $4, $5]) \bind 1 2 3 4 5
|
||||
-- ;
|
||||
-- SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
-- -- prepared statements will also be squashed
|
||||
-- -- the IN and ARRAY forms of this statement will have the same queryId
|
||||
-- SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- PREPARE p1(int, int, int, int, int) AS
|
||||
-- SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5);
|
||||
-- EXECUTE p1(1, 2, 3, 4, 5);
|
||||
-- DEALLOCATE p1;
|
||||
-- PREPARE p1(int, int, int, int, int) AS
|
||||
-- SELECT * FROM test_squash WHERE id = ANY(ARRAY[$1, $2, $3, $4, $5]);
|
||||
-- EXECUTE p1(1, 2, 3, 4, 5);
|
||||
-- DEALLOCATE p1;
|
||||
-- SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
-- More conditions in the query
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND data = 2;
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND data = 2;
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) AND data = 2;
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9]) AND data = 2;
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) AND data = 2;
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) AND data = 2;
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
---------------------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash WHERE id IN ($1 /*, ... */) AND data = $2 | 6
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- Multiple squashed intervals
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
AND data IN (1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
AND data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
|
||||
AND data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
AND data = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
AND data = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
AND data = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash WHERE id IN ($1 /*, ... */)+| 6
|
||||
AND data IN ($2 /*, ... */) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- No constants squashing for OpExpr
|
||||
-- The IN and ARRAY forms of this statement will have the same queryId
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN
|
||||
(1 + 1, 2 + 2, 3 + 3, 4 + 4, 5 + 5, 6 + 6, 7 + 7, 8 + 8, 9 + 9);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN
|
||||
(@ '-1', @ '-2', @ '-3', @ '-4', @ '-5', @ '-6', @ '-7', @ '-8', @ '-9');
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY
|
||||
[1 + 1, 2 + 2, 3 + 3, 4 + 4, 5 + 5, 6 + 6, 7 + 7, 8 + 8, 9 + 9]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY
|
||||
[@ '-1', @ '-2', @ '-3', @ '-4', @ '-5', @ '-6', @ '-7', @ '-8', @ '-9']);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
----------------------------------------------------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash WHERE id IN +| 2
|
||||
($1 + $2, $3 + $4, $5 + $6, $7 + $8, $9 + $10, $11 + $12, $13 + $14, $15 + $16, $17 + $18) |
|
||||
SELECT * FROM test_squash WHERE id IN +| 2
|
||||
(@ $1, @ $2, @ $3, @ $4, @ $5, @ $6, @ $7, @ $8, @ $9) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
--
|
||||
-- FuncExpr
|
||||
--
|
||||
-- Verify multiple type representation end up with the same query_id
|
||||
CREATE TABLE test_float (data float);
|
||||
-- The casted ARRAY expressions will have the same queryId as the IN clause
|
||||
-- form of the query
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT data FROM test_float WHERE data IN (1, 2);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data IN (1, '2');
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data IN ('1', 2);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data IN ('1', '2');
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data IN (1.0, 1.0);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY['1'::double precision, '2'::double precision]);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[1.0::double precision, 1.0::double precision]);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[1, 2]);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[1, '2']);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY['1', 2]);
|
||||
data
|
||||
------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
--------------------------------------------------------------------+-------
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[$1 /*, ... */]) | 3
|
||||
SELECT data FROM test_float WHERE data IN ($1 /*, ... */) | 7
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
-- Numeric type, implicit cast is squashed
|
||||
CREATE TABLE test_squash_numeric (id int, data numeric(5, 2));
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_numeric WHERE data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_numeric WHERE data = ANY(ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
--------------------------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_numeric WHERE data = ANY(ARRAY[$1 /*, ... */]) | 1
|
||||
SELECT * FROM test_squash_numeric WHERE data IN ($1 /*, ... */) | 1
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
-- Bigint, implicit cast is squashed
|
||||
CREATE TABLE test_squash_bigint (id int, data bigint);
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_bigint WHERE data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_bigint WHERE data = ANY(ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_bigint WHERE data = ANY(ARRAY[$1 /*, ... */]) | 1
|
||||
SELECT * FROM test_squash_bigint WHERE data IN ($1 /*, ... */) | 1
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
-- Bigint, explicit cast is squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_bigint WHERE data IN
|
||||
(1::bigint, 2::bigint, 3::bigint, 4::bigint, 5::bigint, 6::bigint,
|
||||
7::bigint, 8::bigint, 9::bigint, 10::bigint, 11::bigint);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_bigint WHERE data = ANY(ARRAY[
|
||||
1::bigint, 2::bigint, 3::bigint, 4::bigint, 5::bigint, 6::bigint,
|
||||
7::bigint, 8::bigint, 9::bigint, 10::bigint, 11::bigint]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_bigint WHERE data IN +| 2
|
||||
($1 /*, ... */) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- Bigint, long tokens with parenthesis, will not squash
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_bigint WHERE id IN
|
||||
(abs(100), abs(200), abs(300), abs(400), abs(500), abs(600), abs(700),
|
||||
abs(800), abs(900), abs(1000), ((abs(1100))));
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_bigint WHERE id = ANY(ARRAY[
|
||||
abs(100), abs(200), abs(300), abs(400), abs(500), abs(600), abs(700),
|
||||
abs(800), abs(900), abs(1000), ((abs(1100)))]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_bigint WHERE id IN +| 2
|
||||
(abs($1), abs($2), abs($3), abs($4), abs($5), abs($6), abs($7),+|
|
||||
abs($8), abs($9), abs($10), ((abs($11)))) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- Multiple FuncExpr's. Will not squash
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT WHERE 1 IN (1::int::bigint::int, 2::int::bigint::int);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT WHERE 1 = ANY(ARRAY[1::int::bigint::int, 2::int::bigint::int]);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT WHERE $1 IN ($2 /*, ... */) | 2
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
--
|
||||
-- CoerceViaIO
|
||||
--
|
||||
-- Create some dummy type to force CoerceViaIO
|
||||
CREATE TYPE casttesttype;
|
||||
CREATE FUNCTION casttesttype_in(cstring)
|
||||
RETURNS casttesttype
|
||||
AS 'textin'
|
||||
LANGUAGE internal STRICT IMMUTABLE;
|
||||
NOTICE: return type casttesttype is only a shell
|
||||
CREATE FUNCTION casttesttype_out(casttesttype)
|
||||
RETURNS cstring
|
||||
AS 'textout'
|
||||
LANGUAGE internal STRICT IMMUTABLE;
|
||||
NOTICE: argument type casttesttype is only a shell
|
||||
LINE 1: CREATE FUNCTION casttesttype_out(casttesttype)
|
||||
^
|
||||
CREATE TYPE casttesttype (
|
||||
internallength = variable,
|
||||
input = casttesttype_in,
|
||||
output = casttesttype_out,
|
||||
alignment = int4
|
||||
);
|
||||
CREATE CAST (int4 AS casttesttype) WITH INOUT;
|
||||
CREATE FUNCTION casttesttype_eq(casttesttype, casttesttype)
|
||||
returns boolean language sql immutable as $$
|
||||
SELECT true
|
||||
$$;
|
||||
CREATE OPERATOR = (
|
||||
leftarg = casttesttype,
|
||||
rightarg = casttesttype,
|
||||
procedure = casttesttype_eq,
|
||||
commutator = =);
|
||||
CREATE TABLE test_squash_cast (id int, data casttesttype);
|
||||
-- Use the introduced type to construct a list of CoerceViaIO around Const
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_cast WHERE data IN
|
||||
(1::int4::casttesttype, 2::int4::casttesttype, 3::int4::casttesttype,
|
||||
4::int4::casttesttype, 5::int4::casttesttype, 6::int4::casttesttype,
|
||||
7::int4::casttesttype, 8::int4::casttesttype, 9::int4::casttesttype,
|
||||
10::int4::casttesttype, 11::int4::casttesttype);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_cast WHERE data = ANY (ARRAY
|
||||
[1::int4::casttesttype, 2::int4::casttesttype, 3::int4::casttesttype,
|
||||
4::int4::casttesttype, 5::int4::casttesttype, 6::int4::casttesttype,
|
||||
7::int4::casttesttype, 8::int4::casttesttype, 9::int4::casttesttype,
|
||||
10::int4::casttesttype, 11::int4::casttesttype]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_cast WHERE data IN +| 2
|
||||
($1 /*, ... */) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- Some casting expression are simplified to Const
|
||||
CREATE TABLE test_squash_jsonb (id int, data jsonb);
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_jsonb WHERE data IN
|
||||
(('"1"')::jsonb, ('"2"')::jsonb, ('"3"')::jsonb, ('"4"')::jsonb,
|
||||
('"5"')::jsonb, ('"6"')::jsonb, ('"7"')::jsonb, ('"8"')::jsonb,
|
||||
('"9"')::jsonb, ('"10"')::jsonb);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_jsonb WHERE data = ANY (ARRAY
|
||||
[('"1"')::jsonb, ('"2"')::jsonb, ('"3"')::jsonb, ('"4"')::jsonb,
|
||||
('"5"')::jsonb, ('"6"')::jsonb, ('"7"')::jsonb, ('"8"')::jsonb,
|
||||
('"9"')::jsonb, ('"10"')::jsonb]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_jsonb WHERE data IN +| 2
|
||||
($1 /*, ... */) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- CoerceViaIO, SubLink instead of a Const. Will not squash
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash_jsonb WHERE data IN
|
||||
((SELECT '"1"')::jsonb, (SELECT '"2"')::jsonb, (SELECT '"3"')::jsonb,
|
||||
(SELECT '"4"')::jsonb, (SELECT '"5"')::jsonb, (SELECT '"6"')::jsonb,
|
||||
(SELECT '"7"')::jsonb, (SELECT '"8"')::jsonb, (SELECT '"9"')::jsonb,
|
||||
(SELECT '"10"')::jsonb);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash_jsonb WHERE data = ANY(ARRAY
|
||||
[(SELECT '"1"')::jsonb, (SELECT '"2"')::jsonb, (SELECT '"3"')::jsonb,
|
||||
(SELECT '"4"')::jsonb, (SELECT '"5"')::jsonb, (SELECT '"6"')::jsonb,
|
||||
(SELECT '"7"')::jsonb, (SELECT '"8"')::jsonb, (SELECT '"9"')::jsonb,
|
||||
(SELECT '"10"')::jsonb]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
----------------------------------------------------------------------+-------
|
||||
SELECT * FROM test_squash_jsonb WHERE data IN +| 2
|
||||
((SELECT $1)::jsonb, (SELECT $2)::jsonb, (SELECT $3)::jsonb,+|
|
||||
(SELECT $4)::jsonb, (SELECT $5)::jsonb, (SELECT $6)::jsonb,+|
|
||||
(SELECT $7)::jsonb, (SELECT $8)::jsonb, (SELECT $9)::jsonb,+|
|
||||
(SELECT $10)::jsonb) |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- Multiple CoerceViaIO are squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT WHERE 1 IN (1::text::int::text::int, 1::text::int::text::int);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT WHERE 1 = ANY(ARRAY[1::text::int::text::int, 1::text::int::text::int]);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT WHERE $1 IN ($2 /*, ... */) | 2
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
--
|
||||
-- RelabelType
|
||||
--
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- However many layers of RelabelType there are, the list will be squashable.
|
||||
SELECT * FROM test_squash WHERE id IN
|
||||
(1::oid, 2::oid, 3::oid, 4::oid, 5::oid, 6::oid, 7::oid, 8::oid, 9::oid);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT ARRAY[1::oid, 2::oid, 3::oid, 4::oid, 5::oid, 6::oid, 7::oid, 8::oid, 9::oid];
|
||||
array
|
||||
---------------------
|
||||
{1,2,3,4,5,6,7,8,9}
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_squash WHERE id IN (1::oid, 2::oid::int::oid);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY[1::oid, 2::oid::int::oid]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
-- RelabelType together with CoerceViaIO is also squashable
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY[1::oid::text::int::oid, 2::oid::int::oid]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY[1::text::int::oid, 2::oid::int::oid]);
|
||||
id | data
|
||||
----+------
|
||||
(0 rows)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT * FROM test_squash WHERE id IN +| 5
|
||||
($1 /*, ... */) |
|
||||
SELECT ARRAY[$1 /*, ... */] | 1
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(3 rows)
|
||||
|
||||
--
|
||||
-- edge cases
|
||||
--
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- for nested arrays, only constants are squashed
|
||||
SELECT ARRAY[
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
];
|
||||
array
|
||||
-----------------------------------------------------------------------------------------------
|
||||
{{1,2,3,4,5,6,7,8,9,10},{1,2,3,4,5,6,7,8,9,10},{1,2,3,4,5,6,7,8,9,10},{1,2,3,4,5,6,7,8,9,10}}
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT ARRAY[ +| 1
|
||||
ARRAY[$1 /*, ... */], +|
|
||||
ARRAY[$2 /*, ... */], +|
|
||||
ARRAY[$3 /*, ... */], +|
|
||||
ARRAY[$4 /*, ... */] +|
|
||||
] |
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
(2 rows)
|
||||
|
||||
-- Test constants evaluation in a CTE, which was causing issues in the past
|
||||
WITH cte AS (
|
||||
SELECT 'const' as const FROM test_squash
|
||||
)
|
||||
SELECT ARRAY['a', 'b', 'c', const::varchar] AS result
|
||||
FROM cte;
|
||||
result
|
||||
--------
|
||||
(0 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- Rewritten as an OpExpr, so it will not be squashed
|
||||
select where '1' IN ('1'::int, '2'::int::text);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
-- Rewritten as an ArrayExpr, so it will be squashed
|
||||
select where '1' IN ('1'::int, '2'::int);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
select where $1 IN ($2 /*, ... */) | 1
|
||||
select where $1 IN ($2::int, $3::int::text) | 1
|
||||
(3 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
t
|
||||
---
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- Both of these queries will be rewritten as an ArrayExpr, so they
|
||||
-- will be squashed, and have a similar queryId
|
||||
select where '1' IN ('1'::int::text, '2'::int::text);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
select where '1' = ANY (array['1'::int::text, '2'::int::text]);
|
||||
--
|
||||
(1 row)
|
||||
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls
|
||||
-------------------------------------------------+-------
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t | 1
|
||||
select where $1 IN ($2 /*, ... */) | 2
|
||||
(2 rows)
|
||||
|
||||
--
|
||||
-- cleanup
|
||||
--
|
||||
DROP TABLE test_squash;
|
||||
DROP TABLE test_float;
|
||||
DROP TABLE test_squash_numeric;
|
||||
DROP TABLE test_squash_bigint;
|
||||
DROP TABLE test_squash_cast CASCADE;
|
||||
DROP TABLE test_squash_jsonb;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -42,6 +42,19 @@ SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|||
SELECT pg_stat_monitor_reset() |
|
||||
(5 rows)
|
||||
|
||||
-- make sure that we handle nested queries correctly
|
||||
BEGIN;
|
||||
DO $$
|
||||
DECLARE
|
||||
i int;
|
||||
BEGIN
|
||||
-- default stack limit is 2000kB, 50000 is much larger than that
|
||||
FOR i IN 1..50000 LOOP
|
||||
EXECUTE format('SELECT %s', i);
|
||||
END LOOP;
|
||||
END;
|
||||
$$;
|
||||
COMMIT;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
|
|
|||
|
|
@ -42,6 +42,19 @@ SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|||
SELECT pg_stat_monitor_reset() |
|
||||
(5 rows)
|
||||
|
||||
-- make sure that we handle nested queries correctly
|
||||
BEGIN;
|
||||
DO $$
|
||||
DECLARE
|
||||
i int;
|
||||
BEGIN
|
||||
-- default stack limit is 2000kB, 50000 is much larger than that
|
||||
FOR i IN 1..50000 LOOP
|
||||
EXECUTE format('SELECT %s', i);
|
||||
END LOOP;
|
||||
END;
|
||||
$$;
|
||||
COMMIT;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ CREATE EXTENSION pg_stat_monitor;
|
|||
SELECT pg_stat_monitor_version();
|
||||
pg_stat_monitor_version
|
||||
-------------------------
|
||||
2.0.2
|
||||
2.3.1
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
SELECT 1 AS num;
|
||||
SELECT query,application_name FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
SELECT 1 AS num;
|
||||
SET pg_stat_monitor.pgsm_track_application_names='no';
|
||||
SELECT 1 AS num;
|
||||
SELECT query,application_name FROM pg_stat_monitor ORDER BY query, application_name COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
i integer;
|
||||
BEGIN
|
||||
FOR i IN 10..24 LOOP
|
||||
RAISE NOTICE 'error_code: %, error_level: %', i, decode_error_level(i);
|
||||
END LOOP;
|
||||
END $$;
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_track='all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
CREATE OR REPLACE FUNCTION test() RETURNS VOID AS
|
||||
$$
|
||||
BEGIN
|
||||
PERFORM 1 + 2;
|
||||
END; $$ language plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION test2() RETURNS VOID AS
|
||||
$$
|
||||
BEGIN
|
||||
PERFORM 1 + 2;
|
||||
END; $$ language plpgsql;
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
SELECT test();
|
||||
SELECT test2();
|
||||
|
||||
SELECT 1 + 2;
|
||||
SELECT left(query, 15) as query, calls, top_query, pgsm_query_id FROM pg_stat_monitor ORDER BY query, top_query COLLATE "C";
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
--
|
||||
-- Statement level tracking
|
||||
--
|
||||
|
||||
SELECT setting::integer < 140000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_track_utility = TRUE;
|
||||
SET pg_stat_monitor.pgsm_normalized_query = TRUE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
-- DO block - top-level tracking.
|
||||
CREATE TABLE stats_track_tab (x int);
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
WHERE query LIKE '%DELETE%' ORDER BY query COLLATE "C", toplevel;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
-- DO block - all-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
|
||||
-- DO block - top-level tracking without utility.
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
SET pg_stat_monitor.pgsm_track_utility = FALSE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
|
||||
-- DO block - all-level tracking without utility.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DELETE FROM stats_track_tab;
|
||||
DO $$
|
||||
BEGIN
|
||||
DELETE FROM stats_track_tab;
|
||||
END; $$;
|
||||
DO LANGUAGE plpgsql $$
|
||||
BEGIN
|
||||
-- this is a SELECT
|
||||
PERFORM 'hello world'::TEXT;
|
||||
END; $$;
|
||||
SELECT toplevel, calls, query FROM pg_stat_monitor
|
||||
ORDER BY query COLLATE "C", toplevel;
|
||||
|
||||
-- PL/pgSQL function - top-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'top';
|
||||
SET pg_stat_monitor.pgsm_track_utility = FALSE;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
||||
DECLARE
|
||||
r INTEGER;
|
||||
BEGIN
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
||||
RETURN r;
|
||||
END; $$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT PLUS_TWO(3);
|
||||
SELECT PLUS_TWO(7);
|
||||
|
||||
-- SQL function --- use LIMIT to keep it from being inlined
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
||||
|
||||
SELECT PLUS_ONE(8);
|
||||
SELECT PLUS_ONE(10);
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- immutable SQL function --- can be executed at plan time
|
||||
CREATE FUNCTION PLUS_THREE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT i + 3 LIMIT 1 $$ IMMUTABLE LANGUAGE SQL;
|
||||
|
||||
SELECT PLUS_THREE(8);
|
||||
SELECT PLUS_THREE(10);
|
||||
|
||||
SELECT toplevel, calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- PL/pgSQL function - all-level tracking.
|
||||
SET pg_stat_monitor.pgsm_track = 'all';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
-- we drop and recreate the functions to avoid any caching funnies
|
||||
DROP FUNCTION PLUS_ONE(INTEGER);
|
||||
DROP FUNCTION PLUS_TWO(INTEGER);
|
||||
DROP FUNCTION PLUS_THREE(INTEGER);
|
||||
|
||||
-- PL/pgSQL function
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$
|
||||
DECLARE
|
||||
r INTEGER;
|
||||
BEGIN
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r;
|
||||
RETURN r;
|
||||
END; $$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT PLUS_TWO(-1);
|
||||
SELECT PLUS_TWO(2);
|
||||
|
||||
-- SQL function --- use LIMIT to keep it from being inlined
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
|
||||
|
||||
SELECT PLUS_ONE(3);
|
||||
SELECT PLUS_ONE(1);
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- immutable SQL function --- can be executed at plan time
|
||||
CREATE FUNCTION PLUS_THREE(i INTEGER) RETURNS INTEGER AS
|
||||
$$ SELECT i + 3 LIMIT 1 $$ IMMUTABLE LANGUAGE SQL;
|
||||
|
||||
SELECT PLUS_THREE(8);
|
||||
SELECT PLUS_THREE(10);
|
||||
|
||||
SELECT toplevel, calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- pg_stat_monitor.pgsm_track = none
|
||||
--
|
||||
SET pg_stat_monitor.pgsm_track = 'none';
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
SELECT 1 AS "one";
|
||||
SELECT 1 + 1 AS "two";
|
||||
|
||||
SELECT calls, rows, query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset();
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
--
|
||||
-- Tests for parallel statistics
|
||||
--
|
||||
|
||||
SELECT setting::integer < 180000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pgsm.track_utility = FALSE;
|
||||
|
||||
-- encourage use of parallel plans
|
||||
SET parallel_setup_cost = 0;
|
||||
SET parallel_tuple_cost = 0;
|
||||
SET min_parallel_table_scan_size = 0;
|
||||
SET max_parallel_workers_per_gather = 2;
|
||||
|
||||
CREATE TABLE pgsm_parallel_tab (a int);
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
|
||||
SELECT count(*) FROM pgsm_parallel_tab;
|
||||
|
||||
SELECT query,
|
||||
parallel_workers_to_launch > 0 AS has_workers_to_launch,
|
||||
parallel_workers_launched > 0 AS has_workers_launched
|
||||
FROM pg_stat_monitor
|
||||
WHERE query ~ 'SELECT count'
|
||||
ORDER BY query COLLATE "C";
|
||||
|
||||
DROP TABLE pgsm_parallel_tab;
|
||||
|
|
@ -0,0 +1,312 @@
|
|||
--
|
||||
-- Const squashing functionality
|
||||
--
|
||||
|
||||
SELECT setting::integer < 180000 AS skip_test FROM pg_settings where name = 'server_version_num' \gset
|
||||
\if :skip_test
|
||||
\quit
|
||||
\endif
|
||||
|
||||
CREATE EXTENSION pg_stat_monitor;
|
||||
SET pg_stat_monitor.pgsm_normalized_query = TRUE;
|
||||
|
||||
--
|
||||
-- Simple Lists
|
||||
--
|
||||
|
||||
CREATE TABLE test_squash (id int, data int);
|
||||
|
||||
-- single element will not be squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash WHERE id IN (1);
|
||||
SELECT ARRAY[1];
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- more than 1 element in a list will be squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3);
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4);
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5);
|
||||
SELECT ARRAY[1, 2, 3];
|
||||
SELECT ARRAY[1, 2, 3, 4];
|
||||
SELECT ARRAY[1, 2, 3, 4, 5];
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- built-in functions will be squashed
|
||||
-- the IN and ARRAY forms of this statement will have the same queryId
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT WHERE 1 IN (1, int4(1), int4(2), 2);
|
||||
SELECT WHERE 1 = ANY (ARRAY[1, int4(1), int4(2), 2]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- This tests are disabled due bug in PGSM, see: https://perconadev.atlassian.net/browse/PG-1936
|
||||
-- -- external parameters will be squashed
|
||||
-- SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5) \bind 1 2 3 4 5
|
||||
-- ;
|
||||
-- SELECT * FROM test_squash WHERE id::text = ANY(ARRAY[$1, $2, $3, $4, $5]) \bind 1 2 3 4 5
|
||||
-- ;
|
||||
-- SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- -- prepared statements will also be squashed
|
||||
-- -- the IN and ARRAY forms of this statement will have the same queryId
|
||||
-- SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- PREPARE p1(int, int, int, int, int) AS
|
||||
-- SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5);
|
||||
-- EXECUTE p1(1, 2, 3, 4, 5);
|
||||
-- DEALLOCATE p1;
|
||||
-- PREPARE p1(int, int, int, int, int) AS
|
||||
-- SELECT * FROM test_squash WHERE id = ANY(ARRAY[$1, $2, $3, $4, $5]);
|
||||
-- EXECUTE p1(1, 2, 3, 4, 5);
|
||||
-- DEALLOCATE p1;
|
||||
-- SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- More conditions in the query
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND data = 2;
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND data = 2;
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) AND data = 2;
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9]) AND data = 2;
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) AND data = 2;
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) AND data = 2;
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Multiple squashed intervals
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
AND data IN (1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
AND data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
SELECT * FROM test_squash WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
|
||||
AND data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
AND data = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
AND data = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
||||
SELECT * FROM test_squash WHERE id = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
AND data = ANY (ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
|
||||
-- No constants squashing for OpExpr
|
||||
-- The IN and ARRAY forms of this statement will have the same queryId
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash WHERE id IN
|
||||
(1 + 1, 2 + 2, 3 + 3, 4 + 4, 5 + 5, 6 + 6, 7 + 7, 8 + 8, 9 + 9);
|
||||
SELECT * FROM test_squash WHERE id IN
|
||||
(@ '-1', @ '-2', @ '-3', @ '-4', @ '-5', @ '-6', @ '-7', @ '-8', @ '-9');
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY
|
||||
[1 + 1, 2 + 2, 3 + 3, 4 + 4, 5 + 5, 6 + 6, 7 + 7, 8 + 8, 9 + 9]);
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY
|
||||
[@ '-1', @ '-2', @ '-3', @ '-4', @ '-5', @ '-6', @ '-7', @ '-8', @ '-9']);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- FuncExpr
|
||||
--
|
||||
|
||||
-- Verify multiple type representation end up with the same query_id
|
||||
CREATE TABLE test_float (data float);
|
||||
-- The casted ARRAY expressions will have the same queryId as the IN clause
|
||||
-- form of the query
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT data FROM test_float WHERE data IN (1, 2);
|
||||
SELECT data FROM test_float WHERE data IN (1, '2');
|
||||
SELECT data FROM test_float WHERE data IN ('1', 2);
|
||||
SELECT data FROM test_float WHERE data IN ('1', '2');
|
||||
SELECT data FROM test_float WHERE data IN (1.0, 1.0);
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY['1'::double precision, '2'::double precision]);
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[1.0::double precision, 1.0::double precision]);
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[1, 2]);
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY[1, '2']);
|
||||
SELECT data FROM test_float WHERE data = ANY(ARRAY['1', 2]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Numeric type, implicit cast is squashed
|
||||
CREATE TABLE test_squash_numeric (id int, data numeric(5, 2));
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_numeric WHERE data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
SELECT * FROM test_squash_numeric WHERE data = ANY(ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Bigint, implicit cast is squashed
|
||||
CREATE TABLE test_squash_bigint (id int, data bigint);
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_bigint WHERE data IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
SELECT * FROM test_squash_bigint WHERE data = ANY(ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Bigint, explicit cast is squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_bigint WHERE data IN
|
||||
(1::bigint, 2::bigint, 3::bigint, 4::bigint, 5::bigint, 6::bigint,
|
||||
7::bigint, 8::bigint, 9::bigint, 10::bigint, 11::bigint);
|
||||
SELECT * FROM test_squash_bigint WHERE data = ANY(ARRAY[
|
||||
1::bigint, 2::bigint, 3::bigint, 4::bigint, 5::bigint, 6::bigint,
|
||||
7::bigint, 8::bigint, 9::bigint, 10::bigint, 11::bigint]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Bigint, long tokens with parenthesis, will not squash
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_bigint WHERE id IN
|
||||
(abs(100), abs(200), abs(300), abs(400), abs(500), abs(600), abs(700),
|
||||
abs(800), abs(900), abs(1000), ((abs(1100))));
|
||||
SELECT * FROM test_squash_bigint WHERE id = ANY(ARRAY[
|
||||
abs(100), abs(200), abs(300), abs(400), abs(500), abs(600), abs(700),
|
||||
abs(800), abs(900), abs(1000), ((abs(1100)))]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Multiple FuncExpr's. Will not squash
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT WHERE 1 IN (1::int::bigint::int, 2::int::bigint::int);
|
||||
SELECT WHERE 1 = ANY(ARRAY[1::int::bigint::int, 2::int::bigint::int]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- CoerceViaIO
|
||||
--
|
||||
|
||||
-- Create some dummy type to force CoerceViaIO
|
||||
CREATE TYPE casttesttype;
|
||||
|
||||
CREATE FUNCTION casttesttype_in(cstring)
|
||||
RETURNS casttesttype
|
||||
AS 'textin'
|
||||
LANGUAGE internal STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION casttesttype_out(casttesttype)
|
||||
RETURNS cstring
|
||||
AS 'textout'
|
||||
LANGUAGE internal STRICT IMMUTABLE;
|
||||
|
||||
CREATE TYPE casttesttype (
|
||||
internallength = variable,
|
||||
input = casttesttype_in,
|
||||
output = casttesttype_out,
|
||||
alignment = int4
|
||||
);
|
||||
|
||||
CREATE CAST (int4 AS casttesttype) WITH INOUT;
|
||||
|
||||
CREATE FUNCTION casttesttype_eq(casttesttype, casttesttype)
|
||||
returns boolean language sql immutable as $$
|
||||
SELECT true
|
||||
$$;
|
||||
|
||||
CREATE OPERATOR = (
|
||||
leftarg = casttesttype,
|
||||
rightarg = casttesttype,
|
||||
procedure = casttesttype_eq,
|
||||
commutator = =);
|
||||
|
||||
CREATE TABLE test_squash_cast (id int, data casttesttype);
|
||||
|
||||
-- Use the introduced type to construct a list of CoerceViaIO around Const
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_cast WHERE data IN
|
||||
(1::int4::casttesttype, 2::int4::casttesttype, 3::int4::casttesttype,
|
||||
4::int4::casttesttype, 5::int4::casttesttype, 6::int4::casttesttype,
|
||||
7::int4::casttesttype, 8::int4::casttesttype, 9::int4::casttesttype,
|
||||
10::int4::casttesttype, 11::int4::casttesttype);
|
||||
SELECT * FROM test_squash_cast WHERE data = ANY (ARRAY
|
||||
[1::int4::casttesttype, 2::int4::casttesttype, 3::int4::casttesttype,
|
||||
4::int4::casttesttype, 5::int4::casttesttype, 6::int4::casttesttype,
|
||||
7::int4::casttesttype, 8::int4::casttesttype, 9::int4::casttesttype,
|
||||
10::int4::casttesttype, 11::int4::casttesttype]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Some casting expression are simplified to Const
|
||||
CREATE TABLE test_squash_jsonb (id int, data jsonb);
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_jsonb WHERE data IN
|
||||
(('"1"')::jsonb, ('"2"')::jsonb, ('"3"')::jsonb, ('"4"')::jsonb,
|
||||
('"5"')::jsonb, ('"6"')::jsonb, ('"7"')::jsonb, ('"8"')::jsonb,
|
||||
('"9"')::jsonb, ('"10"')::jsonb);
|
||||
SELECT * FROM test_squash_jsonb WHERE data = ANY (ARRAY
|
||||
[('"1"')::jsonb, ('"2"')::jsonb, ('"3"')::jsonb, ('"4"')::jsonb,
|
||||
('"5"')::jsonb, ('"6"')::jsonb, ('"7"')::jsonb, ('"8"')::jsonb,
|
||||
('"9"')::jsonb, ('"10"')::jsonb]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- CoerceViaIO, SubLink instead of a Const. Will not squash
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash_jsonb WHERE data IN
|
||||
((SELECT '"1"')::jsonb, (SELECT '"2"')::jsonb, (SELECT '"3"')::jsonb,
|
||||
(SELECT '"4"')::jsonb, (SELECT '"5"')::jsonb, (SELECT '"6"')::jsonb,
|
||||
(SELECT '"7"')::jsonb, (SELECT '"8"')::jsonb, (SELECT '"9"')::jsonb,
|
||||
(SELECT '"10"')::jsonb);
|
||||
SELECT * FROM test_squash_jsonb WHERE data = ANY(ARRAY
|
||||
[(SELECT '"1"')::jsonb, (SELECT '"2"')::jsonb, (SELECT '"3"')::jsonb,
|
||||
(SELECT '"4"')::jsonb, (SELECT '"5"')::jsonb, (SELECT '"6"')::jsonb,
|
||||
(SELECT '"7"')::jsonb, (SELECT '"8"')::jsonb, (SELECT '"9"')::jsonb,
|
||||
(SELECT '"10"')::jsonb]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Multiple CoerceViaIO are squashed
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
SELECT WHERE 1 IN (1::text::int::text::int, 1::text::int::text::int);
|
||||
SELECT WHERE 1 = ANY(ARRAY[1::text::int::text::int, 1::text::int::text::int]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- RelabelType
|
||||
--
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- However many layers of RelabelType there are, the list will be squashable.
|
||||
SELECT * FROM test_squash WHERE id IN
|
||||
(1::oid, 2::oid, 3::oid, 4::oid, 5::oid, 6::oid, 7::oid, 8::oid, 9::oid);
|
||||
SELECT ARRAY[1::oid, 2::oid, 3::oid, 4::oid, 5::oid, 6::oid, 7::oid, 8::oid, 9::oid];
|
||||
SELECT * FROM test_squash WHERE id IN (1::oid, 2::oid::int::oid);
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY[1::oid, 2::oid::int::oid]);
|
||||
-- RelabelType together with CoerceViaIO is also squashable
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY[1::oid::text::int::oid, 2::oid::int::oid]);
|
||||
SELECT * FROM test_squash WHERE id = ANY(ARRAY[1::text::int::oid, 2::oid::int::oid]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- edge cases
|
||||
--
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- for nested arrays, only constants are squashed
|
||||
SELECT ARRAY[
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
];
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- Test constants evaluation in a CTE, which was causing issues in the past
|
||||
WITH cte AS (
|
||||
SELECT 'const' as const FROM test_squash
|
||||
)
|
||||
SELECT ARRAY['a', 'b', 'c', const::varchar] AS result
|
||||
FROM cte;
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- Rewritten as an OpExpr, so it will not be squashed
|
||||
select where '1' IN ('1'::int, '2'::int::text);
|
||||
-- Rewritten as an ArrayExpr, so it will be squashed
|
||||
select where '1' IN ('1'::int, '2'::int);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
SELECT pg_stat_monitor_reset() IS NOT NULL AS t;
|
||||
-- Both of these queries will be rewritten as an ArrayExpr, so they
|
||||
-- will be squashed, and have a similar queryId
|
||||
select where '1' IN ('1'::int::text, '2'::int::text);
|
||||
select where '1' = ANY (array['1'::int::text, '2'::int::text]);
|
||||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- cleanup
|
||||
--
|
||||
DROP TABLE test_squash;
|
||||
DROP TABLE test_float;
|
||||
DROP TABLE test_squash_numeric;
|
||||
DROP TABLE test_squash_bigint;
|
||||
DROP TABLE test_squash_cast CASCADE;
|
||||
DROP TABLE test_squash_jsonb;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
@ -16,5 +16,22 @@ $$ language plpgsql;
|
|||
|
||||
SELECT add2(1,2);
|
||||
SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
|
||||
-- make sure that we handle nested queries correctly
|
||||
|
||||
BEGIN;
|
||||
DO $$
|
||||
DECLARE
|
||||
i int;
|
||||
BEGIN
|
||||
-- default stack limit is 2000kB, 50000 is much larger than that
|
||||
FOR i IN 1..50000 LOOP
|
||||
EXECUTE format('SELECT %s', i);
|
||||
END LOOP;
|
||||
END;
|
||||
$$;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ my $pgdata = $node->data_dir;
|
|||
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||
print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
||||
print $conf "pg_stat_monitor.pgsm_bucket_time = 360000\n";
|
||||
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n";
|
||||
print $conf "pg_stat_monitor.pgsm_query_shared_buffer = 1\n"; # Min possible value
|
||||
print $conf "pg_stat_monitor.pgsm_normalized_query = 'yes'\n";
|
||||
close $conf;
|
||||
|
||||
|
|
@ -109,6 +109,29 @@ ok($cmdret == 0, "Run pgbench");
|
|||
ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_query_shared_buffer = 2048\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");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name='pg_stat_monitor.pgsm_query_shared_buffer';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "Print PGSM EXTENSION Settings");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
$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,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "DROP PGSM EXTENSION");
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ my $pgdata = $node->data_dir;
|
|||
# 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";
|
||||
print $conf "pg_stat_monitor.pgsm_max = 2048\n";
|
||||
close $conf;
|
||||
|
||||
# Start server
|
||||
|
|
@ -62,7 +62,7 @@ PGSM::append_to_file($stdout);
|
|||
ok($cmdret == 0, "Print PGSM EXTENSION Settings");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 10\n");
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max = 10\n"); # Min possible value
|
||||
$node->restart();
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_stat_monitor_reset();', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,39 @@ print $conf "shared_preload_libraries = 'pg_stat_monitor'\n";
|
|||
close $conf;
|
||||
|
||||
# Dictionary for expected PGSM columns names on different PG server versions
|
||||
my %pg_versions_pgsm_columns = ( 16 => "application_name,blk_read_time," .
|
||||
my %pg_versions_pgsm_columns = ( 18 => "application_name,".
|
||||
"bucket,bucket_done,bucket_start_time,calls," .
|
||||
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
||||
"datname,dbid,elevel,jit_deform_count,jit_deform_time," .
|
||||
"jit_emission_count,jit_emission_time,jit_functions,jit_generation_time," .
|
||||
"jit_inlining_count,jit_inlining_time,jit_optimization_count,jit_optimization_time," .
|
||||
"local_blk_read_time,local_blk_write_time,local_blks_dirtied,local_blks_hit,".
|
||||
"local_blks_read,local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
||||
"mean_plan_time,message,min_exec_time,min_plan_time,minmax_stats_since," .
|
||||
"parallel_workers_launched,parallel_workers_to_launch," .
|
||||
"pgsm_query_id,planid,plans,query,query_plan,queryid,relations,resp_calls,rows," .
|
||||
"shared_blk_read_time,shared_blk_write_time,shared_blks_dirtied," .
|
||||
"shared_blks_hit,shared_blks_read,shared_blks_written,sqlcode,stats_since," .
|
||||
"stddev_exec_time,stddev_plan_time,temp_blk_read_time,temp_blk_write_time," .
|
||||
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
||||
"total_exec_time,total_plan_time,userid,username,wal_buffers_full,wal_bytes," .
|
||||
"wal_fpi,wal_records",
|
||||
17 => "application_name,".
|
||||
"bucket,bucket_done,bucket_start_time,calls," .
|
||||
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
||||
"datname,dbid,elevel,jit_deform_count,jit_deform_time," .
|
||||
"jit_emission_count,jit_emission_time,jit_functions,jit_generation_time," .
|
||||
"jit_inlining_count,jit_inlining_time,jit_optimization_count,jit_optimization_time," .
|
||||
"local_blk_read_time,local_blk_write_time,local_blks_dirtied,local_blks_hit,".
|
||||
"local_blks_read,local_blks_written,max_exec_time,max_plan_time,mean_exec_time," .
|
||||
"mean_plan_time,message,min_exec_time,min_plan_time,minmax_stats_since," .
|
||||
"pgsm_query_id,planid,plans,query,query_plan,queryid,relations,resp_calls,rows," .
|
||||
"shared_blk_read_time,shared_blk_write_time,shared_blks_dirtied," .
|
||||
"shared_blks_hit,shared_blks_read,shared_blks_written,sqlcode,stats_since," .
|
||||
"stddev_exec_time,stddev_plan_time,temp_blk_read_time,temp_blk_write_time," .
|
||||
"temp_blks_read,temp_blks_written,top_query,top_queryid,toplevel," .
|
||||
"total_exec_time,total_plan_time,userid,username,wal_bytes,wal_fpi,wal_records",
|
||||
16 => "application_name,blk_read_time," .
|
||||
"blk_write_time,bucket,bucket_done,bucket_start_time,calls," .
|
||||
"client_ip,cmd_type,cmd_type_text,comments,cpu_sys_time,cpu_user_time," .
|
||||
"datname,dbid,elevel,jit_emission_count,jit_emission_time,jit_functions," .
|
||||
|
|
|
|||
|
|
@ -35,6 +35,15 @@ $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = y
|
|||
my $rt_value = $node->start;
|
||||
ok($rt_value == 1, "Start Server");
|
||||
|
||||
my $col_shared_blk_read_time = "shared_blk_read_time";
|
||||
my $col_shared_blk_write_time = "shared_blk_write_time";
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION <= 16)
|
||||
{
|
||||
$col_shared_blk_read_time = "blk_read_time";
|
||||
$col_shared_blk_write_time = "blk_write_time";
|
||||
}
|
||||
|
||||
# CREATE EXTENSION and change out file permissions
|
||||
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_statements;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE PGSS EXTENSION");
|
||||
|
|
@ -78,16 +87,16 @@ ok($cmdret == 0, "Run pgbench");
|
|||
ok($cmdret == 0, "Run pg_sleep for 2 seconds ");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,30),calls, rows, ROUND(total_exec_time::numeric,4) AS total_exec_time, ROUND(min_exec_time::numeric,4) AS min_exec_time, ROUND(max_exec_time::numeric,4) AS max_exec_time, ROUND(mean_exec_time::numeric,4) AS mean_exec_time, ROUND(stddev_exec_time::numeric,4) AS stddev_exec_time, ROUND(blk_read_time::numeric,4) AS blk_read_time, ROUND(blk_write_time::numeric,4) AS blk_write_time FROM pg_stat_statements WHERE query LIKE \'%bench%\' ORDER BY query,calls DESC;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT substr(query,0,30),calls, rows, ROUND(total_exec_time::numeric,4) AS total_exec_time, ROUND(min_exec_time::numeric,4) AS min_exec_time, ROUND(max_exec_time::numeric,4) AS max_exec_time, ROUND(mean_exec_time::numeric,4) AS mean_exec_time, ROUND(stddev_exec_time::numeric,4) AS stddev_exec_time, ROUND(${col_shared_blk_read_time}::numeric,4) AS ${col_shared_blk_read_time}, ROUND(${col_shared_blk_write_time}::numeric,4) AS ${col_shared_blk_write_time} FROM pg_stat_statements WHERE query LIKE '%bench%' ORDER BY query,calls DESC;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT bucket, bucket_start_time, queryid, substr(query,0,30) AS query, calls, rows, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time, ROUND(blk_read_time::numeric,4) AS blk_read_time, ROUND(blk_write_time::numeric,4) AS blk_write_time, cpu_user_time, cpu_sys_time FROM pg_stat_monitor WHERE query LIKE \'%bench%\' ORDER BY query,calls DESC;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT bucket, bucket_start_time, queryid, substr(query,0,30) AS query, calls, rows, total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time, ROUND(${col_shared_blk_read_time}::numeric,4) AS ${col_shared_blk_read_time}, ROUND(${col_shared_blk_write_time}::numeric,4) AS ${col_shared_blk_write_time}, cpu_user_time, cpu_sys_time FROM pg_stat_monitor WHERE query LIKE '%bench%' ORDER BY query,calls DESC;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,30) AS query,calls,rows,wal_records,wal_fpi,wal_bytes FROM pg_stat_statements WHERE query LIKE \'%bench%\' ORDER BY query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,30) AS query,calls,rows,wal_records,wal_fpi,wal_bytes,wal_buffers_full FROM pg_stat_statements WHERE query LIKE \'%bench%\' ORDER BY query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT bucket, bucket_start_time, substr(query,0,30) AS query,calls, rows, wal_records,wal_fpi,wal_bytes, cmd_type_text FROM pg_stat_monitor WHERE query LIKE \'%bench%\' ORDER BY query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT bucket, bucket_start_time, substr(query,0,30) AS query,calls, rows, wal_records,wal_fpi,wal_bytes,wal_buffers_full, cmd_type_text FROM pg_stat_monitor WHERE query LIKE \'%bench%\' ORDER BY query,calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Compare values for query 'DELETE FROM pgbench_accounts WHERE $1 = $2'
|
||||
|
|
@ -131,6 +140,21 @@ is($stdout,'t',"Compare: wal_fpi is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_bytes are equal.");
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION >= 18)
|
||||
{
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_buffers_full) = SUM(PGSS.wal_buffers_full) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_buffers_full are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_to_launch) = SUM(PGSS.parallel_workers_to_launch) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_to_launch are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_launched) = SUM(PGSS.parallel_workers_launched) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_launched are equal.");
|
||||
}
|
||||
|
||||
# Compare values for query 'INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP)'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.calls) = SUM(PGSS.calls) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
|
|
@ -160,13 +184,13 @@ is($stdout,'t',"Compare: mean_exec_time is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(ROUND(PGSM.blk_read_time::numeric,4)) = SUM(ROUND(PGSS.blk_read_time::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_read_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_read_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: blk_read_time is equal.");
|
||||
is($stdout,'t',"Compare: ${col_shared_blk_read_time} is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(ROUND(PGSM.blk_write_time::numeric,4)) = SUM(ROUND(PGSS.blk_write_time::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_write_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: blk_write_time is equal.");
|
||||
is($stdout,'t',"Compare: ${col_shared_blk_write_time} is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
|
|
@ -180,6 +204,21 @@ is($stdout,'t',"Compare: wal_fpi is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_bytes are equal.");
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION >= 18)
|
||||
{
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_buffers_full) = SUM(PGSS.wal_buffers_full) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_buffers_full are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_to_launch) = SUM(PGSS.parallel_workers_to_launch) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_to_launch are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_launched) = SUM(PGSS.parallel_workers_launched) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_launched are equal.");
|
||||
}
|
||||
|
||||
# Compare values for query 'SELECT abalance FROM pgbench_accounts WHERE aid = $1'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.calls) = SUM(PGSS.calls) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
|
|
@ -209,13 +248,13 @@ is($stdout,'t',"Compare: mean_exec_time is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(ROUND(PGSM.blk_read_time::numeric,4)) = SUM(ROUND(PGSS.blk_read_time::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_read_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_read_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: blk_read_time is equal.");
|
||||
is($stdout,'t',"Compare: ${col_shared_blk_read_time} is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(ROUND(PGSM.blk_write_time::numeric,4)) = SUM(ROUND(PGSS.blk_write_time::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_write_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: blk_write_time is equal.");
|
||||
is($stdout,'t',"Compare: ${col_shared_blk_write_time} is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
|
|
@ -229,6 +268,21 @@ is($stdout,'t',"Compare: wal_fpi is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_bytes are equal.");
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION >= 18)
|
||||
{
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_buffers_full) = SUM(PGSS.wal_buffers_full) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_buffers_full are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_to_launch) = SUM(PGSS.parallel_workers_to_launch) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_to_launch are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_launched) = SUM(PGSS.parallel_workers_launched) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%SELECT abalance FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_launched are equal.");
|
||||
}
|
||||
|
||||
# Compare values for query 'UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.calls) = SUM(PGSS.calls) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
|
|
@ -258,9 +312,9 @@ is($stdout,'t',"Compare: mean_exec_time is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: stddev_exec_time is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(ROUND(PGSM.blk_write_time::numeric,4)) = SUM(ROUND(PGSS.blk_write_time::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(ROUND(PGSM.${col_shared_blk_write_time}::numeric,4)) = SUM(ROUND(PGSS.${col_shared_blk_write_time}::numeric,4)) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: blk_write_time is equal.");
|
||||
is($stdout,'t',"Compare: ${col_shared_blk_write_time} is equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_records) = SUM(PGSS.wal_records) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
|
|
@ -274,6 +328,21 @@ is($stdout,'t',"Compare: wal_fpi is equal.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_bytes are equal.");
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION >= 18)
|
||||
{
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.wal_buffers_full) = SUM(PGSS.wal_buffers_full) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: wal_buffers_full are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_to_launch) = SUM(PGSS.parallel_workers_to_launch) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_to_launch are equal.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.parallel_workers_launched) = SUM(PGSS.parallel_workers_launched) FROM pg_stat_monitor AS PGSM INNER JOIN pg_stat_statements AS PGSS ON PGSS.query = PGSM.query WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Compare: parallel_workers_launched are equal.");
|
||||
}
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "DROP PGSM EXTENSION");
|
||||
|
|
|
|||
|
|
@ -35,6 +35,15 @@ $node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = y
|
|||
my $rt_value = $node->start;
|
||||
ok($rt_value == 1, "Start Server");
|
||||
|
||||
my $col_shared_blk_read_time = "shared_blk_read_time";
|
||||
my $col_shared_blk_write_time = "shared_blk_write_time";
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION <= 16)
|
||||
{
|
||||
$col_shared_blk_read_time = "blk_read_time";
|
||||
$col_shared_blk_write_time = "blk_write_time";
|
||||
}
|
||||
|
||||
# CREATE EXTENSION and change out file permissions
|
||||
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_statements;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE PGSS EXTENSION");
|
||||
|
|
@ -86,7 +95,7 @@ PGSM::append_to_debug_file($stdout);
|
|||
PGSM::append_to_debug_file($stdout);
|
||||
PGSM::append_to_debug_file("--------");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT substr(query,0,130) AS query, calls, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, blk_read_time, blk_write_time FROM pg_stat_monitor WHERE query LIKE \'%bench%\' ORDER BY query,calls DESC;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT substr(query,0,130) AS query, calls, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, ${col_shared_blk_read_time}, ${col_shared_blk_write_time} FROM pg_stat_monitor WHERE query LIKE '%bench%' ORDER BY query,calls DESC;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Compare values for query 'DELETE FROM pgbench_accounts WHERE $1 = $2'
|
||||
|
|
@ -106,13 +115,13 @@ is($stdout,'t',"Check: shared_blks_dirtied should not be 0.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_read_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%DELETE FROM pgbench_accounts%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: blk_read_time should not be 0.");
|
||||
is($stdout,'t',"Check: ${col_shared_blk_read_time} should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%DELETE FROM pgbench_accounts%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_write_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%DELETE FROM pgbench_accounts%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: blk_write_time should not be 0.");
|
||||
is($stdout,'t',"Check: ${col_shared_blk_write_time} should not be 0.");
|
||||
|
||||
# Compare values for query 'INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP)'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.shared_blks_hit) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
|
|
@ -127,9 +136,9 @@ is($stdout,'t',"Check: shared_blks_dirtied should not be 0.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO pgbench_history%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_write_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%INSERT INTO pgbench_history%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: blk_write_time should not be 0.");
|
||||
is($stdout,'t',"Check: ${col_shared_blk_write_time} should not be 0.");
|
||||
|
||||
# Compare values for query 'UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.shared_blks_hit) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
|
|
@ -148,13 +157,13 @@ is($stdout,'t',"Check: shared_blks_dirtied should not be 0.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Check: shared_blks_written should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT SUM(PGSM.${col_shared_blk_read_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%UPDATE pgbench_accounts SET abalance%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: blk_read_time should not be 0.");
|
||||
is($stdout,'t',"Check: ${col_shared_blk_read_time} should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres','SELECT SUM(PGSM.blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%UPDATE pgbench_accounts SET abalance%\' GROUP BY PGSM.query;', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres',"SELECT SUM(PGSM.${col_shared_blk_write_time}) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE '%UPDATE pgbench_accounts SET abalance%' GROUP BY PGSM.query;", extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: blk_write_time should not be 0.");
|
||||
is($stdout,'t',"Check: ${col_shared_blk_write_time} should not be 0.");
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
|
|
|
|||
|
|
@ -70,10 +70,26 @@ is($stdout,'t',"Check: local_blks_hit should not be 0.");
|
|||
trim($stdout);
|
||||
is($stdout,'t',"Check: local_blks_dirtied should not be 0.");
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION >= 17)
|
||||
{
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.local_blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%INSERT INTO t1%\'', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: local_blk_write_time should not be 0.");
|
||||
}
|
||||
|
||||
|
||||
# Compare values for query 'SELECT * FROM t1'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT PGSM.local_blks_hit != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: shared_blks_hit should not be 0.");
|
||||
is($stdout,'t',"Check: local_blks_hit should not be 0.");
|
||||
|
||||
# TODO: Find a way how to bypass cache and get real block reads
|
||||
# if ($PGSM::PG_MAJOR_VERSION >= 17)
|
||||
# {
|
||||
# ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.local_blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
# trim($stdout);
|
||||
# is($stdout,'t',"Check: local_blk_read_time should not be 0.");
|
||||
# }
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
|
|
|
|||
|
|
@ -85,11 +85,22 @@ PGSM::append_to_debug_file($stdout);
|
|||
# Compare values for query 'SELECT * FROM t1'
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT PGSM.temp_blks_read != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: shared_blks_hit should not be 0.");
|
||||
is($stdout,'t',"Check: temp_blks_read should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT PGSM.temp_blks_written != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: temp_blks_read should not be 0.");
|
||||
is($stdout,'t',"Check: temp_blks_written should not be 0.");
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION >= 15)
|
||||
{
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.temp_blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: temp_blk_read_time should not be 0.");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.temp_blk_write_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\'', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: temp_blk_write_time should not be 0.");
|
||||
}
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
use Test::More;
|
||||
use lib 't';
|
||||
use pgsm;
|
||||
|
||||
# Get file name and CREATE out file name and dirs WHERE requried
|
||||
PGSM::setup_files_dir(basename($0));
|
||||
|
||||
# CREATE new PostgreSQL node and do initdb
|
||||
my $node = PGSM->pgsm_init_pg();
|
||||
my $pgdata = $node->data_dir;
|
||||
|
||||
# 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 = 2147483647\n"; # Max value for this parameter
|
||||
print $conf "pg_stat_monitor.pgsm_max_buckets = 20000\n"; # Max value for this parameter
|
||||
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");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
# 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");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT 1 AS num;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "Print results of a test query");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
($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']);
|
||||
ok($cmdret == 0, "Check query stats");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "DROP PGSM EXTENSION");
|
||||
PGSM::append_to_file($stdout);
|
||||
|
||||
# Stop the server
|
||||
$node->stop;
|
||||
|
||||
# compare the expected and out file
|
||||
my $compare = PGSM->compare_results();
|
||||
|
||||
# Test/check if expected and result/out file match. If Yes, test passes.
|
||||
is($compare,0,"Compare Files: $PGSM::expected_filename_with_path and $PGSM::out_filename_with_path files.");
|
||||
|
||||
# Done testing for this testcase file.
|
||||
done_testing();
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
use Test::More;
|
||||
use lib 't';
|
||||
use pgsm;
|
||||
|
||||
# Get file name and CREATE out file name and dirs WHERE requried
|
||||
PGSM::setup_files_dir(basename($0));
|
||||
|
||||
my $PG_VERSION_STRING = `pg_config --version`;
|
||||
|
||||
if (index(lc($PG_VERSION_STRING), lc("percona")) == -1)
|
||||
{
|
||||
plan skip_all => "pg_stat_monitor test case only for PPG server package install with extensions.";
|
||||
}
|
||||
|
||||
# CREATE new PostgreSQL node and do initdb
|
||||
my $node = PGSM->pgsm_init_pg();
|
||||
my $pgdata = $node->data_dir;
|
||||
|
||||
# UPDATE postgresql.conf to include/load pg_stat_monitor library
|
||||
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||
print $conf "shared_preload_libraries = 'pg_stat_monitor, pgaudit, set_user, pg_repack'\n";
|
||||
print $conf "pg_stat_monitor.pgsm_bucket_time = 360000\n";
|
||||
print $conf "pg_stat_monitor.pgsm_normalized_query = 'yes'\n";
|
||||
close $conf;
|
||||
|
||||
# Start server
|
||||
my $rt_value = $node->start;
|
||||
ok($rt_value == 1, "Start Server");
|
||||
|
||||
# Create PGSM extension
|
||||
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE PGSM EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($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");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Create Other extensions
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pgaudit;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE pgaudit EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS set_user;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE set_user EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_repack;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE pg_repack EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SET pgaudit.log = 'none'; CREATE EXTENSION IF NOT EXISTS postgis; SET pgaudit.log = 'all';", extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE postgis EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS postgis_raster;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE postgis_raster EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE postgis_sfcgal EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE fuzzystrmatch EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS address_standardizer;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE address_standardizer EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE address_standardizer_data_us EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "CREATE postgis_tiger_geocoder EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Print PGSM settings
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name='pg_stat_monitor.pgsm_query_shared_buffer';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "Print PGSM EXTENSION Settings");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# 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");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
my $port = $node->port;
|
||||
print "port $port \n";
|
||||
|
||||
my $out = system ("pgbench -i -s 20 -p $port example");
|
||||
print " out: $out \n";
|
||||
ok($cmdret == 0, "Perform pgbench init");
|
||||
|
||||
$out = system ("pgbench -c 10 -j 2 -t 5000 -p $port example");
|
||||
print " out: $out \n";
|
||||
ok($cmdret == 0, "Run pgbench");
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls;', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "DROP PGSM EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Stop the server
|
||||
$node->stop;
|
||||
|
||||
# Done testing for this testcase file.
|
||||
done_testing();
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use File::Copy;
|
||||
use Text::Trim qw(trim);
|
||||
use Test::More;
|
||||
use lib 't';
|
||||
use pgsm;
|
||||
|
||||
# Get filename and create out file name and dirs where requried
|
||||
PGSM::setup_files_dir(basename($0));
|
||||
|
||||
if ($PGSM::PG_MAJOR_VERSION <= 16)
|
||||
{
|
||||
plan skip_all => "pg_stat_monitor test cases for versions 16 and below.";
|
||||
}
|
||||
|
||||
# Create new PostgreSQL node and do initdb
|
||||
my $node = PGSM->pgsm_init_pg();
|
||||
my $pgdata = $node->data_dir;
|
||||
|
||||
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||
$node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_stat_monitor'");
|
||||
|
||||
# Set change postgresql.conf for this test case.
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_bucket_time = 1");
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_max_buckets = 3");
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_normalized_query = yes");
|
||||
$node->append_conf('postgresql.conf', "pg_stat_monitor.pgsm_track = 'all'");
|
||||
|
||||
# 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");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Run 'SELECT pg_stat_monitor settings' and dump output to out file
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name LIKE '%pg_stat_monitor%';", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "Print PGSM EXTENSION Settings");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# 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");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_sleep(1);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "1 - Run pg_sleep(1)");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_sleep(1);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "2 - Run pg_sleep(1)");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT pg_sleep(1);', extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($cmdret == 0, "3 - Run pg_sleep(1)");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Check that we have more than one bucket
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT COUNT(bucket) != 0 AS PGSM FROM pg_stat_monitor WHERE query LIKE '%sleep%';", extra_params => ['-t', '-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: we have more that one bucket");
|
||||
|
||||
# Check that stats timestamps are different for each query/bucket
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT COUNT(DISTINCT stats_since) = COUNT(stats_since) AS PGSM FROM pg_stat_monitor WHERE query LIKE '%sleep%';", extra_params => ['-t', '-Pformat=unaligned','-Ptuples_only=on']);
|
||||
trim($stdout);
|
||||
is($stdout,'t',"Check: for every bucket stats_since should be unique");
|
||||
|
||||
# Check that minmax_stats_since always match stats_since
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT COUNT(*) AS ST FROM pg_stat_monitor WHERE query LIKE '%sleep%' AND stats_since != minmax_stats_since;", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=off']);
|
||||
ok($stdout == 0, "Compare: Calls count is 1");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "DROP PGSM EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Stop the server
|
||||
$node->stop;
|
||||
|
||||
# Done testing for this testcase file.
|
||||
done_testing();
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use File::Compare;
|
||||
use Test::More;
|
||||
use lib 't';
|
||||
use pgsm;
|
||||
|
||||
# Get filename and create out file name and dirs where requried
|
||||
PGSM::setup_files_dir(basename($0));
|
||||
|
||||
# Create new PostgreSQL node and do initdb
|
||||
my $node = PGSM->pgsm_init_pg();
|
||||
my $pgdata = $node->data_dir;
|
||||
|
||||
# Update postgresql.conf to include/load pg_stat_monitor library
|
||||
$node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_stat_monitor'");
|
||||
|
||||
# Start server
|
||||
my $rt_value = $node->start;
|
||||
ok($rt_value == 1, "Start Server");
|
||||
|
||||
# Create EXTENSION version 2.0
|
||||
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_stat_monitor VERSION "2.0";', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "Create PGSM EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Check that we have some results for version 2.0
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * FROM pg_stat_monitor;", extra_params => ['-a']);
|
||||
ok($cmdret == 0, "Check PGSM returns some results for version 2.0");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Update EXTENSION to new version 2.1
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', 'ALTER EXTENSION pg_stat_monitor UPDATE TO "2.1";', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "Update PGSM EXTENSION to new version");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Check that we have some results for version 2.1
|
||||
($cmdret, $stdout, $stderr) = $node->psql('postgres', "SELECT * FROM pg_stat_monitor;", extra_params => ['-a']);
|
||||
ok($cmdret == 0, "Check PGSM returns some results for version 2.1");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# DROP EXTENSION
|
||||
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']);
|
||||
ok($cmdret == 0, "DROP PGSM EXTENSION");
|
||||
PGSM::append_to_debug_file($stdout);
|
||||
|
||||
# Stop the server
|
||||
$node->stop;
|
||||
|
||||
# Done testing for this testcase file.
|
||||
done_testing();
|
||||
|
|
@ -7,7 +7,7 @@ SELECT pg_stat_monitor_reset();
|
|||
|
||||
SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name LIKE '%pg_stat_monitor%';
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -23,9 +23,10 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_planning | off | | user | bool | default | | | | off | off | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(17 rows)
|
||||
(18 rows)
|
||||
|
||||
SELECT datname, substr(query,0,100) AS query, calls FROM pg_stat_monitor ORDER BY datname, query, calls DESC Limit 20;
|
||||
datname | query | calls
|
||||
|
|
@ -36,7 +37,7 @@ SELECT datname, substr(query,0,100) AS query, calls FROM pg_stat_monitor ORDER B
|
|||
|
||||
SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name LIKE '%pg_stat_monitor%';
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -52,9 +53,10 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_planning | off | | user | bool | default | | | | off | off | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(17 rows)
|
||||
(18 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ SELECT pg_stat_monitor_reset();
|
|||
|
||||
SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name LIKE '%pg_stat_monitor%';
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -23,8 +23,9 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(16 rows)
|
||||
(17 rows)
|
||||
|
||||
SELECT datname, substr(query,0,100) AS query, calls FROM pg_stat_monitor ORDER BY datname, query, calls DESC Limit 20;
|
||||
datname | query | calls
|
||||
|
|
@ -35,7 +36,7 @@ SELECT datname, substr(query,0,100) AS query, calls FROM pg_stat_monitor ORDER B
|
|||
|
||||
SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name LIKE '%pg_stat_monitor%';
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
-------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
----------------------------------------------+---------+------+------------+---------+---------+---------+------------+----------------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_bucket_time | 60 | s | postmaster | integer | default | 1 | 2147483647 | | 60 | 60 | f
|
||||
pg_stat_monitor.pgsm_enable_overflow | on | | postmaster | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_enable_pgsm_query_id | on | | user | bool | default | | | | on | on | f
|
||||
|
|
@ -51,8 +52,9 @@ SELECT name, setting, unit, context, vartype, source, min_val, max_val, enumvals
|
|||
pg_stat_monitor.pgsm_query_max_len | 2048 | | postmaster | integer | default | 1024 | 2147483647 | | 2048 | 2048 | f
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | MB | postmaster | integer | default | 1 | 10000 | | 20 | 20 | f
|
||||
pg_stat_monitor.pgsm_track | top | | user | enum | default | | | {none,top,all} | top | top | f
|
||||
pg_stat_monitor.pgsm_track_application_names | on | | user | bool | default | | | | on | on | f
|
||||
pg_stat_monitor.pgsm_track_utility | on | | user | bool | default | | | | on | on | f
|
||||
(16 rows)
|
||||
(17 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
|
|
|
|||
|
|
@ -111,4 +111,41 @@ SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_m
|
|||
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 name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name='pg_stat_monitor.pgsm_query_shared_buffer';
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
------------------------------------------+---------+------+------------+---------+--------------------+---------+---------+----------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 2048 | MB | postmaster | integer | configuration file | 1 | 10000 | | 20 | 2048 | f
|
||||
(1 row)
|
||||
|
||||
SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20;
|
||||
datname | query | calls
|
||||
---------+---------------------------------------------------------------------------------------------------------------+-------
|
||||
example | BEGIN | 10000
|
||||
example | END | 10000
|
||||
example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000
|
||||
example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000
|
||||
example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000
|
||||
example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000
|
||||
example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000
|
||||
example | alter table pgbench_accounts add primary key (aid) | 1
|
||||
example | alter table pgbench_branches add primary key (bid) | 1
|
||||
example | alter table pgbench_tellers add primary key (tid) | 1
|
||||
example | begin | 1
|
||||
example | commit | 1
|
||||
example | copy pgbench_accounts from stdin | 1
|
||||
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1
|
||||
example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1
|
||||
example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1
|
||||
example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1
|
||||
example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1
|
||||
example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10
|
||||
example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100
|
||||
(20 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
|
|
@ -111,4 +111,41 @@ SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_m
|
|||
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 name, setting, unit, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, pending_restart FROM pg_settings WHERE name='pg_stat_monitor.pgsm_query_shared_buffer';
|
||||
name | setting | unit | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | pending_restart
|
||||
------------------------------------------+---------+------+------------+---------+--------------------+---------+---------+----------+----------+-----------+-----------------
|
||||
pg_stat_monitor.pgsm_query_shared_buffer | 2048 | MB | postmaster | integer | configuration file | 1 | 10000 | | 20 | 2048 | f
|
||||
(1 row)
|
||||
|
||||
SELECT datname, substr(query,0,150) AS query, SUM(calls) AS calls FROM pg_stat_monitor GROUP BY datname, query ORDER BY datname, query, calls DESC Limit 20;
|
||||
datname | query | calls
|
||||
---------+---------------------------------------------------------------------------------------------------------------+-------
|
||||
example | BEGIN | 10000
|
||||
example | END | 10000
|
||||
example | INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($1, $2, $3, $4, CURRENT_TIMESTAMP) | 10000
|
||||
example | SELECT abalance FROM pgbench_accounts WHERE aid = $1 | 10000
|
||||
example | UPDATE pgbench_accounts SET abalance = abalance + $1 WHERE aid = $2 | 10000
|
||||
example | UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2 | 10000
|
||||
example | UPDATE pgbench_tellers SET tbalance = tbalance + $1 WHERE tid = $2 | 10000
|
||||
example | alter table pgbench_accounts add primary key (aid) | 1
|
||||
example | alter table pgbench_branches add primary key (bid) | 1
|
||||
example | alter table pgbench_tellers add primary key (tid) | 1
|
||||
example | begin | 1
|
||||
example | commit | 1
|
||||
example | copy pgbench_accounts from stdin with (freeze on) | 1
|
||||
example | create table pgbench_accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=100) | 1
|
||||
example | create table pgbench_branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=100) | 1
|
||||
example | create table pgbench_history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)) | 1
|
||||
example | create table pgbench_tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=100) | 1
|
||||
example | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | 1
|
||||
example | insert into pgbench_branches(bid,bbalance) values($1,$2) | 10
|
||||
example | insert into pgbench_tellers(tid,bid,tbalance) values ($1,$2,$3) | 100
|
||||
(20 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue