mirror of
https://github.com/minio/minio.git
synced 2025-03-30 17:23:42 -04:00
select: fix int overflow of math.MaxInt64 on ARM (#6317)
This commit is contained in:
parent
0aee722e3f
commit
8601f29d95
@ -48,13 +48,13 @@ func (reader *Input) runSelectParser(selectExpression string, myRow chan *Row) {
|
|||||||
// ParseSelect parses the SELECT expression, and effectively tokenizes it into
|
// ParseSelect parses the SELECT expression, and effectively tokenizes it into
|
||||||
// its separate parts. It returns the requested column names,alias,limit of
|
// its separate parts. It returns the requested column names,alias,limit of
|
||||||
// records, and the where clause.
|
// 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
|
// return columnNames, alias, limitOfRecords, whereclause,coalStore, nil
|
||||||
|
|
||||||
stmt, err := sqlparser.Parse(sqlInput)
|
stmt, err := sqlparser.Parse(sqlInput)
|
||||||
var whereClause interface{}
|
var whereClause interface{}
|
||||||
var alias string
|
var alias string
|
||||||
var limit int
|
var limit int64
|
||||||
myFuncs := &SelectFuncs{}
|
myFuncs := &SelectFuncs{}
|
||||||
// TODO Maybe can parse their errors a bit to return some more of the s3 errors
|
// TODO Maybe can parse their errors a bit to return some more of the s3 errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -137,7 +137,8 @@ func (reader *Input) ParseSelect(sqlInput string) ([]string, string, int, interf
|
|||||||
switch expr := stmt.Limit.Rowcount.(type) {
|
switch expr := stmt.Limit.Rowcount.(type) {
|
||||||
case *sqlparser.SQLVal:
|
case *sqlparser.SQLVal:
|
||||||
// The Value of how many rows we're going to limit by
|
// 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 {
|
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
|
// 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
|
// the where clause it currently prints the appropriate row given the requested
|
||||||
// columns.
|
// 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
|
counter := -1
|
||||||
filtrCount := 0
|
filtrCount := 0
|
||||||
functionFlag := false
|
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
|
// When we have reached our limit, on what the user specified as the number
|
||||||
// of rows they wanted, we terminate our interpreter.
|
// of rows they wanted, we terminate our interpreter.
|
||||||
if filtrCount == limitOfRecords && limitOfRecords != 0 {
|
if int64(filtrCount) == limitOfRecords && limitOfRecords != 0 {
|
||||||
close(myRow)
|
close(myRow)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ func TestMyParser(t *testing.T) {
|
|||||||
if alias != table.alias {
|
if alias != table.alias {
|
||||||
t.Error()
|
t.Error()
|
||||||
}
|
}
|
||||||
if myLimit != table.myLimit {
|
if myLimit != int64(table.myLimit) {
|
||||||
t.Error()
|
t.Error()
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(table.aggFuncs, aggFunctionNames) {
|
if !reflect.DeepEqual(table.aggFuncs, aggFunctionNames) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user