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

Commit1afc1fe

Browse files
committed
Back-patch some minor bug fixes in GUC code.
In 9.4, fix a 9.4.1 regression that allowed multiple entries for aPGC_POSTMASTER variable to cause bogus complaints in the postmaster log.(The issue here was that commitbf007a2 unintentionally reverted3e3f659, which suppressed any duplicate entries withinParseConfigFp. Back-patch the reimplementation just made in HEAD, whichmakes use of an "ignore" field to prevent application of superseded items.)Add missed failure check in AlterSystemSetConfigFile(). We don't reallyexpect ParseConfigFp() to fail, but that's not an excuse for not checking.In both 9.3 and 9.4, remove mistaken assignment to ConfigFileLineno thatcaused line counting after an include_dir directive to be completely wrong.
1 parentf9f7150 commit1afc1fe

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

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

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,17 @@ ProcessConfigFile(GucContext context)
230230
* same reason, we don't attempt to validate the options' values here.
231231
*
232232
* In addition, the GUC_IS_IN_FILE flag is set on each existing GUC
233-
* variable mentioned in the file.
233+
* variable mentioned in the file; and we detect duplicate entries in
234+
* the file and mark the earlier occurrences as ignorable.
234235
*/
235236
for (item = head; item; item = item->next)
236237
{
237238
structconfig_generic *record;
238239

240+
/* Ignore anything already marked as ignorable */
241+
if (item->ignore)
242+
continue;
243+
239244
/*
240245
* Try to find the variable; but do not create a custom placeholder
241246
* if it's not there already.
@@ -244,7 +249,24 @@ ProcessConfigFile(GucContext context)
244249

245250
if (record)
246251
{
247-
/* Found, so mark it as present in file */
252+
/* If it's already marked, then this is a duplicate entry */
253+
if (record->status & GUC_IS_IN_FILE)
254+
{
255+
/*
256+
* Mark the earlier occurrence(s) as dead/ignorable. We could
257+
* avoid the O(N^2) behavior here with some additional state,
258+
* but it seems unlikely to be worth the trouble.
259+
*/
260+
ConfigVariable *pitem;
261+
262+
for (pitem = head; pitem != item; pitem = pitem->next)
263+
{
264+
if (!pitem->ignore &&
265+
strcmp(pitem->name, item->name) ==0)
266+
pitem->ignore =true;
267+
}
268+
}
269+
/* Now mark it as present in file */
248270
record->status |= GUC_IS_IN_FILE;
249271
}
250272
elseif (strchr(item->name, GUC_QUALIFIER_SEPARATOR) ==NULL)
@@ -352,6 +374,10 @@ ProcessConfigFile(GucContext context)
352374
char *pre_value =NULL;
353375
intscres;
354376

377+
/* Ignore anything marked as ignorable */
378+
if (item->ignore)
379+
continue;
380+
355381
/* In SIGHUP cases in the postmaster, we want to report changes */
356382
if (context == PGC_SIGHUP && !IsUnderPostmaster)
357383
{
@@ -557,19 +583,25 @@ GUC_flex_fatal(const char *msg)
557583
*config_file: absolute or relative path name of the configuration file
558584
*depth: recursion depth (should be 0 in the outermost call)
559585
*elevel: error logging level to use
560-
* Output parameters:
586+
*Input/Output parameters:
561587
*head_p, tail_p: head and tail of linked list of name/value pairs
562588
*
563-
* *head_p and *tail_p must be initializedto NULLbefore calling the outer
564-
*recursion level. On exit, they contain a list of name-value pairs read
565-
* from the input file(s).
589+
* *head_p and *tail_p must be initialized, eitherto NULLor valid pointers
590+
*to a ConfigVariable list, before calling the outer recursion level. Any
591+
*name-value pairs readfrom the input file(s) will be appended to the list.
566592
*
567593
* Returns TRUE if successful, FALSE if an error occurred. The error has
568594
* already been ereport'd, it is only necessary for the caller to clean up
569595
* its own state and release the ConfigVariable list.
570596
*
571597
* Note: if elevel >= ERROR then an error will not return control to the
572598
* caller, so there is no need to check the return value in that case.
599+
*
600+
* Note: this function is used to parse not only postgresql.conf, but
601+
* various other configuration files that use the same "name = value"
602+
* syntax. Hence, do not do anything here or in the subsidiary routines
603+
* ParseConfigFile/ParseConfigDirectory that assumes we are processing
604+
* GUCs specifically.
573605
*/
574606
bool
575607
ParseConfigFp(FILE *fp,constchar *config_file,int depth,int elevel,
@@ -658,11 +690,10 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
658690
* processed immediately.
659691
*/
660692
if (!ParseConfigDirectory(opt_value, config_file,
661-
depth +1, elevel,
662-
head_p, tail_p))
693+
depth +1, elevel,
694+
head_p, tail_p))
663695
OK =false;
664696
yy_switch_to_buffer(lex_buffer);
665-
ConfigFileLineno = save_ConfigFileLineno;
666697
pfree(opt_name);
667698
pfree(opt_value);
668699
}
@@ -702,6 +733,7 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
702733
item->value = opt_value;
703734
item->filename =pstrdup(config_file);
704735
item->sourceline = ConfigFileLineno-1;
736+
item->ignore =false;
705737
item->next =NULL;
706738
if (*head_p ==NULL)
707739
*head_p = item;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6620,6 +6620,7 @@ replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
66206620
item->value=pstrdup(value);
66216621
item->filename=pstrdup("");/* new item has no location */
66226622
item->sourceline=0;
6623+
item->ignore= false;
66236624
item->next=NULL;
66246625

66256626
if (*head_p==NULL)
@@ -6767,7 +6768,10 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
67676768
AutoConfFileName)));
67686769

67696770
/* parse it */
6770-
ParseConfigFp(infile,AutoConfFileName,0,LOG,&head,&tail);
6771+
if (!ParseConfigFp(infile,AutoConfFileName,0,LOG,&head,&tail))
6772+
ereport(ERROR,
6773+
(errmsg("could not parse contents of file \"%s\"",
6774+
AutoConfFileName)));
67716775

67726776
FreeFile(infile);
67736777
}

‎src/include/utils/guc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ typedef enum
110110
}GucSource;
111111

112112
/*
113-
* Parsing the configuration file will return a list of name-value pairs
113+
* Parsing the configuration file(s) will return a list of name-value pairs
114114
* with source location info.
115+
*
116+
* If "ignore" is true, don't attempt to apply the item (it might be an item
117+
* we determined to be duplicate, for instance).
115118
*/
116119
typedefstructConfigVariable
117120
{
@@ -120,6 +123,7 @@ typedef struct ConfigVariable
120123
char*filename;
121124
intsourceline;
122125
structConfigVariable*next;
126+
boolignore;
123127
}ConfigVariable;
124128

125129
externboolParseConfigFile(constchar*config_file,constchar*calling_file,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp