Add stats kind filter to pgstat_drop_matching_entries() pgstat_drop_matching_entries() scans all variable-numbered stats hash tables. Some callers already know which stats kind they want to scan, and such a kind may have its own dshash.
pgstat_drop_matching_entries() is upgraded with a stats kind argument. PGSTAT_KIND_INVALID preserves the existing all-kinds behavior, while a specific kind scans the hash mapped to that kind. When that hash is shared by multiple stats kinds, entries are filtered by kind before invoking the match callback, or applying the drop-all behavior if no match callback is defined. An immediate motivation is pg_stat_statements, where some follow-up work can use this to drop matching entries from its stats kind, without having to scan all the stats hastables. Author: Sami Imseih <[email protected]> Reviewed-by: Bertrand Drouvot <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Discussion: https://postgr.es/m/CAN12+YL7SrAwzMpzfNLrVcy=w5l03p7czyo73rfs06kmdqs...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/31f89191ff7b22b6c69ae5f3c6ab48c5d8bb0f2b Modified Files -------------- src/backend/utils/activity/pgstat_shmem.c | 38 +++++++++++++++--- src/include/utils/pgstat_internal.h | 3 +- .../test_custom_stats/t/001_custom_stats.pl | 34 +++++++++++++++- .../test_custom_var_stats--1.0.sql | 5 +++ .../test_custom_stats/test_custom_var_stats.c | 45 +++++++++++++++++++++- 5 files changed, 116 insertions(+), 9 deletions(-)
