@@ -129,7 +129,7 @@ ProcessConfigFile(GucContext context)
129
129
/* Parse the file into a list of option names and values */
130
130
head = tail = NULL;
131
131
132
- if (!ParseConfigFile(ConfigFileName, NULL, 0, elevel, &head, &tail))
132
+ if (!ParseConfigFile(ConfigFileName, NULL, true, 0, elevel, &head, &tail))
133
133
{
134
134
/* Syntax error(s) detected in the file, so bail out */
135
135
error = true;
@@ -363,7 +363,7 @@ ProcessConfigFile(GucContext context)
363
363
* and absolute-ifying the path name if necessary.
364
364
*/
365
365
bool
366
- ParseConfigFile (const char *config_file, const char *calling_file,
366
+ ParseConfigFile (const char *config_file, const char *calling_file, bool strict,
367
367
int depth, int elevel,
368
368
ConfigVariable **head_p,
369
369
ConfigVariable **tail_p)
@@ -414,11 +414,19 @@ ParseConfigFile(const char *config_file, const char *calling_file,
414
414
fp = AllocateFile (config_file, " r" );
415
415
if (!fp)
416
416
{
417
- ereport (elevel,
418
- (errcode_for_file_access (),
419
- errmsg (" could not open configuration file \" %s\" : %m" ,
417
+ if (strict)
418
+ {
419
+ ereport (elevel,
420
+ (errcode_for_file_access (),
421
+ errmsg (" could not open configuration file \" %s\" : %m" ,
422
+ config_file)));
423
+ return false ;
424
+ }
425
+
426
+ ereport (LOG,
427
+ (errmsg (" skipping missing configuration file \" %s\" " ,
420
428
config_file)));
421
- return false ;
429
+ return OK ;
422
430
}
423
431
424
432
OK = ParseConfigFp (fp, config_file, depth, elevel, head_p, tail_p);
@@ -512,15 +520,32 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
512
520
}
513
521
514
522
/* OK, process the option name and value */
515
- if (guc_name_compare (opt_name, " include" ) == 0 )
523
+ if (guc_name_compare (opt_name, " include_if_exists" ) == 0 )
524
+ {
525
+ /*
526
+ * An include_if_exists directive isn't a variable and should be
527
+ * processed immediately.
528
+ */
529
+ unsigned int save_ConfigFileLineno = ConfigFileLineno;
530
+
531
+ if (!ParseConfigFile (opt_value, config_file, false ,
532
+ depth + 1 , elevel,
533
+ head_p, tail_p))
534
+ OK = false ;
535
+ yy_switch_to_buffer (lex_buffer);
536
+ ConfigFileLineno = save_ConfigFileLineno;
537
+ pfree (opt_name);
538
+ pfree (opt_value);
539
+ }
540
+ else if (guc_name_compare (opt_name, " include" ) == 0 )
516
541
{
517
542
/*
518
543
* An include directive isn't a variable and should be processed
519
544
* immediately.
520
545
*/
521
546
unsigned int save_ConfigFileLineno = ConfigFileLineno;
522
547
523
- if (!ParseConfigFile (opt_value, config_file,
548
+ if (!ParseConfigFile (opt_value, config_file, true ,
524
549
depth + 1 , elevel,
525
550
head_p, tail_p))
526
551
OK = false ;
0 commit comments