[ 
https://issues.apache.org/jira/browse/CASSANDRA-17919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609477#comment-17609477
 ] 

Benjamin Lerer edited comment on CASSANDRA-17919 at 9/26/22 12:38 PM:
----------------------------------------------------------------------

According to [Wikipedia|https://en.wikipedia.org/wiki/ISO_8601#Durations]:

{quote} Date and time elements including their designator may be omitted if 
their value is zero, and lower-order elements may also be omitted for reduced 
precision. For example, "P23DT23H" and "P4Y" are both acceptable duration 
representations. However, at least one element must be present, thus "P" is not 
a valid representation for a duration of 0 seconds. "PT0S" or "P0D", however, 
are both valid and represent the same duration. \{quote}

 

Effectively the lexer rule should be rewritten.


was (Author: blerer):
According to [Wikipedia|https://en.wikipedia.org/wiki/ISO_8601#Durations]:

{quote}Date and time elements including their designator may be omitted if 
their value is zero, and lower-order elements may also be omitted for reduced 
precision. For example, "P23DT23H" and "P4Y" are both acceptable duration 
representations. However, at least one element must be present, thus "P" is not 
a valid representation for a duration of 0 seconds. "PT0S" or "P0D", however, 
are both valid and represent the same duration. \{quote}

Effectively the lexer rule should be rewritten.

> 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-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to