-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. go version move into Makefile 2. add golden test for ast 3. explainAbleSQL use tidb parser also
- Loading branch information
1 parent
8bb48a2
commit eeeab8e
Showing
12 changed files
with
790 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
SELECT * FROM film WHERE length = 86; | ||
SELECT * FROM film WHERE length = 86; | ||
SELECT * FROM film WHERE length IS NULL; | ||
SELECT * FROM film WHERE length IS NULL; | ||
SELECT * FROM film HAVING title = 'abc'; | ||
SELECT * FROM film HAVING title = 'abc'; | ||
SELECT * FROM sakila.film WHERE length >= 60; | ||
SELECT * FROM sakila.film WHERE length >= 60; | ||
SELECT * FROM sakila.film WHERE length >= '60'; | ||
SELECT * FROM sakila.film WHERE length >= '60'; | ||
SELECT * FROM film WHERE length BETWEEN 60 AND 84; | ||
SELECT * FROM film WHERE length BETWEEN 60 AND 84; | ||
SELECT * FROM film WHERE title LIKE 'AIR%'; | ||
SELECT * FROM film WHERE title LIKE 'AIR%'; | ||
SELECT * FROM film WHERE title IS NOT NULL; | ||
SELECT * FROM film WHERE title IS NOT NULL; | ||
SELECT * FROM film WHERE length = 114 and title = 'ALABAMA DEVIL'; | ||
SELECT * FROM film WHERE length = 114 and title = 'ALABAMA DEVIL'; | ||
SELECT * FROM film WHERE length > 100 and title = 'ALABAMA DEVIL'; | ||
SELECT * FROM film WHERE length > 100 and title = 'ALABAMA DEVIL'; | ||
SELECT * FROM film WHERE length > 100 and language_id < 10 and title = 'xyz'; | ||
SELECT * FROM film WHERE length > 100 and language_id < 10 and title = 'xyz'; | ||
SELECT * FROM film WHERE length > 100 and language_id < 10; | ||
SELECT * FROM film WHERE length > 100 and language_id < 10; | ||
SELECT release_year, sum(length) FROM film WHERE length = 123 AND language_id = 1 GROUP BY release_year; | ||
SELECT release_year, sum(length) FROM film WHERE length = 123 AND language_id = 1 GROUP BY release_year; | ||
SELECT release_year, sum(length) FROM film WHERE length >= 123 GROUP BY release_year; | ||
SELECT release_year, sum(length) FROM film WHERE length >= 123 GROUP BY release_year; | ||
SELECT release_year, language_id, sum(length) FROM film GROUP BY release_year, language_id; | ||
SELECT release_year, language_id, sum(length) FROM film GROUP BY release_year, language_id; | ||
SELECT release_year, sum(length) FROM film WHERE length = 123 GROUP BY release_year,(length+language_id); | ||
SELECT release_year, sum(length) FROM film WHERE length = 123 GROUP BY release_year,(length+language_id); | ||
SELECT release_year, sum(film_id) FROM film GROUP BY release_year; | ||
SELECT release_year, sum(film_id) FROM film GROUP BY release_year; | ||
SELECT * FROM address GROUP BY address,district; | ||
SELECT * FROM address GROUP BY address,district; | ||
SELECT title FROM film WHERE ABS(language_id) = 3 GROUP BY title; | ||
SELECT title FROM film WHERE ABS(language_id) = 3 GROUP BY title; | ||
SELECT language_id FROM film WHERE length = 123 GROUP BY release_year ORDER BY language_id; | ||
SELECT language_id FROM film WHERE length = 123 GROUP BY release_year ORDER BY language_id; | ||
SELECT release_year FROM film WHERE length = 123 GROUP BY release_year ORDER BY release_year; | ||
SELECT release_year FROM film WHERE length = 123 GROUP BY release_year ORDER BY release_year; | ||
SELECT * FROM film WHERE length = 123 ORDER BY release_year ASC, language_id DESC; | ||
SELECT * FROM film WHERE length = 123 ORDER BY release_year ASC, language_id DESC; | ||
SELECT release_year FROM film WHERE length = 123 GROUP BY release_year ORDER BY release_year LIMIT 10; | ||
SELECT release_year FROM film WHERE length = 123 GROUP BY release_year ORDER BY release_year LIMIT 10; | ||
SELECT * FROM film WHERE length = 123 ORDER BY release_year LIMIT 10; | ||
SELECT * FROM film WHERE length = 123 ORDER BY release_year LIMIT 10; | ||
SELECT * FROM film ORDER BY release_year LIMIT 10; | ||
SELECT * FROM film ORDER BY release_year LIMIT 10; | ||
SELECT film_id FROM film ORDER BY release_year LIMIT 10; | ||
SELECT film_id FROM film ORDER BY release_year LIMIT 10; | ||
SELECT * FROM film WHERE length > 100 ORDER BY length LIMIT 10; | ||
SELECT * FROM film WHERE length > 100 ORDER BY length LIMIT 10; | ||
SELECT * FROM film WHERE length < 100 ORDER BY length LIMIT 10; | ||
SELECT * FROM film WHERE length < 100 ORDER BY length LIMIT 10; | ||
SELECT * FROM customer WHERE address_id in (224,510) ORDER BY last_name; | ||
SELECT * FROM customer WHERE address_id in (224,510) ORDER BY last_name; | ||
SELECT * FROM film WHERE release_year = 2016 AND length != 1 ORDER BY title; | ||
SELECT * FROM film WHERE release_year = 2016 AND length != 1 ORDER BY title; | ||
SELECT title FROM film WHERE release_year = 1995; | ||
SELECT title FROM film WHERE release_year = 1995; | ||
SELECT title, replacement_cost FROM film WHERE language_id = 5 AND length = 70; | ||
SELECT title, replacement_cost FROM film WHERE language_id = 5 AND length = 70; | ||
SELECT title FROM film WHERE language_id > 5 AND length > 70; | ||
SELECT title FROM film WHERE language_id > 5 AND length > 70; | ||
SELECT * FROM film WHERE length = 100 and title = 'xyz' ORDER BY release_year; | ||
SELECT * FROM film WHERE length = 100 and title = 'xyz' ORDER BY release_year; | ||
SELECT * FROM film WHERE length > 100 and title = 'xyz' ORDER BY release_year; | ||
SELECT * FROM film WHERE length > 100 and title = 'xyz' ORDER BY release_year; | ||
SELECT * FROM film WHERE length > 100 ORDER BY release_year; | ||
SELECT * FROM film WHERE length > 100 ORDER BY release_year; | ||
SELECT * FROM city a INNER JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a INNER JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id WHERE b.last_update IS NULL; | ||
SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id WHERE b.last_update IS NULL; | ||
SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id WHERE a.last_update IS NULL; | ||
SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id WHERE a.last_update IS NULL; | ||
SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id UNION SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id UNION SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id; | ||
SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id WHERE a.last_update IS NULL UNION SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id WHERE b.last_update IS NULL; | ||
SELECT * FROM city a RIGHT JOIN country b ON a.country_id=b.country_id WHERE a.last_update IS NULL UNION SELECT * FROM city a LEFT JOIN country b ON a.country_id=b.country_id WHERE b.last_update IS NULL; | ||
SELECT country_id, last_update FROM city NATURAL JOIN country; | ||
SELECT country_id, last_update FROM city NATURAL JOIN country; | ||
SELECT country_id, last_update FROM city NATURAL LEFT JOIN country; | ||
SELECT country_id, last_update FROM city NATURAL LEFT JOIN country; | ||
SELECT country_id, last_update FROM city NATURAL RIGHT JOIN country; | ||
SELECT country_id, last_update FROM city NATURAL RIGHT JOIN country; | ||
SELECT a.country_id, a.last_update FROM city a STRAIGHT_JOIN country b ON a.country_id=b.country_id; | ||
SELECT a.country_id, a.last_update FROM city a STRAIGHT_JOIN country b ON a.country_id=b.country_id; | ||
SELECT d.deptno,d.dname,d.loc FROM scott.dept d WHERE d.deptno IN (SELECT e.deptno FROM scott.emp e); | ||
SELECT d.deptno,d.dname,d.loc FROM scott.dept d WHERE d.deptno IN (SELECT e.deptno FROM scott.emp e); | ||
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc; | ||
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc; | ||
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1; | ||
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1; | ||
DELETE city FROM city LEFT JOIN country ON city.country_id = country.country_id WHERE country.country IS NULL; | ||
DELETE city FROM city LEFT JOIN country ON city.country_id = country.country_id WHERE country.country IS NULL; | ||
DELETE a1, a2 FROM city AS a1 INNER JOIN country AS a2 WHERE a1.country_id=a2.country_id; | ||
DELETE a1, a2 FROM city AS a1 INNER JOIN country AS a2 WHERE a1.country_id=a2.country_id; | ||
DELETE FROM a1, a2 USING city AS a1 INNER JOIN country AS a2 WHERE a1.country_id=a2.country_id; | ||
DELETE FROM a1, a2 USING city AS a1 INNER JOIN country AS a2 WHERE a1.country_id=a2.country_id; | ||
DELETE FROM film WHERE length > 100; | ||
DELETE FROM film WHERE length > 100; | ||
UPDATE city INNER JOIN country USING(country_id) SET city.city = 'Abha', city.last_update = '2006-02-15 04:45:25', country.country = 'Afghanistan' WHERE city.city_id=10; | ||
UPDATE city INNER JOIN country USING(country_id) SET city.city = 'Abha', city.last_update = '2006-02-15 04:45:25', country.country = 'Afghanistan' WHERE city.city_id=10; | ||
UPDATE city INNER JOIN country ON city.country_id = country.country_id INNER JOIN address ON city.city_id = address.city_id SET city.city = 'Abha', city.last_update = '2006-02-15 04:45:25', country.country = 'Afghanistan' WHERE city.city_id=10; | ||
UPDATE city INNER JOIN country ON city.country_id = country.country_id INNER JOIN address ON city.city_id = address.city_id SET city.city = 'Abha', city.last_update = '2006-02-15 04:45:25', country.country = 'Afghanistan' WHERE city.city_id=10; | ||
UPDATE city, country SET city.city = 'Abha', city.last_update = '2006-02-15 04:45:25', country.country = 'Afghanistan' WHERE city.country_id = country.country_id AND city.city_id=10; | ||
UPDATE city, country SET city.city = 'Abha', city.last_update = '2006-02-15 04:45:25', country.country = 'Afghanistan' WHERE city.country_id = country.country_id AND city.city_id=10; | ||
UPDATE film SET length = 10 WHERE language_id = 20; | ||
UPDATE film SET length = 10 WHERE language_id = 20; | ||
INSERT INTO city (country_id) SELECT country_id FROM country; | ||
INSERT INTO city (country_id) SELECT country_id FROM country; | ||
INSERT INTO city (country_id) VALUES (1),(2),(3); | ||
INSERT INTO city (country_id) VALUES (1),(2),(3); | ||
INSERT INTO city (country_id) VALUES (10); | ||
INSERT INTO city (country_id) VALUES (10); | ||
INSERT INTO city (country_id) SELECT 10 FROM DUAL; | ||
INSERT INTO city (country_id) SELECT 10 FROM DUAL; | ||
REPLACE INTO city (country_id) SELECT country_id FROM country; | ||
REPLACE INTO city (country_id) SELECT country_id FROM country; | ||
REPLACE INTO city (country_id) VALUES (1),(2),(3); | ||
REPLACE INTO city (country_id) VALUES (1),(2),(3); | ||
REPLACE INTO city (country_id) VALUES (10); | ||
REPLACE INTO city (country_id) VALUES (10); | ||
REPLACE INTO city (country_id) SELECT 10 FROM DUAL; | ||
REPLACE INTO city (country_id) SELECT 10 FROM DUAL; | ||
SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film; | ||
SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM ( SELECT film_id FROM film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film ) film; | ||
SELECT * FROM film WHERE language_id = (SELECT language_id FROM language LIMIT 1); | ||
SELECT * FROM film WHERE language_id = (SELECT language_id FROM language LIMIT 1); | ||
SELECT * FROM city i left JOIN country o ON i.city_id=o.country_id union SELECT * FROM city i right JOIN country o ON i.city_id=o.country_id; | ||
SELECT * FROM city i left JOIN country o ON i.city_id=o.country_id union SELECT * FROM city i right JOIN country o ON i.city_id=o.country_id; | ||
SELECT * FROM (SELECT * FROM actor WHERE last_update='2006-02-15 04:34:33' and last_name='CHASE') t WHERE last_update='2006-02-15 04:34:33' and last_name='CHASE' GROUP BY first_name; | ||
SELECT * FROM (SELECT * FROM actor WHERE last_update='2006-02-15 04:34:33' and last_name='CHASE') t WHERE last_update='2006-02-15 04:34:33' and last_name='CHASE' GROUP BY first_name; | ||
SELECT * FROM city i left JOIN country o ON i.city_id=o.country_id union SELECT * FROM city i right JOIN country o ON i.city_id=o.country_id; | ||
SELECT * FROM city i left JOIN country o ON i.city_id=o.country_id union SELECT * FROM city i right JOIN country o ON i.city_id=o.country_id; | ||
SELECT * FROM city i left JOIN country o ON i.city_id=o.country_id WHERE o.country_id is null union SELECT * FROM city i right JOIN country o ON i.city_id=o.country_id WHERE i.city_id is null; | ||
SELECT * FROM city i left JOIN country o ON i.city_id=o.country_id WHERE o.country_id is null union SELECT * FROM city i right JOIN country o ON i.city_id=o.country_id WHERE i.city_id is null; | ||
SELECT first_name,last_name,email FROM customer STRAIGHT_JOIN address ON customer.address_id=address.address_id; | ||
SELECT first_name,last_name,email FROM customer STRAIGHT_JOIN address ON customer.address_id=address.address_id; | ||
SELECT ID,name FROM (SELECT address FROM customer_list WHERE SID=1 order by phone limit 50,10) a JOIN customer_list l ON (a.address=l.address) JOIN city c ON (c.city=l.city) order by phone desc; | ||
SELECT ID,name FROM (SELECT address FROM customer_list WHERE SID=1 order by phone limit 50,10) a JOIN customer_list l ON (a.address=l.address) JOIN city c ON (c.city=l.city) order by phone desc; | ||
SELECT * FROM film WHERE date(last_update)='2006-02-15'; | ||
SELECT * FROM film WHERE date(last_update)='2006-02-15'; | ||
SELECT last_update FROM film GROUP BY date(last_update); | ||
SELECT last_update FROM film GROUP BY date(last_update); | ||
SELECT last_update FROM film order by date(last_update); | ||
SELECT last_update FROM film order by date(last_update); | ||
SELECT description FROM film WHERE description IN('NEWS','asd') GROUP BY description; | ||
SELECT description FROM film WHERE description IN('NEWS','asd') GROUP BY description; | ||
alter table address add index idx_city_id(city_id); | ||
alter table address add index idx_city_id(city_id); | ||
alter table inventory add index `idx_store_film` (`store_id`,`film_id`); | ||
alter table inventory add index `idx_store_film` (`store_id`,`film_id`); | ||
alter table inventory add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`); | ||
alter table inventory add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`); | ||
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d') | ||
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d') | ||
create table hello.t (id int unsigned); | ||
create table hello.t (id int unsigned); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
orignal: "hello world" | ||
quoted: "hello world" | ||
orignal: `hello world` | ||
quoted: `hello world` | ||
orignal: 'hello world' | ||
quoted: 'hello world' | ||
orignal: hello world | ||
quoted: | ||
orignal: 'hello \'world' | ||
quoted: 'hello \'world' | ||
orignal: "hello \"wor\"ld" | ||
quoted: "hello \"wor\"ld" | ||
orignal: "hello \"world" | ||
quoted: "hello \"world" | ||
orignal: "" | ||
quoted: "" | ||
orignal: '' | ||
quoted: '' | ||
orignal: `` | ||
quoted: `` | ||
orignal: 'hello 'world' | ||
quoted: 'hello ' | ||
orignal: "hello "world" | ||
quoted: "hello " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1 | ||
0 | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1 | ||
2 | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
0 select * from test; | ||
1 select 'asd;fas', col from test; | ||
2 -- select * from test;hello | ||
3 #select * from test;hello | ||
4 select * /*comment*/from test; | ||
5 select * /*comment;*/from test; | ||
6 select * /*comment | ||
;*/ | ||
from test; | ||
7 select * from test | ||
8 /*comment*/ | ||
9 /*comment*/; | ||
10 -- | ||
11 -- comment | ||
12 # comment | ||
13 select | ||
* | ||
-- comment | ||
0 select * from test\Ghello | ||
1 select 'hello\Gworld', col from test\Ghello | ||
2 -- select * from test\Ghello | ||
3 #select * from test\Ghello | ||
4 select * /*comment*/from test\Ghello | ||
5 select * /*comment;*/from test\Ghello | ||
6 select * /*comment | ||
\\G*/ | ||
from test\\Ghello |
Oops, something went wrong.