Skip to content

Commit

Permalink
*: support cast value to boolean radondb#480
Browse files Browse the repository at this point in the history
[summary]
Using CastToBool instead of judging value directly will make the result more accurate.
[test case]
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/depends/sqltypes/arithmetic_test.go
[patch codecov]
94.2%
  • Loading branch information
zhyass committed Oct 30, 2019
1 parent c08a881 commit f0ffc4b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
11 changes: 5 additions & 6 deletions src/executor/engine/join_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (j *JoinEngine) Execute(ctx *xcontext.ResultContext) error {
return operator.ExecSubPlan(j.log, j.node, ctx)
}

// execBindVars used to execute querys with bindvas.
// execBindVars used to execute querys with bindvars.
func (j *JoinEngine) execBindVars(ctx *xcontext.ResultContext, bindVars map[string]*querypb.BindVariable, wantfields bool) error {
var err error
lctx := xcontext.NewResultContext()
Expand All @@ -115,16 +115,15 @@ func (j *JoinEngine) execBindVars(ctx *xcontext.ResultContext, bindVars map[stri
}

for _, lrow := range lctx.Results.Rows {
blend := true
leftMatch := true
matchCnt := 0
for _, idx := range j.node.LeftTmpCols {
vn := lrow[idx].ToNative()
if vn.(int64) == 0 {
blend = false
if !sqltypes.CastToBool(lrow[idx]) {
leftMatch = false
break
}
}
if blend {
if leftMatch {
for k, col := range j.node.Vars {
joinVars[k] = sqltypes.ValueBindVariable(lrow[col])
}
Expand Down
9 changes: 4 additions & 5 deletions src/executor/engine/merge_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,16 @@ func concatLeftAndRight(lrows, rrows [][]sqltypes.Value, node *planner.JoinNode,
return
}

blend := true
leftMatch := true
matchCnt := 0
for _, idx := range node.LeftTmpCols {
vn := lrow[idx].ToNative()
if vn == nil || vn.(int64) == 0 {
blend = false
if !sqltypes.CastToBool(lrow[idx]) {
leftMatch = false
break
}
}

if blend {
if leftMatch {
for _, rrow := range rrows {
match := true
for _, filter := range node.CmpFilter {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0ffc4b

Please sign in to comment.