1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-26 09:41:40 +03:00

Fix pg_stat_get_backend_activity() to use multi-byte truncated result

pg_stat_get_backend_activity() calls pgstat_clip_activity() to ensure
that the reported query string is correctly truncated when it finishes
with an incomplete multi-byte sequence.  However, the result returned by
the function was not what pgstat_clip_activity() generated, but the
non-truncated, original, contents from PgBackendStatus.st_activity_raw.

Oversight in 54b6cd589a, so backpatch all the way down.

Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAEoWx2mDzwc48q2EK9tSXS6iJMJ35wvxNQnHX+rXjy5VgLvJQw@mail.gmail.com
Backpatch-through: 14
This commit is contained in:
Michael Paquier
2025-12-27 17:23:30 +09:00
parent e82e9aaa6a
commit 36b8f4974a

View File

@@ -806,7 +806,7 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
activity = beentry->st_activity_raw;
clipped_activity = pgstat_clip_activity(activity);
ret = cstring_to_text(activity);
ret = cstring_to_text(clipped_activity);
pfree(clipped_activity);
PG_RETURN_TEXT_P(ret);