Parser cannot pass default value with an expression
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
version `09d12f0` (tried old version got the same behaviour)
```
package main
import (
"fmt"
"github.com/pingcap/tidb/pkg/parser"
"github.com/pingcap/tidb/pkg/parser/ast"
_ "github.com/pingcap/tidb/pkg/parser/test_driver"
)
func parse(sql string) (*ast.StmtNode, error) {
p := parser.New()
stmtNodes, _, err := p.ParseSQL(sql)
if err != nil {
return nil, err
}
return &stmtNodes[0], nil
}
func main() {
astNode, err := parse("ALTER TABLE `roles` MODIFY COLUMN `long_description` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ('');")
if err != nil {
fmt.Printf("parse error: %v\n", err.Error())
return
}
fmt.Printf("%v\n", *astNode)
}
```
### 2. What did you expect to see? (Required)
As documented by mysql, the [BLOB](https://dev.mysql.com/doc/refman/8.0/en/blob.html), [TEXT](https://dev.mysql.com/doc/refman/8.0/en/blob.html), GEOMETRY, and [JSON](https://dev.mysql.com/doc/refman/8.0/en/json.html) data types can be assigned a default value only if the value is written as an expression
### 3. What did you see instead (Required)
Run the simple script, and got error instead
```
parse error: line 1 column 131 near "'');"
```
Contributor guide
Assessment
This issue has not been assessed yet.