planner: fix plus prefix for select constant#9707
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9707 +/- ##
================================================
- Coverage 67.1882% 67.1782% -0.0101%
================================================
Files 381 381
Lines 79947 79956 +9
================================================
- Hits 53715 53713 -2
- Misses 21448 21455 +7
- Partials 4784 4788 +4 |
|
@erjiaqing PTAL |
| // See #9683 | ||
| // TRUE or FALSE can be a int64 | ||
| if mysql.HasIsBooleanFlag(valueExpr.Type.Flag) { | ||
| i, _ := valueExpr.GetValue().(int64) |
There was a problem hiding this comment.
if i := valueExpr.GetValue().(int64); i == 0{
return xxx
}else{
return xxx
}
There was a problem hiding this comment.
We need to check the BooleanFlag, would you mean
if mysql.HasIsBooleanFlag(valueExpr.Type.Flag) {
if i := valueExpr.GetValue().(int64); i == 0{
return xxx
}else{
return xxx
}
}
There was a problem hiding this comment.
linting
✘ https://revive.run/r#indent-error-flow if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
planner/core/logical_plan_builder.go:622:11
There was a problem hiding this comment.
Ok, my fault, we should not use else{
|
/run-all-tests |
|
It seems that the test case in common-test need to be update. 2019/03/14 14:25:06.272 main.go:718: [fatal] run test [operator] err: sql:select --1, ++1, -+1, + "select --1, ++1, -+1, + around line 13, we need(99): select --1, ++1, -+1, + --1 ++1 -+1 + 1 1 -1 18446744073709551614 0 but got(99): select --1, ++1, -+1, + --1 1 -+1 + 1 1 -1 18446744073709551614 0 1 in test case, |
|
/run-common-test tidb-test=pr/757 |
|
@XuHuaiyu Please run the test again. |
|
Check tidb> select +
->
-> 1;
+-------+
|
1 |
+-------+
| 1 |
+-------+
1 row in set (0.00 sec) |
|
/run-all-tests |
|
/run-common-test tidb-test=pr/757 |
| fieldName := field.Text() | ||
| fieldName = strings.TrimLeft(fieldName, " +(") | ||
| fieldName = strings.TrimRight(fieldName, " )") | ||
| fieldName = strings.TrimLeft(fieldName, "\n +(") |
There was a problem hiding this comment.
I had considered \t, but I found that I can't type \t by Mysql-client. And you're right, we need to deal with \t.
10af7c0 to
d385e39
Compare


What problem does this PR solve?
For #9683
What is changed and how it works?
Return
TRUEorFALSEforselect true;orselect falseTrim the plus prefix for most of types except bit literal or hex literal,
besides, trim the
(or)and it not long needs innerExpr.Text()Check List
Tests
Code changes
Side effects
Related changes