ParseConfigFile currently exits on the first parsing error. Changed
guc_file.l to report all parsing errors before exiting:
* Moved parse_error: block inside while() loop
* Removed cleanup_exit: and associated 'goto'
* Added ereport if ParseConfigFile() returns false
* changed OK to ok ;)
* Added comment - TODO: Report bogus variables in addition to parsing
errors before bailing out
-selena
--
Selena Deckelmann
End Point Corporation
sel...@endpoint.com
503-282-2512
*** a/src/backend/utils/misc/guc-file.l
--- b/src/backend/utils/misc/guc-file.l
***************
*** 143,149 **** ProcessConfigFile(GucContext context)
--- 143,155 ----
if (!ParseConfigFile(ConfigFileName, NULL,
0, context, elevel,
&head, &tail))
+ {
+ ereport(elevel,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("Did not reload \"%s\" due to earlier
parsing error(s)", ConfigFileName)));
+ /* TODO: Report bogus variables in addition to parsing errors
before bailing out */
goto cleanup_list;
+ }
/*
* We need the proposed new value of custom_variable_classes to check
***************
*** 361,367 **** ParseConfigFile(const char *config_file, const char
*calling_file,
struct name_value_pair **head_p,
struct name_value_pair **tail_p)
{
! bool OK = true;
char abs_path[MAXPGPATH];
FILE *fp;
YY_BUFFER_STATE lex_buffer;
--- 367,373 ----
struct name_value_pair **head_p,
struct name_value_pair **tail_p)
{
! bool ok = true;
char abs_path[MAXPGPATH];
FILE *fp;
YY_BUFFER_STATE lex_buffer;
***************
*** 461,472 **** ParseConfigFile(const char *config_file, const char
*calling_file,
if (!ParseConfigFile(opt_value, config_file,
depth + 1,
context, elevel,
head_p,
tail_p))
! {
! pfree(opt_name);
! pfree(opt_value);
! OK = false;
! goto cleanup_exit;
! }
yy_switch_to_buffer(lex_buffer);
ConfigFileLineno = save_ConfigFileLineno;
pfree(opt_name);
--- 467,474 ----
if (!ParseConfigFile(opt_value, config_file,
depth + 1,
context, elevel,
head_p,
tail_p))
! ok = false;
!
yy_switch_to_buffer(lex_buffer);
ConfigFileLineno = save_ConfigFileLineno;
pfree(opt_name);
***************
*** 525,552 **** ParseConfigFile(const char *config_file, const char
*calling_file,
/* break out of loop if read EOF, else loop for next line */
if (token == 0)
break;
- }
! /* successful completion of parsing */
! goto cleanup_exit;
! parse_error:
! if (token == GUC_EOL || token == 0)
! ereport(elevel,
! (errcode(ERRCODE_SYNTAX_ERROR),
! errmsg("syntax error in file \"%s\" line %u,
near end of line",
! config_file, ConfigFileLineno -
1)));
! else
! ereport(elevel,
! (errcode(ERRCODE_SYNTAX_ERROR),
! errmsg("syntax error in file \"%s\" line %u,
near token \"%s\"",
! config_file, ConfigFileLineno,
yytext)));
! OK = false;
! cleanup_exit:
yy_delete_buffer(lex_buffer);
FreeFile(fp);
! return OK;
}
--- 527,555 ----
/* break out of loop if read EOF, else loop for next line */
if (token == 0)
break;
! /* skip over parse_error if we made it this far without error */
! continue;
! parse_error:
! if (token == GUC_EOL || token == 0)
! ereport(elevel,
! (errcode(ERRCODE_SYNTAX_ERROR),
! errmsg("syntax error in file
\"%s\" line %u, near end of line",
! config_file,
ConfigFileLineno - 1)));
! else
! ereport(elevel,
! (errcode(ERRCODE_SYNTAX_ERROR),
! errmsg("syntax error in file
\"%s\" line %u, near token \"%s\"",
! config_file,
ConfigFileLineno, yytext)));
! ok = false;
! }
! /* completion of parsing */
yy_delete_buffer(lex_buffer);
FreeFile(fp);
!
! return ok;
}
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers