-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner, executor: fix PREPARE FROM @var_name
#8437
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,7 @@ func (b *PlanBuilder) Build(node ast.Node) (Plan, error) { | |
case *ast.LoadStatsStmt: | ||
return b.buildLoadStats(x), nil | ||
case *ast.PrepareStmt: | ||
return b.buildPrepare(x), nil | ||
return b.buildPrepare(x) | ||
case *ast.SelectStmt: | ||
return b.buildSelect(x) | ||
case *ast.UnionStmt: | ||
|
@@ -396,17 +396,20 @@ func (b *PlanBuilder) buildSelectLock(src LogicalPlan, lock ast.SelectLockType) | |
return selectLock | ||
} | ||
|
||
func (b *PlanBuilder) buildPrepare(x *ast.PrepareStmt) Plan { | ||
func (b *PlanBuilder) buildPrepare(x *ast.PrepareStmt) (Plan, error) { | ||
p := &Prepare{ | ||
Name: x.Name, | ||
} | ||
if x.SQLVar != nil { | ||
// TODO: Prepared statement from variable expression do not work as expected. | ||
// p.SQLText, _ = x.SQLVar.GetValue().(string) | ||
if v, ok := b.ctx.GetSessionVars().Users[x.SQLVar.Name]; ok { | ||
p.SQLText = v | ||
} else { | ||
p.SQLText = "NULL" | ||
} | ||
} else { | ||
p.SQLText = x.SQLText | ||
} | ||
return p | ||
return p, nil | ||
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. Why adding one more return value error which is always nil? 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. I think we may address some errors in this function first thought; but found no such errors should be address here. 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. Then I prefer removing it. 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. Address this comment makes an LGTM. @AndrewDi |
||
} | ||
|
||
func (b *PlanBuilder) buildCheckIndex(dbName model.CIStr, as *ast.AdminStmt) (Plan, error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to
execute stmt
to see whether the result is correct.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine, result check addressed.