Skip to content

Commit b7678f0

Browse files
author
James Cor
committed
test fix
1 parent d171439 commit b7678f0

File tree

10 files changed

+28
-38
lines changed

10 files changed

+28
-38
lines changed

memory/table_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (td *TableData) errIfDuplicateEntryExist(ctx context.Context, cols []string
297297
if hasNulls(idxPrefixKey) {
298298
continue
299299
}
300-
h, err := sql.HashOf(ctx, idxPrefixKey)
300+
h, err := sql.HashOf(ctx, td.schema.Schema, idxPrefixKey)
301301
if err != nil {
302302
return err
303303
}

sql/cache.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
// HashOf returns a hash of the given value to be used as key in a cache.
29-
func HashOf(sch Schema, v Row) (uint64, error) {
29+
func HashOf(ctx context.Context, sch Schema, v Row) (uint64, error) {
3030
hash := digestPool.Get().(*xxhash.Digest)
3131
hash.Reset()
3232
defer digestPool.Put(hash)
@@ -41,11 +41,16 @@ func HashOf(sch Schema, v Row) (uint64, error) {
4141
if i < len(sch) {
4242
typ := sch[i].Type
4343
if strType, ok := typ.(StringType); ok {
44-
strType.Convert(nil, )
45-
strType.Collation().WriteWeightString(hash, )
46-
44+
newX, _, err := strType.Convert(ctx, x)
45+
if err != nil {
46+
return 0, err
47+
}
48+
err = strType.Collation().WriteWeightString(hash, newX.(string))
49+
if err != nil {
50+
return 0, err
51+
}
52+
continue
4753
}
48-
continue
4954
}
5055

5156
// TODO: probably much faster to do this with a type switch

sql/iters/rel_iters.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func (di *distinctIter) Next(ctx *sql.Context) (sql.Row, error) {
571571
return nil, err
572572
}
573573

574-
hash, err := sql.HashOf(ctx, row)
574+
hash, err := sql.HashOf(ctx, nil, row)
575575
if err != nil {
576576
return nil, err
577577
}
@@ -647,7 +647,7 @@ func (ii *IntersectIter) Next(ctx *sql.Context) (sql.Row, error) {
647647
return nil, err
648648
}
649649

650-
hash, herr := sql.HashOf(ctx, res)
650+
hash, herr := sql.HashOf(ctx, nil, res)
651651
if herr != nil {
652652
return nil, herr
653653
}
@@ -669,7 +669,7 @@ func (ii *IntersectIter) Next(ctx *sql.Context) (sql.Row, error) {
669669
return nil, err
670670
}
671671

672-
hash, herr := sql.HashOf(ctx, res)
672+
hash, herr := sql.HashOf(ctx, nil, res)
673673
if herr != nil {
674674
return nil, herr
675675
}
@@ -714,7 +714,7 @@ func (ei *ExceptIter) Next(ctx *sql.Context) (sql.Row, error) {
714714
return nil, err
715715
}
716716

717-
hash, herr := sql.HashOf(ctx, res)
717+
hash, herr := sql.HashOf(ctx, nil, res)
718718
if herr != nil {
719719
return nil, herr
720720
}
@@ -736,7 +736,7 @@ func (ei *ExceptIter) Next(ctx *sql.Context) (sql.Row, error) {
736736
return nil, err
737737
}
738738

739-
hash, herr := sql.HashOf(ctx, res)
739+
hash, herr := sql.HashOf(ctx, nil, res)
740740
if herr != nil {
741741
return nil, herr
742742
}

sql/plan/hash_lookup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (n *HashLookup) GetHashKey(ctx *sql.Context, e sql.Expression, row sql.Row)
127127
return nil, err
128128
}
129129
if s, ok := key.([]interface{}); ok {
130-
return sql.HashOf(ctx, s)
130+
return sql.HashOf(ctx, n.Schema(), s)
131131
}
132132
// byte slices are not hashable
133133
if k, ok := key.([]byte); ok {

sql/plan/insubquery.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ package plan
1616

1717
import (
1818
"fmt"
19-
"github.com/cespare/xxhash/v2"
20-
21-
"github.com/dolthub/go-mysql-server/sql"
19+
"github.com/dolthub/go-mysql-server/sql"
2220
"github.com/dolthub/go-mysql-server/sql/expression"
2321
"github.com/dolthub/go-mysql-server/sql/types"
2422
)
@@ -48,7 +46,7 @@ func NewInSubquery(left sql.Expression, right sql.Expression) *InSubquery {
4846
return &InSubquery{expression.BinaryExpressionStub{LeftChild: left, RightChild: right}}
4947
}
5048

51-
var nilKey, _ = sql.HashOf(nil, sql.NewRow(nil))
49+
var nilKey, _ = sql.HashOf(nil, nil, sql.NewRow(nil))
5250

5351
// Eval implements the Expression interface.
5452
func (in *InSubquery) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
@@ -97,20 +95,7 @@ func (in *InSubquery) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
9795
return false, nil
9896
}
9997

100-
if strTyp, ok := rTyp.(sql.StringType); ok {
101-
weightStr := xxhash.New()
102-
valStr, err := types.ConvertToString(ctx, nLeft, strTyp, nil)
103-
if err != nil {
104-
return nil, err
105-
}
106-
err = strTyp.Collation().WriteWeightString(weightStr, valStr)
107-
if err != nil {
108-
return nil, err
109-
}
110-
nLeft = weightStr
111-
}
112-
113-
key, err := sql.HashOf(ctx, sql.NewRow(nLeft))
98+
key, err := sql.HashOf(ctx, sql.Schema{&sql.Column{Type: rTyp}}, sql.NewRow(nLeft))
11499
if err != nil {
115100
return nil, err
116101
}

sql/plan/subquery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ func putAllRows(ctx *sql.Context, cache sql.KeyValueCache, sch sql.Schema, vals
485485
if err != nil {
486486
return err
487487
}
488-
rowKey, err := sql.HashOf(ctx, sql.NewRow(normVal))
488+
rowKey, err := sql.HashOf(ctx, sch, sql.NewRow(normVal))
489489
if err != nil {
490490
return err
491491
}

sql/rowexec/join_iters.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func (i *fullJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
462462

463463
rightRow, err := i.r.Next(ctx)
464464
if err == io.EOF {
465-
key, err := sql.HashOf(ctx, i.leftRow)
465+
key, err := sql.HashOf(ctx, nil, i.leftRow)
466466
if err != nil {
467467
return nil, err
468468
}
@@ -485,12 +485,12 @@ func (i *fullJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
485485
if !sql.IsTrue(matches) {
486486
continue
487487
}
488-
rkey, err := sql.HashOf(ctx, rightRow)
488+
rkey, err := sql.HashOf(ctx, nil, rightRow)
489489
if err != nil {
490490
return nil, err
491491
}
492492
i.seenRight[rkey] = struct{}{}
493-
lKey, err := sql.HashOf(ctx, i.leftRow)
493+
lKey, err := sql.HashOf(ctx, nil, i.leftRow)
494494
if err != nil {
495495
return nil, err
496496
}
@@ -517,7 +517,7 @@ func (i *fullJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
517517
return nil, io.EOF
518518
}
519519

520-
key, err := sql.HashOf(ctx, rightRow)
520+
key, err := sql.HashOf(ctx, nil, rightRow)
521521
if err != nil {
522522
return nil, err
523523
}

sql/rowexec/other_iters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func (ci *concatIter) Next(ctx *sql.Context) (sql.Row, error) {
334334
if err != nil {
335335
return nil, err
336336
}
337-
hash, err := sql.HashOf(ctx, res)
337+
hash, err := sql.HashOf(ctx, nil, res)
338338
if err != nil {
339339
return nil, err
340340
}

sql/rowexec/rel_iters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func (r *recursiveCteIter) Next(ctx *sql.Context) (sql.Row, error) {
446446

447447
var key uint64
448448
if r.deduplicate {
449-
key, _ = sql.HashOf(ctx, row)
449+
key, _ = sql.HashOf(ctx, nil, row)
450450
if k, _ := r.cache.Get(key); k != nil {
451451
// skip duplicate
452452
continue

sql/rowexec/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func (u *updateJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
249249

250250
// Determine whether this row in the table has already been updated
251251
cache := u.getOrCreateCache(ctx, tableName)
252-
hash, err := sql.HashOf(ctx, oldTableRow)
252+
hash, err := sql.HashOf(ctx, nil, oldTableRow)
253253
if err != nil {
254254
return nil, err
255255
}

0 commit comments

Comments
 (0)