Add missing EmitWarningsOnPlaceholders() calls.

Extensions that define any custom GUCs should call
EmitWarningsOnPlaceholders after doing so, to help catch misspellings.
Many of our contrib modules hadn't gotten the memo on that, though.

Also add such calls to src/test/modules extensions that have GUCs.
While these aren't really user-facing, they should illustrate good
practice not faulty practice.

Shinya Kato

Discussion: https://postgr.es/m/524fa2c0a34f34b68fbfa90d0760d515@oss.nttdata.com
This commit is contained in:
Tom Lane 2021-12-21 12:12:24 -05:00
parent 0e6e7f0806
commit 1fada5d81e
9 changed files with 26 additions and 0 deletions

View File

@ -67,6 +67,9 @@ _PG_init(void)
NULL,
NULL,
NULL);
EmitWarningsOnPlaceholders("auth_delay");
/* Install Hooks */
original_client_auth_hook = ClientAuthentication_hook;
ClientAuthentication_hook = auth_delay_checks;

View File

@ -100,6 +100,8 @@ _PG_init(void)
NULL,
NULL,
NULL);
EmitWarningsOnPlaceholders("pg_trgm");
}
/*

View File

@ -469,4 +469,6 @@ _PG_init(void)
NULL,
NULL,
NULL);
EmitWarningsOnPlaceholders("postgres_fdw");
}

View File

@ -455,6 +455,8 @@ _PG_init(void)
NULL,
NULL);
EmitWarningsOnPlaceholders("sepgsql");
/* Initialize userspace access vector cache */
sepgsql_avc_init();

View File

@ -9194,6 +9194,9 @@ reapply_stacked_values(struct config_generic *variable,
}
}
/*
* Functions for extensions to call to define their custom GUC variables.
*/
void
DefineCustomBoolVariable(const char *name,
const char *short_desc,
@ -9333,6 +9336,10 @@ DefineCustomEnumVariable(const char *name,
define_custom_variable(&var->gen);
}
/*
* Extensions should call this after they've defined all of their custom
* GUCs, to help catch misspelled config-file entries,
*/
void
EmitWarningsOnPlaceholders(const char *className)
{

View File

@ -474,6 +474,9 @@ _PG_init(void)
PGC_SUSET, 0,
NULL, NULL, NULL);
EmitWarningsOnPlaceholders("pltcl");
EmitWarningsOnPlaceholders("pltclu");
pltcl_pm_init_done = true;
}

View File

@ -91,6 +91,8 @@ _PG_init(void)
NULL,
NULL);
EmitWarningsOnPlaceholders("delay_execution");
/* Install our hook */
prev_planner_hook = planner_hook;
planner_hook = delay_execution_planner;

View File

@ -48,6 +48,9 @@ _PG_init(void)
NULL,
NULL,
NULL);
EmitWarningsOnPlaceholders("ssl_passphrase");
if (ssl_passphrase)
openssl_tls_init_hook = set_rot13;
}

View File

@ -322,6 +322,8 @@ _PG_init(void)
0,
NULL, NULL, NULL);
EmitWarningsOnPlaceholders("worker_spi");
/* set up common data for all our workers */
memset(&worker, 0, sizeof(worker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS |