parser
parser copied to clipboard
Parser fails on CREATE FUNCTION
Bug Report
- What did you do?
I ran the following Go program
package main
import (
"fmt"
"github.com/pingcap/parser"
_ "github.com/pingcap/parser/test_driver"
)
const query = `CREATE FUNCTION say_hello(s text) RETURNS text
DETERMINISTIC
RETURN CONCAT('hello ', s);
`
func main() {
p := parser.New()
_, _, err := p.Parse(query, "", "")
if err != nil {
fmt.Printf("parse error: %v\n", err.Error())
return
}
fmt.Println("success")
}
- What did you expect to see?
$ go run main.go
success
- What did you see instead?
$ go run main.go
parse error: line 1 column 15 near "FUNCTION say_hello(s text) RETURNS text
DETERMINISTIC
RETURN CONCAT('hello ', s);
"
- What version of TiDB SQL Parser are you using?
// go.mod
module github.com/kyleconroy/parser-issue
go 1.14
require github.com/pingcap/parser v0.0.0-20200827073852-7a050a496310
TiDB does not support functions or stored procedures as of 4.0, so pingcap/parser currently have not implemented the syntax around these features.
@kyleconroy If you need this syntax, you can file a pull request to support it.
As a parser that claims to be "MySQL Compatible", I think we should support it, and regarding parser failure as a bug.