Skip to content

Commit b41f6f3

Browse files
authored
Merge pull request pingcap#3 from rebelice/chore/export-ExtractTableList
chore: export ExtractTableList
2 parents 5d3b71e + 8d0c426 commit b41f6f3

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

planner/core/logical_plan_builder.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -827,10 +827,10 @@ func (b *PlanBuilder) buildJoin(ctx context.Context, joinNode *ast.Join) (Logica
827827
// on the "USING" clause.
828828
//
829829
// According to the standard SQL, columns are ordered in the following way:
830-
// 1. coalesced common columns of "leftPlan" and "rightPlan", in the order they
831-
// appears in "leftPlan".
832-
// 2. the rest columns in "leftPlan", in the order they appears in "leftPlan".
833-
// 3. the rest columns in "rightPlan", in the order they appears in "rightPlan".
830+
// 1. coalesced common columns of "leftPlan" and "rightPlan", in the order they
831+
// appears in "leftPlan".
832+
// 2. the rest columns in "leftPlan", in the order they appears in "leftPlan".
833+
// 3. the rest columns in "rightPlan", in the order they appears in "rightPlan".
834834
func (b *PlanBuilder) buildUsingClause(p *LogicalJoin, leftPlan, rightPlan LogicalPlan, join *ast.Join) error {
835835
filter := make(map[string]bool, len(join.Using))
836836
for _, col := range join.Using {
@@ -851,9 +851,10 @@ func (b *PlanBuilder) buildUsingClause(p *LogicalJoin, leftPlan, rightPlan Logic
851851
// buildNaturalJoin builds natural join output schema. It finds out all the common columns
852852
// then using the same mechanism as buildUsingClause to eliminate redundant columns and build join conditions.
853853
// According to standard SQL, producing this display order:
854-
// All the common columns
855-
// Every column in the first (left) table that is not a common column
856-
// Every column in the second (right) table that is not a common column
854+
//
855+
// All the common columns
856+
// Every column in the first (left) table that is not a common column
857+
// Every column in the second (right) table that is not a common column
857858
func (b *PlanBuilder) buildNaturalJoin(p *LogicalJoin, leftPlan, rightPlan LogicalPlan, join *ast.Join) error {
858859
err := b.coalesceCommonColumns(p, leftPlan, rightPlan, join.Tp, nil)
859860
if err != nil {
@@ -1799,7 +1800,9 @@ func (b *PlanBuilder) buildUnion(ctx context.Context, selects []LogicalPlan, aft
17991800
// divideUnionSelectPlans resolves union's select stmts to logical plans.
18001801
// and divide result plans into "union-distinct" and "union-all" parts.
18011802
// divide rule ref:
1802-
// https://dev.mysql.com/doc/refman/5.7/en/union.html
1803+
//
1804+
// https://dev.mysql.com/doc/refman/5.7/en/union.html
1805+
//
18031806
// "Mixed UNION types are treated such that a DISTINCT union overrides any ALL union to its left."
18041807
func (b *PlanBuilder) divideUnionSelectPlans(_ context.Context, selects []LogicalPlan, setOprTypes []*ast.SetOprType) (distinctSelects []LogicalPlan, allSelects []LogicalPlan, err error) {
18051808
firstUnionAllIdx := 0
@@ -6490,6 +6493,12 @@ func (u *updatableTableListResolver) Leave(inNode ast.Node) (ast.Node, bool) {
64906493
return inNode, true
64916494
}
64926495

6496+
// ExtractTableList extracts all the TableNames from node.
6497+
// Tag: no-upstream.
6498+
func ExtractTableList(node ast.Node, input []*ast.TableName, asName bool) []*ast.TableName {
6499+
return extractTableList(node, input, asName)
6500+
}
6501+
64936502
// extractTableList extracts all the TableNames from node.
64946503
// If asName is true, extract AsName prior to OrigName.
64956504
// Privilege check should use OrigName, while expression may use AsName.

0 commit comments

Comments
 (0)