postgresql/src/backend
Nathan Bossart d0fe3046ee Use actual backend IDs in pg_stat_get_backend_subxact().
Unlike the other pg_stat_get_backend* functions,
pg_stat_get_backend_subxact() looks up the backend entry by using
its integer argument as a 1-based index in an internal array.  The
other functions look for the entry with the matching session
backend ID.  These numbers often match, but that isn't reliably
true.

This commit resolves this discrepancy by introducing
pgstat_get_local_beentry_by_backend_id() and using it in
pg_stat_get_backend_subxact().  We cannot use
pgstat_get_beentry_by_backend_id() because it returns a
PgBackendStatus, which lacks the locally computed additions
available in LocalPgBackendStatus that are required by
pg_stat_get_backend_subxact().

Author: Ian Barwick
Reviewed-by: Sami Imseih, Michael Paquier, Robert Haas
Discussion: https://postgr.es/m/CAB8KJ%3Dj-ACb3H4L9a_b3ZG3iCYDW5aEu3WsPAzkm2S7JzS1Few%40mail.gmail.com
Backpatch-through: 16
2023-08-30 14:47:01 -07:00
..
access Tweak pg_promote() to report failures on kill() or postmaster failures 2023-08-29 08:45:04 +09:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Introduce macros for protocol characters. 2023-08-22 19:16:12 -07:00
bootstrap Make error messages about WAL segment size more consistent 2023-08-28 15:17:04 +02:00
catalog Disallow changing NO INHERIT status of a not-null constraint 2023-08-29 19:19:24 +02:00
commands Fix possible compiler warning 2023-08-30 16:21:21 +02:00
executor Fix RLS policy usage in MERGE. 2023-08-07 09:28:47 +01:00
foreign Expand some more uses of "deleg" to "delegation" or "delegated". 2023-05-21 10:55:18 -04:00
jit Remove duplicated assignment of LLVMJitHandle->lljit 2023-07-13 16:44:17 +09:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq Generate new LOG for "trust" connections under log_connections 2023-08-26 20:11:19 +09:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Catalog not-null constraints 2023-08-25 13:31:24 +02:00
optimizer Catalog not-null constraints 2023-08-25 13:31:24 +02:00
parser Make more use of makeColumnDef() 2023-08-29 08:45:05 +02:00
partitioning Add missing ObjectIdGetDatum() in syscache lookup calls for Oids 2023-07-20 15:18:25 +09:00
po Translation updates 2023-08-07 12:39:30 +02:00
port Add GUC parameter "huge_pages_status" 2023-07-06 14:42:36 +09:00
postmaster Initialize ListenSocket array earlier. 2023-08-29 09:09:40 +03:00
regex All supported systems have locale_t. 2023-07-09 11:55:18 +12:00
replication Rename logical_replication_mode to debug_logical_replication_streaming 2023-08-29 15:19:56 +02:00
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:28:47 +01:00
snowball Fix the install rule for snowball_create.sql. 2023-05-23 11:15:57 -04:00
statistics Take pg_attribute out of VacAttrStats 2023-07-03 07:18:57 +02:00
storage Rename hook functions for debug_io_direct to match variable name. 2023-08-24 22:25:49 +12:00
tcop Fix misuse of PqMsg_Close. 2023-08-29 18:32:38 -07:00
tsearch Take pg_attribute out of VacAttrStats 2023-07-03 07:18:57 +02:00
utils Use actual backend IDs in pg_stat_get_backend_subxact(). 2023-08-30 14:47:01 -07:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Add system view pg_wait_events 2023-08-20 15:35:02 +09:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00