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

parser: support syntax set binding status by sql digest #39515

Merged
merged 24 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
188cd19
undo
fzzf678 Nov 24, 2022
f346bb0
Merge remote-tracking branch 'upstream/master' into binding_set_parser
fzzf678 Nov 30, 2022
056163b
Delete planbuilder.go
fzzf678 Nov 30, 2022
1a53a3c
Revert "Delete planbuilder.go"
fzzf678 Nov 30, 2022
838cd21
fixed
fzzf678 Nov 30, 2022
16708d3
make parser
fzzf678 Nov 30, 2022
5cd2cfd
supply test
fzzf678 Nov 30, 2022
41dca53
UT
fzzf678 Nov 30, 2022
ee578d3
Merge branch 'master' into binding_set_parser
fzzf678 Nov 30, 2022
8d10962
Merge remote-tracking branch 'upstream/master' into binding_set_parser
fzzf678 Dec 7, 2022
e6dd2ad
conflict
fzzf678 Dec 7, 2022
bdf5d9c
Merge remote-tracking branch 'upstream/master' into binding_set_parser
fzzf678 Dec 8, 2022
16d109f
Update parser.go
fzzf678 Dec 8, 2022
39cc0ee
Merge remote-tracking branch 'upstream/master' into binding_set_parser
fzzf678 Dec 13, 2022
a68b7be
Update parser.go
fzzf678 Dec 13, 2022
4c2a986
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
a08d827
Merge branch 'master' into binding_set_parser
qw4990 Dec 14, 2022
76b72d3
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
a4efe2d
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
479f896
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
a4dce7d
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
73ffb9a
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
1ef6c76
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
c336fd0
Merge branch 'master' into binding_set_parser
fzzf678 Dec 14, 2022
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
37 changes: 23 additions & 14 deletions parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,7 @@ type SetBindingStmt struct {
BindingStatusType BindingStatusType
OriginNode StmtNode
HintedNode StmtNode
SQLDigest string
}

func (n *SetBindingStmt) Restore(ctx *format.RestoreCtx) error {
Expand All @@ -1952,14 +1953,19 @@ func (n *SetBindingStmt) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord("DISABLED ")
}
ctx.WriteKeyWord("FOR ")
if err := n.OriginNode.Restore(ctx); err != nil {
return errors.Trace(err)
}
if n.HintedNode != nil {
ctx.WriteKeyWord(" USING ")
if err := n.HintedNode.Restore(ctx); err != nil {
if n.OriginNode == nil {
ctx.WriteKeyWord("SQL DIGEST ")
ctx.WriteString(n.SQLDigest)
} else {
if err := n.OriginNode.Restore(ctx); err != nil {
return errors.Trace(err)
}
if n.HintedNode != nil {
ctx.WriteKeyWord(" USING ")
if err := n.HintedNode.Restore(ctx); err != nil {
return errors.Trace(err)
}
}
}
return nil
}
Expand All @@ -1970,17 +1976,20 @@ func (n *SetBindingStmt) Accept(v Visitor) (Node, bool) {
return v.Leave(newNode)
}
n = newNode.(*SetBindingStmt)
origNode, ok := n.OriginNode.Accept(v)
if !ok {
return n, false
}
n.OriginNode = origNode.(StmtNode)
if n.HintedNode != nil {
hintedNode, ok := n.HintedNode.Accept(v)
if n.OriginNode != nil {
// OriginNode is nil means we set binding stmt by sql digest
origNode, ok := n.OriginNode.Accept(v)
if !ok {
return n, false
}
n.HintedNode = hintedNode.(StmtNode)
n.OriginNode = origNode.(StmtNode)
if n.HintedNode != nil {
hintedNode, ok := n.HintedNode.Accept(v)
if !ok {
return n, false
}
n.HintedNode = hintedNode.(StmtNode)
}
}
return v.Leave(n)
}
Expand Down
Loading