mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: Correctly parse the minimum value of int64 (#41009)
issue: #40729 Current approach to parse negative numbers is first parse the numeric part and then multiply the result by -1(mainly to distinguish the precedence of the negative sign and the subtraction operator). However, for the minimum value of int64(`-9223372036854775808`), the value `9223372036854775808` already exceeds the representable range of int64. As a result, parsing error occurs. Therefore, use a specific rule to match `-9223372036854775808`. --------- Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
758cf29e77
commit
a7713df18d
@ -1,8 +1,8 @@
|
||||
grammar Plan;
|
||||
|
||||
expr:
|
||||
IntegerConstant # Integer
|
||||
| FloatingConstant # Floating
|
||||
(ADD | SUB)? IntegerConstant # Integer
|
||||
| (ADD | SUB)? FloatingConstant # Floating
|
||||
| BooleanConstant # Boolean
|
||||
| StringLiteral # String
|
||||
| (Identifier|Meta) # Identifier
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -98,7 +98,7 @@ func (v *ParserVisitor) VisitBoolean(ctx *parser.BooleanContext) interface{} {
|
||||
|
||||
// VisitInteger translates expr to GenericValue.
|
||||
func (v *ParserVisitor) VisitInteger(ctx *parser.IntegerContext) interface{} {
|
||||
literal := ctx.IntegerConstant().GetText()
|
||||
literal := ctx.GetText()
|
||||
i, err := strconv.ParseInt(literal, 0, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -118,7 +118,7 @@ func (v *ParserVisitor) VisitInteger(ctx *parser.IntegerContext) interface{} {
|
||||
|
||||
// VisitFloating translates expr to GenericValue.
|
||||
func (v *ParserVisitor) VisitFloating(ctx *parser.FloatingContext) interface{} {
|
||||
literal := ctx.FloatingConstant().GetText()
|
||||
literal := ctx.GetText()
|
||||
f, err := strconv.ParseFloat(literal, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -194,6 +194,7 @@ func TestExpr_UnaryRange(t *testing.T) {
|
||||
`VarCharField <= "str7"`,
|
||||
`JSONField["A"] > 10`,
|
||||
`$meta["A"] > 10`,
|
||||
`A == -9223372036854775808`,
|
||||
}
|
||||
for _, exprStr := range exprStrs {
|
||||
assertValidExpr(t, helper, exprStr)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user