logical plan need a deep clone function
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
logical plan need a deep clone function, currently we can only do below
```
cloneLP := *LP
```
the interesting is that some time the slice inside cloneLP can be safely modified without any change back to the original one.
while for something like the holder as *schema, the slice column inside this *schema share the same pointer to the column slice,
under which we couldn't safely do the slice modification.
```
LogicalJoin{
LogicalSchemaProducer
EqualCondition []*expression.Expression
}
// LogicalSchemaProducer stores the schema for the logical plans who can produce schema directly.
type LogicalSchemaProducer struct {
schema *expression.Schema
names types.NameSlice
BaseLogicalPlan
}
```
Contributor guide
Research direction
Start by locating the logical-plan definitions, LogicalSchemaProducer, expression.Schema, and types.NameSlice in the TiDB source. Trace which nested slices and pointers are shared by a shallow copy, then inspect related logical-plan tests. Done means a deep-clone API with coverage showing nested modifications do not affect the original plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100