You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Maxim Chanturiay (Jira)" <ji...@apache.org> on 2022/10/27 09:41:00 UTC
[jira] [Commented] (CASSANDRA-17919) Capital P gets confused in the parser for a Duration in places where IDENT are needed
[ https://issues.apache.org/jira/browse/CASSANDRA-17919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17624988#comment-17624988 ]
Maxim Chanturiay commented on CASSANDRA-17919:
----------------------------------------------
[~dcapwell] , [~blerer] Hello! I'd like to work on the issue.
I will assign myself - so please remove me if it is already taken. I'll watch the ticket updates' mail.
+What has been done so far?+
I've checked out a branch from Cassandra 4.1, created a couple of unit tests that fail because of "DROP TABLE P" and "CREATE TABLE P" with the same error as in the bug report. In short - there is a functioning local dev environment to test out code changes.
I'd like to go with [~blerer]'s solution.
I've tried other options, like placing token IDENT above DURATION or trying to identify P as duration only when it's enclosed by parentheses ().
None of them worked either because of the ambiguity where both IDENT and DURATION contain a letter and optional digit or too complicated code wise.
And given the thousands of code lines in parser logic - more complication is the last thing that is needed :D
> Capital P gets confused in the parser for a Duration in places where IDENT are needed
> -------------------------------------------------------------------------------------
>
> Key: CASSANDRA-17919
> URL: https://issues.apache.org/jira/browse/CASSANDRA-17919
> Project: Cassandra
> Issue Type: Bug
> Components: CQL/Syntax
> Reporter: David Capwell
> Priority: Normal
>
> This was found while adding Accord Transaction syntax into CQL and fuzz testing to validate all possible cases… in doing this the following was found
> {code}
> String query = "BEGIN TRANSACTION\n" +
> " LET P = (SELECT v FROM " + keyspace + ".tbl WHERE k=? AND c=?);\n" +
> " LET row2 = (SELECT v FROM " + keyspace + ".tbl WHERE k=? AND c=?);\n" +
> " SELECT v FROM " + keyspace + ".tbl WHERE k=? AND c=?;\n" +
> " IF P IS NULL AND row2.v = ? THEN\n" +
> " INSERT INTO " + keyspace + ".tbl (k, c, v) VALUES (?, ?, ?);\n" +
> " END IF\n" +
> "COMMIT TRANSACTION";
> {code}
> Fails with
> {code}
> SyntaxException: line 2:6 mismatched input 'P' expecting IDENT (BEGIN TRANSACTION LET [P]...)
> {code}
> The new LET syntax found this, but was able to reproduce in other cases
> {code}
> cqlsh:ks> CREATE TABLE P (k INT PRIMARY KEY);
> SyntaxException: line 1:13 no viable alternative at input 'P' (CREATE TABLE [P]...)
> cqlsh:ks>
> cqlsh:ks> CREATE TABLE p (k INT PRIMARY KEY);
> cqlsh:ks>
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org