Meituan-Dianping / Meituan-Dianping/SQLAdvisor
命令行使用-q参数后面跟多个SQL无法解析出来
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 5.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
```
./sqladvisor -u xxx -p xxx -h xxxx -P xxx -d xxxx -q "SELECT p.*,s.cn_name FROM cc_paysystem_withdrawal as p LEFT JOIN cc_shop as s ON p.type_id = s.id WHERE ( p.type = 'SHOP' ) ORDER BY p.id LIMIT 0,50;select * from cc_paysystem_withdrawal where type='SHOP' order by id limit 0,50" -v 1
```
修改sqladvisor/main.cc:main函数:
```c
while ((query = options.query[i]) != NULL) {
sql_print_information("Query %d:%s\n", i, query);
sql_lex = sql_parser(query, options.dbname);
```
Query输出结果如下:
```
2017-03-13 16:09:34 31549 [Note] Query 0:SELECT p.*,s.cn_name FROM cc_paysystem_withdrawal as p LEFT JOIN cc_shop as s ON p.type_id = s.id WHERE ( p.type = 'SHOP' ) ORDER BY p.id LIMIT 0,50;select * from cc_paysystem_withdrawal where type='SHOP' order by id limit 0,50
```
可以看到并没有按照SEP设置进行SQL切分
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in sqladvisor/main.cc, in main where options.query is iterated and each entry is passed to sql_parser. Reproduce the command with two semicolon-separated SQL statements and inspect how the SEP setting is expected to split them. Done means the queries are separated and processed individually rather than logged as one query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, sql
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100