select: fix int overflow of math.MaxInt64 on ARM (#6317)

master
Raphael Randschau 6 years ago committed by Nitish Tiwari
parent 0aee722e3f
commit 8601f29d95
  1. 11
      pkg/s3select/select.go
  2. 2
      pkg/s3select/select_test.go

@ -48,13 +48,13 @@ func (reader *Input) runSelectParser(selectExpression string, myRow chan *Row) {
// ParseSelect parses the SELECT expression, and effectively tokenizes it into
// its separate parts. It returns the requested column names,alias,limit of
// records, and the where clause.
func (reader *Input) ParseSelect(sqlInput string) ([]string, string, int, interface{}, []string, *SelectFuncs, error) {
func (reader *Input) ParseSelect(sqlInput string) ([]string, string, int64, interface{}, []string, *SelectFuncs, error) {
// return columnNames, alias, limitOfRecords, whereclause,coalStore, nil
stmt, err := sqlparser.Parse(sqlInput)
var whereClause interface{}
var alias string
var limit int
var limit int64
myFuncs := &SelectFuncs{}
// TODO Maybe can parse their errors a bit to return some more of the s3 errors
if err != nil {
@ -137,7 +137,8 @@ func (reader *Input) ParseSelect(sqlInput string) ([]string, string, int, interf
switch expr := stmt.Limit.Rowcount.(type) {
case *sqlparser.SQLVal:
// The Value of how many rows we're going to limit by
limit, _ = strconv.Atoi(string(expr.Val[:]))
parsedLimit, _ := strconv.Atoi(string(expr.Val[:]))
limit = int64(parsedLimit)
}
}
if stmt.GroupBy != nil {
@ -157,7 +158,7 @@ func (reader *Input) ParseSelect(sqlInput string) ([]string, string, int, interf
// This is the main function, It goes row by row and for records which validate
// the where clause it currently prints the appropriate row given the requested
// columns.
func (reader *Input) processSelectReq(reqColNames []string, alias string, whereClause interface{}, limitOfRecords int, functionNames []string, myRow chan *Row, myFunc *SelectFuncs) {
func (reader *Input) processSelectReq(reqColNames []string, alias string, whereClause interface{}, limitOfRecords int64, functionNames []string, myRow chan *Row, myFunc *SelectFuncs) {
counter := -1
filtrCount := 0
functionFlag := false
@ -203,7 +204,7 @@ func (reader *Input) processSelectReq(reqColNames []string, alias string, whereC
}
// When we have reached our limit, on what the user specified as the number
// of rows they wanted, we terminate our interpreter.
if filtrCount == limitOfRecords && limitOfRecords != 0 {
if int64(filtrCount) == limitOfRecords && limitOfRecords != 0 {
close(myRow)
return
}

@ -296,7 +296,7 @@ func TestMyParser(t *testing.T) {
if alias != table.alias {
t.Error()
}
if myLimit != table.myLimit {
if myLimit != int64(table.myLimit) {
t.Error()
}
if !reflect.DeepEqual(table.aggFuncs, aggFunctionNames) {

Loading…
Cancel
Save