mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
Fix precendence bug in S3Select SQL IN clauses (#18708)
Fixes a precendence issue in SQL Select where `a in b and c = 3` was parsed as `a in (b and c = 3)`. Fixes #18682
This commit is contained in:
committed by
GitHub
parent
8bd4f6568b
commit
496027b589
@@ -134,7 +134,7 @@ func (e *ConditionRHS) analyze(s *Select) (result qProp) {
|
||||
result.combine(e.Between.Start.analyze(s))
|
||||
result.combine(e.Between.End.analyze(s))
|
||||
case e.In != nil:
|
||||
result.combine(e.In.ListExpression.analyze(s))
|
||||
result.combine(e.In.analyze(s))
|
||||
case e.Like != nil:
|
||||
result.combine(e.Like.Pattern.analyze(s))
|
||||
if e.Like.EscapeChar != nil {
|
||||
@@ -146,6 +146,25 @@ func (e *ConditionRHS) analyze(s *Select) (result qProp) {
|
||||
return
|
||||
}
|
||||
|
||||
func (e *In) analyze(s *Select) (result qProp) {
|
||||
switch {
|
||||
case e.JPathExpr != nil:
|
||||
// Check if the path expression is valid
|
||||
if len(e.JPathExpr.PathExpr) > 0 {
|
||||
if e.JPathExpr.BaseKey.String() != s.From.As && !strings.EqualFold(e.JPathExpr.BaseKey.String(), baseTableName) {
|
||||
result = qProp{err: errInvalidKeypath}
|
||||
return
|
||||
}
|
||||
}
|
||||
result = qProp{isRowFunc: true}
|
||||
case e.ListExpr != nil:
|
||||
result = e.ListExpr.analyze(s)
|
||||
default:
|
||||
result = qProp{err: errUnexpectedInvalidNode}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (e *Operand) analyze(s *Select) (result qProp) {
|
||||
result.combine(e.Left.analyze(s))
|
||||
for _, r := range e.Right {
|
||||
|
||||
Reference in New Issue
Block a user