parser: some test case failed
func main(){
sql := "select * from wn where id = 2"
pa := parser.New()
//set charsetInfo and collation
charsetInfo, collation := "utf8", "utf8_general_ci"
pa.SetSQLMode(mysql.ModeNone)
stmtNodes, err := pa.Parse( sql, charsetInfo, collation)
fmt.Println(stmtNodes[0], err)
}
It works when I use sql=“select * from wn”
But it failed when I use sql=“select * from wn where id = 2”
The golang version is 1.11.1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5e3ef8]
goroutine 1 [running]:
github.com/pingcap/parser.yyParse(0x715e60, 0xc000154048, 0xc000154000, 0xc00010bf68)
/root/wn/go/pkg/mod/github.com/pingcap/parser@v0.0.0-20181119030059-e8ee63ef2cb2/parser.go:8654 +0x16ac8
github.com/pingcap/parser.(*Parser).Parse(0xc000154000, 0x7fffc6f056eb, 0x1b, 0x6b7519, 0x4, 0x6bd81d, 0xf, 0x0, 0x0, 0xc00010bf10, ...)
/root/wn/go/pkg/mod/github.com/pingcap/parser@v0.0.0-20181119030059-e8ee63ef2cb2/yy_parser.go:101 +0x15f
main.main()
/root/wn/go/test2/hello.go:26 +0x2a9
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (1 by maintainers)
tidb最新版本没有parser_driver包,应该依赖那个版本啊
why cannot " go get github.com/pingcap/tidb@v3.0.5"?
hello @464319127
sorry, you should add this import in head of
hello.go
The reason why we should add this
import
is that we want to decoupleparser
’s value expresion implement fromtidb
(so other also can have their own value expression impl), so we need import the driver package to choose tidb’s value expression impl if we want to use tidb’s impl(just like choose mysql sql driver).maybe we should add a developer usage example for parser and provide better panic message @tiancaiamao