Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a9e530

Browse files
committed
Fix another oversight in logging of changes in postgresql.conf settings.
We were using GetConfigOption to collect the old value of each setting,overlooking the possibility that it didn't exist yet. This does happenin the case of adding a new entry within a custom variable class, asexhibited in bug #6097 from Maxim Boguk.To fix, add a missing_ok parameter to GetConfigOption, but only in 9.1and HEAD --- it seems possible that some third-party code is using thatfunction, so changing its API in a minor release would cause problems.In 9.0, create a near-duplicate function instead.
1 parentd1ca2a1 commit9a9e530

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ ProcessConfigFile(GucContext context)
317317
/* In SIGHUP cases in the postmaster, report changes */
318318
if (context == PGC_SIGHUP && !IsUnderPostmaster)
319319
{
320-
constchar *preval =GetConfigOption(item->name,false);
320+
constchar *preval =GetConfigOptionNoError(item->name);
321321

322-
/*string variables could beNULL; treatthatas empty */
322+
/*If option doesn't exist yet or isNULL, treat as empty string */
323323
if (!preval)
324324
preval ="";
325325
/* must dup, else might have dangling pointer below */
@@ -334,7 +334,7 @@ ProcessConfigFile(GucContext context)
334334

335335
if (pre_value)
336336
{
337-
constchar *post_value =GetConfigOption(item->name,false);
337+
constchar *post_value =GetConfigOptionNoError(item->name);
338338

339339
if (!post_value)
340340
post_value ="";

‎src/backend/utils/misc/guc.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5391,6 +5391,46 @@ GetConfigOption(const char *name, bool restrict_superuser)
53915391
returnNULL;
53925392
}
53935393

5394+
/*
5395+
* As above, but return NULL if no such option.
5396+
* (This is a stopgap to avoid changing GetConfigOption's API within the
5397+
* 9.0.x release series.)
5398+
*/
5399+
constchar*
5400+
GetConfigOptionNoError(constchar*name)
5401+
{
5402+
structconfig_generic*record;
5403+
staticcharbuffer[256];
5404+
5405+
record=find_option(name, false,ERROR);
5406+
if (record==NULL)
5407+
returnNULL;
5408+
5409+
switch (record->vartype)
5410+
{
5411+
casePGC_BOOL:
5412+
return*((structconfig_bool*)record)->variable ?"on" :"off";
5413+
5414+
casePGC_INT:
5415+
snprintf(buffer,sizeof(buffer),"%d",
5416+
*((structconfig_int*)record)->variable);
5417+
returnbuffer;
5418+
5419+
casePGC_REAL:
5420+
snprintf(buffer,sizeof(buffer),"%g",
5421+
*((structconfig_real*)record)->variable);
5422+
returnbuffer;
5423+
5424+
casePGC_STRING:
5425+
return*((structconfig_string*)record)->variable;
5426+
5427+
casePGC_ENUM:
5428+
returnconfig_enum_lookup_by_value((structconfig_enum*)record,
5429+
*((structconfig_enum*)record)->variable);
5430+
}
5431+
returnNULL;
5432+
}
5433+
53945434
/*
53955435
* Get the RESET value associated with the given option.
53965436
*

‎src/include/utils/guc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ extern void DefineCustomEnumVariable(
253253
externvoidEmitWarningsOnPlaceholders(constchar*className);
254254

255255
externconstchar*GetConfigOption(constchar*name,boolrestrict_superuser);
256+
externconstchar*GetConfigOptionNoError(constchar*name);
256257
externconstchar*GetConfigOptionResetString(constchar*name);
257258
externvoidProcessConfigFile(GucContextcontext);
258259
externvoidInitializeGUCOptions(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp