diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-04-07 00:11:01 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-04-07 00:12:02 -0400 |
commit | 2594cf0e8c04406ffff19b1651c5a406d376657c (patch) | |
tree | 8ced737d26b54f4499a8029d8cad0ab42fc83ba3 /src/include/commands/variable.h | |
parent | 5d0e462366f4521e37744fdb42fed3c6819a3374 (diff) | |
download | postgresql-2594cf0e8c04406ffff19b1651c5a406d376657c.tar.gz postgresql-2594cf0e8c04406ffff19b1651c5a406d376657c.zip |
Revise the API for GUC variable assign hooks.
The previous functions of assign hooks are now split between check hooks
and assign hooks, where the former can fail but the latter shouldn't.
Aside from being conceptually clearer, this approach exposes the
"canonicalized" form of the variable value to guc.c without having to do
an actual assignment. And that lets us fix the problem recently noted by
Bernd Helmle that the auto-tune patch for wal_buffers resulted in bogus
log messages about "parameter "wal_buffers" cannot be changed without
restarting the server". There may be some speed advantage too, because
this design lets hook functions avoid re-parsing variable values when
restoring a previous state after a rollback (they can store a pre-parsed
representation of the value instead). This patch also resolves a
longstanding annoyance about custom error messages from variable assign
hooks: they should modify, not appear separately from, guc.c's own message
about "invalid parameter value".
Diffstat (limited to 'src/include/commands/variable.h')
-rw-r--r-- | src/include/commands/variable.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/include/commands/variable.h b/src/include/commands/variable.h index 39bccbd5bf6..1d904ff984b 100644 --- a/src/include/commands/variable.h +++ b/src/include/commands/variable.h @@ -13,31 +13,28 @@ #include "utils/guc.h" -extern const char *assign_datestyle(const char *value, - bool doit, GucSource source); -extern const char *assign_timezone(const char *value, - bool doit, GucSource source); +extern bool check_datestyle(char **newval, void **extra, GucSource source); +extern void assign_datestyle(const char *newval, void *extra); +extern bool check_timezone(char **newval, void **extra, GucSource source); +extern void assign_timezone(const char *newval, void *extra); extern const char *show_timezone(void); -extern const char *assign_log_timezone(const char *value, - bool doit, GucSource source); +extern bool check_log_timezone(char **newval, void **extra, GucSource source); +extern void assign_log_timezone(const char *newval, void *extra); extern const char *show_log_timezone(void); -extern bool assign_transaction_read_only(bool value, - bool doit, GucSource source); -extern const char *assign_XactIsoLevel(const char *value, - bool doit, GucSource source); +extern bool check_transaction_read_only(bool *newval, void **extra, GucSource source); +extern bool check_XactIsoLevel(char **newval, void **extra, GucSource source); +extern void assign_XactIsoLevel(const char *newval, void *extra); extern const char *show_XactIsoLevel(void); -extern bool assign_transaction_deferrable(bool newval, bool doit, - GucSource source); -extern bool assign_random_seed(double value, - bool doit, GucSource source); +extern bool check_transaction_deferrable(bool *newval, void **extra, GucSource source); +extern bool check_random_seed(double *newval, void **extra, GucSource source); +extern void assign_random_seed(double newval, void *extra); extern const char *show_random_seed(void); -extern const char *assign_client_encoding(const char *value, - bool doit, GucSource source); -extern const char *assign_role(const char *value, - bool doit, GucSource source); +extern bool check_client_encoding(char **newval, void **extra, GucSource source); +extern void assign_client_encoding(const char *newval, void *extra); +extern bool check_session_authorization(char **newval, void **extra, GucSource source); +extern void assign_session_authorization(const char *newval, void *extra); +extern bool check_role(char **newval, void **extra, GucSource source); +extern void assign_role(const char *newval, void *extra); extern const char *show_role(void); -extern const char *assign_session_authorization(const char *value, - bool doit, GucSource source); -extern const char *show_session_authorization(void); #endif /* VARIABLE_H */ |