*** a/src/backend/utils/misc/guc-file.l --- b/src/backend/utils/misc/guc-file.l *************** *** 103,109 **** STRING \'([^'\\\n]|\\.|\'\')*\' void ProcessConfigFile(GucContext context) { ! int elevel; ConfigVariable *item, *head, *tail; --- 103,110 ---- 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; *************** *** 145,151 **** ProcessConfigFile(GucContext context) { cvc = guc_strdup(elevel, cvc_struct->reset_val); if (cvc == NULL) ! goto cleanup_list; } else if (head != NULL && guc_name_compare(head->name, "custom_variable_classes") == 0) --- 147,153 ---- { cvc = guc_strdup(elevel, cvc_struct->reset_val); if (cvc == NULL) ! errorcount++; } else if (head != NULL && guc_name_compare(head->name, "custom_variable_classes") == 0) *************** *** 162,168 **** ProcessConfigFile(GucContext context) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid value for parameter \"%s\": \"%s\"", head->name, head->value))); ! goto cleanup_list; } } --- 164,170 ---- (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid value for parameter \"%s\": \"%s\"", head->name, head->value))); ! errorcount++; } } *************** *** 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,239 ---- 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 *************** *** 294,300 **** ProcessConfigFile(GucContext context) set_config_option("client_encoding", envvar, PGC_POSTMASTER, PGC_S_ENV_VAR, GUC_ACTION_SET, true); ! /* If we got here all the options checked out okay, so apply them. */ for (item = head; item; item = item->next) { --- 305,311 ---- set_config_option("client_encoding", envvar, PGC_POSTMASTER, PGC_S_ENV_VAR, GUC_ACTION_SET, true); ! /* If we got here all the options checked out okay, so apply them. */ for (item = head; item; item = item->next) { *************** *** 354,360 **** ParseConfigFile(const char *config_file, const char *calling_file, ConfigVariable **head_p, ConfigVariable **tail_p) { ! bool OK = true; FILE *fp; char abs_path[MAXPGPATH]; --- 365,371 ---- ConfigVariable **head_p, ConfigVariable **tail_p) { ! bool ok = true; FILE *fp; char abs_path[MAXPGPATH]; *************** *** 407,417 **** ParseConfigFile(const char *config_file, const char *calling_file, return false; } ! OK = ParseConfigFp(fp, config_file, depth, elevel, head_p, tail_p); FreeFile(fp); ! return OK; } /* --- 418,428 ---- return false; } ! ok = ParseConfigFp(fp, config_file, depth, elevel, head_p, tail_p); FreeFile(fp); ! return ok; } /* *************** *** 444,452 **** 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 --- 455,463 ---- 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 *************** *** 455,460 **** ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, --- 466,472 ---- yy_switch_to_buffer(lex_buffer); ConfigFileLineno = 1; + errorcount = 0; /* This loop iterates once per logical line */ while ((token = yylex())) *************** *** 512,519 **** 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; --- 524,530 ---- { pfree(opt_name); pfree(opt_value); ! goto parse_error; } yy_switch_to_buffer(lex_buffer); ConfigFileLineno = save_ConfigFileLineno; *************** *** 573,599 **** 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; } --- 584,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); }