parser_continue_on_errors.diff
application/octet-stream
Filename: parser_continue_on_errors.diff
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc-file.l | 37 | 0 |
*** a/src/backend/utils/misc/guc-file.l
--- b/src/backend/utils/misc/guc-file.l
***************
*** 104,110 **** STRING \'([^'\\\n]|\\.|\'\')*\'
void
ProcessConfigFile(GucContext context)
{
! int elevel;
ConfigVariable *item,
*head,
*tail;
--- 104,111 ----
void
ProcessConfigFile(GucContext context)
{
! int elevel,
! errorcount;
ConfigVariable *item,
*head,
*tail;
***************
*** 127,132 **** ProcessConfigFile(GucContext context)
--- 128,134 ----
/* Parse the file into a list of option names and values */
head = tail = NULL;
+ errorcount = 0;
if (!ParseConfigFile(ConfigFileName, NULL, 0, elevel, &head, &tail))
goto cleanup_list;
***************
*** 161,167 **** ProcessConfigFile(GucContext context)
goto cleanup_list;
if (!call_string_check_hook(cvc_struct, &cvc, &extra,
PGC_S_FILE, elevel))
! goto cleanup_list;
if (extra)
free(extra);
}
--- 163,169 ----
goto cleanup_list;
if (!call_string_check_hook(cvc_struct, &cvc, &extra,
PGC_S_FILE, elevel))
! errorcount++;
if (extra)
free(extra);
}
***************
*** 201,207 **** ProcessConfigFile(GucContext context)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("unrecognized configuration parameter \"%s\"",
item->name)));
! goto cleanup_list;
}
/*
* 2. There is no GUC entry. If we called set_config_option then
--- 203,209 ----
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("unrecognized configuration parameter \"%s\"",
item->name)));
! errorcount++;
}
/*
* 2. There is no GUC entry. If we called set_config_option then
***************
*** 221,228 **** ProcessConfigFile(GucContext context)
if (!set_config_option(item->name, item->value, context,
PGC_S_FILE, GUC_ACTION_SET, false))
! goto cleanup_list;
! }
/*
* Check for variables having been removed from the config file, and
--- 223,237 ----
if (!set_config_option(item->name, item->value, context,
PGC_S_FILE, GUC_ACTION_SET, false))
! errorcount++;
!
! /* avoid excessive bloat of the log file */
! if (IsUnderPostmaster || errorcount >= 100 )
! break;
! }
! /* Don't change configuration options if errors were detected earlier */
! if (errorcount > 0)
! goto cleanup_list;
/*
* Check for variables having been removed from the config file, and
***************
*** 447,455 **** bool
ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
ConfigVariable **head_p, ConfigVariable **tail_p)
{
- bool OK = true;
YY_BUFFER_STATE lex_buffer;
! int token;
/*
* Parse
--- 456,464 ----
ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
ConfigVariable **head_p, ConfigVariable **tail_p)
{
YY_BUFFER_STATE lex_buffer;
! int token,
! errorcount;
/*
* Parse
***************
*** 458,463 **** ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
--- 467,473 ----
yy_switch_to_buffer(lex_buffer);
ConfigFileLineno = 1;
+ errorcount = 0;
/* This loop iterates once per logical line */
while ((token = yylex()))
***************
*** 515,522 **** ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
{
pfree(opt_name);
pfree(opt_value);
! OK = false;
! goto cleanup_exit;
}
yy_switch_to_buffer(lex_buffer);
ConfigFileLineno = save_ConfigFileLineno;
--- 525,531 ----
{
pfree(opt_name);
pfree(opt_value);
! goto parse_error;
}
yy_switch_to_buffer(lex_buffer);
ConfigFileLineno = save_ConfigFileLineno;
***************
*** 576,602 **** ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
/* 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);
! return OK;
}
--- 585,613 ----
/* 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)));
+ errorcount++;
+ /* avoid excessive bloat of the log file */
+ if (IsUnderPostmaster || errorcount >= 100)
+ break;
}
/* successful completion of parsing */
yy_delete_buffer(lex_buffer);
! return (errorcount == 0);
}