mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
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".
This commit is contained in:
@ -4140,20 +4140,17 @@ CheckDateTokenTables(void)
|
||||
/*
|
||||
* This function gets called during timezone config file load or reload
|
||||
* to create the final array of timezone tokens. The argument array
|
||||
* is already sorted in name order. This data is in a temporary memory
|
||||
* context and must be copied to somewhere permanent.
|
||||
* is already sorted in name order. The data is converted to datetkn
|
||||
* format and installed in *tbl, which must be allocated by the caller.
|
||||
*/
|
||||
void
|
||||
InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n)
|
||||
ConvertTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl,
|
||||
struct tzEntry *abbrevs, int n)
|
||||
{
|
||||
datetkn *newtbl;
|
||||
datetkn *newtbl = tbl->abbrevs;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Copy the data into TopMemoryContext and convert to datetkn format.
|
||||
*/
|
||||
newtbl = (datetkn *) MemoryContextAlloc(TopMemoryContext,
|
||||
n * sizeof(datetkn));
|
||||
tbl->numabbrevs = n;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
strncpy(newtbl[i].token, abbrevs[i].abbrev, TOKMAXLEN);
|
||||
@ -4163,12 +4160,20 @@ InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n)
|
||||
|
||||
/* Check the ordering, if testing */
|
||||
Assert(CheckDateTokenTable("timezone offset", newtbl, n));
|
||||
}
|
||||
|
||||
/* Now safe to replace existing table (if any) */
|
||||
if (timezonetktbl)
|
||||
pfree(timezonetktbl);
|
||||
timezonetktbl = newtbl;
|
||||
sztimezonetktbl = n;
|
||||
/*
|
||||
* Install a TimeZoneAbbrevTable as the active table.
|
||||
*
|
||||
* Caller is responsible that the passed table doesn't go away while in use.
|
||||
*/
|
||||
void
|
||||
InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
|
||||
{
|
||||
int i;
|
||||
|
||||
timezonetktbl = tbl->abbrevs;
|
||||
sztimezonetktbl = tbl->numabbrevs;
|
||||
|
||||
/* clear date cache in case it contains any stale timezone names */
|
||||
for (i = 0; i < MAXDATEFIELDS; i++)
|
||||
|
Reference in New Issue
Block a user