Skip to content

Commit 7296daa

Browse files
author
xinbg
committed
update readme, fix invalid command cause goroutine stuck
1 parent 898baeb commit 7296daa

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,7 @@ Which will be handy when that pm tells you to change somebody's coins to 2^10.
9191
##### Road Map
9292

9393
Mostly all that `TODO` in the code, and tell others about this project.
94+
95+
Apparently from the go report page, there is quiet a lot things to fix, but not sure should fix that.
96+
97+
Better error handle, for example if a SQL is invalid, should suggest what's wrong.

main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@ func sqlRunner(sql string, resultCh chan string, errCh chan error) (chan string,
3636
} else {
3737
errCh <- err
3838
}
39-
}
40-
if sqlparser.DescRegexp.MatchString(sql) && sqlparser.TableRegexp.MatchString(sql) {
39+
} else if sqlparser.DescRegexp.MatchString(sql) && sqlparser.TableRegexp.MatchString(sql) {
4140
if r, err := executors.DescribeTable(sql + " END"); err == nil {
4241
resultCh <- r
4342
} else {
4443
errCh <- err
4544
}
46-
}
47-
// TODO require WHERE field, update all seems not so safe?
48-
if sqlparser.UpdateRegexp.MatchString(sql) {
45+
} else if sqlparser.UpdateRegexp.MatchString(sql) {
46+
// TODO require WHERE field, update all seems not so safe?
4947
if r, err := executors.Update(sql + " END"); err == nil {
5048
resultCh <- r
5149
} else {
5250
errCh <- err
5351
}
52+
} else {
53+
resultCh <- ""
54+
errCh <- nil
5455
}
5556
// TODO support SHOW TABLE
5657
return resultCh, errCh

0 commit comments

Comments
 (0)