Skip to content

Commit 9aafbeb

Browse files
authored
[no-release-notes] tidy up analyzer (#2707)
1 parent 7d0507a commit 9aafbeb

13 files changed

+3
-638
lines changed

sql/analyzer/aggregations.go

Lines changed: 0 additions & 257 deletions
This file was deleted.

sql/analyzer/aliases.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -294,25 +294,6 @@ func aliasedExpressionsInNode(n sql.Node) map[string]string {
294294
return aliasesFromExpressionToName
295295
}
296296

297-
// aliasesDefinedInNode returns the expression aliases that are defined in the first Projector node found, starting
298-
// the search from the specified node. All returned alias names are normalized to lower case.
299-
func aliasesDefinedInNode(n sql.Node) []string {
300-
projector := findFirstProjectorNode(n)
301-
if projector == nil {
302-
return nil
303-
}
304-
305-
var aliases []string
306-
for _, e := range projector.ProjectedExprs() {
307-
alias, ok := e.(*expression.Alias)
308-
if ok {
309-
aliases = append(aliases, strings.ToLower(alias.Name()))
310-
}
311-
}
312-
313-
return aliases
314-
}
315-
316297
// normalizeExpressions returns the expressions given after normalizing them to replace table and expression aliases
317298
// with their underlying names. This is necessary to match such expressions against those declared by implementors of
318299
// various interfaces that declare expressions to handle, such as Index.Expressions(), FilteredTable, etc.

sql/analyzer/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ func (a *Analyzer) analyzeWithSelector(ctx *sql.Context, n sql.Node, scope *plan
518518
a.LogNode(n)
519519

520520
batches := a.Batches
521-
if b, ok := getBatchesForNode(n, batches); ok {
521+
if b, ok := getBatchesForNode(n); ok {
522522
batches = b
523523
}
524524

sql/analyzer/autocommit.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,3 @@ func addAutocommit(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope,
3232
}
3333
return plan.NewTransactionCommittingNode(n), transform.NewTree, nil
3434
}
35-
36-
func hasShowWarningsNode(n sql.Node) bool {
37-
var ret bool
38-
transform.Inspect(n, func(n sql.Node) bool {
39-
if _, ok := n.(plan.ShowWarnings); ok {
40-
ret = true
41-
return false
42-
}
43-
44-
return true
45-
})
46-
47-
return ret
48-
}

sql/analyzer/indexed_joins.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,24 +1387,3 @@ func isWeaklyMonotonic(e sql.Expression) bool {
13871387
}
13881388
})
13891389
}
1390-
1391-
// attrsRefSingleTableCol returns false if there are
1392-
// getFields sourced from zero or more than one table.
1393-
func attrsRefSingleTableCol(e sql.Expression) (tableCol, bool) {
1394-
var tc tableCol
1395-
var invalid bool
1396-
transform.InspectExpr(e, func(e sql.Expression) bool {
1397-
switch e := e.(type) {
1398-
case *expression.GetField:
1399-
newTc := newTableCol(e.Table(), e.Name())
1400-
if tc.table == "" && !invalid {
1401-
tc = newTc
1402-
} else if tc != newTc {
1403-
invalid = true
1404-
}
1405-
default:
1406-
}
1407-
return invalid
1408-
})
1409-
return tc, !invalid && tc.table != ""
1410-
}

sql/analyzer/inserts.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -331,27 +331,3 @@ func isAutoUuidColumn(col *sql.Column) bool {
331331

332332
return false
333333
}
334-
335-
// validGeneratedColumnValue returns true if the column is a generated column and the source node is not a values node.
336-
// Explicit default values (`DEFAULT`) are the only valid values to specify for a generated column
337-
func validGeneratedColumnValue(idx int, source sql.Node) bool {
338-
switch source := source.(type) {
339-
case *plan.Values:
340-
for _, tuple := range source.ExpressionTuples {
341-
switch val := tuple[idx].(type) {
342-
case *sql.ColumnDefaultValue: // should be wrapped, but just in case
343-
return true
344-
case *expression.Wrapper:
345-
if _, ok := val.Unwrap().(*sql.ColumnDefaultValue); ok {
346-
return true
347-
}
348-
return false
349-
default:
350-
return false
351-
}
352-
}
353-
return false
354-
default:
355-
return false
356-
}
357-
}

sql/analyzer/node_batches.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
// getBatchesForNode returns a partial analyzer ruleset for simple node
99
// types that require little prior validation before execution.
10-
func getBatchesForNode(n sql.Node, orig []*Batch) ([]*Batch, bool) {
11-
switch n := n.(type) {
10+
func getBatchesForNode(node sql.Node) ([]*Batch, bool) {
11+
switch n := node.(type) {
1212
case *plan.Commit:
1313
return nil, true
1414
case *plan.StartTransaction:

0 commit comments

Comments
 (0)