Skip to content

Commit 2b7d10d

Browse files
tglsfdcreshke
authored andcommitted
Rename parser token REF to REF_P to avoid a symbol conflict.
In the latest version of Apple's macOS SDK, <sys/socket.h> fails to compile if "REF" is #define'd as something. Apple may or may not agree that this is a bug, and even if they do accept the bug report I filed, they probably won't fix it very quickly. In the meantime, our back branches will all fail to compile gram.y. v15 and HEAD currently escape the problem thanks to the refactoring done in 98e93a1, but that's purely accidental. Moreover, since that patch removed a widely-visible inclusion of <netdb.h>, back-patching it seems too likely to break third-party code. Instead, change the token's code name to REF_P, following our usual convention for naming parser tokens that are likely to have symbol conflicts. The effects of that should be localized to the grammar and immediately surrounding files, so it seems like a safer answer. Per project policy that we want to keep recently-out-of-support branches buildable on modern systems, back-patch all the way to 9.2. Discussion: https://postgr.es/m/1803927.1665938411@sss.pgh.pa.us
1 parent 28dd7b7 commit 2b7d10d

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/backend/parser/gram.y

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ static void check_expressions_in_partition_key(PartitionSpec *spec, core_yyscan_
812812

813813
QUOTE
814814

815-
RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFERENCING
815+
RANGE READ REAL REASSIGN RECHECK RECURSIVE REF_P REFERENCES REFERENCING
816816
REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
817817
RESET RESTART RESTRICT RETRIEVE RETURN RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
818818
ROUTINE ROUTINES ROW ROWS RULE
@@ -18424,7 +18424,7 @@ xmlexists_argument:
1842418424
;
1842518425

1842618426
xml_passing_mech:
18427-
BY REF
18427+
BY REF_P
1842818428
| BY VALUE_P
1842918429
;
1843018430

@@ -19844,7 +19844,7 @@ unreserved_keyword:
1984419844
| REASSIGN
1984519845
| RECHECK
1984619846
| RECURSIVE
19847-
| REF
19847+
| REF_P
1984819848
| REFERENCING
1984919849
| REFRESH
1985019850
| REINDEX
@@ -20853,7 +20853,7 @@ bare_label_keyword:
2085320853
| REASSIGN
2085420854
| RECHECK
2085520855
| RECURSIVE
20856-
| REF
20856+
| REF_P
2085720857
| REFERENCES
2085820858
| REFERENCING
2085920859
| REFRESH

src/include/parser/kwlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ PG_KEYWORD("real", REAL, COL_NAME_KEYWORD, BARE_LABEL)
395395
PG_KEYWORD("reassign", REASSIGN, UNRESERVED_KEYWORD, BARE_LABEL)
396396
PG_KEYWORD("recheck", RECHECK, UNRESERVED_KEYWORD, BARE_LABEL)
397397
PG_KEYWORD("recursive", RECURSIVE, UNRESERVED_KEYWORD, BARE_LABEL)
398-
PG_KEYWORD("ref", REF, UNRESERVED_KEYWORD, BARE_LABEL)
398+
PG_KEYWORD("ref", REF_P, UNRESERVED_KEYWORD, BARE_LABEL)
399399
PG_KEYWORD("references", REFERENCES, RESERVED_KEYWORD, BARE_LABEL)
400400
PG_KEYWORD("referencing", REFERENCING, UNRESERVED_KEYWORD, BARE_LABEL)
401401
PG_KEYWORD("refresh", REFRESH, UNRESERVED_KEYWORD, BARE_LABEL)

0 commit comments

Comments
 (0)