forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
evalengine: Internal cleanup and consistency fixes
While working on vitessio#14841 and running some tests, I ran into some other issues / consistency problems in the evalengine that we can clean up and fix. First we use `time.Duration` for intervals, which already provides constants and we don't have to deal with nanoseconds then separately but they are part of durations. We clean up the tinyweight function which does a bunch of casting which works but isn't as clear and would actually break on 32 bit (but we don't support that anyway). It now also returns 0, 1 or -1 which is more how other Go `Cmp` functions work. We remove `int` from `dataOutOfRangeError` since the `evalengine` only works with `int64` or `uint64` anyway, so any usage of `int` would really be a bug (and we didn't deal with `uint` either so it was inconsistent anyway). The bit shift operations also need to operate on int64 explicitly, since that's what the inputs are in the `evalengine`. So we should keep the types consistent. Next, we were missing a now possible optimization which is that we have size for temporal times at compile time. This means we know if we need to convert to integer or decimal. We don't hit the deoptimize path anymore, and now also error hard if that happens since compilation is broken in that case. Lastly we were not dealing with underflow / overflow checks correctly in `FROM_UNIXTIME` between the evaluator and compiler. We need to check before conversions, because specifically float64 to int64 conversions have badly defined behavior for large float64 values. It behaves differently on amd64 vs arm64 vs i386 for example already. Some convert large values to negative ints, others positive or even other values. By checking before casting we avoid this and can behave consistently. Signed-off-by: Dirkjan Bussink <[email protected]>
- Loading branch information
Showing
13 changed files
with
141 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.