Compare commits
54 Commits
Author | SHA1 | Date |
---|---|---|
|
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 |
|
@ -1,4 +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 @darkfronza
|
||||
* @artemgavrilov @dutow
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
name: Bug Report
|
||||
description: File a bug report
|
||||
labels: ["bug"]
|
||||
assignees: []
|
||||
assignees:
|
||||
- artemgavrilov
|
||||
- dutow
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
name: Feature Request
|
||||
description: Suggest an idea for this project
|
||||
labels: ["feature"]
|
||||
assignees: []
|
||||
assignees:
|
||||
- artemgavrilov
|
||||
- dutow
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
|
|
@ -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 --->
|
||||
|
|
@ -6,15 +6,16 @@ jobs:
|
|||
cppcheck:
|
||||
name: Cppcheck
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: src/pg_stat_monitor
|
||||
|
||||
- name: Checkout cppcheck sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: "danmar/cppcheck"
|
||||
ref: "2.13.4"
|
||||
|
@ -38,16 +39,17 @@ jobs:
|
|||
format:
|
||||
name: Format
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_17_STABLE'
|
||||
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'contrib/pg_stat_monitor'
|
||||
|
||||
|
@ -81,12 +83,13 @@ jobs:
|
|||
license:
|
||||
name: License
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Check license headers
|
||||
uses: apache/skywalking-eyes/header@v0.6.0
|
||||
uses: apache/skywalking-eyes/header@5c5b974209f0de5d905f37deb69369068ebfc15c # v0.7.0
|
||||
with:
|
||||
token: "" # Prevent comments
|
||||
|
|
|
@ -5,13 +5,18 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_15_STABLE'
|
||||
|
@ -78,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -108,7 +113,7 @@ jobs:
|
|||
working-directory: src/pg_stat_monitor
|
||||
|
||||
- name: Upload
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
|
||||
with:
|
||||
verbose: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
@ -125,7 +130,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,10 +7,14 @@ on:
|
|||
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
|
||||
|
@ -18,7 +22,7 @@ jobs:
|
|||
shell: bash
|
||||
|
||||
- name: Check out
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
ref: '${{ inputs.version }}'
|
||||
|
||||
|
|
|
@ -7,13 +7,18 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_12_STABLE'
|
||||
|
@ -79,7 +84,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -113,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
@ -136,7 +141,7 @@ jobs:
|
|||
make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
@ -7,13 +7,18 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -75,7 +80,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,6 +7,9 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-pgsm-pmm-integration-test
|
||||
|
@ -14,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
@ -39,7 +42,7 @@ jobs:
|
|||
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@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-12-ppg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -91,7 +95,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_13_STABLE'
|
||||
|
@ -79,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -113,7 +117,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
@ -136,7 +140,7 @@ jobs:
|
|||
make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-13-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -75,7 +79,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,6 +7,9 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-13-pgsm-pmm-integration-test
|
||||
|
@ -14,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
@ -39,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@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-13-ppg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -88,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_14_STABLE'
|
||||
|
@ -79,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -114,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
@ -136,7 +140,7 @@ jobs:
|
|||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-14-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -74,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,6 +7,9 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-14-pgsm-pmm-integration-test
|
||||
|
@ -14,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
@ -39,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@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-14-ppg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -88,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_15_STABLE'
|
||||
|
@ -79,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -114,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
@ -136,7 +140,7 @@ jobs:
|
|||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -74,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,6 +7,9 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-15-pgsm-pmm-integration-test
|
||||
|
@ -14,7 +17,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone QA Integration repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'Percona-Lab/qa-integration'
|
||||
ref: 'main'
|
||||
|
@ -39,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@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: success() || failure() # run this step even if previous step failed
|
||||
with:
|
||||
name: tests-artifact
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -88,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-16-build-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone postgres repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_16_STABLE'
|
||||
|
@ -79,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -114,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
@ -136,7 +140,7 @@ jobs:
|
|||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-16-pgdg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -74,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: pg-16-ppg-package-test
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -88,7 +92,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -7,16 +7,20 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: 'postgres/postgres'
|
||||
ref: 'REL_17_BETA2' # TODO: Replace with REL_17_STABLE
|
||||
ref: 'REL_17_STABLE'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
@ -79,7 +83,7 @@ jobs:
|
|||
pg_ctl -D /opt/pgsql/data -l logfile start
|
||||
|
||||
- name: Clone pg_stat_monitor repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -114,7 +118,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
@ -136,7 +140,7 @@ jobs:
|
|||
run: make installcheck-world
|
||||
|
||||
- name: Report on installcheck-world test suites fail
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: Regressions output files of failed testsuite, and pg log
|
||||
|
|
|
@ -7,13 +7,17 @@ on:
|
|||
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@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: 'src/pg_stat_monitor'
|
||||
|
||||
|
@ -74,7 +78,7 @@ jobs:
|
|||
|
||||
- name: Upload logs on fail
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: Regressions diff and postgresql log
|
||||
path: |
|
||||
|
|
|
@ -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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run analysis
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
publish_results: true
|
||||
|
||||
- name: Upload results
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
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@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
|
||||
with:
|
||||
sarif_file: results.sarif
|
|
@ -2,7 +2,7 @@
|
|||
"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.1.0",
|
||||
"version": "2.1.1",
|
||||
"maintainer": [
|
||||
"Artem Gavrilov <artem.gavrilov@percona.com>",
|
||||
"Diego dos Santos Fronza <diego.fronza@percona.com>"
|
||||
|
@ -15,7 +15,7 @@
|
|||
"abstract": "PostgreSQL Query Performance Monitoring Tool",
|
||||
"file": "pg_stat_monitor--2.0--2.1.sql",
|
||||
"docfile": "README.md",
|
||||
"version": "2.1.0"
|
||||
"version": "2.1.1"
|
||||
}
|
||||
},
|
||||
"prereqs": {
|
||||
|
|
23
Makefile
23
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 pg_stat_monitor--2.0--2.1.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
|
||||
|
||||
PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements"
|
||||
|
||||
|
@ -12,7 +12,26 @@ LDFLAGS_SL += $(filter -lm, $(LIBS))
|
|||
|
||||
TAP_TESTS = 1
|
||||
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression
|
||||
REGRESS = basic version guc pgsm_query_id functions counters relations database error_insert application_name application_name_unique top_query different_parent_queries cmd_type error rows tags user level_tracking
|
||||
REGRESS = basic \
|
||||
version \
|
||||
guc \
|
||||
pgsm_query_id \
|
||||
functions \
|
||||
counters \
|
||||
relations \
|
||||
database \
|
||||
error_insert \
|
||||
application_name \
|
||||
application_name_unique \
|
||||
top_query \
|
||||
different_parent_queries \
|
||||
cmd_type \
|
||||
error \
|
||||
rows \
|
||||
tags \
|
||||
user \
|
||||
level_tracking \
|
||||
decode_error_level
|
||||
|
||||
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
|
||||
# which typical installcheck users do not have (e.g. buildfarm clients).
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
[](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-17-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
|
||||
|
|
|
@ -17,6 +17,7 @@ install_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',
|
||||
kwargs: contrib_data_args,
|
||||
)
|
||||
|
||||
|
|
|
@ -162,7 +162,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
|
||||
|
@ -211,17 +212,18 @@ install_deps() {
|
|||
|
||||
if [ x"$RHEL" = x8 ];
|
||||
then
|
||||
clang_version=$(yum list --showduplicates clang-devel | grep "17.0" | grep clang | awk '{print $2}' | head -n 1)
|
||||
yum install -y clang-devel-${clang_version} clang-${clang_version}
|
||||
clang_version=$(yum list --showduplicates clang-devel | grep "17.0" | grep clang | awk '{print $2}' | head -n 1)
|
||||
llvm_version=$(yum list --showduplicates llvm-devel | grep "17.0" | grep llvm | awk '{print $2}' | head -n 1)
|
||||
yum install -y clang-devel-${clang_version} clang-${clang_version} llvm-devel-${llvm_version}
|
||||
dnf module -y disable llvm-toolset
|
||||
else
|
||||
yum install -y clang-devel clang
|
||||
yum install -y clang-devel clang llvm-devel
|
||||
fi
|
||||
|
||||
PKGLIST="percona-postgresql${PG_RELEASE}-devel"
|
||||
PKGLIST+=" git llvm-devel rpmdevtools vim wget"
|
||||
PKGLIST+=" git rpmdevtools vim wget"
|
||||
PKGLIST+=" perl binutils gcc gcc-c++"
|
||||
PKGLIST+=" 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
|
||||
|
|
|
@ -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;
|
|
@ -19,7 +19,6 @@
|
|||
#include "access/parallel.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "utils/guc.h"
|
||||
#include <regex.h>
|
||||
#include "pgstat.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "commands/explain.h"
|
||||
|
@ -37,7 +36,7 @@ typedef enum pgsmVersion
|
|||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
#define BUILD_VERSION "2.1.0"
|
||||
#define BUILD_VERSION "2.2.0"
|
||||
|
||||
/* Number of output arguments (columns) for various API versions */
|
||||
#define PG_STAT_MONITOR_COLS_V1_0 52
|
||||
|
@ -96,8 +95,6 @@ uint64 *nested_queryids;
|
|||
char **nested_query_txts;
|
||||
List *lentries = NIL;
|
||||
|
||||
/* Regex object used to extract query comments. */
|
||||
static regex_t preg_query_comments;
|
||||
static char relations[REL_LST][REL_LEN];
|
||||
|
||||
static int num_relations; /* Number of relation in the query */
|
||||
|
@ -203,7 +200,7 @@ char *unpack_sql_state(int sql_state);
|
|||
|
||||
static pgsmEntry *pgsm_create_hash_entry(uint64 bucket_id, uint64 queryid, PlanInfo *plan_info);
|
||||
static void pgsm_add_to_list(pgsmEntry *entry, char *query_text, int query_len);
|
||||
static pgsmEntry *pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create);
|
||||
static pgsmEntry *pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create, CmdType cmd_type);
|
||||
static uint64 get_pgsm_query_id_hash(const char *norm_query, int len);
|
||||
|
||||
static void pgsm_cleanup_callback(void *arg);
|
||||
|
@ -261,6 +258,18 @@ static int comp_location(const void *a, const void *b);
|
|||
|
||||
static uint64 get_next_wbucket(pgsmSharedState *pgsm);
|
||||
|
||||
/*
|
||||
* To prevent deadlocks against our own backend we need to disable error
|
||||
* capture while holding the LWLock. The error capture hook is resposible
|
||||
* itself for re-enabling data capture when called on ERROR or above since
|
||||
* then we may not have been able to call pgsm_lock_release() due to the
|
||||
* statement being aborted.
|
||||
*/
|
||||
static bool disable_error_capture = false;
|
||||
|
||||
static void pgsm_lock_aquire(pgsmSharedState *pgsm, LWLockMode mode);
|
||||
static void pgsm_lock_release(pgsmSharedState *pgsm);
|
||||
|
||||
/*
|
||||
* Module load callback
|
||||
*/
|
||||
|
@ -268,8 +277,6 @@ static uint64 get_next_wbucket(pgsmSharedState *pgsm);
|
|||
void
|
||||
_PG_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
elog(DEBUG2, "[pg_stat_monitor] pg_stat_monitor: %s().", __FUNCTION__);
|
||||
|
||||
/*
|
||||
|
@ -297,18 +304,8 @@ _PG_init(void)
|
|||
EnableQueryId();
|
||||
#endif
|
||||
|
||||
|
||||
EmitWarningsOnPlaceholders("pg_stat_monitor");
|
||||
|
||||
/*
|
||||
* Compile regular expression for extracting out query comments only once.
|
||||
*/
|
||||
rc = regcomp(&preg_query_comments, "/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/", REG_EXTENDED);
|
||||
if (rc != 0)
|
||||
{
|
||||
elog(ERROR, "[pg_stat_monitor] _PG_init: query comments regcomp() failed, return code=(%d).", rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Install hooks.
|
||||
*/
|
||||
|
@ -724,7 +721,7 @@ pgsm_ExecutorEnd(QueryDesc *queryDesc)
|
|||
|
||||
if (queryId != UINT64CONST(0) && queryDesc->totaltime && pgsm_enabled(nesting_level))
|
||||
{
|
||||
entry = pgsm_get_entry_for_query(queryId, plan_ptr, (char *) queryDesc->sourceText, strlen(queryDesc->sourceText), true);
|
||||
entry = pgsm_get_entry_for_query(queryId, plan_ptr, (char *) queryDesc->sourceText, strlen(queryDesc->sourceText), true, queryDesc->operation);
|
||||
if (!entry)
|
||||
{
|
||||
elog(DEBUG2, "[pg_stat_monitor] pgsm_ExecutorEnd: Failed to find entry for [%lu] %s.", queryId, queryDesc->sourceText);
|
||||
|
@ -751,6 +748,8 @@ pgsm_ExecutorEnd(QueryDesc *queryDesc)
|
|||
sys_info.stime = time_diff(rusage_end.ru_stime, rusage_start.ru_stime);
|
||||
}
|
||||
|
||||
entry->counters.info.cmd_type = queryDesc->operation;
|
||||
|
||||
pgsm_update_entry(entry, /* entry */
|
||||
NULL, /* query */
|
||||
NULL, /* comments */
|
||||
|
@ -896,7 +895,7 @@ pgsm_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par
|
|||
INSTR_TIME_SET_CURRENT(start);
|
||||
|
||||
if (MemoryContextIsValid(MessageContext))
|
||||
entry = pgsm_get_entry_for_query(parse->queryId, NULL, query_string, strlen(query_string), true);
|
||||
entry = pgsm_get_entry_for_query(parse->queryId, NULL, query_string, strlen(query_string), true, parse->commandType);
|
||||
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
nesting_level++;
|
||||
|
@ -1187,7 +1186,7 @@ pgsm_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
|||
query_text = (char *) CleanQuerytext(queryString, &location, &query_len);
|
||||
|
||||
entry->pgsm_query_id = get_pgsm_query_id_hash(query_text, query_len);
|
||||
entry->counters.info.cmd_type = 0;
|
||||
entry->counters.info.cmd_type = pstmt->commandType;
|
||||
|
||||
pgsm_add_to_list(entry, query_text, query_len);
|
||||
|
||||
|
@ -1729,7 +1728,7 @@ pgsm_add_to_list(pgsmEntry *entry, char *query_text, int query_len)
|
|||
}
|
||||
|
||||
static pgsmEntry *
|
||||
pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create)
|
||||
pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create, CmdType cmd_type)
|
||||
{
|
||||
pgsmEntry *entry = NULL;
|
||||
ListCell *lc = NULL;
|
||||
|
@ -1766,6 +1765,7 @@ pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_
|
|||
* worry about these.
|
||||
*/
|
||||
entry->pgsm_query_id = get_pgsm_query_id_hash(query_text, query_len);
|
||||
entry->counters.info.cmd_type = cmd_type;
|
||||
pgsm_add_to_list(entry, (char *) query_text, query_len);
|
||||
}
|
||||
|
||||
|
@ -1967,7 +1967,7 @@ pgsm_store(pgsmEntry *entry)
|
|||
* Acquire a share lock to start with. We'd have to acquire exclusive if
|
||||
* we need to create the entry.
|
||||
*/
|
||||
LWLockAcquire(pgsm->lock, LW_SHARED);
|
||||
pgsm_lock_aquire(pgsm, LW_SHARED);
|
||||
shared_hash_entry = (pgsmEntry *) pgsm_hash_find(get_pgsmHash(), &entry->key, &found);
|
||||
|
||||
if (!shared_hash_entry)
|
||||
|
@ -1985,7 +1985,7 @@ pgsm_store(pgsmEntry *entry)
|
|||
dsa_query_pointer = dsa_allocate_extended(query_dsa_area, query_len + 1, DSA_ALLOC_NO_OOM | DSA_ALLOC_ZERO);
|
||||
if (!DsaPointerIsValid(dsa_query_pointer))
|
||||
{
|
||||
LWLockRelease(pgsm->lock);
|
||||
pgsm_lock_release(pgsm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1996,30 +1996,25 @@ pgsm_store(pgsmEntry *entry)
|
|||
query_buff = dsa_get_address(query_dsa_area, dsa_query_pointer);
|
||||
memcpy(query_buff, query, query_len);
|
||||
|
||||
LWLockRelease(pgsm->lock);
|
||||
LWLockAcquire(pgsm->lock, LW_EXCLUSIVE);
|
||||
pgsm_lock_release(pgsm);
|
||||
pgsm_lock_aquire(pgsm, LW_EXCLUSIVE);
|
||||
|
||||
/* OK to create a new hashtable entry */
|
||||
PGSM_DISABLE_ERROR_CAPUTRE();
|
||||
PG_TRY();
|
||||
{
|
||||
PG_TRY();
|
||||
{
|
||||
shared_hash_entry = hash_entry_alloc(pgsm, &entry->key, GetDatabaseEncoding());
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
LWLockRelease(pgsm->lock);
|
||||
|
||||
if (DsaPointerIsValid(dsa_query_pointer))
|
||||
dsa_free(query_dsa_area, dsa_query_pointer);
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
} PGSM_END_DISABLE_ERROR_CAPTURE();
|
||||
shared_hash_entry = hash_entry_alloc(pgsm, &entry->key, GetDatabaseEncoding());
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
if (DsaPointerIsValid(dsa_query_pointer))
|
||||
dsa_free(query_dsa_area, dsa_query_pointer);
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
|
||||
if (shared_hash_entry == NULL)
|
||||
{
|
||||
LWLockRelease(pgsm->lock);
|
||||
pgsm_lock_release(pgsm);
|
||||
|
||||
if (DsaPointerIsValid(dsa_query_pointer))
|
||||
dsa_free(query_dsa_area, dsa_query_pointer);
|
||||
|
@ -2032,14 +2027,13 @@ pgsm_store(pgsmEntry *entry)
|
|||
{
|
||||
pgsm->pgsm_oom = true;
|
||||
|
||||
PGSM_DISABLE_ERROR_CAPUTRE();
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("[pg_stat_monitor] pgsm_store: Hash table is out of memory and can no longer store queries!"),
|
||||
errdetail("You may reset the view or when the buckets are deallocated, pg_stat_monitor will resume saving " \
|
||||
"queries. Alternatively, try increasing the value of pg_stat_monitor.pgsm_max.")));
|
||||
} PGSM_END_DISABLE_ERROR_CAPTURE();
|
||||
disable_error_capture = true;
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("[pg_stat_monitor] pgsm_store: Hash table is out of memory and can no longer store queries!"),
|
||||
errdetail("You may reset the view or when the buckets are deallocated, pg_stat_monitor will resume saving " \
|
||||
"queries. Alternatively, try increasing the value of pg_stat_monitor.pgsm_max.")));
|
||||
disable_error_capture = false;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2081,8 +2075,13 @@ pgsm_store(pgsmEntry *entry)
|
|||
reset, /* reset */
|
||||
PGSM_STORE);
|
||||
|
||||
if (reset)
|
||||
{
|
||||
shared_hash_entry->counters.info.cmd_type = entry->counters.info.cmd_type;
|
||||
}
|
||||
|
||||
memset(&entry->counters, 0, sizeof(entry->counters));
|
||||
LWLockRelease(pgsm->lock);
|
||||
pgsm_lock_release(pgsm);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2100,10 +2099,10 @@ pg_stat_monitor_reset(PG_FUNCTION_ARGS)
|
|||
errmsg("pg_stat_monitor: must be loaded via shared_preload_libraries")));
|
||||
|
||||
pgsm = pgsm_get_ss();
|
||||
LWLockAcquire(pgsm->lock, LW_EXCLUSIVE);
|
||||
pgsm_lock_aquire(pgsm, LW_EXCLUSIVE);
|
||||
hash_entry_dealloc(-1, -1, NULL);
|
||||
|
||||
LWLockRelease(pgsm->lock);
|
||||
pgsm_lock_release(pgsm);
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
@ -2237,7 +2236,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
|||
MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
pgsm = pgsm_get_ss();
|
||||
LWLockAcquire(pgsm->lock, LW_SHARED);
|
||||
pgsm_lock_aquire(pgsm, LW_SHARED);
|
||||
pgsm_hash_seq_init(&hstat, get_pgsmHash(), false);
|
||||
|
||||
while ((entry = pgsm_hash_seq_next(&hstat)) != NULL)
|
||||
|
@ -2602,7 +2601,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
|||
}
|
||||
/* clean up and return the tuplestore */
|
||||
pgsm_hash_seq_term(&hstat);
|
||||
LWLockRelease(pgsm->lock);
|
||||
pgsm_lock_release(pgsm);
|
||||
}
|
||||
|
||||
static uint64
|
||||
|
@ -2652,10 +2651,10 @@ get_next_wbucket(pgsmSharedState *pgsm)
|
|||
/* Update bucket id and retrieve the previous one. */
|
||||
prev_bucket_id = pg_atomic_exchange_u64(&pgsm->current_wbucket, new_bucket_id);
|
||||
|
||||
LWLockAcquire(pgsm->lock, LW_EXCLUSIVE);
|
||||
pgsm_lock_aquire(pgsm, LW_EXCLUSIVE);
|
||||
hash_entry_dealloc(new_bucket_id, prev_bucket_id, NULL);
|
||||
|
||||
LWLockRelease(pgsm->lock);
|
||||
pgsm_lock_release(pgsm);
|
||||
|
||||
/* Allign the value in prev_bucket_sec to the bucket start time */
|
||||
tv.tv_sec = (tv.tv_sec) - (tv.tv_sec % pgsm_bucket_time);
|
||||
|
@ -2701,12 +2700,19 @@ get_pgsm_query_id_hash(const char *norm_query, int norm_len)
|
|||
*/
|
||||
if (*norm_q_iter == '/' && *(norm_q_iter + 1) == '*')
|
||||
{
|
||||
while (*norm_q_iter && *norm_q_iter != '*' && *(norm_q_iter + 1) != '/')
|
||||
while (*norm_q_iter && *(norm_q_iter + 1) && (*norm_q_iter != '*' || *(norm_q_iter + 1) != '/'))
|
||||
norm_q_iter++;
|
||||
|
||||
/* Skip the '/' if the current character is valid. */
|
||||
/*
|
||||
* Skip the end if the current character is valid. norm_q_iter
|
||||
* points to the *, we have to skip 2 characters
|
||||
*/
|
||||
if (*norm_q_iter)
|
||||
norm_q_iter++;
|
||||
if (*norm_q_iter)
|
||||
norm_q_iter++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3754,12 +3760,12 @@ pgsm_emit_log_hook(ErrorData *edata)
|
|||
if (MyProc == NULL)
|
||||
goto exit;
|
||||
|
||||
/* Do not store */
|
||||
if (PGSM_ERROR_CAPTURE_ENABLED && edata->elevel >= WARNING && IsSystemOOM() == false)
|
||||
{
|
||||
pgsm_store_error(debug_query_string ? debug_query_string : "",
|
||||
edata);
|
||||
}
|
||||
if (edata->elevel >= WARNING && !disable_error_capture && IsSystemOOM() == false)
|
||||
pgsm_store_error(debug_query_string ? debug_query_string : "", edata);
|
||||
|
||||
/* We need to make sure we re-enble error capture if query was aborted */
|
||||
if (edata->elevel >= ERROR)
|
||||
disable_error_capture = false;
|
||||
exit:
|
||||
if (prev_emit_log_hook)
|
||||
prev_emit_log_hook(edata);
|
||||
|
@ -3956,46 +3962,70 @@ get_histogram_timings(PG_FUNCTION_ARGS)
|
|||
return CStringGetTextDatum(text_str);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
append_comment_char(char *comments, size_t max_len, size_t *idx, char c)
|
||||
{
|
||||
if (*idx >= max_len)
|
||||
return false;
|
||||
|
||||
comments[*idx] = c;
|
||||
(*idx)++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
extract_query_comments(const char *query, char *comments, size_t max_len)
|
||||
{
|
||||
int rc;
|
||||
size_t nmatch = 1;
|
||||
regmatch_t pmatch;
|
||||
regoff_t comment_len,
|
||||
total_len = 0;
|
||||
const char *s = query;
|
||||
size_t curr_len = 0;
|
||||
const char *q_iter = query;
|
||||
|
||||
while (total_len < max_len)
|
||||
if (!pgsm_extract_comments)
|
||||
{
|
||||
rc = regexec(&preg_query_comments, s, nmatch, &pmatch, 0);
|
||||
if (rc != 0)
|
||||
break;
|
||||
comments[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
comment_len = pmatch.rm_eo - pmatch.rm_so;
|
||||
|
||||
if (total_len + comment_len > max_len)
|
||||
break; /* TODO: log error in error view, insufficient
|
||||
* space for comment. */
|
||||
|
||||
total_len += comment_len;
|
||||
|
||||
/* Not 1st iteration, append ", " before next comment. */
|
||||
if (s != query)
|
||||
while (q_iter && *q_iter)
|
||||
{
|
||||
/*
|
||||
* multiline comments, + 1 is safe even if we've reach end of string
|
||||
*/
|
||||
if (*q_iter == '/' && *(q_iter + 1) == '*')
|
||||
{
|
||||
if (total_len + 2 > max_len)
|
||||
break; /* TODO: log error in error view, insufficient
|
||||
* space for ", " + comment. */
|
||||
if (curr_len != 0)
|
||||
{
|
||||
if (!append_comment_char(comments, max_len, &curr_len, ','))
|
||||
return;
|
||||
if (!append_comment_char(comments, max_len, &curr_len, ' '))
|
||||
return;
|
||||
}
|
||||
while (*q_iter && *(q_iter + 1) && (*q_iter != '*' || *(q_iter + 1) != '/'))
|
||||
{
|
||||
if (!append_comment_char(comments, max_len, &curr_len, *q_iter))
|
||||
return;
|
||||
q_iter++;
|
||||
}
|
||||
|
||||
memcpy(comments, ", ", 2);
|
||||
comments += 2;
|
||||
total_len += 2;
|
||||
if (*q_iter)
|
||||
{
|
||||
if (!append_comment_char(comments, max_len, &curr_len, *q_iter))
|
||||
return;
|
||||
q_iter++;
|
||||
}
|
||||
if (*q_iter)
|
||||
{
|
||||
if (!append_comment_char(comments, max_len, &curr_len, *q_iter))
|
||||
return;
|
||||
q_iter++;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(comments, s + pmatch.rm_so, comment_len);
|
||||
comments += comment_len;
|
||||
s += pmatch.rm_eo;
|
||||
q_iter++;
|
||||
}
|
||||
|
||||
comments[curr_len] = 0;
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM < 140000
|
||||
|
@ -4018,3 +4048,18 @@ get_query_id(JumbleState *jstate, Query *query)
|
|||
return queryid;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
pgsm_lock_aquire(pgsmSharedState *pgsm, LWLockMode mode)
|
||||
{
|
||||
/* Disable error capturing while holding the lock to avoid deadlocks */
|
||||
LWLockAcquire(pgsm->lock, mode);
|
||||
disable_error_capture = true;
|
||||
}
|
||||
|
||||
static void
|
||||
pgsm_lock_release(pgsmSharedState *pgsm)
|
||||
{
|
||||
disable_error_capture = false;
|
||||
LWLockRelease(pgsm->lock);
|
||||
}
|
||||
|
|
|
@ -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.1'
|
||||
default_version = '2.2'
|
||||
module_pathname = '$libdir/pg_stat_monitor'
|
||||
relocatable = true
|
||||
|
|
|
@ -112,31 +112,6 @@
|
|||
/* 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.
|
||||
|
|
|
@ -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;
|
|
@ -2,7 +2,7 @@ CREATE EXTENSION pg_stat_monitor;
|
|||
SELECT pg_stat_monitor_version();
|
||||
pg_stat_monitor_version
|
||||
-------------------------
|
||||
2.1.0
|
||||
2.2.0
|
||||
(1 row)
|
||||
|
||||
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;
|
Loading…
Reference in New Issue