@@ -42,6 +42,13 @@ struct syncrep_yy_extra_type
4242StringInfoData xdbuf;
4343};
4444
45+ /*
46+ * Better keep this definition here than put it in replication/syncrep.h and
47+ * save a bit of duplication. Putting it in replication/syncrep.h would leak
48+ * the definition to other parts and possibly affect other scanners.
49+ */
50+ #define YY_DECL extern int syncrep_yylex (union YYSTYPE *yylval_param,char **syncrep_parse_error_msg_p,yyscan_t yyscanner)
51+
4552/* LCOV_EXCL_START*/
4653
4754%}
@@ -104,7 +111,7 @@ xdinside[^"]+
104111return NAME;
105112}
106113<xd><<EOF>> {
107- syncrep_yyerror (yyscanner," unterminated quoted identifier" );
114+ syncrep_yyerror (NULL , syncrep_parse_error_msg_p, yyscanner," unterminated quoted identifier" );
108115return JUNK;
109116}
110117
@@ -136,12 +143,21 @@ xdinside[^"]+
136143#undef yyextra
137144#define yyextra (((struct yyguts_t *) yyscanner)->yyextra_r)
138145
139- /* Needs to be here for access to yytext */
146+ /*
147+ * This yyerror() function does not raise an error (elog or similar), it just
148+ * collects the error message in *syncrep_parse_error_msg_p and leaves it to
149+ * the ultimate caller of the syncrep parser to raise the error. (The
150+ * ultimate caller will do that with special GUC error functions.)
151+ *
152+ * (The first argument is enforced by Bison to match the first argument of
153+ * yyparse(), but it is not used here.)
154+ */
140155void
141- syncrep_yyerror (yyscan_t yyscanner,const char *message)
156+ syncrep_yyerror (SyncRepConfigData **syncrep_parse_result_p, char **syncrep_parse_error_msg_p, yyscan_t yyscanner,const char *message)
142157{
143158struct yyguts_t *yyg = (struct yyguts_t *) yyscanner;/* needed for yytext
144159 * macro */
160+ char *syncrep_parse_error_msg = *syncrep_parse_error_msg_p;
145161
146162/* report only the first error in a parse operation */
147163if (syncrep_parse_error_msg)