Skip to content

Commit

Permalink
[release-20.0] Fix crash in the evalengine (#17487) (#17489)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
  • Loading branch information
vitess-bot[bot] authored Jan 8, 2025
1 parent 1aa5a1f commit 8f1dad7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (a *Arena) newEvalEnum(raw []byte, values *EnumSetValues) *evalEnum {
} else {
a.aEnum = append(a.aEnum, evalEnum{})
}
val := &a.aEnum[len(a.aInt64)-1]
val := &a.aEnum[len(a.aEnum)-1]
s := string(raw)
val.string = s
val.value = valueIdx(values, s)
Expand All @@ -84,7 +84,7 @@ func (a *Arena) newEvalSet(raw []byte, values *EnumSetValues) *evalSet {
} else {
a.aSet = append(a.aSet, evalSet{})
}
val := &a.aSet[len(a.aInt64)-1]
val := &a.aSet[len(a.aSet)-1]
s := string(raw)
val.string = s
val.set = evalSetBits(values, s)
Expand Down
14 changes: 14 additions & 0 deletions go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,20 @@ func TestCompilerSingle(t *testing.T) {
expression: `WEEK(timestamp '2024-01-01 10:34:58', 1)`,
result: `INT64(1)`,
},
{
expression: `column0 + 1`,
values: []sqltypes.Value{sqltypes.MakeTrusted(sqltypes.Enum, []byte("foo"))},
// Returns 0, as unknown enums evaluate here to -1. We have this test to
// exercise the path to push enums onto the stack.
result: `FLOAT64(0)`,
},
{
expression: `column0 + 1`,
values: []sqltypes.Value{sqltypes.MakeTrusted(sqltypes.Set, []byte("foo"))},
// Returns 1, as unknown sets evaluate here to 0. We have this test to
// exercise the path to push sets onto the stack.
result: `FLOAT64(1)`,
},
}

tz, _ := time.LoadLocation("Europe/Madrid")
Expand Down

0 comments on commit 8f1dad7

Please sign in to comment.