Skip to content
Snippets Groups Projects
Unverified Commit 5b4a1755 authored by ou yuanning's avatar ou yuanning Committed by GitHub
Browse files

fix set clause bug (#4589)

fix set clause bug: when set uint64 value in sql, but save int64 to session.

Approved by: @daviszhen, @aressu1985
parent e921e189
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
......@@ -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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment