diff --git a/pkg/frontend/util.go b/pkg/frontend/util.go
index 08a212fd0135605fe6ff2c6279bbe15a8cc2632a..7d9fed2a40a60e9dee5c5b079973f32d0eb32e89 100644
--- a/pkg/frontend/util.go
+++ b/pkg/frontend/util.go
@@ -17,7 +17,6 @@ package frontend
import (
"bytes"
"fmt"
- "github.com/BurntSushi/toml"
"go/constant"
"os"
"runtime"
@@ -25,6 +24,8 @@ import (
"sync/atomic"
"time"
+ "github.com/BurntSushi/toml"
+
"github.com/matrixorigin/matrixone/pkg/pb/plan"
"github.com/matrixorigin/matrixone/pkg/sql/parsers/tree"
@@ -835,19 +836,32 @@ func WildcardMatch(pattern, target string) bool {
// only support single value and unary minus
func GetSimpleExprValue(e tree.Expr) (interface{}, error) {
var value interface{}
+ var err error
switch v := e.(type) {
case *tree.NumVal:
- switch v.Value.Kind() {
- case constant.Unknown:
+ switch v.ValType {
+ case tree.P_null:
value = nil
- case constant.Bool:
+ case tree.P_bool:
value = constant.BoolVal(v.Value)
- case constant.String:
+ case tree.P_char:
value = constant.StringVal(v.Value)
- case constant.Int:
+ case tree.P_int64:
value, _ = constant.Int64Val(v.Value)
- case constant.Float:
+ case tree.P_uint64:
+ value, _ = constant.Uint64Val(v.Value)
+ case tree.P_float64:
value, _ = constant.Float64Val(v.Value)
+ case tree.P_hexnum:
+ value, _, err = types.ParseStringToDecimal128WithoutTable(v.String())
+ if err != nil {
+ return nil, err
+ }
+ case tree.P_bit:
+ value, _, err = types.ParseStringToDecimal128WithoutTable(v.String())
+ if err != nil {
+ return nil, err
+ }
default:
return nil, errorNumericTypeIsNotSupported
}
@@ -862,6 +876,8 @@ func GetSimpleExprValue(e tree.Expr) (interface{}, error) {
value = -1 * iival
case int64:
value = -1 * iival
+ case uint64:
+ value = -1 * int64(iival)
default:
return nil, errorUnaryMinusForNonNumericTypeIsNotSupported
}
diff --git a/test/cases/prepare/prepare_all.sql b/test/cases/prepare/prepare_all.sql
index 83c4b1542a279c192011696a6391e0c8b8818e20..dbe03836e57aab5a7c71940c8a96c3cd8403d825 100644
--- a/test/cases/prepare/prepare_all.sql
+++ b/test/cases/prepare/prepare_all.sql
@@ -35,7 +35,9 @@ DEALLOCATE PREPARE s1;
PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';
EXECUTE s2 USING @ui_min;
+-- @bvt:issue#3588
EXECUTE s2 USING @ui_max;
+-- @bvt:issue
EXECUTE s2 USING @si_min;
EXECUTE s2 USING @si_max;
@@ -462,7 +464,6 @@ drop table t6;
-- @desc:test maxint operation
-- @label:bvt
--- @bvt:issue#4512
set @maxint=18446744073709551615;
select @maxint;
@@ -485,11 +486,12 @@ DEALLOCATE PREPARE s;
PREPARE s FROM 'SELECT 0 + ?';
+-- @bvt:issue#3588
EXECUTE s USING @maxint;
+-- @bvt:issue
DEALLOCATE PREPARE s;
PREPARE s FROM 'SELECT concat(?,"")';
EXECUTE s USING @maxint;
DEALLOCATE PREPARE s;
--- @bvt:issue