diff options
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/sqlvm/common/decimal/decimal.go | 14 | ||||
-rw-r--r-- | core/vm/sqlvm/runtime/instructions.go | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/core/vm/sqlvm/common/decimal/decimal.go b/core/vm/sqlvm/common/decimal/decimal.go index 96212ed27..390f440e3 100644 --- a/core/vm/sqlvm/common/decimal/decimal.go +++ b/core/vm/sqlvm/common/decimal/decimal.go @@ -1,16 +1,22 @@ package decimal -import "github.com/dexon-foundation/decimal" +import ( + "fmt" + "math" + + "github.com/dexon-foundation/decimal" +) // Shared vars. var ( False = decimal.New(0, 0) True = decimal.New(1, 0) - Int64Max = decimal.New(1, 63).Sub(decimal.One) - Int64Min = decimal.New(1, 63).Neg() + MaxInt64 = decimal.New(math.MaxInt64, 0) + MinInt64 = decimal.New(math.MinInt64, 0) - UInt16Max = decimal.New(1, 16).Sub(decimal.One) + MaxUint16 = decimal.New(math.MaxUint16, 0) + MaxUint64 = decimal.RequireFromString(fmt.Sprint(uint64(math.MaxUint64))) ) // Val2Bool convert value to boolean definition. diff --git a/core/vm/sqlvm/runtime/instructions.go b/core/vm/sqlvm/runtime/instructions.go index 4b179f4aa..b6b37052e 100644 --- a/core/vm/sqlvm/runtime/instructions.go +++ b/core/vm/sqlvm/runtime/instructions.go @@ -347,7 +347,7 @@ func bool2Raw(b bool) (r *Raw) { } func value2ColIdx(v decimal.Decimal) (idx uint16) { - if v.GreaterThan(dec.UInt16Max) { + if v.GreaterThan(dec.MaxUint16) { panic(errors.New("field index greater than uint16 max")) } else if v.LessThan(decimal.Zero) { panic(errors.New("field index less than 0")) |