Rename parser token REF to REF_P to avoid a symbol conflict.
authorTom Lane <[email protected]>
Sun, 16 Oct 2022 19:27:04 +0000 (15:27 -0400)
committerTom Lane <[email protected]>
Sun, 16 Oct 2022 19:27:04 +0000 (15:27 -0400)
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 98e93a1fc, 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

src/backend/parser/gram.y
src/include/parser/kwlist.h

index 39a917c29500dde19e330f170138a6c276793abf..079c4bdec2963b670ae38945d604389235db559e 100644 (file)
@@ -544,7 +544,7 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
 
    QUOTE
 
-   RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REINDEX
+   RANGE READ REAL REASSIGN RECHECK RECURSIVE REF_P REFERENCES REINDEX
    RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
    RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK
    ROW ROWS RULE
@@ -11355,15 +11355,15 @@ xmlexists_argument:
                {
                    $$ = $2;
                }
-           | PASSING c_expr BY REF
+           | PASSING c_expr BY REF_P
                {
                    $$ = $2;
                }
-           | PASSING BY REF c_expr
+           | PASSING BY REF_P c_expr
                {
                    $$ = $4;
                }
-           | PASSING BY REF c_expr BY REF
+           | PASSING BY REF_P c_expr BY REF_P
                {
                    $$ = $4;
                }
@@ -12461,7 +12461,7 @@ unreserved_keyword:
            | REASSIGN
            | RECHECK
            | RECURSIVE
-           | REF
+           | REF_P
            | REINDEX
            | RELATIVE_P
            | RELEASE
index ab88350037796968068368fa094661c6b41ec5ce..64d5e9b64950657dd56b896e14c17b29993d298e 100644 (file)
@@ -297,7 +297,7 @@ PG_KEYWORD("real", REAL, COL_NAME_KEYWORD)
 PG_KEYWORD("reassign", REASSIGN, UNRESERVED_KEYWORD)
 PG_KEYWORD("recheck", RECHECK, UNRESERVED_KEYWORD)
 PG_KEYWORD("recursive", RECURSIVE, UNRESERVED_KEYWORD)
-PG_KEYWORD("ref", REF, UNRESERVED_KEYWORD)
+PG_KEYWORD("ref", REF_P, UNRESERVED_KEYWORD)
 PG_KEYWORD("references", REFERENCES, RESERVED_KEYWORD)
 PG_KEYWORD("reindex", REINDEX, UNRESERVED_KEYWORD)
 PG_KEYWORD("relative", RELATIVE_P, UNRESERVED_KEYWORD)