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

some test case failed #43

Closed
464319127 opened this issue Nov 19, 2018 · 18 comments · Fixed by #44
Closed

some test case failed #43

464319127 opened this issue Nov 19, 2018 · 18 comments · Fixed by #44
Assignees
Labels
question Further information is requested

Comments

@464319127
Copy link

464319127 commented Nov 19, 2018

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
@shenli
Copy link
Member

shenli commented Nov 19, 2018

@tiancaiamao @lysu PTAL

@lysu
Copy link
Collaborator

lysu commented Nov 19, 2018

hello @464319127

sorry, you should add this import in head of hello.go

import _ "github.com/pingcap/tidb/types/parser_driver"

The reason why we should add this import is that we want to decouple parser's value expresion implement from tidb(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

@lysu lysu added the question Further information is requested label Nov 19, 2018
@lysu lysu self-assigned this Nov 19, 2018
@464319127
Copy link
Author

@lysu thanks a lot. It works now.

@464319127
Copy link
Author

464319127 commented Nov 20, 2018

import _ "github.com/pingcap/tidb/types/parser_driver"

when I add the import in head, the go mod default require the tidb@v2.0.9+incompatible.

But there is no tidb/types/parser_driver in tidb@v2.0.9+incompatible.

So I use go get github.com/pingcap/tidb@master to get it. Then I modify the go.mod

require (
    github.com/pingcap/parser v0.0.0-20181120072820-10951bcfca73
    github.com/pingcap/tidb v0.0.0-20181120082053-012cb6da9443
)

@winjeg
Copy link

winjeg commented Jun 14, 2019

这个parser拆的也太不清真了吧, 要使用还要 go get tidb 驱动为啥不放在parser里

@rarpainting
Copy link

rarpainting commented Aug 15, 2019

@winjeg
For dependencies, see the top description of value_expr.go

@winjeg
Copy link

winjeg commented Oct 23, 2019

Now it's not working according to the offical document, I was lead back here by the error print in my co nsole.

no such package github.com/pingcap/tidb/types/parser_driver in tidb now

@tiancaiamao
Copy link
Collaborator

Try this command:

go get -u github.com/pingcap/tidb@master

@winjeg

@bugcai
Copy link

bugcai commented Nov 13, 2019

go get -u github.com/pingcap/tidb@master

why cannot " go get github.com/pingcap/tidb@v3.0.5"?

@funlake
Copy link

funlake commented Feb 21, 2020

Try this command:

go get -u github.com/pingcap/tidb@master

@winjeg

Didn't works,got error
go get: error loading module requirements

@xeoncross
Copy link

go get -u github.com/pingcap/tidb@master

why cannot " go get github.com/pingcap/tidb@v3.0.5"?

Good question. master currently points at tidb@v1.1.0-beta.0.20200417160137-a0c7407846fb which claims to be from April 4th, but isn't a release/tag: https://github.com/pingcap/tidb/tags

@didip
Copy link

didip commented Jun 18, 2020

I am guessing that parser_driver is deleted in tidb?

go: finding module for package github.com/pingcap/tidb/types/parser_driver
main.go:7:2: module github.com/pingcap/tidb@latest found (v2.0.11+incompatible), but does not contain package github.com/pingcap/tidb/types/parser_driver

@abao2016 abao2016 mentioned this issue Jul 18, 2020
@lwfofgit
Copy link

lwfofgit commented Jul 24, 2020

tidb最新版本没有parser_driver包,应该依赖那个版本啊

@zhangysh1995
Copy link

I solved a first error with #812, and I got this error again:

go: finding module for package github.com/pingcap/tidb/types/parser_driver
main.go:7:2: module github.com/pingcap/tidb@latest found (v2.0.11+incompatible), but does not contain package github.com/pingcap/tidb/types/parser_driver

Compilation finished with exit code 1

My import:

import (
	"fmt"
	"github.com/pingcap/parser"
	"github.com/pingcap/parser/ast"
	_ "github.com/pingcap/tidb/types/parser_driver"
)

@zhangysh1995
Copy link

For anyone who has this issue, please see my comments here.

@TerryLiu
Copy link

TerryLiu commented Apr 7, 2024

import _ "github.com/pingcap/parser/test_driver"

@dobet
Copy link

dobet commented Apr 15, 2024

no bady update quickstart? and reslove this problem?

@twz915
Copy link

twz915 commented May 17, 2024

import (
	_ "github.com/pingcap/tidb/pkg/parser/test_driver"
)

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

Successfully merging a pull request may close this issue.