From d2c1842fde62b50a11e9399778b498b1549e3fa9 Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Thu, 13 Nov 2025 15:29:50 +0200 Subject: [PATCH 1/4] Bump version to 2.3.1 Increment pg_stat_monitor version to 2.3.1 --- META.json | 4 ++-- pg_stat_monitor.c | 2 +- regression/expected/version.out | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/META.json b/META.json index be3b162..92e66a5 100644 --- a/META.json +++ b/META.json @@ -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.3.0", + "version": "2.3.1", "maintainer": [ "Artem Gavrilov ", "Diego dos Santos Fronza " @@ -15,7 +15,7 @@ "abstract": "PostgreSQL Query Performance Monitoring Tool", "file": "pg_stat_monitor--2.2--2.3.sql", "docfile": "README.md", - "version": "2.3.0" + "version": "2.3.1" } }, "prereqs": { diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index c7c983f..0d270cf 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -43,7 +43,7 @@ typedef enum pgsmVersion PG_MODULE_MAGIC; -#define BUILD_VERSION "2.3.0" +#define BUILD_VERSION "2.3.1" /* Number of output arguments (columns) for various API versions */ #define PG_STAT_MONITOR_COLS_V1_0 52 diff --git a/regression/expected/version.out b/regression/expected/version.out index deade3b..7a87d65 100644 --- a/regression/expected/version.out +++ b/regression/expected/version.out @@ -2,7 +2,7 @@ CREATE EXTENSION pg_stat_monitor; SELECT pg_stat_monitor_version(); pg_stat_monitor_version ------------------------- - 2.3.0 + 2.3.1 (1 row) DROP EXTENSION pg_stat_monitor; From 2235e8bf4432f7cca88298122e80b91f2ef3a03d Mon Sep 17 00:00:00 2001 From: Manika Singhal Date: Thu, 20 Nov 2025 17:57:15 +0530 Subject: [PATCH 2/4] fix llvm for ol8 --- percona-packaging/scripts/pg_stat_monitor_builder.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/percona-packaging/scripts/pg_stat_monitor_builder.sh b/percona-packaging/scripts/pg_stat_monitor_builder.sh index 8d05077..56c095f 100755 --- a/percona-packaging/scripts/pg_stat_monitor_builder.sh +++ b/percona-packaging/scripts/pg_stat_monitor_builder.sh @@ -213,12 +213,12 @@ 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) - 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 + clang_version=$(yum list --showduplicates clang-devel | grep "20.1" | grep clang | awk '{print $2}' | head -n 1) + llvm_version=$(yum list --showduplicates llvm-devel | grep "20.1" | grep llvm | awk '{print $2}' | head -n 1) + yum install -y clang-devel-${clang_version} clang-${clang_version} llvm-devel-${llvm_version} + dnf module disable -y rust-toolset llvm-toolset else - yum install -y clang-devel clang llvm-devel + yum install -y clang-devel clang llvm-devel fi PKGLIST="percona-postgresql${PG_RELEASE}-devel" From bcd345a8738c412bb0626e34cd6c34857d5a1924 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Thu, 20 Nov 2025 18:19:31 +0100 Subject: [PATCH 3/4] PG-2014 Initalize nested query stack to fix crash on DDL The pgsm_ProcessUtility() which handles DDL increments nesting_level but does not put a query text on the next_queries stack while pgsm_ExecutorRun() does both. It is unclear to me if this is a mistake or by design but since readers of the query check for is the query text pointer is NULL and pgsm_ExecutorRun() reset the pointer to NULL before returning it is safe as long as we initialize the stack to all NULL pointers, which we did not. This bug was found by our test suite in Jenkins on some RHEL based distro version and seems to mostly happen when the first query of a backend is CREATE EXTENSION and we have enabled query normalization but it is entirely possible that it could happen under other circumstances too. The use of calloc() over palloc0() is to keep the patch small since the previous code used malloc(). --- pg_stat_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 0d270cf..6630326 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -343,7 +343,7 @@ _PG_init(void) ExecutorCheckPerms_hook = HOOK(pgsm_ExecutorCheckPerms); nested_queryids = (int64 *) malloc(sizeof(int64) * max_stack_depth); - nested_query_txts = (char **) malloc(sizeof(char *) * max_stack_depth); + nested_query_txts = (char **) calloc(max_stack_depth, sizeof(char *)); system_init = true; } From 133432ed92564059e74bca7ac2bc06f94299a7a3 Mon Sep 17 00:00:00 2001 From: "Andrei V. Lepikhov" Date: Sat, 29 Nov 2025 11:43:59 +0100 Subject: [PATCH 4/4] Fix annoying compilation warnings --- pg_stat_monitor.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 6630326..2338c06 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -82,7 +82,6 @@ void _PG_init(void); /* Current nesting depth of planner/ExecutorRun/ProcessUtility calls */ static int nesting_level = 0; -volatile bool __pgsm_do_not_capture_error = false; #if PG_VERSION_NUM < 170000 /* Before planner nesting level was conunted separately */ @@ -98,10 +97,10 @@ static int hist_bucket_count_total; static uint32 pgsm_client_ip = PGSM_INVALID_IP_MASK; -/* The array to store outer layer query id*/ -int64 *nested_queryids; -char **nested_query_txts; -List *lentries = NIL; +/* The array to store outer layer query id */ +static int64 *nested_queryids; +static char **nested_query_txts; +static List *lentries = NIL; static char relations[REL_LST][REL_LEN]; @@ -211,12 +210,12 @@ static void pgsm_cleanup_callback(void *arg); static void pgsm_store_error(const char *query, ErrorData *edata); /*---- Local variables ----*/ -MemoryContextCallback mem_cxt_reset_callback = +static MemoryContextCallback mem_cxt_reset_callback = { .func = pgsm_cleanup_callback, .arg = NULL }; -volatile bool callback_setup = false; +static volatile bool callback_setup = false; static void pgsm_update_entry(pgsmEntry *entry, const char *query,