pgsql: test_custom_stats: Fail if loading module outside shared_preload

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: test_custom_stats: Fail if loading module outside shared_preload
Date: 2026-07-02 06:53:23
Message-ID: E1wfBIa-0013FM-08@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

test_custom_stats: Fail if loading module outside shared_preload_libraries

Previously, test_custom_var_stats and test_custom_fixed_stats silently
skipped pgstat_register_kind() when not loaded via
shared_preload_libraries, behavior inherited from injection_points.
This left the SQL functions callable without the kind registered,
leading to various issues on the backend side.

This code is not designed to work without the pgstats kinds registered.
pgstat_register_kind() gets now called when these libraries are loaded,
with or without shared_preload_libraries, letting the registration fail
if loading the modules at a later step than startup. test_custom_rmgrs
does the same thing.

Oversight in 31280d96a648.

Author: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Discussion: https://postgr.es/m/akS/ldidWeqG1FWk(at)bdtpg
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5045d9ff3b5a8b09742d8bf70221c7d708305219

Modified Files
--------------
src/test/modules/test_custom_stats/test_custom_fixed_stats.c | 4 ----
src/test/modules/test_custom_stats/test_custom_var_stats.c | 4 ----
2 files changed, 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message John Naylor 2026-07-02 08:58:22 pgsql: Use ssup_datum_*_cmp in more places
Previous Message John Naylor 2026-07-02 06:36:39 pgsql: Fix loss of precision in pg_stat_us_to_ms()