Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-19.0] Fix crash in the evalengine (#17487) #17488

Closed
wants to merge 1 commit into from
Closed
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
29 changes: 29 additions & 0 deletions go/vt/vtgate/evalengine/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,35 @@
return a.newEvalDecimalWithPrec(dec.Clamp(m-d, d), d)
}

<<<<<<< HEAD

Check failure on line 64 in go/vt/vtgate/evalengine/arena.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: non-declaration statement outside function body
=======
func (a *Arena) newEvalEnum(raw []byte, values *EnumSetValues) *evalEnum {
if cap(a.aEnum) > len(a.aEnum) {
a.aEnum = a.aEnum[:len(a.aEnum)+1]
} else {
a.aEnum = append(a.aEnum, evalEnum{})
}
val := &a.aEnum[len(a.aEnum)-1]
s := string(raw)
val.string = s
val.value = valueIdx(values, s)
return val
}

func (a *Arena) newEvalSet(raw []byte, values *EnumSetValues) *evalSet {
if cap(a.aSet) > len(a.aSet) {
a.aSet = a.aSet[:len(a.aSet)+1]
} else {
a.aSet = append(a.aSet, evalSet{})
}
val := &a.aSet[len(a.aSet)-1]
s := string(raw)
val.string = s
val.set = evalSetBits(values, s)
return val
}

>>>>>>> 06def14056 (Fix crash in the evalengine (#17487))

Check failure on line 92 in go/vt/vtgate/evalengine/arena.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: non-declaration statement outside function body

Check failure on line 92 in go/vt/vtgate/evalengine/arena.go

View workflow job for this annotation

GitHub Actions / Code Coverage

invalid character U+0023 '#'
func (a *Arena) newEvalBool(b bool) *evalInt64 {
if b {
return a.newEvalInt64(1)
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 @@ -716,6 +716,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
Loading