Hi Tatsuo,
> In addition you see #define INITIAL in gram.h?
Yes -- here gram.h has both the enum and the macro:
enum yytokentype { ...; INITIAL = 472; ... };
#define INITIAL 472
The file header says "made by GNU Bison 2.3". That's macOS's system
bison, and it still emits the #define token macros, so INITIAL collides
with flex's #define INITIAL 0 in the scanner. Your 3.8.2 emits only the
enum, which is why you don't see it. 2.3 is the minimum the tree still
accepts (meson.build asks for >= 2.3) and it's what macOS ships, so a
build on that floor hits the warning.
> probably we should consider change "INITIAL" to something like
> "INITIAL_P" to avoid the collision?
That matches the _P convention already used for NULL_P / TRUE_P / IN_P,
so it seemed worth trying. I've attached a small patch that renames the
token to INITIAL_P in kwlist.h and gram.y; the SQL keyword stays
"initial". With it applied, both -Wmacro-redefined warnings are gone and
the build is warning-clean here, still on bison 2.3. The patch is on top
of v49 and named nocfbot-*.txt so cfbot doesn't pick it up. No rush on
this -- it can wait for whenever a cleanup pass fits. Please fold it in
or adjust as you see fit.
Regards,
Seongjun
From 7a4f72d7ac89a62c94ad6e8e7dbeca5b8c1e35a3 Mon Sep 17 00:00:00 2001
From: Seongjun Shin <[email protected]>
Date: Sun, 19 Jul 2026 17:23:52 +0900
Subject: [PATCH] Rename INITIAL keyword token to INITIAL_P to avoid macro
collision
The row pattern recognition patch adds an INITIAL keyword. With bison
2.3 -- still emitted by macOS's system bison, and the minimum the tree
supports -- the token is emitted as "#define INITIAL" in gram.h, which
collides with flex's built-in INITIAL start condition ("#define
INITIAL 0") and produces -Wmacro-redefined warnings in the backend and
ecpg scanners. Rename the token to INITIAL_P, following the existing
convention (NULL_P, TRUE_P, IN_P, ...). The SQL keyword itself
("initial") is unchanged.
---
src/backend/parser/gram.y | 10 +++++-----
src/include/parser/kwlist.h | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 731b01eb742..a12e2411a7f 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -793,7 +793,7 @@ static const char *rpr_invalid_quantifier_token(const char
*tok);
HANDLER HAVING HEADER_P HOLD HOUR_P
IDENTITY_P IF_P IGNORE_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P
IN_P INCLUDE
- INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIAL
INITIALLY INLINE_P
+ INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIAL_P
INITIALLY INLINE_P
INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
@@ -947,7 +947,7 @@ static const char *rpr_invalid_quantifier_token(const char
*tok);
%nonassoc UNBOUNDED NESTED /* ideally would have same precedence as IDENT
*/
%nonassoc IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE
ROLLUP
SET KEYS OBJECT_P SCALAR TO USING VALUE_P WITH WITHOUT
PATH
- AFTER INITIAL SEEK PATTERN_P
+ AFTER INITIAL_P SEEK PATTERN_P
%left Op OPERATOR RIGHT_ARROW '|' /* multi-character ops and
user-defined operators */
%left '+' '-'
%left '*' '/' '%'
@@ -17613,7 +17613,7 @@ opt_row_pattern_skip_to:
;
opt_row_pattern_initial_or_seek:
- INITIAL { $$ = true; }
+ INITIAL_P { $$ = true; }
| SEEK
{
ereport(ERROR,
@@ -19410,7 +19410,7 @@ unreserved_keyword:
| INDEXES
| INHERIT
| INHERITS
- | INITIAL
+ | INITIAL_P
| INLINE_P
| INPUT_P
| INSENSITIVE
@@ -20021,7 +20021,7 @@ bare_label_keyword:
| INDEXES
| INHERIT
| INHERITS
- | INITIAL
+ | INITIAL_P
| INITIALLY
| INLINE_P
| INNER_P
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 3894fad9023..d140d5a94a7 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -222,7 +222,7 @@ PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("indexes", INDEXES, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("inherit", INHERIT, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("inherits", INHERITS, UNRESERVED_KEYWORD, BARE_LABEL)
-PG_KEYWORD("initial", INITIAL, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("initial", INITIAL_P, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("initially", INITIALLY, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("inline", INLINE_P, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("inner", INNER_P, TYPE_FUNC_NAME_KEYWORD, BARE_LABEL)
--
2.50.1 (Apple Git-155)