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

wip:*: Support sytax of reset placement options #1353

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/pingcap/parser/terror"
"github.com/pingcap/parser/tidb"
"github.com/pingcap/parser/types"
"strings"
)

var (
Expand Down Expand Up @@ -1942,7 +1943,11 @@ func (n *PlacementOption) Restore(ctx *format.RestoreCtx) error {
case PlacementOptionPolicy:
ctx.WriteKeyWord("PLACEMENT POLICY ")
ctx.WritePlain("= ")
ctx.WriteName(n.StrValue)
if strings.ToLower(n.StrValue) == "default" {
ctx.WriteKeyWord("DEFAULT")
} else {
ctx.WriteName(n.StrValue)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want 'DEFAULT' and DEFAULT to be distinguishable you should create a separate PlacementOptionType. playing tricks in Restore() won't do much.

Copy link
Contributor Author

@sylzd sylzd Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also want to make `DEFAULT`(identifier) differs from DEFAULT (keyword) 🤣, does it work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. "DEFAULT" in parser.y always refer to the keyword. since DEFAULT is a reserved keyword it shouldn't collide with Identifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great to me, I will try it.😆

default:
isSupported = false
}
Expand Down
Loading