func NullsafeSum(sum, v Value, resultType querypb.Type, prec int) (Value, error) {
	if sum.IsNull() {
		return v, nil
	}
	if v.IsNull() {
		return sum, nil
	}
	lv1, err := newNumericFloat(sum)
	if err != nil {
		return NULL, err
	}
	lv2, err := newNumericFloat(v)
	if err != nil {
		return NULL, err
	}
	res := numeric{}
	if resultType == Decimal {
		res = numeric{typ: Decimal, dval: decimal.NewFromFloat(lv1.fval).Add(decimal.NewFromFloat(lv2.fval))}
	} else {
		fval := lv1.fval + lv2.fval
		if math.IsInf(fval, 0) {
			return NULL, fmt.Errorf("DOUBLE.value.is.out.of.range.in: '%v + %v'", lv1.fval, lv2.fval)
		}
		res = numeric{typ: Float64, fval: fval}
	}
	return castFromNumeric(res, resultType, prec)
}
NullsafeSum adds v to sum, used in 'sum' aggregation. The `sum` aggregation's
result is `float64` or `decimal`, So need cast the value to `float64`.
By using NullsafeSum instead of NullsafeAdd, can avoid overflow between two integers.
package sqltypes
import (
	"bytes"
	"fmt"
	"math"
	"strconv"
	"github.com/shopspring/decimal"
	"github.com/xelabs/go-mysqlstack/sqlparser/depends/common"
	querypb "github.com/xelabs/go-mysqlstack/sqlparser/depends/query"
)
type numeric struct {
	typ  querypb.Type
	ival int64
	uval uint64
	fval float64
	dval decimal.Decimal
}
func NullsafeAdd(v1, v2 Value, resultType querypb.Type, prec int) (Value, error) {
	if v1.IsNull() {
		return v2, nil
	}
	if v2.IsNull() {
		return v1, nil
	}
	lv1, err := newNumeric(v1)
	if err != nil {
		return NULL, err
	}
	lv2, err := newNumeric(v2)
	if err != nil {
		return NULL, err
	}
	res, err := addNumeric(lv1, lv2)
	if err != nil {
		return NULL, err
	}
	return castFromNumeric(res, resultType, prec)
}