Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a00c0e

Browse files
committed
Remove the custom_variable_classes parameter.
This variable provides only marginal error-prevention capability (since it can only check the prefix of a qualified GUC name), and the consensus is that that isn't worth the amount of hassle that maintaining the setting creates for DBAs. So, let's just remove it. With this commit, the system will silently accept a value for any qualified GUC name at all, whether it has anything to do with any known extension or not. (Unqualified names still have to match known built-in settings, though; and you will get a WARNING at extension load time if there's an unrecognized setting with that extension's prefix.) There's still some discussion ongoing about whether to tighten that up and if so how; but if we do come up with a solution, it's not likely to look anything like custom_variable_classes.
1 parent 76074fc commit 1a00c0e

15 files changed

+51
-323
lines changed

doc/src/sgml/auth-delay.sgml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,14 @@
4242
</variablelist>
4343

4444
<para>
45-
In order to set these parameters in your <filename>postgresql.conf</> file,
46-
you will need to add <literal>auth_delay</> to
47-
<xref linkend="guc-custom-variable-classes">. Typical usage might be:
45+
These parameters must be set in <filename>postgresql.conf</>.
46+
Typical usage might be:
4847
</para>
4948

5049
<programlisting>
5150
# postgresql.conf
5251
shared_preload_libraries = 'auth_delay'
5352

54-
custom_variable_classes = 'auth_delay'
5553
auth_delay.milliseconds = '500'
5654
</programlisting>
5755
</sect2>

doc/src/sgml/auto-explain.sgml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,14 @@ LOAD 'auto_explain';
158158
</variablelist>
159159

160160
<para>
161-
In order to set these parameters in your <filename>postgresql.conf</> file,
162-
you will need to add <literal>auto_explain</> to
163-
<xref linkend="guc-custom-variable-classes">. Typical usage might be:
161+
These parameters must be set in <filename>postgresql.conf</>.
162+
Typical usage might be:
164163
</para>
165164

166165
<programlisting>
167166
# postgresql.conf
168167
shared_preload_libraries = 'auto_explain'
169168

170-
custom_variable_classes = 'auto_explain'
171169
auto_explain.log_min_duration = '3s'
172170
</programlisting>
173171
</sect2>

doc/src/sgml/config.sgml

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5940,58 +5940,25 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
59405940
<para>
59415941
This feature was designed to allow parameters not normally known to
59425942
<productname>PostgreSQL</productname> to be added by add-on modules
5943-
(such as procedural languages). This allows add-on modules to be
5943+
(such as procedural languages). This allows extension modules to be
59445944
configured in the standard ways.
59455945
</para>
59465946

5947-
<variablelist>
5948-
5949-
<varlistentry id="guc-custom-variable-classes" xreflabel="custom_variable_classes">
5950-
<term><varname>custom_variable_classes</varname> (<type>string</type>)</term>
5951-
<indexterm>
5952-
<primary><varname>custom_variable_classes</> configuration parameter</primary>
5953-
</indexterm>
5954-
<listitem>
5955-
<para>
5956-
This variable specifies one or several class names to be used for
5957-
custom variables, in the form of a comma-separated list. A custom
5958-
variable is a variable not normally known
5959-
to <productname>PostgreSQL</productname> proper but used by some
5960-
add-on module. Such variables must have names consisting of a class
5961-
name, a dot, and a variable name. <varname>custom_variable_classes</>
5962-
specifies all the class names in use in a particular installation.
5963-
This parameter can only be set in the <filename>postgresql.conf</>
5964-
file or on the server command line.
5965-
</para>
5966-
5967-
</listitem>
5968-
</varlistentry>
5969-
</variablelist>
5970-
59715947
<para>
5972-
The difficulty with setting custom variables in
5973-
<filename>postgresql.conf</> is that the file must be read before add-on
5974-
modules have been loaded, and so custom variables would ordinarily be
5975-
rejected as unknown. When <varname>custom_variable_classes</> is set,
5976-
the server will accept definitions of arbitrary variables within each
5977-
specified class. These variables will be treated as placeholders and
5978-
will have no function until the module that defines them is loaded. When a
5979-
module for a specific class is loaded, it will add the proper variable
5980-
definitions for its class name, convert any placeholder
5981-
values according to those definitions, and issue warnings for any
5982-
unrecognized placeholders of its class that remain.
5948+
Custom options have two-part names: an extension name, then a dot, then
5949+
the parameter name proper, much like qualified names in SQL. An example
5950+
is <literal>plpgsql.variable_conflict</>.
59835951
</para>
59845952

59855953
<para>
5986-
Here is an example of what <filename>postgresql.conf</> might contain
5987-
when using custom variables:
5988-
5989-
<programlisting>
5990-
custom_variable_classes = 'plpgsql,plperl'
5991-
plpgsql.variable_conflict = use_variable
5992-
plperl.use_strict = true
5993-
plruby.use_strict = true # generates error: unknown class name
5994-
</programlisting>
5954+
Because custom options may need to be set in processes that have not
5955+
loaded the relevant extension module, <productname>PostgreSQL</>
5956+
will accept a setting for any two-part parameter name. Such variables
5957+
are treated as placeholders and have no function until the module that
5958+
defines them is loaded. When an extension module is loaded, it will add
5959+
its variable definitions, convert any placeholder values according to
5960+
those definitions, and issue warnings for any unrecognized placeholders
5961+
that begin with its extension name.
59955962
</para>
59965963
</sect1>
59975964

doc/src/sgml/pgstatstatements.sgml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,13 @@
275275
</para>
276276

277277
<para>
278-
In order to set any of these parameters in your
279-
<filename>postgresql.conf</> file,
280-
you will need to add <literal>pg_stat_statements</> to
281-
<xref linkend="guc-custom-variable-classes">. Typical usage might be:
278+
These parameters must be set in <filename>postgresql.conf</>.
279+
Typical usage might be:
282280

283281
<programlisting>
284282
# postgresql.conf
285283
shared_preload_libraries = 'pg_stat_statements'
286284

287-
custom_variable_classes = 'pg_stat_statements'
288285
pg_stat_statements.max = 10000
289286
pg_stat_statements.track = all
290287
</programlisting>

doc/src/sgml/plperl.sgml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,10 +1219,6 @@ CREATE TRIGGER test_valid_id_trig
12191219

12201220
<para>
12211221
This section lists configuration parameters that affect <application>PL/Perl</>.
1222-
To set any of these parameters before <application>PL/Perl</> has been loaded,
1223-
it is necessary to have added <quote><literal>plperl</></> to the
1224-
<xref linkend="guc-custom-variable-classes"> list in
1225-
<filename>postgresql.conf</filename>.
12261222
</para>
12271223

12281224
<variablelist>

doc/src/sgml/plpgsql.sgml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,11 +4007,8 @@ BEGIN
40074007
<literal>use_column</> (where <literal>error</> is the factory default).
40084008
This parameter affects subsequent compilations
40094009
of statements in <application>PL/pgSQL</> functions, but not statements
4010-
already compiled in the current session. To set the parameter before
4011-
<application>PL/pgSQL</> has been loaded, it is necessary to have added
4012-
<quote><literal>plpgsql</></> to the <xref
4013-
linkend="guc-custom-variable-classes"> list in
4014-
<filename>postgresql.conf</filename>. Because changing this setting
4010+
already compiled in the current session.
4011+
Because changing this setting
40154012
can cause unexpected changes in the behavior of <application>PL/pgSQL</>
40164013
functions, it can only be changed by a superuser.
40174014
</para>

src/backend/utils/misc/guc-file.l

Lines changed: 11 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ ProcessConfigFile(GucContext context)
111111
ConfigVariable *item,
112112
*head,
113113
*tail;
114-
char *cvc = NULL;
115-
struct config_string *cvc_struct;
116114
int i;
117115
118116
/*
@@ -138,50 +136,6 @@ ProcessConfigFile(GucContext context)
138136
goto cleanup_list;
139137
}
140138
141-
/*
142-
* We need the proposed new value of custom_variable_classes to check
143-
* custom variables with. ParseConfigFile ensured that if it's in
144-
* the file, it's first in the list. But first check to see if we
145-
* have an active value from the command line, which should override
146-
* the file in any case. (Since there's no relevant env var, the
147-
* only possible nondefault sources are the file and ARGV.)
148-
*/
149-
cvc_struct = (struct config_string *)
150-
find_option("custom_variable_classes", false, elevel);
151-
Assert(cvc_struct);
152-
if (cvc_struct->gen.reset_source > PGC_S_FILE)
153-
{
154-
cvc = guc_strdup(elevel, cvc_struct->reset_val);
155-
if (cvc == NULL)
156-
{
157-
error = true;
158-
goto cleanup_list;
159-
}
160-
}
161-
else if (head != NULL &&
162-
guc_name_compare(head->name, "custom_variable_classes") == 0)
163-
{
164-
/*
165-
* Need to canonicalize the value by calling the check hook.
166-
*/
167-
void *extra = NULL;
168-
169-
cvc = guc_strdup(elevel, head->value);
170-
if (cvc == NULL)
171-
{
172-
error = true;
173-
goto cleanup_list;
174-
}
175-
if (!call_string_check_hook(cvc_struct, &cvc, &extra,
176-
PGC_S_FILE, elevel))
177-
{
178-
error = true;
179-
goto cleanup_list;
180-
}
181-
if (extra)
182-
free(extra);
183-
}
184-
185139
/*
186140
* Mark all extant GUC variables as not present in the config file.
187141
* We need this so that we can tell below which ones have been removed
@@ -199,39 +153,29 @@ ProcessConfigFile(GucContext context)
199153
* quasi-syntactic check on the validity of the config file. It is
200154
* important that the postmaster and all backends agree on the results
201155
* of this phase, else we will have strange inconsistencies about which
202-
* processes accept a config file update and which don't. Hence, custom
203-
* variable names can only be checked against custom_variable_classes,
204-
* not against any loadable modules that might (or might not) be present.
205-
* Likewise, we don't attempt to validate the options' values here.
156+
* processes accept a config file update and which don't. Hence, unknown
157+
* custom variable names have to be accepted without complaint. For the
158+
* same reason, we don't attempt to validate the options' values here.
206159
*
207160
* In addition, the GUC_IS_IN_FILE flag is set on each existing GUC
208161
* variable mentioned in the file.
209162
*/
210163
for (item = head; item; item = item->next)
211164
{
212-
char *sep = strchr(item->name, GUC_QUALIFIER_SEPARATOR);
213165
struct config_generic *record;
214166

215-
if (sep)
216-
{
217-
/* Custom variable, so check against custom_variable_classes */
218-
if (!is_custom_class(item->name, sep - item->name, cvc))
219-
{
220-
ereport(elevel,
221-
(errcode(ERRCODE_UNDEFINED_OBJECT),
222-
errmsg("unrecognized configuration parameter \"%s\" in file \"%s\" line %u",
223-
item->name,
224-
item->filename, item->sourceline)));
225-
error = true;
226-
continue;
227-
}
228-
}
229-
167+
/*
168+
* Try to find the variable; but do not create a custom placeholder
169+
* if it's not there already.
170+
*/
230171
record = find_option(item->name, false, elevel);
231172

232173
if (record)
174+
{
175+
/* Found, so mark it as present in file */
233176
record->status |= GUC_IS_IN_FILE;
234-
else if (!sep)
177+
}
178+
else if (strchr(item->name, GUC_QUALIFIER_SEPARATOR) == NULL)
235179
{
236180
/* Invalid non-custom variable, so complain */
237181
ereport(elevel,
@@ -382,8 +326,6 @@ ProcessConfigFile(GucContext context)
382326

383327
cleanup_list:
384328
FreeConfigVariables(head);
385-
if (cvc)
386-
free(cvc);
387329

388330
if (error)
389331
{
@@ -581,40 +523,6 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
581523
pfree(opt_name);
582524
pfree(opt_value);
583525
}
584-
else if (guc_name_compare(opt_name, "custom_variable_classes") == 0)
585-
{
586-
/*
587-
* This variable must be processed first as it controls
588-
* the validity of other variables; so it goes at the head
589-
* of the result list. If we already found a value for it,
590-
* replace with this one.
591-
*/
592-
item = *head_p;
593-
if (item != NULL &&
594-
guc_name_compare(item->name, "custom_variable_classes") == 0)
595-
{
596-
/* replace existing head item */
597-
pfree(item->name);
598-
pfree(item->value);
599-
item->name = opt_name;
600-
item->value = opt_value;
601-
item->filename = pstrdup(config_file);
602-
item->sourceline = ConfigFileLineno-1;
603-
}
604-
else
605-
{
606-
/* prepend to list */
607-
item = palloc(sizeof *item);
608-
item->name = opt_name;
609-
item->value = opt_value;
610-
item->filename = pstrdup(config_file);
611-
item->sourceline = ConfigFileLineno-1;
612-
item->next = *head_p;
613-
*head_p = item;
614-
if (*tail_p == NULL)
615-
*tail_p = item;
616-
}
617-
}
618526
else
619527
{
620528
/* ordinary variable, append to list */

0 commit comments

Comments
 (0)