Files
scylladb/test/cql/query_bounds_test.result
Nadav Har'El 57ffbcbb22 cql3: fix spurious token names in syntax error messages
We have known for a long time (see issue #1703) that the quality of our
CQL "syntax error" messages leave a lot to be desired, especially when
compared to Cassandra. This patch doesn't yet bring us great error
messages with great context - doing this isn't easy and it appears that
Antlr3's C++ runtime isn't as good as the Java one in this regard -
but this patch at least fixes **garbage** printed in some error messages.

Specifically, when the parser can deduce that a specific token is missing,
it used to print

    line 1:83 missing ')' at '<missing '

After this patch we get rid of the meaningless string '<missing ':

    line 1:83 : Missing ')'

Also, when the parser deduced that a specific token was unneeded, it
used to print:

    line 1:83 extraneous input ')' expecting <invalid>

Now we got rid of this silly "<invalid>" and write just:

    line 1:83 : Unexpected ')'

Refs #1703. I didn't yet marked that issue "fixed" because I think a
complete fix would also require printing the entire misparsed line and the
point of the parse failure. Scylla still prints a generic "Syntax Error"
in most cases now, and although the character number (83 in the above
example) can help, it's much more useful to see the actual failed
statement and where character 83 is.

Unfortunately some tests enshrine buggy error messages and had to be
fixed. Other tests enshrined strange text for a generic unexplained
error message, which used to say "  : syntax error..." (note the two
spaces and elipses) and after this patch is " : Syntax error". So
these tests are changed. Another message, "no viable alternative at
input" is deliberately kept unchanged by this patch so as not to break
many more tests which enshrined this message.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>

Closes #13731
2023-05-02 11:23:58 +03:00

269 lines
7.4 KiB
Plaintext

> create table foo (a int, b int, c int, PRIMARY KEY (a, b, c)) WITH CLUSTERING ORDER BY (b DESC, c ASC);
OK
>
> INSERT INTO foo (a, b, c) VALUES (0, 2, 0);
OK
> INSERT INTO foo (a, b, c) VALUES (0, 1, 0);
OK
> INSERT INTO foo (a, b, c) VALUES (0, 1, 1);
OK
> INSERT INTO foo (a, b, c) VALUES (0, 0, 0);
OK
>
> SELECT * FROM foo WHERE a=0 AND (b, c) > (1, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
| 0 | 1 | 1 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) > (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) >= (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) >= SCYLLA_CLUSTERING_BOUND (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) < (1, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) < SCYLLA_CLUSTERING_BOUND (1, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) < (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) < SCYLLA_CLUSTERING_BOUND (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) <= (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b, c) <= SCYLLA_CLUSTERING_BOUND (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
>
> SELECT * FROM foo WHERE a=0 AND (b) > (1);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (1);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) > (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) >= (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) >= SCYLLA_CLUSTERING_BOUND (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) < (1);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) < SCYLLA_CLUSTERING_BOUND (1);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) < (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) < SCYLLA_CLUSTERING_BOUND (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) <= (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) <= SCYLLA_CLUSTERING_BOUND (2);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
>
>
>
> SELECT * FROM foo WHERE a=0 AND (b) > (1) AND (b, c) <= (2, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 2 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (1) AND (b, c) <= SCYLLA_CLUSTERING_BOUND (0, 0);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 0 | 0 |
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) > (2) AND (b, c) <= (2, 1);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
+-----+-----+-----+
>
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (2) AND (b, c) <= SCYLLA_CLUSTERING_BOUND(1, 1);
+-----+-----+-----+
| a | b | c |
|-----+-----+-----|
| 0 | 1 | 0 |
| 0 | 1 | 1 |
+-----+-----+-----+
>
> -- error checks --
>
> -- wrong side of condition
> SELECT * FROM foo WHERE a=0 AND SCYLLA_CLUSTERING_BOUND(b) > (2);
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:32 no viable alternative at input 'SCYLLA_CLUSTERING_BOUND'">
>
> -- both sides of condition
> SELECT * FROM foo WHERE a=0 AND SCYLLA_CLUSTERING_BOUND(b) > SCYLLA_CLUSTERING_BOUND(2);
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:32 no viable alternative at input 'SCYLLA_CLUSTERING_BOUND'">
>
> -- too many values --
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1, 0, 5);
Error from server: code=2200 [Invalid query] message="Expected 2 elements in value tuple, but got 3: (1, 0, 5)"
>
> -- too few values --
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1);
Error from server: code=2200 [Invalid query] message="Expected 2 elements in value tuple, but got 1: (1)"
>
> -- missing values --
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND;
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:64 : Syntax error">
>
> -- not tuple --
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND 45;
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:65 : Missing '('">
>
> -- just wrong --
> SELECT * FROM foo WHERE a=0 SCYLLA_CLUSTERING_BOUND AND (b, c) > (0, 1);
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:28 : Syntax error">
> SELECT * FROM foo WHERE a=0 AND (b, c) > (0, 1) SCYLLA_CLUSTERING_BOUND;
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:48 : Syntax error">
>
> -- mixing apples and make_count_rows_function
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND(2, 0) AND (b, c) < (1, 1);
Error from server: code=2200 [Invalid query] message="Invalid combination of restrictions (SCYLLA_CLUSTERING_BOUND / plain)"
> -- and again --
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND(2, 0) AND (b, c) < (2, 0);
Error from server: code=2200 [Invalid query] message="Invalid combination of restrictions (SCYLLA_CLUSTERING_BOUND / plain)"