PG-1621: fix cmd_type mostly showing 0 values (#538)

This was actually caused by two bugs internally:

* cmd_type was only set in some codepaths, other parts of the code
never set a value. Depending on which query / how was executed,
it was possibly never changed (after a reset to 0)
* the update first set the cmd_type, then reset all counters. As
the cmd_type is stored within the counters for some reason, this
reset its value to 0 in most execution paths, even if it was corretly
set before.

And according to this the fix is simple:

* cmd_type is now set in all codepaths except for failing queries,
as we only have the error string in this case, without the type.
* in the update logic, we again overwrite cmd_type with the proper
value after a reset
This commit is contained in:
Zsolt Parragi
2025-06-17 15:52:28 +02:00
committed by GitHub
parent f7dc7fb5fe
commit 61662cc58f
8 changed files with 51 additions and 15 deletions

View File

@@ -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