diff options
| author | John Naylor <john.naylor@postgresql.org> | 2022-09-04 11:33:31 +0700 |
|---|---|---|
| committer | John Naylor <john.naylor@postgresql.org> | 2022-09-04 12:09:01 +0700 |
| commit | dac048f71ebbcf2f980d280711f8ff8001331c5d (patch) | |
| tree | 48311f22d4636b6fb12cf2bb43925622521e758a /src/backend/replication | |
| parent | 80e8450a744b1f6fa75663f37f1db3388995dc67 (diff) | |
Build all Flex files standalone
The proposed Meson build system will need a way to ignore certain
generated files in order to coexist with the autoconf build system,
and C files generated by Flex which are #include'd into .y files make
this more difficult. In similar vein to 72b1e3a21, arrange for all Flex
C files to compile to their own .o targets.
Reviewed by Andres Freund
Discussion: https://www.postgresql.org/message-id/20220810171935.7k5zgnjwqzalzmtm%40awork3.anarazel.de
Discussion: https://www.postgresql.org/message-id/CAFBsxsF8Gc2StS3haXofshHCzqNMRXiSxvQEYGwnFsTmsdwNeg@mail.gmail.com
Diffstat (limited to 'src/backend/replication')
| -rw-r--r-- | src/backend/replication/.gitignore | 2 | ||||
| -rw-r--r-- | src/backend/replication/Makefile | 22 | ||||
| -rw-r--r-- | src/backend/replication/repl_gram.y | 2 | ||||
| -rw-r--r-- | src/backend/replication/repl_scanner.l | 31 | ||||
| -rw-r--r-- | src/backend/replication/syncrep_gram.y | 2 | ||||
| -rw-r--r-- | src/backend/replication/syncrep_scanner.l | 21 |
6 files changed, 55 insertions, 25 deletions
diff --git a/src/backend/replication/.gitignore b/src/backend/replication/.gitignore index d1df6147bd0..77d5a51068d 100644 --- a/src/backend/replication/.gitignore +++ b/src/backend/replication/.gitignore @@ -1,4 +1,6 @@ +/repl_gram.h /repl_gram.c /repl_scanner.c +/syncrep_gram.h /syncrep_gram.c /syncrep_scanner.c diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile index 2bffac58c0d..23f29ba5457 100644 --- a/src/backend/replication/Makefile +++ b/src/backend/replication/Makefile @@ -16,10 +16,12 @@ override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) OBJS = \ repl_gram.o \ + repl_scanner.o \ slot.o \ slotfuncs.o \ syncrep.o \ syncrep_gram.o \ + syncrep_scanner.o \ walreceiver.o \ walreceiverfuncs.o \ walsender.o @@ -28,11 +30,23 @@ SUBDIRS = logical include $(top_srcdir)/src/backend/common.mk -# repl_scanner is compiled as part of repl_gram -repl_gram.o: repl_scanner.c +# See notes in src/backend/parser/Makefile about the following two rules +repl_gram.h: repl_gram.c + touch $@ -# syncrep_scanner is compiled as part of syncrep_gram -syncrep_gram.o: syncrep_scanner.c +repl_gram.c: BISONFLAGS += -d + +# Force these dependencies to be known even without dependency info built: +repl_gram.o repl_scanner.o: repl_gram.h + +# See notes in src/backend/parser/Makefile about the following two rules +syncrep_gram.h: syncrep_gram.c + touch $@ + +syncrep_gram.c: BISONFLAGS += -d + +# Force these dependencies to be known even without dependency info built: +syncrep_gram.o syncrep_scanner.o: syncrep_gram.h # repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c # are in the distribution tarball, so they are not cleaned here. diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y index 4cf087e602e..b343f108d31 100644 --- a/src/backend/replication/repl_gram.y +++ b/src/backend/replication/repl_gram.y @@ -416,5 +416,3 @@ ident_or_keyword: ; %% - -#include "repl_scanner.c" diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l index 586f0d3a5c8..23fcb2a11d1 100644 --- a/src/backend/replication/repl_scanner.l +++ b/src/backend/replication/repl_scanner.l @@ -1,4 +1,4 @@ -%{ +%top{ /*------------------------------------------------------------------------- * * repl_scanner.l @@ -18,6 +18,15 @@ #include "utils/builtins.h" #include "parser/scansup.h" +/* + * NB: include repl_gram.h only AFTER including walsender_private.h, because + * walsender_private includes headers that define XLogRecPtr. + */ +#include "replication/walsender_private.h" +#include "repl_gram.h" +} + +%{ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ #undef fprintf #define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) @@ -130,7 +139,7 @@ WAIT { return K_WAIT; } {space}+ { /* do nothing */ } {digit}+ { - yylval.uintval = strtoul(yytext, NULL, 10); + replication_yylval.uintval = strtoul(yytext, NULL, 10); return UCONST; } @@ -138,8 +147,8 @@ WAIT { return K_WAIT; } uint32 hi, lo; if (sscanf(yytext, "%X/%X", &hi, &lo) != 2) - yyerror("invalid streaming start location"); - yylval.recptr = ((uint64) hi) << 32 | lo; + replication_yyerror("invalid streaming start location"); + replication_yylval.recptr = ((uint64) hi) << 32 | lo; return RECPTR; } @@ -151,7 +160,7 @@ WAIT { return K_WAIT; } <xq>{quotestop} { yyless(1); BEGIN(INITIAL); - yylval.str = litbufdup(); + replication_yylval.str = litbufdup(); return SCONST; } @@ -173,9 +182,9 @@ WAIT { return K_WAIT; } yyless(1); BEGIN(INITIAL); - yylval.str = litbufdup(); - len = strlen(yylval.str); - truncate_identifier(yylval.str, len, true); + replication_yylval.str = litbufdup(); + len = strlen(replication_yylval.str); + truncate_identifier(replication_yylval.str, len, true); return IDENT; } @@ -186,7 +195,7 @@ WAIT { return K_WAIT; } {identifier} { int len = strlen(yytext); - yylval.str = downcase_truncate_identifier(yytext, len, true); + replication_yylval.str = downcase_truncate_identifier(yytext, len, true); return IDENT; } @@ -195,7 +204,7 @@ WAIT { return K_WAIT; } return yytext[0]; } -<xq,xd><<EOF>> { yyerror("unterminated quoted string"); } +<xq,xd><<EOF>> { replication_yyerror("unterminated quoted string"); } <<EOF>> { @@ -231,7 +240,7 @@ addlitchar(unsigned char ychar) } void -yyerror(const char *message) +replication_yyerror(const char *message) { ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/backend/replication/syncrep_gram.y b/src/backend/replication/syncrep_gram.y index d932f2cda32..4fc3647da15 100644 --- a/src/backend/replication/syncrep_gram.y +++ b/src/backend/replication/syncrep_gram.y @@ -112,5 +112,3 @@ create_syncrep_config(const char *num_sync, List *members, uint8 syncrep_method) return config; } - -#include "syncrep_scanner.c" diff --git a/src/backend/replication/syncrep_scanner.l b/src/backend/replication/syncrep_scanner.l index 1952c8c6e02..bdb1a3391cf 100644 --- a/src/backend/replication/syncrep_scanner.l +++ b/src/backend/replication/syncrep_scanner.l @@ -1,4 +1,4 @@ -%{ +%top{ /*------------------------------------------------------------------------- * * syncrep_scanner.l @@ -17,6 +17,15 @@ #include "lib/stringinfo.h" +/* + * NB: include syncrep_gram.h only AFTER including syncrep.h, because syncrep.h + * includes node definitions needed for YYSTYPE. + */ +#include "replication/syncrep.h" +#include "syncrep_gram.h" +} + +%{ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ #undef fprintf #define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) @@ -82,28 +91,28 @@ xdinside [^"]+ appendStringInfoString(&xdbuf, yytext); } <xd>{xdstop} { - yylval.str = xdbuf.data; + syncrep_yylval.str = xdbuf.data; xdbuf.data = NULL; BEGIN(INITIAL); return NAME; } <xd><<EOF>> { - yyerror("unterminated quoted identifier"); + syncrep_yyerror("unterminated quoted identifier"); return JUNK; } {identifier} { - yylval.str = pstrdup(yytext); + syncrep_yylval.str = pstrdup(yytext); return NAME; } {digit}+ { - yylval.str = pstrdup(yytext); + syncrep_yylval.str = pstrdup(yytext); return NUM; } "*" { - yylval.str = "*"; + syncrep_yylval.str = "*"; return NAME; } |
