From 9cca8a11e0c5107cc4577cd0d14c79a3cd154d62 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 29 Aug 2025 13:18:50 +0200 Subject: [PATCH 1/7] Improve pgbench definition of yyscan_t It was defining yyscan_t as a macro while the rest of the code uses a typedef with #ifdef guards around it. The latter is also what the flex generated code uses. So it seems best to make it look like those other places for consistency. The old way also had a potential for conflict if some code included multiple headers providing yyscan_t. exprscan.l includes #include "fe_utils/psqlscan_int.h" #include "pgbench.h" and fe_utils/psqlscan_int.h contains #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void *yyscan_t; #endif which was then followed by pgbench.h #define yyscan_t void * and then the generated code in exprscan.c #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif This works, but if the #ifdef guard in psqlscan_int.h is removed, this fails. We want to move toward allowing repeat typedefs, per C11, but for that we need to make sure they are all the same. --- src/bin/pgbench/pgbench.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h index e053c9e2eb6..f8b7b497d1e 100644 --- a/src/bin/pgbench/pgbench.h +++ b/src/bin/pgbench/pgbench.h @@ -16,11 +16,14 @@ /* * This file is included outside exprscan.l, in places where we can't see * flex's definition of typedef yyscan_t. Fortunately, it's documented as - * being "void *", so we can use a macro to keep the function declarations + * being "void *", so we can use typedef to keep the function declarations * here looking like the definitions in exprscan.l. exprparse.y and * pgbench.c also use this to be able to declare things as "yyscan_t". */ -#define yyscan_t void * +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void *yyscan_t; +#endif /* * Likewise, we can't see exprparse.y's definition of union YYSTYPE here, base-commit: 5d7f58848ce59d9e09b7214d2541ab3ec853f89c -- 2.51.0