-
Notifications
You must be signed in to change notification settings - Fork 6.1k
planner: implements support for dumping multiple SQL statements in a single PLAN REPLAYER DUMP EXPLAIN command
#66162
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -301,6 +301,10 @@ type PlanReplayerStmt struct { | |
| // 2. plan replayer dump explain <analyze> 'file' | ||
| File string | ||
|
|
||
| // StmtList is used for PLAN REPLAYER DUMP EXPLAIN [ANALYZE] ( "sql1", "sql2", ... ) | ||
| // When non-nil, multiple SQL strings are dumped in one command. | ||
| StmtList []string | ||
|
|
||
| // Fields below are currently useless. | ||
|
|
||
| // Where is the where clause in select statement. | ||
|
|
@@ -347,6 +351,17 @@ func (n *PlanReplayerStmt) Restore(ctx *format.RestoreCtx) error { | |
| } else { | ||
| ctx.WriteKeyWord("EXPLAIN ") | ||
| } | ||
| if len(n.StmtList) > 0 { | ||
| ctx.WritePlain("(") | ||
| for i, s := range n.StmtList { | ||
| if i > 0 { | ||
| ctx.WritePlain(", ") | ||
| } | ||
| ctx.WriteString(s) | ||
| } | ||
| ctx.WritePlain(")") | ||
| return nil | ||
| } | ||
| if n.Stmt == nil { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: When will
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if len(n.File) > 0 { | ||
| ctx.WriteString(n.File) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -343,6 +343,10 @@ func TestPlanReplayerStmtRestore(t *testing.T) { | |
| "PLAN REPLAYER DUMP EXPLAIN ANALYZE 'test'"}, | ||
| {"plan replayer dump with stats as of timestamp '12345' explain analyze 'test2'", | ||
| "PLAN REPLAYER DUMP WITH STATS AS OF TIMESTAMP _UTF8MB4'12345' EXPLAIN ANALYZE 'test2'"}, | ||
| {"plan replayer dump explain ('SELECT * FROM t1', 'SELECT * FROM t2')", | ||
| "PLAN REPLAYER DUMP EXPLAIN ('SELECT * FROM t1', 'SELECT * FROM t2')"}, | ||
| {"plan replayer dump explain analyze ('SELECT * FROM t1')", | ||
| "PLAN REPLAYER DUMP EXPLAIN ANALYZE ('SELECT * FROM t1')"}, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add edge case that with empty and non empty in the stmt list?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| extractNodeFunc := func(node ast.Node) ast.Node { | ||
| return node.(*ast.PlanReplayerStmt) | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.