-
Notifications
You must be signed in to change notification settings - Fork 6.2k
planner: build multi alternative logical plan from shared AST (#66677) #68859
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 |
|---|---|---|
|
|
@@ -65,10 +65,31 @@ func AllocateTaskID() uint64 { | |
| // SQLWarn relates a sql warning and it's level. | ||
| type SQLWarn = contextutil.SQLWarn | ||
|
|
||
| <<<<<<< HEAD | ||
| type jsonSQLWarn struct { | ||
| Level string `json:"level"` | ||
| SQLErr *terror.Error `json:"err,omitempty"` | ||
| Msg string `json:"msg,omitempty"` | ||
| ======= | ||
| // LogicalPlanBuildState stores the statement-scoped planner state that is mutated while | ||
| // building a logical plan from AST. | ||
| type LogicalPlanBuildState struct { | ||
| warnings []SQLWarn | ||
| extraWarnings []SQLWarn | ||
| tables []TableEntry | ||
| tableStats map[int64]any | ||
| lockTableIDs map[int64]struct{} | ||
| tblInfo2UnionScan map[*model.TableInfo]bool | ||
| useDynamicPruneMode bool | ||
| viewDepth int32 | ||
| colRefFromUpdatePlan intset.FastIntSet | ||
| // plan cache related stuff | ||
| planCacheUseCache bool | ||
| planCacheType contextutil.PlanCacheType | ||
| planCacheUnqualified string | ||
| planCacheForce bool | ||
| planCacheAlwaysWarn bool | ||
| >>>>>>> d59e531fe61 (planner: build multi alternative logical plan from shared AST (#66677)) | ||
| } | ||
|
Comment on lines
+68
to
93
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. Resolve the cherry-pick conflict before merge. Line 68 still starts a 🤖 Prompt for AI Agents |
||
|
|
||
| // ReferenceCount indicates the reference count of StmtCtx. | ||
|
|
@@ -572,6 +593,44 @@ func (sc *StatementContext) Reset() bool { | |
| return true | ||
| } | ||
|
|
||
| // SaveLogicalPlanBuildState captures the statement-scoped planner state before building | ||
| // another logical plan candidate from the same AST. | ||
| func (sc *StatementContext) SaveLogicalPlanBuildState() LogicalPlanBuildState { | ||
| planCacheUseCache, planCacheType, planCacheUnqualified, planCacheForce, planCacheAlwaysWarn := sc.PlanCacheTracker.Save() | ||
| return LogicalPlanBuildState{ | ||
| warnings: slices.Clone(sc.GetWarnings()), | ||
| extraWarnings: slices.Clone(sc.GetExtraWarnings()), | ||
| tables: slices.Clone(sc.Tables), | ||
| tableStats: maps.Clone(sc.TableStats), | ||
| lockTableIDs: maps.Clone(sc.LockTableIDs), | ||
| tblInfo2UnionScan: maps.Clone(sc.TblInfo2UnionScan), | ||
| useDynamicPruneMode: sc.UseDynamicPruneMode, | ||
| viewDepth: sc.ViewDepth, | ||
| colRefFromUpdatePlan: sc.ColRefFromUpdatePlan.Copy(), | ||
|
Comment on lines
+607
to
+609
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.
Lines 608 and 628 reference Also applies to: 627-629 🤖 Prompt for AI Agents |
||
| planCacheUseCache: planCacheUseCache, | ||
| planCacheType: planCacheType, | ||
| planCacheUnqualified: planCacheUnqualified, | ||
| planCacheForce: planCacheForce, | ||
| planCacheAlwaysWarn: planCacheAlwaysWarn, | ||
| } | ||
| } | ||
|
|
||
| // RestoreLogicalPlanBuildState restores the statement-scoped planner state after a | ||
| // discarded logical plan build attempt. | ||
| func (sc *StatementContext) RestoreLogicalPlanBuildState(state LogicalPlanBuildState) { | ||
| sc.SetWarnings(slices.Clone(state.warnings)) | ||
| sc.SetExtraWarnings(slices.Clone(state.extraWarnings)) | ||
| sc.Tables = slices.Clone(state.tables) | ||
| sc.TableStats = maps.Clone(state.tableStats) | ||
| sc.LockTableIDs = maps.Clone(state.lockTableIDs) | ||
| sc.TblInfo2UnionScan = maps.Clone(state.tblInfo2UnionScan) | ||
| sc.UseDynamicPruneMode = state.useDynamicPruneMode | ||
| sc.ViewDepth = state.viewDepth | ||
| sc.ColRefFromUpdatePlan.CopyFrom(state.colRefFromUpdatePlan) | ||
| sc.PlanCacheTracker.Restore(state.planCacheUseCache, state.planCacheType, state.planCacheUnqualified, state.planCacheForce, state.planCacheAlwaysWarn) | ||
| sc.RangeFallbackHandler = contextutil.NewRangeFallbackHandler(&sc.PlanCacheTracker, sc) | ||
| } | ||
|
|
||
| // CtxID returns the context id of the statement | ||
| func (sc *StatementContext) CtxID() uint64 { | ||
| return sc.ctxID | ||
|
|
||
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.
Remove the leftover conflict markers from the Bazel rule.
Line 48 still contains merge-conflict markers, so Bazel cannot parse this file. Keep only the intended
shard_countentry.🤖 Prompt for AI Agents