-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: fix update panic when update in prepare and execute #26759
Changes from all commits
ccf66fd
e66e134
0b94fdc
47b7c9a
843fabe
0644de4
9ba22b5
91127a1
39bdf6f
7f75aac
d04b0dd
dbe84bf
525a740
b358909
f5d7f0a
1d5e335
13e0a6f
d6ec84b
4548083
44146c4
3be9a6f
3f0de0e
e9227ed
2959ab5
48b66e4
4dd7843
8086a16
42b381b
d41aa35
5a20e18
2e1d6da
52f774d
963f737
ac14ea0
da070d7
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 |
---|---|---|
|
@@ -63,6 +63,13 @@ func WithPreprocessorReturn(ret *PreprocessorReturn) PreprocessOpt { | |
} | ||
} | ||
|
||
// WithExecuteInfoSchemaUpdate return a PreprocessOpt to update the `Execute` infoSchema under some conditions. | ||
func WithExecuteInfoSchemaUpdate(pe *PreprocessExecuteISUpdate) PreprocessOpt { | ||
return func(p *preprocessor) { | ||
p.PreprocessExecuteISUpdate = pe | ||
} | ||
} | ||
|
||
// TryAddExtraLimit trys to add an extra limit for SELECT or UNION statement when sql_select_limit is set. | ||
func TryAddExtraLimit(ctx sessionctx.Context, node ast.StmtNode) ast.StmtNode { | ||
if ctx.GetSessionVars().SelectLimit == math.MaxUint64 || ctx.GetSessionVars().InRestrictedSQL { | ||
|
@@ -143,6 +150,12 @@ type PreprocessorReturn struct { | |
TxnScope string | ||
} | ||
|
||
// PreprocessExecuteISUpdate is used to update information schema for special Execute statement in the preprocessor. | ||
type PreprocessExecuteISUpdate struct { | ||
ExecuteInfoSchemaUpdate func(node ast.Node, sctx sessionctx.Context) infoschema.InfoSchema | ||
Node ast.Node | ||
} | ||
|
||
// preprocessor is an ast.Visitor that preprocess | ||
// ast Nodes parsed from parser. | ||
type preprocessor struct { | ||
|
@@ -157,6 +170,7 @@ type preprocessor struct { | |
|
||
// values that may be returned | ||
*PreprocessorReturn | ||
*PreprocessExecuteISUpdate | ||
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 not name it Preprocessor like other members? 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 is 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. import circle problem, pass function poninter here is trying to do this |
||
err error | ||
} | ||
|
||
|
@@ -1596,9 +1610,17 @@ func (p *preprocessor) handleAsOfAndReadTS(node *ast.AsOfClause) { | |
// - session variable | ||
// - transaction context | ||
func (p *preprocessor) ensureInfoSchema() infoschema.InfoSchema { | ||
if p.InfoSchema == nil { | ||
p.InfoSchema = p.ctx.GetInfoSchema().(infoschema.InfoSchema) | ||
if p.InfoSchema != nil { | ||
return p.InfoSchema | ||
} | ||
// `Execute` under some conditions need to see the latest information schema. | ||
if p.PreprocessExecuteISUpdate != nil { | ||
if newInfoSchema := p.ExecuteInfoSchemaUpdate(p.Node, p.ctx); newInfoSchema != nil { | ||
p.InfoSchema = newInfoSchema | ||
return p.InfoSchema | ||
} | ||
} | ||
p.InfoSchema = p.ctx.GetInfoSchema().(infoschema.InfoSchema) | ||
return p.InfoSchema | ||
} | ||
|
||
|
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.
What if executing normal statements without prepare-execute model? It affects those statements now.
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.
it's ok, it's is a normal limitation.