From: Michael Paquier Date: Thu, 2 Jul 2026 06:52:46 +0000 (+0900) Subject: test_custom_stats: Fail if loading module outside shared_preload_libraries X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5045d9ff3b5a8b09742d8bf70221c7d708305219;p=thirdparty%2Fpostgresql.git 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 Reviewed-by: Ewan Young Discussion: https://postgr.es/m/akS/ldidWeqG1FWk@bdtpg Backpatch-through: 19 --- diff --git a/src/test/modules/test_custom_stats/test_custom_fixed_stats.c b/src/test/modules/test_custom_stats/test_custom_fixed_stats.c index a066ce117a6..32be1d587a1 100644 --- a/src/test/modules/test_custom_stats/test_custom_fixed_stats.c +++ b/src/test/modules/test_custom_stats/test_custom_fixed_stats.c @@ -72,10 +72,6 @@ static const PgStat_KindInfo custom_stats = { void _PG_init(void) { - /* Must be loaded via shared_preload_libraries */ - if (!process_shared_preload_libraries_in_progress) - return; - /* Register custom statistics kind */ pgstat_register_kind(PGSTAT_KIND_TEST_CUSTOM_FIXED_STATS, &custom_stats); } diff --git a/src/test/modules/test_custom_stats/test_custom_var_stats.c b/src/test/modules/test_custom_stats/test_custom_var_stats.c index 863d6a52492..024dae85a45 100644 --- a/src/test/modules/test_custom_stats/test_custom_var_stats.c +++ b/src/test/modules/test_custom_stats/test_custom_var_stats.c @@ -129,10 +129,6 @@ static const PgStat_KindInfo custom_stats = { void _PG_init(void) { - /* Must be loaded via shared_preload_libraries */ - if (!process_shared_preload_libraries_in_progress) - return; - /* Register custom statistics kind */ pgstat_register_kind(PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, &custom_stats); }