CBL-6240: Align with server SQL++ reserved words#2386
Open
jianminzhao wants to merge 2 commits intomasterfrom
Open
CBL-6240: Align with server SQL++ reserved words#2386jianminzhao wants to merge 2 commits intomasterfrom
jianminzhao wants to merge 2 commits intomasterfrom
Conversation
When parsing a query in SQL++, we log a warning if an (unquoted) identifier is reserved in the server.
|
Code Coverage Results:
|
borrrden
reviewed
Nov 21, 2025
| } | ||
|
|
||
| constexpr const char* kServerReservedWords = | ||
| "ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER " |
Member
There was a problem hiding this comment.
Remove ADVISE ALTER ANALYZE BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CLUSTER
borrrden
reviewed
Nov 21, 2025
|
|
||
| constexpr const char* kServerReservedWords = | ||
| "ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER " | ||
| "COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT" |
Member
There was a problem hiding this comment.
Remove COLLECTION COMMIT COMMITTED CONNECT CONTINUE CREATE
borrrden
reviewed
Nov 21, 2025
| constexpr const char* kServerReservedWords = | ||
| "ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER " | ||
| "COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT" | ||
| " CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT " |
Member
There was a problem hiding this comment.
remove CYCLE DATABASE DATASET DATASTORE DECLARE DELETE DROP
borrrden
reviewed
Nov 21, 2025
| "COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT" | ||
| " CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT " | ||
| "ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS" | ||
| " FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT " |
borrrden
reviewed
Nov 21, 2025
| " CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT " | ||
| "ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS" | ||
| " FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT " | ||
| "INDEX INFER INLINE INSERT INTERSECT INTO ISOLATION JAVASCRIPT KEY" |
borrrden
reviewed
Nov 21, 2025
| "ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS" | ||
| " FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT " | ||
| "INDEX INFER INLINE INSERT INTERSECT INTO ISOLATION JAVASCRIPT KEY" | ||
| " KEYS KEYSPACE KNOWN LANGUAGE LAST LATERAL LET LETTING LEVEL LSM MAP MAPPING MATCHED MATERIALIZED " |
borrrden
reviewed
Nov 21, 2025
| "PRECEDING PREPARE PREV PREVIOUS PREVVAL PRIMARY PRIVATE PRIVILEGE PROBE PROCEDURE PUBLIC" | ||
| " RANGE RAW READ REALM RECURSIVE REDUCE RENAME REPLACE RESPECT RESTART RESTRICT RETURN RETURNING REVOKE " | ||
| "ROLE ROLES ROLLBACK ROW ROWS SAVEPOINT SCHEMA SCOPE SELF SEMI SEQUENCE" | ||
| " SET SHOW SOME START STATISTICS STRING SYSTEM TIES TO TRAN TRANSACTION TRIGGER TRUNCATE UNBOUNDED UNDER " |
snej
requested changes
Nov 25, 2025
Comment on lines
+402
to
+415
| const char* p = kServerReservedWords; | ||
| const char* start = nullptr; | ||
| for ( ; *p != '\0'; ++p ) { | ||
| if ( *p == ' ' ) { | ||
| if ( start != nullptr ) { | ||
| //start -> p | ||
| serverReserved.emplace(start, p); | ||
| start = nullptr; | ||
| } | ||
| } else if ( start == nullptr ) { | ||
| start = p; | ||
| } | ||
| } | ||
| if ( start != nullptr ) { serverReserved.emplace(start, p); } |
Collaborator
There was a problem hiding this comment.
Use split() for this instead of nasty C code:
/** Splits the string at occurrences of `separator` and calls the callback for each piece.
There may be empty pieces, if the separator occurs at the start or end or twice in a row. */
void split(std::string_view str, std::string_view separator, fleece::function_ref<void(std::string_view)> callback);You'll need a consistent delimiter between words though, probably a single space.
| static bool isServerReservedWord(std::string word); | ||
|
|
||
| static string warnOnServerReservedWord(const char* input) { | ||
| if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in the Server SQL++)", input); } |
Collaborator
There was a problem hiding this comment.
Suggested change
| if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in the Server SQL++)", input); } | |
| if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in Server SQL++)", input); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When parsing a query in SQL++, we log a warning if an (unquoted) identifier is reserved in the server.