Compare commits

..

No commits in common. "main" and "2.1.0" have entirely different histories.
main ... 2.1.0

44 changed files with 205 additions and 522 deletions

2
.github/CODEOWNERS vendored
View File

@ -1,4 +1,4 @@
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners # 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. # Order is important; the last matching pattern takes the most precedence.
* @artemgavrilov @dutow * @artemgavrilov @darkfronza

View File

@ -1,10 +1,7 @@
name: Bug Report name: Bug Report
description: File a bug report description: File a bug report
labels: ["bug"] labels: ["bug"]
assignees: assignees: []
- artemgavrilov
- dutow
body: body:
- type: markdown - type: markdown
attributes: attributes:

View File

@ -1,10 +1,7 @@
name: Feature Request name: Feature Request
description: Suggest an idea for this project description: Suggest an idea for this project
labels: ["feature"] labels: ["feature"]
assignees: assignees: []
- artemgavrilov
- dutow
body: body:
- type: markdown - type: markdown
attributes: attributes:

View File

@ -1,9 +0,0 @@
PG-0
### Description
<!--- Describe your changes in detail -->
### Links
<!--- Please provide links to any related PRs in this or other repositories --->

View File

@ -6,16 +6,15 @@ jobs:
cppcheck: cppcheck:
name: Cppcheck name: Cppcheck
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 5
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: src/pg_stat_monitor path: src/pg_stat_monitor
- name: Checkout cppcheck sources - name: Checkout cppcheck sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: "danmar/cppcheck" repository: "danmar/cppcheck"
ref: "2.13.4" ref: "2.13.4"
@ -39,17 +38,16 @@ jobs:
format: format:
name: Format name: Format
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 5
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_17_STABLE' ref: 'REL_17_STABLE'
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'contrib/pg_stat_monitor' path: 'contrib/pg_stat_monitor'
@ -83,13 +81,12 @@ jobs:
license: license:
name: License name: License
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 5
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
- name: Check license headers - name: Check license headers
uses: apache/skywalking-eyes/header@5c5b974209f0de5d905f37deb69369068ebfc15c # v0.7.0 uses: apache/skywalking-eyes/header@v0.6.0
with: with:
token: "" # Prevent comments token: "" # Prevent comments

View File

@ -5,18 +5,13 @@ on:
branches: branches:
- main - main
permissions:
contents: read
jobs: jobs:
build: build:
name: coverage-test name: coverage-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_15_STABLE' ref: 'REL_15_STABLE'
@ -83,7 +78,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -113,7 +108,7 @@ jobs:
working-directory: src/pg_stat_monitor working-directory: src/pg_stat_monitor
- name: Upload - name: Upload
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 uses: codecov/codecov-action@v4
with: with:
verbose: true verbose: true
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
@ -130,7 +125,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,14 +7,10 @@ on:
required: true required: true
type: string type: string
permissions:
contents: read
jobs: jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 10
container: pgxn/pgxn-tools container: pgxn/pgxn-tools
steps: steps:
- name: Validate version tag - name: Validate version tag
@ -22,7 +18,7 @@ jobs:
shell: bash shell: bash
- name: Check out - name: Check out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
ref: '${{ inputs.version }}' ref: '${{ inputs.version }}'

View File

@ -7,18 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-12-build-test name: pg-12-build-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_12_STABLE' ref: 'REL_12_STABLE'
@ -84,7 +79,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -118,7 +113,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |
@ -141,7 +136,7 @@ jobs:
make installcheck-world make installcheck-world
- name: Report on installcheck-world test suites fail - name: Report on installcheck-world test suites fail
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: Regressions output files of failed testsuite, and pg log name: Regressions output files of failed testsuite, and pg log

View File

@ -7,18 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-12-pgdg-package-test name: pg-12-pgdg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -80,7 +75,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,9 +7,6 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-12-pgsm-pmm-integration-test name: pg-12-pgsm-pmm-integration-test
@ -17,7 +14,7 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- name: Clone QA Integration repository - name: Clone QA Integration repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'Percona-Lab/qa-integration' repository: 'Percona-Lab/qa-integration'
ref: 'main' ref: 'main'
@ -42,7 +39,7 @@ jobs:
run: docker exec pgsql_pgsm_12 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log run: docker exec pgsql_pgsm_12 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
- name: Upload Tests Artifacts - name: Upload Tests Artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: success() || failure() # run this step even if previous step failed if: success() || failure() # run this step even if previous step failed
with: with:
name: tests-artifact name: tests-artifact

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-12-ppg-package-test name: pg-12-ppg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -95,7 +91,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-13-build-test name: pg-13-build-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_13_STABLE' ref: 'REL_13_STABLE'
@ -83,7 +79,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -117,7 +113,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |
@ -140,7 +136,7 @@ jobs:
make installcheck-world make installcheck-world
- name: Report on installcheck-world test suites fail - name: Report on installcheck-world test suites fail
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: Regressions output files of failed testsuite, and pg log name: Regressions output files of failed testsuite, and pg log

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-13-pgdg-package-test name: pg-13-pgdg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -79,7 +75,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,9 +7,6 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-13-pgsm-pmm-integration-test name: pg-13-pgsm-pmm-integration-test
@ -17,7 +14,7 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- name: Clone QA Integration repository - name: Clone QA Integration repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'Percona-Lab/qa-integration' repository: 'Percona-Lab/qa-integration'
ref: 'main' ref: 'main'
@ -42,7 +39,7 @@ jobs:
run: docker exec pgsql_pgsm_13 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log run: docker exec pgsql_pgsm_13 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
- name: Upload Tests Artifacts - name: Upload Tests Artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: success() || failure() # run this step even if previous step failed if: success() || failure() # run this step even if previous step failed
with: with:
name: tests-artifact name: tests-artifact

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-13-ppg-package-test name: pg-13-ppg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -92,7 +88,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-14-build-test name: pg-14-build-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_14_STABLE' ref: 'REL_14_STABLE'
@ -83,7 +79,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -118,7 +114,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |
@ -140,7 +136,7 @@ jobs:
run: make installcheck-world run: make installcheck-world
- name: Report on installcheck-world test suites fail - name: Report on installcheck-world test suites fail
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: Regressions output files of failed testsuite, and pg log name: Regressions output files of failed testsuite, and pg log

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-14-pgdg-package-test name: pg-14-pgdg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -78,7 +74,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,9 +7,6 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-14-pgsm-pmm-integration-test name: pg-14-pgsm-pmm-integration-test
@ -17,7 +14,7 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- name: Clone QA Integration repository - name: Clone QA Integration repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'Percona-Lab/qa-integration' repository: 'Percona-Lab/qa-integration'
ref: 'main' ref: 'main'
@ -42,7 +39,7 @@ jobs:
run: docker exec pgsql_pgsm_14 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log run: docker exec pgsql_pgsm_14 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
- name: Upload Tests Artifacts - name: Upload Tests Artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: success() || failure() # run this step even if previous step failed if: success() || failure() # run this step even if previous step failed
with: with:
name: tests-artifact name: tests-artifact

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-14-ppg-package-test name: pg-14-ppg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -92,7 +88,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-15-build-test name: pg-15-build-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_15_STABLE' ref: 'REL_15_STABLE'
@ -83,7 +79,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -118,7 +114,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |
@ -140,7 +136,7 @@ jobs:
run: make installcheck-world run: make installcheck-world
- name: Report on installcheck-world test suites fail - name: Report on installcheck-world test suites fail
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: Regressions output files of failed testsuite, and pg log name: Regressions output files of failed testsuite, and pg log

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-15-pgdg-package-test name: pg-15-pgdg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -78,7 +74,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,9 +7,6 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-15-pgsm-pmm-integration-test name: pg-15-pgsm-pmm-integration-test
@ -17,7 +14,7 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- name: Clone QA Integration repository - name: Clone QA Integration repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'Percona-Lab/qa-integration' repository: 'Percona-Lab/qa-integration'
ref: 'main' ref: 'main'
@ -42,7 +39,7 @@ jobs:
run: docker exec pgsql_pgsm_15 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log run: docker exec pgsql_pgsm_15 cat pmm-agent.log > ./pmm-ui-tests/tests/output/pmm-agent.log
- name: Upload Tests Artifacts - name: Upload Tests Artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: success() || failure() # run this step even if previous step failed if: success() || failure() # run this step even if previous step failed
with: with:
name: tests-artifact name: tests-artifact

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-15-ppg-package-test name: pg-15-ppg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -92,7 +88,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-16-build-test name: pg-16-build-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_16_STABLE' ref: 'REL_16_STABLE'
@ -83,7 +79,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -118,7 +114,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |
@ -140,7 +136,7 @@ jobs:
run: make installcheck-world run: make installcheck-world
- name: Report on installcheck-world test suites fail - name: Report on installcheck-world test suites fail
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: Regressions output files of failed testsuite, and pg log name: Regressions output files of failed testsuite, and pg log

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-16-pgdg-package-test name: pg-16-pgdg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -78,7 +74,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-16-ppg-package-test name: pg-16-ppg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -92,7 +88,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -7,20 +7,16 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-17-build-test name: pg-17-build-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone postgres repository - name: Clone postgres repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
repository: 'postgres/postgres' repository: 'postgres/postgres'
ref: 'REL_17_STABLE' ref: 'REL_17_BETA2' # TODO: Replace with REL_17_STABLE
- name: Install dependencies - name: Install dependencies
run: | run: |
@ -83,7 +79,7 @@ jobs:
pg_ctl -D /opt/pgsql/data -l logfile start pg_ctl -D /opt/pgsql/data -l logfile start
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -118,7 +114,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |
@ -140,7 +136,7 @@ jobs:
run: make installcheck-world run: make installcheck-world
- name: Report on installcheck-world test suites fail - name: Report on installcheck-world test suites fail
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: Regressions output files of failed testsuite, and pg log name: Regressions output files of failed testsuite, and pg log

View File

@ -7,17 +7,13 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
jobs: jobs:
build: build:
name: pg-17-pgdg-package-test name: pg-17-pgdg-package-test
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 30
steps: steps:
- name: Clone pg_stat_monitor repository - name: Clone pg_stat_monitor repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@v4
with: with:
path: 'src/pg_stat_monitor' path: 'src/pg_stat_monitor'
@ -78,7 +74,7 @@ jobs:
- name: Upload logs on fail - name: Upload logs on fail
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@v4
with: with:
name: Regressions diff and postgresql log name: Regressions diff and postgresql log
path: | path: |

View File

@ -1,48 +0,0 @@
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

View File

@ -2,7 +2,7 @@
"name": "pg_stat_monitor", "name": "pg_stat_monitor",
"abstract": "PostgreSQL Query Performance Monitoring Tool", "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.", "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.1", "version": "2.1.0",
"maintainer": [ "maintainer": [
"Artem Gavrilov <artem.gavrilov@percona.com>", "Artem Gavrilov <artem.gavrilov@percona.com>",
"Diego dos Santos Fronza <diego.fronza@percona.com>" "Diego dos Santos Fronza <diego.fronza@percona.com>"
@ -15,7 +15,7 @@
"abstract": "PostgreSQL Query Performance Monitoring Tool", "abstract": "PostgreSQL Query Performance Monitoring Tool",
"file": "pg_stat_monitor--2.0--2.1.sql", "file": "pg_stat_monitor--2.0--2.1.sql",
"docfile": "README.md", "docfile": "README.md",
"version": "2.1.1" "version": "2.1.0"
} }
}, },
"prereqs": { "prereqs": {

View File

@ -4,7 +4,7 @@ MODULE_big = pg_stat_monitor
OBJS = hash_query.o guc.o pg_stat_monitor.o $(WIN32RES) OBJS = hash_query.o guc.o pg_stat_monitor.o $(WIN32RES)
EXTENSION = pg_stat_monitor 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 pg_stat_monitor--2.1--2.2.sql DATA = pg_stat_monitor--2.0.sql pg_stat_monitor--1.0--2.0.sql pg_stat_monitor--2.0--2.1.sql
PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements" PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements"
@ -12,26 +12,7 @@ LDFLAGS_SL += $(filter -lm, $(LIBS))
TAP_TESTS = 1 TAP_TESTS = 1
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_monitor/pg_stat_monitor.conf --inputdir=regression
REGRESS = basic \ 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
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", # Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
# which typical installcheck users do not have (e.g. buildfarm clients). # which typical installcheck users do not have (e.g. buildfarm clients).

View File

@ -6,8 +6,6 @@
[![postgresql-17-pgdg-package](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-17-pgdg-package.yml/badge.svg)](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-17-pgdg-package.yml) [![postgresql-17-pgdg-package](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-17-pgdg-package.yml/badge.svg)](https://github.com/percona/pg_stat_monitor/actions/workflows/postgresql-17-pgdg-package.yml)
[![PGXN version](https://badge.fury.io/pg/pg_stat_monitor.svg)](https://badge.fury.io/pg/pg_stat_monitor) [![PGXN version](https://badge.fury.io/pg/pg_stat_monitor.svg)](https://badge.fury.io/pg/pg_stat_monitor)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/percona/pg_stat_monitor/badge)](https://scorecard.dev/viewer/?uri=github.com/percona/pg_stat_monitor)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9703/badge)](https://www.bestpractices.dev/projects/9703)
[![Code coverage](https://codecov.io/gh/percona/pg_stat_monitor/branch/main/graph/badge.svg)](https://codecov.io/gh/percona/pg_stat_monitor) [![Code coverage](https://codecov.io/gh/percona/pg_stat_monitor/branch/main/graph/badge.svg)](https://codecov.io/gh/percona/pg_stat_monitor)
[![Forum](https://img.shields.io/badge/Forum-join-brightgreen)](https://forums.percona.com/) [![Forum](https://img.shields.io/badge/Forum-join-brightgreen)](https://forums.percona.com/)
# pg_stat_monitor: Query Performance Monitoring Tool for PostgreSQL # pg_stat_monitor: Query Performance Monitoring Tool for PostgreSQL

View File

@ -17,7 +17,6 @@ install_data(
'pg_stat_monitor--2.0.sql', 'pg_stat_monitor--2.0.sql',
'pg_stat_monitor--1.0--2.0.sql', 'pg_stat_monitor--1.0--2.0.sql',
'pg_stat_monitor--2.0--2.1.sql', 'pg_stat_monitor--2.0--2.1.sql',
'pg_stat_monitor--2.1--2.2.sql',
kwargs: contrib_data_args, kwargs: contrib_data_args,
) )

View File

@ -162,8 +162,7 @@ get_sources(){
source pg-stat-monitor.properties source pg-stat-monitor.properties
# #
tar --owner=0 --group=0 --exclude=.* -czf ${PRODUCT_FULL}.tar.gz ${PRODUCT_FULL} tar --owner=0 --group=0 --exclude=.* -czf ${PRODUCT_FULL}.tar.gz ${PRODUCT_FULL}
DATE_TIMESTAMP=$(date +%F_%H-%M-%S) echo "UPLOAD=UPLOAD/experimental/BUILDS/${PRODUCT}/${PRODUCT_FULL}/${BRANCH}/${REVISION}/${BUILD_ID}" >> pg-stat-monitor.properties
echo "UPLOAD=UPLOAD/experimental/BUILDS/${PRODUCT}/${PRODUCT_FULL}/${BRANCH}/${REVISION}/${DATE_TIMESTAMP}/${BUILD_ID}" >> pg-stat-monitor.properties
mkdir $WORKDIR/source_tarball mkdir $WORKDIR/source_tarball
mkdir $CURDIR/source_tarball mkdir $CURDIR/source_tarball
cp ${PRODUCT_FULL}.tar.gz $WORKDIR/source_tarball cp ${PRODUCT_FULL}.tar.gz $WORKDIR/source_tarball
@ -212,18 +211,17 @@ install_deps() {
if [ x"$RHEL" = x8 ]; if [ x"$RHEL" = x8 ];
then then
clang_version=$(yum list --showduplicates clang-devel | grep "17.0" | grep clang | awk '{print $2}' | head -n 1) 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}
yum install -y clang-devel-${clang_version} clang-${clang_version} llvm-devel-${llvm_version}
dnf module -y disable llvm-toolset dnf module -y disable llvm-toolset
else else
yum install -y clang-devel clang llvm-devel yum install -y clang-devel clang
fi fi
PKGLIST="percona-postgresql${PG_RELEASE}-devel" PKGLIST="percona-postgresql${PG_RELEASE}-devel"
PKGLIST+=" git rpmdevtools vim wget" PKGLIST+=" git llvm-devel rpmdevtools vim wget"
PKGLIST+=" perl binutils gcc gcc-c++" PKGLIST+=" perl binutils gcc gcc-c++"
PKGLIST+=" git rpm-build rpmdevtools wget gcc make autoconf" PKGLIST+=" llvm-devel git rpm-build rpmdevtools wget gcc make autoconf"
if [[ "${RHEL}" -ge 8 ]]; then if [[ "${RHEL}" -ge 8 ]]; then
dnf config-manager --set-enabled ol${RHEL}_codeready_builder dnf config-manager --set-enabled ol${RHEL}_codeready_builder
dnf -y module disable postgresql || true dnf -y module disable postgresql || true

View File

@ -1,48 +0,0 @@
/* 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;

View File

@ -19,6 +19,7 @@
#include "access/parallel.h" #include "access/parallel.h"
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "utils/guc.h" #include "utils/guc.h"
#include <regex.h>
#include "pgstat.h" #include "pgstat.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "commands/explain.h" #include "commands/explain.h"
@ -36,7 +37,7 @@ typedef enum pgsmVersion
PG_MODULE_MAGIC; PG_MODULE_MAGIC;
#define BUILD_VERSION "2.2.0" #define BUILD_VERSION "2.1.0"
/* Number of output arguments (columns) for various API versions */ /* Number of output arguments (columns) for various API versions */
#define PG_STAT_MONITOR_COLS_V1_0 52 #define PG_STAT_MONITOR_COLS_V1_0 52
@ -95,6 +96,8 @@ uint64 *nested_queryids;
char **nested_query_txts; char **nested_query_txts;
List *lentries = NIL; List *lentries = NIL;
/* Regex object used to extract query comments. */
static regex_t preg_query_comments;
static char relations[REL_LST][REL_LEN]; static char relations[REL_LST][REL_LEN];
static int num_relations; /* Number of relation in the query */ static int num_relations; /* Number of relation in the query */
@ -200,7 +203,7 @@ char *unpack_sql_state(int sql_state);
static pgsmEntry *pgsm_create_hash_entry(uint64 bucket_id, uint64 queryid, PlanInfo *plan_info); 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 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, CmdType cmd_type); static pgsmEntry *pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create);
static uint64 get_pgsm_query_id_hash(const char *norm_query, int len); static uint64 get_pgsm_query_id_hash(const char *norm_query, int len);
static void pgsm_cleanup_callback(void *arg); static void pgsm_cleanup_callback(void *arg);
@ -258,18 +261,6 @@ static int comp_location(const void *a, const void *b);
static uint64 get_next_wbucket(pgsmSharedState *pgsm); 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 * Module load callback
*/ */
@ -277,6 +268,8 @@ static void pgsm_lock_release(pgsmSharedState *pgsm);
void void
_PG_init(void) _PG_init(void)
{ {
int rc;
elog(DEBUG2, "[pg_stat_monitor] pg_stat_monitor: %s().", __FUNCTION__); elog(DEBUG2, "[pg_stat_monitor] pg_stat_monitor: %s().", __FUNCTION__);
/* /*
@ -304,8 +297,18 @@ _PG_init(void)
EnableQueryId(); EnableQueryId();
#endif #endif
EmitWarningsOnPlaceholders("pg_stat_monitor"); 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. * Install hooks.
*/ */
@ -721,7 +724,7 @@ pgsm_ExecutorEnd(QueryDesc *queryDesc)
if (queryId != UINT64CONST(0) && queryDesc->totaltime && pgsm_enabled(nesting_level)) 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, queryDesc->operation); entry = pgsm_get_entry_for_query(queryId, plan_ptr, (char *) queryDesc->sourceText, strlen(queryDesc->sourceText), true);
if (!entry) if (!entry)
{ {
elog(DEBUG2, "[pg_stat_monitor] pgsm_ExecutorEnd: Failed to find entry for [%lu] %s.", queryId, queryDesc->sourceText); elog(DEBUG2, "[pg_stat_monitor] pgsm_ExecutorEnd: Failed to find entry for [%lu] %s.", queryId, queryDesc->sourceText);
@ -748,8 +751,6 @@ pgsm_ExecutorEnd(QueryDesc *queryDesc)
sys_info.stime = time_diff(rusage_end.ru_stime, rusage_start.ru_stime); 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 */ pgsm_update_entry(entry, /* entry */
NULL, /* query */ NULL, /* query */
NULL, /* comments */ NULL, /* comments */
@ -895,7 +896,7 @@ pgsm_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par
INSTR_TIME_SET_CURRENT(start); INSTR_TIME_SET_CURRENT(start);
if (MemoryContextIsValid(MessageContext)) if (MemoryContextIsValid(MessageContext))
entry = pgsm_get_entry_for_query(parse->queryId, NULL, query_string, strlen(query_string), true, parse->commandType); entry = pgsm_get_entry_for_query(parse->queryId, NULL, query_string, strlen(query_string), true);
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
nesting_level++; nesting_level++;
@ -1186,7 +1187,7 @@ pgsm_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
query_text = (char *) CleanQuerytext(queryString, &location, &query_len); query_text = (char *) CleanQuerytext(queryString, &location, &query_len);
entry->pgsm_query_id = get_pgsm_query_id_hash(query_text, query_len); entry->pgsm_query_id = get_pgsm_query_id_hash(query_text, query_len);
entry->counters.info.cmd_type = pstmt->commandType; entry->counters.info.cmd_type = 0;
pgsm_add_to_list(entry, query_text, query_len); pgsm_add_to_list(entry, query_text, query_len);
@ -1728,7 +1729,7 @@ pgsm_add_to_list(pgsmEntry *entry, char *query_text, int query_len)
} }
static pgsmEntry * static pgsmEntry *
pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create, CmdType cmd_type) pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_text, int query_len, bool create)
{ {
pgsmEntry *entry = NULL; pgsmEntry *entry = NULL;
ListCell *lc = NULL; ListCell *lc = NULL;
@ -1765,7 +1766,6 @@ pgsm_get_entry_for_query(uint64 queryid, PlanInfo *plan_info, const char *query_
* worry about these. * worry about these.
*/ */
entry->pgsm_query_id = get_pgsm_query_id_hash(query_text, query_len); 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); 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 * Acquire a share lock to start with. We'd have to acquire exclusive if
* we need to create the entry. * we need to create the entry.
*/ */
pgsm_lock_aquire(pgsm, LW_SHARED); LWLockAcquire(pgsm->lock, LW_SHARED);
shared_hash_entry = (pgsmEntry *) pgsm_hash_find(get_pgsmHash(), &entry->key, &found); shared_hash_entry = (pgsmEntry *) pgsm_hash_find(get_pgsmHash(), &entry->key, &found);
if (!shared_hash_entry) 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); dsa_query_pointer = dsa_allocate_extended(query_dsa_area, query_len + 1, DSA_ALLOC_NO_OOM | DSA_ALLOC_ZERO);
if (!DsaPointerIsValid(dsa_query_pointer)) if (!DsaPointerIsValid(dsa_query_pointer))
{ {
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
return; return;
} }
@ -1996,25 +1996,30 @@ pgsm_store(pgsmEntry *entry)
query_buff = dsa_get_address(query_dsa_area, dsa_query_pointer); query_buff = dsa_get_address(query_dsa_area, dsa_query_pointer);
memcpy(query_buff, query, query_len); memcpy(query_buff, query, query_len);
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
pgsm_lock_aquire(pgsm, LW_EXCLUSIVE); LWLockAcquire(pgsm->lock, LW_EXCLUSIVE);
/* OK to create a new hashtable entry */ /* OK to create a new hashtable entry */
PG_TRY(); PGSM_DISABLE_ERROR_CAPUTRE();
{ {
shared_hash_entry = hash_entry_alloc(pgsm, &entry->key, GetDatabaseEncoding()); PG_TRY();
} {
PG_CATCH(); shared_hash_entry = hash_entry_alloc(pgsm, &entry->key, GetDatabaseEncoding());
{ }
if (DsaPointerIsValid(dsa_query_pointer)) PG_CATCH();
dsa_free(query_dsa_area, dsa_query_pointer); {
PG_RE_THROW(); LWLockRelease(pgsm->lock);
}
PG_END_TRY(); if (DsaPointerIsValid(dsa_query_pointer))
dsa_free(query_dsa_area, dsa_query_pointer);
PG_RE_THROW();
}
PG_END_TRY();
} PGSM_END_DISABLE_ERROR_CAPTURE();
if (shared_hash_entry == NULL) if (shared_hash_entry == NULL)
{ {
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
if (DsaPointerIsValid(dsa_query_pointer)) if (DsaPointerIsValid(dsa_query_pointer))
dsa_free(query_dsa_area, dsa_query_pointer); dsa_free(query_dsa_area, dsa_query_pointer);
@ -2027,13 +2032,14 @@ pgsm_store(pgsmEntry *entry)
{ {
pgsm->pgsm_oom = true; pgsm->pgsm_oom = true;
disable_error_capture = true; PGSM_DISABLE_ERROR_CAPUTRE();
ereport(WARNING, {
(errcode(ERRCODE_OUT_OF_MEMORY), ereport(WARNING,
errmsg("[pg_stat_monitor] pgsm_store: Hash table is out of memory and can no longer store queries!"), (errcode(ERRCODE_OUT_OF_MEMORY),
errdetail("You may reset the view or when the buckets are deallocated, pg_stat_monitor will resume saving " \ errmsg("[pg_stat_monitor] pgsm_store: Hash table is out of memory and can no longer store queries!"),
"queries. Alternatively, try increasing the value of pg_stat_monitor.pgsm_max."))); errdetail("You may reset the view or when the buckets are deallocated, pg_stat_monitor will resume saving " \
disable_error_capture = false; "queries. Alternatively, try increasing the value of pg_stat_monitor.pgsm_max.")));
} PGSM_END_DISABLE_ERROR_CAPTURE();
} }
return; return;
@ -2075,13 +2081,8 @@ pgsm_store(pgsmEntry *entry)
reset, /* reset */ reset, /* reset */
PGSM_STORE); PGSM_STORE);
if (reset)
{
shared_hash_entry->counters.info.cmd_type = entry->counters.info.cmd_type;
}
memset(&entry->counters, 0, sizeof(entry->counters)); memset(&entry->counters, 0, sizeof(entry->counters));
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
} }
/* /*
@ -2099,10 +2100,10 @@ pg_stat_monitor_reset(PG_FUNCTION_ARGS)
errmsg("pg_stat_monitor: must be loaded via shared_preload_libraries"))); errmsg("pg_stat_monitor: must be loaded via shared_preload_libraries")));
pgsm = pgsm_get_ss(); pgsm = pgsm_get_ss();
pgsm_lock_aquire(pgsm, LW_EXCLUSIVE); LWLockAcquire(pgsm->lock, LW_EXCLUSIVE);
hash_entry_dealloc(-1, -1, NULL); hash_entry_dealloc(-1, -1, NULL);
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
@ -2236,7 +2237,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
pgsm = pgsm_get_ss(); pgsm = pgsm_get_ss();
pgsm_lock_aquire(pgsm, LW_SHARED); LWLockAcquire(pgsm->lock, LW_SHARED);
pgsm_hash_seq_init(&hstat, get_pgsmHash(), false); pgsm_hash_seq_init(&hstat, get_pgsmHash(), false);
while ((entry = pgsm_hash_seq_next(&hstat)) != NULL) while ((entry = pgsm_hash_seq_next(&hstat)) != NULL)
@ -2601,7 +2602,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
} }
/* clean up and return the tuplestore */ /* clean up and return the tuplestore */
pgsm_hash_seq_term(&hstat); pgsm_hash_seq_term(&hstat);
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
} }
static uint64 static uint64
@ -2651,10 +2652,10 @@ get_next_wbucket(pgsmSharedState *pgsm)
/* Update bucket id and retrieve the previous one. */ /* Update bucket id and retrieve the previous one. */
prev_bucket_id = pg_atomic_exchange_u64(&pgsm->current_wbucket, new_bucket_id); prev_bucket_id = pg_atomic_exchange_u64(&pgsm->current_wbucket, new_bucket_id);
pgsm_lock_aquire(pgsm, LW_EXCLUSIVE); LWLockAcquire(pgsm->lock, LW_EXCLUSIVE);
hash_entry_dealloc(new_bucket_id, prev_bucket_id, NULL); hash_entry_dealloc(new_bucket_id, prev_bucket_id, NULL);
pgsm_lock_release(pgsm); LWLockRelease(pgsm->lock);
/* Allign the value in prev_bucket_sec to the bucket start time */ /* Allign the value in prev_bucket_sec to the bucket start time */
tv.tv_sec = (tv.tv_sec) - (tv.tv_sec % pgsm_bucket_time); tv.tv_sec = (tv.tv_sec) - (tv.tv_sec % pgsm_bucket_time);
@ -2700,19 +2701,12 @@ get_pgsm_query_id_hash(const char *norm_query, int norm_len)
*/ */
if (*norm_q_iter == '/' && *(norm_q_iter + 1) == '*') if (*norm_q_iter == '/' && *(norm_q_iter + 1) == '*')
{ {
while (*norm_q_iter && *(norm_q_iter + 1) && (*norm_q_iter != '*' || *(norm_q_iter + 1) != '/')) while (*norm_q_iter && *norm_q_iter != '*' && *(norm_q_iter + 1) != '/')
norm_q_iter++; 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) if (*norm_q_iter)
norm_q_iter++; norm_q_iter++;
if (*norm_q_iter)
norm_q_iter++;
continue;
} }
/* /*
@ -3760,12 +3754,12 @@ pgsm_emit_log_hook(ErrorData *edata)
if (MyProc == NULL) if (MyProc == NULL)
goto exit; goto exit;
if (edata->elevel >= WARNING && !disable_error_capture && IsSystemOOM() == false) /* Do not store */
pgsm_store_error(debug_query_string ? debug_query_string : "", edata); if (PGSM_ERROR_CAPTURE_ENABLED && edata->elevel >= WARNING && IsSystemOOM() == false)
{
/* We need to make sure we re-enble error capture if query was aborted */ pgsm_store_error(debug_query_string ? debug_query_string : "",
if (edata->elevel >= ERROR) edata);
disable_error_capture = false; }
exit: exit:
if (prev_emit_log_hook) if (prev_emit_log_hook)
prev_emit_log_hook(edata); prev_emit_log_hook(edata);
@ -3962,70 +3956,46 @@ get_histogram_timings(PG_FUNCTION_ARGS)
return CStringGetTextDatum(text_str); 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 static void
extract_query_comments(const char *query, char *comments, size_t max_len) extract_query_comments(const char *query, char *comments, size_t max_len)
{ {
size_t curr_len = 0; int rc;
const char *q_iter = query; size_t nmatch = 1;
regmatch_t pmatch;
regoff_t comment_len,
total_len = 0;
const char *s = query;
if (!pgsm_extract_comments) while (total_len < max_len)
{ {
comments[0] = 0; rc = regexec(&preg_query_comments, s, nmatch, &pmatch, 0);
return; if (rc != 0)
} break;
while (q_iter && *q_iter) comment_len = pmatch.rm_eo - pmatch.rm_so;
{
/* if (total_len + comment_len > max_len)
* multiline comments, + 1 is safe even if we've reach end of string break; /* TODO: log error in error view, insufficient
*/ * space for comment. */
if (*q_iter == '/' && *(q_iter + 1) == '*')
total_len += comment_len;
/* Not 1st iteration, append ", " before next comment. */
if (s != query)
{ {
if (curr_len != 0) if (total_len + 2 > max_len)
{ break; /* TODO: log error in error view, insufficient
if (!append_comment_char(comments, max_len, &curr_len, ',')) * space for ", " + comment. */
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++;
}
if (*q_iter) memcpy(comments, ", ", 2);
{ comments += 2;
if (!append_comment_char(comments, max_len, &curr_len, *q_iter)) total_len += 2;
return;
q_iter++;
}
if (*q_iter)
{
if (!append_comment_char(comments, max_len, &curr_len, *q_iter))
return;
q_iter++;
}
} }
q_iter++; memcpy(comments, s + pmatch.rm_so, comment_len);
comments += comment_len;
s += pmatch.rm_eo;
} }
comments[curr_len] = 0;
} }
#if PG_VERSION_NUM < 140000 #if PG_VERSION_NUM < 140000
@ -4048,18 +4018,3 @@ get_query_id(JumbleState *jstate, Query *query)
return queryid; return queryid;
} }
#endif #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);
}

View File

@ -1,5 +1,5 @@
# pg_stat_monitor extension # 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.' 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.2' default_version = '2.1'
module_pathname = '$libdir/pg_stat_monitor' module_pathname = '$libdir/pg_stat_monitor'
relocatable = true relocatable = true

View File

@ -112,6 +112,31 @@
/* Update this if need a enum GUC with more options. */ /* Update this if need a enum GUC with more options. */
#define MAX_ENUM_OPTIONS 6 #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 * 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. * except the query text, which gets stored out of line in the raw DSA area.

View File

@ -27,16 +27,16 @@ DROP TABLE t2;
SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | cmd_type | cmd_type_text query | cmd_type | cmd_type_text
--------------------------------+----------+--------------- --------------------------------+----------+---------------
CREATE TABLE t1 (a INTEGER) | 5 | UTILITY CREATE TABLE t1 (a INTEGER) | 0 |
CREATE TABLE t2 (b INTEGER) | 5 | UTILITY CREATE TABLE t2 (b INTEGER) | 0 |
DELETE FROM t1 | 4 | DELETE DELETE FROM t1 | 4 | DELETE
DROP TABLE t1 | 5 | UTILITY DROP TABLE t1 | 0 |
DROP TABLE t2 | 5 | UTILITY DROP TABLE t2 | 0 |
INSERT INTO t1 VALUES(1) | 3 | INSERT INSERT INTO t1 VALUES(1) | 3 | INSERT
SELECT a FROM t1 | 1 | SELECT SELECT a FROM t1 | 1 | SELECT
SELECT b FROM t2 FOR UPDATE | 1 | SELECT SELECT b FROM t2 FOR UPDATE | 1 | SELECT
SELECT pg_stat_monitor_reset() | 1 | SELECT SELECT pg_stat_monitor_reset() | 1 | SELECT
TRUNCATE t1 | 5 | UTILITY TRUNCATE t1 | 0 |
UPDATE t1 SET a = 2 | 2 | UPDATE UPDATE t1 SET a = 2 | 2 | UPDATE
(11 rows) (11 rows)

View File

@ -23,22 +23,16 @@ SELECT b FROM t2 FOR UPDATE;
TRUNCATE t1; TRUNCATE t1;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2;
SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | cmd_type | cmd_type_text 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 DELETE FROM t1 | 4 | DELETE
DROP TABLE t1 | 6 | UTILITY
DROP TABLE t2 | 6 | UTILITY
INSERT INTO t1 VALUES(1) | 3 | INSERT INSERT INTO t1 VALUES(1) | 3 | INSERT
SELECT a FROM t1 | 1 | SELECT SELECT a FROM t1 | 1 | SELECT
SELECT b FROM t2 FOR UPDATE | 1 | SELECT SELECT b FROM t2 FOR UPDATE | 1 | SELECT
SELECT pg_stat_monitor_reset() | 1 | SELECT SELECT pg_stat_monitor_reset() | 1 | SELECT
TRUNCATE t1 | 6 | UTILITY
UPDATE t1 SET a = 2 | 2 | UPDATE UPDATE t1 SET a = 2 | 2 | UPDATE
(11 rows) (6 rows)
SELECT pg_stat_monitor_reset(); SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset pg_stat_monitor_reset

View File

@ -1,25 +0,0 @@
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;

View File

@ -1,25 +0,0 @@
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;

View File

@ -2,7 +2,7 @@ CREATE EXTENSION pg_stat_monitor;
SELECT pg_stat_monitor_version(); SELECT pg_stat_monitor_version();
pg_stat_monitor_version pg_stat_monitor_version
------------------------- -------------------------
2.2.0 2.1.0
(1 row) (1 row)
DROP EXTENSION pg_stat_monitor; DROP EXTENSION pg_stat_monitor;

View File

@ -1,12 +0,0 @@
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;