From: | momjian(at)svr1(dot)postgresql(dot)org (Bruce Momjian) |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql-server: The patch adresses the TODO list item "Allow external |
Date: | 2004-05-26 15:07:44 |
Message-ID: | 20040526150744.08A03D1B276@svr1.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Log Message:
-----------
The patch adresses the TODO list item "Allow external interfaces to
extend the GUC variable set".
Plugin modules like the pl<lang> modules needs a way to declare
configuration parameters. The postmaster has no knowledge of such
modules when it reads the postgresql.conf file. Rather than allowing
totally unknown configuration parameters, the concept of a variable
"class" is introduced. Variables that belongs to a declared classes will
create a placeholder value of string type and will not generate an
error. When a module is loaded, it will declare variables for such a
class and make those variables "consume" any placeholders that has been
defined. Finally, the module will generate warnings for unrecognized
placeholders defined for its class.
More detail:
The design is outlined after the suggestions made by Tom Lane and Joe
Conway in this thread:
http://archives.postgresql.org/pgsql-hackers/2004-02/msg00229.php
A new string variable 'custom_variable_classes' is introduced. This
variable is a comma separated string of identifiers. Each identifier
denots a 'class' that will allow its members to be added without error.
This variable must be defined in postmaster.conf.
The lexer (guc_file.l) is changed so that it can accept a qualified name
in the form <ID>.<ID> as the name of a variable. I also changed so that
the 'custom_variable_classes', if found, is added first of all variables
in order to remove the order of declaration issue.
The guc_variables table is made more dynamic. It is originally created
with 20% slack and can grow dynamically. A capacity is introduced to
avoid resizing every time a new variable is added. guc_variables and
num_guc_variables becomes static (hidden).
The GucInfoMain now uses the new function get_guc_variables() and
GetNumConfigOptions instead or using the guc_variables directly.
The find_option() function, when passed a missing name, will check if
the name is qualified. If the name is qualified and if the qualifier
denotes a class included in the 'custom_variable_classes', a placeholder
variable will be created. Such a placeholder will not participate in a
list operation but will otherwise function as a normal string variable.
Define<type>GucVariable() functions will be added, one for each variable
type. They are inteded to be used by add-on modules like the pl<lang>
mappings. Example:
extern void DefineCustomBoolVariable(
const char* name,
const char* short_desc,
const char* long_desc,
bool* valueAddr,
GucContext context,
GucBoolAssignHook assign_hook,
GucShowHook show_hook);
(I created typedefs for the assign-hook and show-hook functions). A call
to these functions will define a new GUC-variable. If a placeholder
exists it will be replaced but it's value will be used in place of the
default value. The valueAddr is assumed ot point at a default value when
the define function is called. The only constraint that is imposed on a
Custom variable is that its name is qualified.
Finally, a function:
void EmittWarningsOnPlacholders(const char* className)
was added. This function should be called when a module has completed
its variable definitions. At that time, no placeholders should remain
for the class that the module uses. If they do, elog(INFO, ...) messages
will be issued to inform the user that unrecognized variables are
present.
Thomas Hallgren
Modified Files:
--------------
pgsql-server/doc/src/sgml:
runtime.sgml (r1.263 -> r1.264)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/doc/src/sgml/runtime.sgml.diff?r1=1.263&r2=1.264)
pgsql-server/src/backend/parser:
gram.y (r2.456 -> r2.457)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/parser/gram.y.diff?r1=2.456&r2=2.457)
pgsql-server/src/backend/utils/misc:
guc-file.l (r1.21 -> r1.22)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/misc/guc-file.l.diff?r1=1.21&r2=1.22)
guc.c (r1.207 -> r1.208)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/misc/guc.c.diff?r1=1.207&r2=1.208)
help_config.c (r1.9 -> r1.10)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/misc/help_config.c.diff?r1=1.9&r2=1.10)
pgsql-server/src/include/utils:
guc.h (r1.45 -> r1.46)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/utils/guc.h.diff?r1=1.45&r2=1.46)
guc_tables.h (r1.10 -> r1.11)
(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/utils/guc_tables.h.diff?r1=1.10&r2=1.11)
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2004-05-26 15:26:47 | pgsql-server: The added aggregates are: (1) boolean-and and boolean-or |
Previous Message | Bruce Momjian | 2004-05-26 13:57:06 | pgsql-server: This patch implement the TODO [ALTER DATABASE foo OWNER TO |