Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?

Thomas Munro <thomas.munro@gmail.com>

From: Thomas Munro <thomas.munro@gmail.com>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Bruce Momjian <bruce@momjian.us>, Nitin Jadhav <nitinjadhavpostgres@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Hannu Krosing <hannuk@google.com>, Robert Haas <robertmhaas@gmail.com>, Pavel Stehule <pavel.stehule@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Michael Paquier <michael@paquier.xyz>, torikoshia <torikoshia@oss.nttdata.com>, Atsushi Torikoshi <atorik@gmail.com>, Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, Evgeny Efimkin <efimkin@yandex-team.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-04-08T11:36:48Z
Lists: pgsql-hackers
Hi Julien, Bruce,

A warning appears on 32 bit systems:

In file included from pgstatfuncs.c:15:
pgstatfuncs.c: In function 'pg_stat_get_activity':
../../../../src/include/postgres.h:593:29: warning: cast to pointer
from integer of different size [-Wint-to-pointer-cast]
  593 | #define DatumGetPointer(X) ((Pointer) (X))
      |                             ^
../../../../src/include/postgres.h:678:42: note: in expansion of macro
'DatumGetPointer'
  678 | #define DatumGetUInt64(X) (* ((uint64 *) DatumGetPointer(X)))
      |                                          ^~~~~~~~~~~~~~~
pgstatfuncs.c:920:18: note: in expansion of macro 'DatumGetUInt64'
  920 |     values[29] = DatumGetUInt64(beentry->st_queryid);
      |                  ^~~~~~~~~~~~~~

Hmm, maybe this should be UInt64GetDatum()?



Commits

  1. Clarify description of pg_stat_statements columns

  2. Fix wording in description of pg_stat_statements.toplevel

  3. Mention that toplevel is part of pg_stat_statements key.

  4. adjust query id feature to use pg_stat_activity.query_id

  5. Update copyright for 2021

  6. Take the statistics collector out of the loop for monitoring backends'