Skip to content

Commit

Permalink
Try more direct approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-rieke committed Dec 15, 2023
1 parent 1785580 commit f3ffd14
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sql/plan/external_procedure.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,32 +202,35 @@ func (n *ExternalProcedure) processParam(ctx *sql.Context, funcParamType reflect
case uintType:
if strconv.IntSize == 64 {
if uint64Val, ok := exprParamVal.(uint64); ok {
if uint64Val > math.MaxUint32 || uint64Val < 0 || uint64Val > math.MaxInt {
if uint64Val < math.MaxUint32 && uint64Val >= 0 && uint64Val < math.MaxInt {
exprParamVal = int(uint64Val)
} else {
overflowErr := fmt.Errorf("expr value overflow %v", exprParamVal)
funcParamVal := reflect.New(funcParamType)
exprParamVal = int(-1)
funcParamVal.Elem().Set(reflect.ValueOf(exprParamVal))
return funcParamVal.Elem(), overflowErr
}
exprParamVal = int(uint64Val)
} else if int64Val, ok := exprParamVal.(int64); ok {
if int64Val > math.MaxUint32 || int64Val < 0 || int64Val > math.MaxInt {
if int64Val < math.MaxUint32 && int64Val >= 0 && int64Val < math.MaxInt {
exprParamVal = int(int64Val)
} else {
overflowErr := fmt.Errorf("expr value overflow %v", exprParamVal)
funcParamVal := reflect.New(funcParamType)
exprParamVal = int(-1)
funcParamVal.Elem().Set(reflect.ValueOf(exprParamVal))
return funcParamVal.Elem(), overflowErr
}
exprParamVal = int(int64Val)
} else if uint32Val, ok := exprParamVal.(uint32); ok {
if uint32Val > math.MaxUint32 || uint32Val < 0 {
if uint32Val < math.MaxUint32 {
exprParamVal = int(uint32Val)
} else {
overflowErr := fmt.Errorf("expr value overflow %v", exprParamVal)
funcParamVal := reflect.New(funcParamType)
exprParamVal = int(-1)
funcParamVal.Elem().Set(reflect.ValueOf(exprParamVal))
return funcParamVal.Elem(), overflowErr
}
exprParamVal = int(uint32Val)
} else {
overflowErr := fmt.Errorf("expr value overflow %v", exprParamVal)
funcParamVal := reflect.New(funcParamType)
Expand Down

0 comments on commit f3ffd14

Please sign in to comment.