*: check privilege when reusing the cached plan#12211
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12211 +/- ##
================================================
- Coverage 81.2062% 81.0534% -0.1528%
================================================
Files 454 454
Lines 99714 98947 -767
================================================
- Hits 80974 80200 -774
- Misses 12936 12951 +15
+ Partials 5804 5796 -8 |
| if i > 0 { | ||
| plannercore.SetPstmtIDSchemaVersion(cacheKey, stmtID, s.sessionVars.PreparedStmts[stmtID].SchemaVersion) | ||
| if i > 0 && preparedAst != nil { | ||
| plannercore.SetPstmtIDSchemaVersion(cacheKey, stmtID, preparedAst.SchemaVersion) |
There was a problem hiding this comment.
maybe s.sessionVars.PreparedStmts[stmtID].SchemaVersion != preparedAst.SchemaVersion and this will let s.PreparedPlanCache().Delete(cacheKey) leave some sth that need be delete
There was a problem hiding this comment.
This is a problem. Current prepared plan cache logic does not handle this and rely on lru list length limit to remove unused plan object, maybe we need to do removal in getPhysicalPlan when schema version changed
| systems map[string]string | ||
| // PreparedStmts stores prepared statement. | ||
| PreparedStmts map[uint32]*ast.Prepared | ||
| PreparedStmts map[uint32]interface{} |
There was a problem hiding this comment.
can we use map[uint32]*plannercore.PrepareObject directly for this field?
| systems map[string]string | ||
| // PreparedStmts stores prepared statement. | ||
| PreparedStmts map[uint32]*ast.Prepared | ||
| PreparedStmts map[uint32]interface{} |
There was a problem hiding this comment.
How about directly store PrepareObject?
zz-jason
left a comment
There was a problem hiding this comment.
please merge master and resolve conflicts.
|
Please resolve the conflict, @cfzjywxk . |
|
/merge |
|
/run-all-tests |
What problem does this PR solve?
Once prepared plan cache enabled and the cached plan hit need
privilege checkandtable lock checkWhat is changed and how it works?
PreparedObject(try not to add many things in ast structure)pull requests #11970 cached execution is faced with same problem(see #11970 comments)
Check List
Tests
Code changes
Side effects
Related changes
Release note