summaryrefslogtreecommitdiff
path: root/src/bin/pgbench
diff options
context:
space:
mode:
authorJohn Naylor2022-09-04 04:33:31 +0000
committerJohn Naylor2022-09-04 05:09:01 +0000
commitdac048f71ebbcf2f980d280711f8ff8001331c5d (patch)
tree48311f22d4636b6fb12cf2bb43925622521e758a /src/bin/pgbench
parent80e8450a744b1f6fa75663f37f1db3388995dc67 (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/bin/pgbench')
-rw-r--r--src/bin/pgbench/.gitignore1
-rw-r--r--src/bin/pgbench/Makefile13
-rw-r--r--src/bin/pgbench/exprparse.y15
-rw-r--r--src/bin/pgbench/exprscan.l12
4 files changed, 22 insertions, 19 deletions
diff --git a/src/bin/pgbench/.gitignore b/src/bin/pgbench/.gitignore
index 983a3cd7a6..07492a993c 100644
--- a/src/bin/pgbench/.gitignore
+++ b/src/bin/pgbench/.gitignore
@@ -1,3 +1,4 @@
+/exprparse.h
/exprparse.c
/exprscan.c
/pgbench
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index f402fe7b91..6647c9fe97 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -10,6 +10,7 @@ include $(top_builddir)/src/Makefile.global
OBJS = \
$(WIN32RES) \
exprparse.o \
+ exprscan.o \
pgbench.o
override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
@@ -26,8 +27,14 @@ all: pgbench
pgbench: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-# exprscan is compiled as part of exprparse
-exprparse.o: exprscan.c
+# See notes in src/backend/parser/Makefile about the following two rules
+exprparse.h: exprparse.c
+ touch $@
+
+exprparse.c: BISONFLAGS += -d
+
+# Force these dependencies to be known even without dependency info built:
+exprparse.o exprscan.o: exprparse.h
distprep: exprparse.c exprscan.c
@@ -45,7 +52,7 @@ clean distclean:
rm -rf tmp_check
maintainer-clean: distclean
- rm -f exprparse.c exprscan.c
+ rm -f exprparse.h exprparse.c exprscan.c
check:
$(prove_check)
diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y
index b5592d4b97..ade2ecdaab 100644
--- a/src/bin/pgbench/exprparse.y
+++ b/src/bin/pgbench/exprparse.y
@@ -526,18 +526,3 @@ make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else
find_func(yyscanner, "!case_end"),
make_elist(else_part, when_then_list));
}
-
-/*
- * exprscan.l is compiled as part of exprparse.y. Currently, this is
- * unavoidable because exprparse does not create a .h file to export
- * its token symbols. If these files ever grow large enough to be
- * worth compiling separately, that could be fixed; but for now it
- * seems like useless complication.
- */
-
-/* First, get rid of "#define yyscan_t" from pgbench.h */
-#undef yyscan_t
-/* ... and the yylval macro, which flex will have its own definition for */
-#undef yylval
-
-#include "exprscan.c"
diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l
index 4f63818606..fe8e32838a 100644
--- a/src/bin/pgbench/exprscan.l
+++ b/src/bin/pgbench/exprscan.l
@@ -1,4 +1,4 @@
-%{
+%top{
/*-------------------------------------------------------------------------
*
* exprscan.l
@@ -22,9 +22,19 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
+/*
+ * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h
+ * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after
+ * psqlscan_int.h for yyscan_t.
+ */
#include "fe_utils/psqlscan_int.h"
+#include "pgbench.h"
+#include "exprparse.h"
+}
+%{
/* context information for reporting errors in expressions */
static const char *expr_source = NULL;
static int expr_lineno = 0;