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

Alex Petrov commented on CASSANDRA-12189:
-----------------------------------------

Some inputs that were previously invalid, are now not closing:

{code}
CREATE KEYSPACE cql_test_keyspace WITH replication = {'class': 
'NetworkTopologyStrategy', 'datacenter1': '1' };
use cql_test_keyspace;
CREATE TABLE testtable (key ascii primary key, val text);

// following inputs are not closing:
INSERT INTO testtable (key, val) VALUES ($$key_empty$$, $$'' value for empty$ 
$);
INSERT INTO testtable (key, val) VALUES ($$key_empty$ $, $$'' value for 
empty$$);
{code}

In both cases it waits for more possible input, which might be 
indistinguishable from end of input. 

What started working after the patch:

{code}
INSERT INTO testtable (key, val) VALUES ($$$foo$_$foo$$, $$$'' value for 
empty$$); 
{code}

User-defined functions and other inputs are working fine however:

{code}
INSERT INTO testtable (key, val) VALUES ($$prim$ $ $key$$, $$some '' arbitrary 
value$$);
INSERT INTO testtable (key, val) VALUES ('$txt$key$$$$txt$', '$txt$'' other 
value$txt$');
INSERT INTO testtable (key, val) VALUES ($$key_empty$$, $$'' value for empty$$);

SELECT key, val FROM testtable WHERE key='prim$ $ $key';
SELECT key, val FROM testtable WHERE key='key_empty';
SELECT key, val FROM testtable WHERE key='$foo$_$foo';
SELECT key, val FROM testtable WHERE key='$txt$key$$$$txt$';

INSERT INTO testtable (key, val) VALUES ($$prim$ $ $key$$, $$some '' arbitrary 
value$$);
INSERT INTO testtable (key, val) VALUES ($$$foo$_$foo$$, $$$'' value for 
empty$$);

CREATE FUNCTION cql_test_keyspace::pgsin ( input double ) RETURNS double USING 
$$org.apache.cassandra.cql3.UFTest#sin$$ ;

CREATE FUNCTION testfn( lst list<double> )
RETURNS NULL ON NULL INPUT
RETURNS list<double>
LANGUAGE java
AS $$return lst;$$;

CREATE FUNCTION testfn2( input double )
CALLED ON NULL INPUT
RETURNS text
LANGUAGE java
AS $$
// parameter val is of type java.lang.Double
/* return type is of type java.lang.Double */
if (input == null) {
return null;
}
return Double.toString(Math.sin(input));
$$;
{code}


In context of CQLsh I don't see a way to distinguish between the end of input 
and incorrectly closed {{$$}}. Do you think it's possible?


> $$ escaped string literals are not handled correctly in cqlsh
> -------------------------------------------------------------
>
>                 Key: CASSANDRA-12189
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12189
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tools
>            Reporter: Mike Adamson
>            Assignee: Mike Adamson
>             Fix For: 3.x
>
>
> The syntax rules for pg ($$) escaped string literals in cqlsh do not match 
> the lexer rule for this type in Lexer.g. 
> The {{unclosedPgString}} rule is not correctly matching pg string literals in 
> multi-line statements so:
> {noformat}
> INSERT INTO test.test (id) values (
> ...$$<xml/>
> {noformat}
> fails with a syntax error at the forward slash.
> Both {{pgStringLiteral}} and {{unclosedPgString}} fail with the following 
> string
> {noformat}
> $$a$b$$
> {noformat}
> where this is allowed by the CQL lexer rule.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to