Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on missing join clause #43

Closed
MarinPostma opened this issue Mar 13, 2024 · 4 comments · Fixed by #47
Closed

Panic on missing join clause #43

MarinPostma opened this issue Mar 13, 2024 · 4 comments · Fixed by #47

Comments

@MarinPostma
Copy link
Contributor

I've been fuzzing the parser and fixed a common cause of panic in tursodatabase/libsql#1209

If the fix suits you, open a PR here.

@gwenn
Copy link
Owner

gwenn commented Mar 14, 2024

#10

@gwenn
Copy link
Owner

gwenn commented Mar 14, 2024

If you are interested, you should be able to generate more crash tests by patching this with:
(you can try first without the patch to check many valid SQLite commands)

misc % diff -u test-grammar.pegjs*
--- test-grammar.pegjs	2024-02-26 20:00:37.000000000 +0100
+++ test-grammar.pegjs.bk	2024-02-26 20:00:06.000000000 +0100
@@ -42,7 +42,8 @@
     return b;
   }
 test_type_start
-  = "do_execsql_test"
+  = "do_catchsql_test"
+  / "do_execsql_test"
   / "do_eqp_test"
   / "execsql"
   / "eqp"

Create a symlink to a local clone of official SQLite3 repository:

% cd sqlite-parser/test
% ln -s ~/sqlite/test raw

Launch

% cd sqlite-parser/test/misc
% sh process-tests.sh

And then with lemon-rs

% find ~/sqlite-parser/test/sql/official-suite/ -type f | xargs ./target/debug/examples/sql_cmds 2> errors.txt > /dev/null

@MarinPostma
Copy link
Contributor Author

oh that's cool! thanks @gwenn I'll give it a shot 👍

gwenn added a commit that referenced this issue Mar 16, 2024
@gwenn gwenn closed this as completed in #47 Mar 16, 2024
@gwenn
Copy link
Owner

gwenn commented Mar 16, 2024

See https://github.com/sqlite/sqlite/blob/d31fc6e9cfd4d25d2fdea2f5aa41fee0a1d5e80c/test/window1.test#L1924

SELECT (SELECT max(x)OVER(ORDER BY x) % min(x)OVER(ORDER BY CASE x WHEN 889 THEN x WHEN x THEN x END)) FROM (SELECT (SELECT sum(CAST(a IN(SELECT (SELECT max(x)OVER(ORDER BY CASE x WHEN 889 THEN 299 WHEN 863 THEN 863 END)) FROM (SELECT (SELECT sum(CAST((SELECT (SELECT max(x)OVER(ORDER BY x) / min(x)OVER(ORDER BY CASE x WHEN 889 THEN 299 WHEN -true THEN 863 END)) FROM (SELECT (SELECT sum(CAST(a IN(SELECT (SELECT max(x) & sum ( a )OVER(ORDER BY CASE x WHEN -8 THEN 299 WHEN 863 THEN 863 END)) FROM (SELECT (SELECT sum(CAST(a AS )) FROM t1) AS x FROM t1)) AS t1 )) FROM t1) AS x FROM t1)) AS x )) FROM t1) AS x FROM t1)) AS real)) FROM t1) AS x FROM t1)
;

which reduces to

SELECT sum(CAST(a AS )) FROM t1

=>

A = Expr::cast(E, T.unwrap()); // FIXME mandatory ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants