Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

fix errors pointed out by staticcheck #582

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func testAudit(
defer os.RemoveAll(tmpDir)

for _, c := range tests {
t.Run(fmt.Sprintf("%s", c.user), func(t *testing.T) {
t.Run(c.user, func(t *testing.T) {
req := require.New(t)

db, err := dsql.Open("mysql", connString(c.user, ""))
Expand Down
2 changes: 0 additions & 2 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/stretchr/testify/require"
)

const driverName = "engine_tests"

var queries = []struct {
query string
expected []sql.Row
Expand Down
3 changes: 1 addition & 2 deletions mem/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ func (t *Table) PartitionCount(ctx *sql.Context) (int64, error) {

// PartitionRows implements the sql.PartitionRows interface.
func (t *Table) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error) {
key := string(partition.Key())
rows, ok := t.partitions[key]
rows, ok := t.partitions[string(partition.Key())]
if !ok {
return nil, fmt.Errorf(
"partition not found: %q", partition.Key(),
Expand Down
3 changes: 1 addition & 2 deletions mem/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ func TestTable(t *testing.T) {
rows, err := sql.RowIterToRows(iter)
require.NoError(err)

key := string(p.Key())
expected := table.partitions[key]
expected := table.partitions[string(p.Key())]
require.Len(rows, len(expected))

for i, row := range rows {
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/aggregations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func reorderAggregations(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("reorder_aggregations")
span, _ := ctx.Span("reorder_aggregations")
defer span.Finish()

if !n.Resolved() {
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/assign_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// assignCatalog sets the catalog in the required nodes.
func assignCatalog(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("assign_catalog")
span, _ := ctx.Span("assign_catalog")
defer span.Finish()

return n.TransformUp(func(n sql.Node) (sql.Node, error) {
Expand Down
5 changes: 0 additions & 5 deletions sql/analyzer/assign_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,6 @@ func containsColumns(e sql.Expression) bool {
return result
}

func isColumn(e sql.Expression) bool {
_, ok := e.(*expression.GetField)
return ok
}

func isEvaluable(e sql.Expression) bool {
return !containsColumns(e)
}
Expand Down
4 changes: 2 additions & 2 deletions sql/analyzer/optimization_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func eraseProjection(ctx *sql.Context, a *Analyzer, node sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("erase_projection")
span, _ := ctx.Span("erase_projection")
defer span.Finish()

if !node.Resolved() {
Expand All @@ -29,7 +29,7 @@ func eraseProjection(ctx *sql.Context, a *Analyzer, node sql.Node) (sql.Node, er
}

func optimizeDistinct(ctx *sql.Context, a *Analyzer, node sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("optimize_distinct")
span, _ := ctx.Span("optimize_distinct")
defer span.Finish()

a.Log("optimize distinct, node of type: %T", node)
Expand Down
11 changes: 2 additions & 9 deletions sql/analyzer/resolve_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type column interface {
}

func qualifyColumns(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("qualify_columns")
span, _ := ctx.Span("qualify_columns")
defer span.Finish()

a.Log("qualify columns")
Expand Down Expand Up @@ -173,9 +173,6 @@ func qualifyColumns(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error)
case column:
table = p.Table()
col = p.Name()
case *expression.GetField:
table = p.Table()
col = p.Name()
default:
continue
}
Expand Down Expand Up @@ -277,11 +274,7 @@ func resolveColumns(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error)
}

name := strings.TrimLeft(uc.Name(), "@")
if strings.HasPrefix(name, sessionPrefix) {
name = name[len(sessionPrefix):]
} else if strings.HasPrefix(name, globalPrefix) {
name = name[len(globalPrefix):]
}
name = strings.TrimPrefix(strings.TrimPrefix(name, globalPrefix), sessionPrefix)
typ, value := ctx.Get(name)
return expression.NewGetSessionField(name, typ, value), nil
}
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_columns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestQualifyColumns(t *testing.T) {
plan.NewTableAlias("a", plan.NewResolvedTable(table)),
)

result, err = f.Apply(sql.NewEmptyContext(), nil, node)
_, err = f.Apply(sql.NewEmptyContext(), nil, node)
require.Error(err)
require.True(sql.ErrTableNotFound.Is(err))

Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func resolveDatabase(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("resolve_database")
span, _ := ctx.Span("resolve_database")
defer span.Finish()

a.Log("resolve database, node of type: %T", n)
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func resolveFunctions(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("resolve_functions")
span, _ := ctx.Span("resolve_functions")
defer span.Finish()

a.Log("resolve functions, node of type %T", n)
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_natural_joins.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type transformedSource struct {
}

func resolveNaturalJoins(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("resolve_natural_joins")
span, _ := ctx.Span("resolve_natural_joins")
defer span.Finish()

if n.Resolved() {
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_orderby.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func resolveOrderBy(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("resolve_orderby")
span, _ := ctx.Span("resolve_orderby")
defer span.Finish()

a.Log("resolving order bys, node of type: %T", n)
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_stars.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func resolveStar(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("resolve_star")
span, _ := ctx.Span("resolve_star")
defer span.Finish()

a.Log("resolving star, node of type: %T", n)
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var dualTable = func() sql.Table {
}()

func resolveTables(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("resolve_tables")
span, _ := ctx.Span("resolve_tables")
defer span.Finish()

a.Log("resolve table, node of type: %T", n)
Expand Down
12 changes: 6 additions & 6 deletions sql/analyzer/validation_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var DefaultValidationRules = []Rule{
}

func validateIsResolved(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("validate_is_resolved")
span, _ := ctx.Span("validate_is_resolved")
defer span.Finish()

if !n.Resolved() {
Expand All @@ -60,7 +60,7 @@ func validateIsResolved(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, er
}

func validateOrderBy(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("validate_order_by")
span, _ := ctx.Span("validate_order_by")
defer span.Finish()

switch n := n.(type) {
Expand All @@ -77,7 +77,7 @@ func validateOrderBy(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error
}

func validateGroupBy(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("validate_group_by")
span, _ := ctx.Span("validate_group_by")
defer span.Finish()

switch n := n.(type) {
Expand Down Expand Up @@ -122,7 +122,7 @@ func isValidAgg(validAggs []string, expr sql.Expression) bool {
}

func validateSchemaSource(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("validate_schema_source")
span, _ := ctx.Span("validate_schema_source")
defer span.Finish()

switch n := n.(type) {
Expand All @@ -138,7 +138,7 @@ func validateSchemaSource(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node,
}

func validateIndexCreation(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("validate_index_creation")
span, _ := ctx.Span("validate_index_creation")
defer span.Finish()

ci, ok := n.(*plan.CreateIndex)
Expand Down Expand Up @@ -179,7 +179,7 @@ func validateSchema(t *plan.ResolvedTable) error {
}

func validateProjectTuples(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error) {
span, ctx := ctx.Span("validate_project_tuples")
span, _ := ctx.Span("validate_project_tuples")
defer span.Finish()

switch n := n.(type) {
Expand Down
2 changes: 1 addition & 1 deletion sql/expression/function/ceil_round_floor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,6 @@ func TestRound(t *testing.T) {
req.NotNil(exprs[0])

result, err := f.Eval(sql.NewEmptyContext(), sql.NewRow([]byte{1, 2, 3}, 2))

req.NoError(err)
req.Equal(int32(0), result)
}
13 changes: 0 additions & 13 deletions sql/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,6 @@ Indexes:
return results
}

type withIndexer interface {
WithIndex(int) Expression
}

func removeIndexes(e Expression) (Expression, error) {
i, ok := e.(withIndexer)
if !ok {
return e, nil
}

return i.WithIndex(-1), nil
}

var (
// ErrIndexIDAlreadyRegistered is the error returned when there is already
// an index with the same ID.
Expand Down
6 changes: 2 additions & 4 deletions sql/index/pilosa/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ const (
)

var (
errCorruptedIndex = errors.NewKind("the index db: %s, table: %s, id: %s is corrupted")
errLoadingIndex = errors.NewKind("cannot load pilosa index: %s")
errInvalidIndexType = errors.NewKind("expecting a pilosa index, instead got %T")
errDeletePilosaField = errors.NewKind("error deleting pilosa field %s: %s")
errCorruptedIndex = errors.NewKind("the index db: %s, table: %s, id: %s is corrupted")
errInvalidIndexType = errors.NewKind("expecting a pilosa index, instead got %T")
)

type (
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy