parser icon indicating copy to clipboard operation
parser copied to clipboard

Parser fails on CREATE FUNCTION

Open kyleconroy opened this issue 5 years ago • 3 comments

Bug Report

  1. 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")
}
  1. What did you expect to see?
$ go run main.go
success
  1. 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);
" 
  1. 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

kyleconroy avatar Aug 27 '20 20:08 kyleconroy

TiDB does not support functions or stored procedures as of 4.0, so pingcap/parser currently have not implemented the syntax around these features.

kennytm avatar Aug 28 '20 06:08 kennytm

@kyleconroy If you need this syntax, you can file a pull request to support it.

tangenta avatar Aug 28 '20 07:08 tangenta

As a parser that claims to be "MySQL Compatible", I think we should support it, and regarding parser failure as a bug.

breezewish avatar Jan 15 '21 10:01 breezewish