Skip to content

Commit

Permalink
Item::print(): remove redundant parentheses
Browse files Browse the repository at this point in the history
by introducing new Item::precedence() method and using it
to decide whether parentheses are required
  • Loading branch information
vuvova committed Dec 12, 2016
1 parent 1db438c commit 180065e
Show file tree
Hide file tree
Showing 188 changed files with 2,684 additions and 2,553 deletions.
4 changes: 2 additions & 2 deletions mysql-test/r/alter_table.result
Expand Up @@ -2073,8 +2073,8 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
CONSTRAINT `min` CHECK (((`a` + `b`) > 100)),
CONSTRAINT `mini` CHECK (((`a` + `b`) > 100))
CONSTRAINT `min` CHECK (`a` + `b` > 100),
CONSTRAINT `mini` CHECK (`a` + `b` > 100)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1(a INT, b INT, CONSTRAINT min check (a>5),
Expand Down
40 changes: 20 additions & 20 deletions mysql-test/r/analyze_format_json.result
Expand Up @@ -18,7 +18,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 30,
"attached_condition": "(t0.a < 3)"
"attached_condition": "t0.a < 3"
}
}
}
Expand Down Expand Up @@ -46,7 +46,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 0,
"attached_condition": "((t0.a > 9) and (t0.a is not null))"
"attached_condition": "t0.a > 9 and t0.a is not null"
},
"table": {
"table_name": "t1",
Expand Down Expand Up @@ -86,7 +86,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"attached_condition": "(t0.a is not null)"
"attached_condition": "t0.a is not null"
},
"table": {
"table_name": "t1",
Expand All @@ -102,7 +102,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 40,
"attached_condition": "(t1.b < 4)"
"attached_condition": "t1.b < 4"
}
}
}
Expand All @@ -128,7 +128,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 20,
"attached_condition": "(tbl1.b < 20)"
"attached_condition": "tbl1.b < 20"
},
"block-nl-join": {
"table": {
Expand All @@ -140,7 +140,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 60,
"attached_condition": "(tbl2.b < 60)"
"attached_condition": "tbl2.b < 60"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
Expand All @@ -166,7 +166,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 20,
"attached_condition": "(tbl1.b < 20)"
"attached_condition": "tbl1.b < 20"
},
"block-nl-join": {
"table": {
Expand All @@ -178,12 +178,12 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 60,
"attached_condition": "(tbl2.b < 60)"
"attached_condition": "tbl2.b < 60"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(tbl1.c > tbl2.c)",
"attached_condition": "tbl1.c > tbl2.c",
"r_filtered": 15.833
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"attached_condition": "(t1.a is not null)"
"attached_condition": "t1.a is not null"
},
"table": {
"table_name": "t2",
Expand Down Expand Up @@ -263,7 +263,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 50,
"attached_condition": "(test.t1.a < 5)"
"attached_condition": "test.t1.a < 5"
}
}
}
Expand Down Expand Up @@ -320,8 +320,8 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 50,
"index_condition": "(t1.pk < 10)",
"attached_condition": "(t1.b > 4)"
"index_condition": "t1.pk < 10",
"attached_condition": "t1.b > 4"
}
}
}
Expand All @@ -344,7 +344,7 @@ ANALYZE
"r_rows": 10,
"r_filtered": 50,
"r_total_time_ms": "REPLACED",
"attached_condition": "((t1.pk < 10) and (t1.b > 4))"
"attached_condition": "t1.pk < 10 and t1.b > 4"
}
}
}
Expand Down Expand Up @@ -444,7 +444,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 50,
"attached_condition": "(tbl1.a < 5)"
"attached_condition": "tbl1.a < 5"
}
}
},
Expand All @@ -462,7 +462,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 20,
"attached_condition": "(tbl2.a in (2,3))"
"attached_condition": "tbl2.a in (2,3)"
}
}
}
Expand Down Expand Up @@ -492,7 +492,7 @@ ANALYZE
"select_id": 1,
"r_loops": 1,
"volatile parameter": "REPLACED",
"having_condition": "(TOP > t2.a)",
"having_condition": "TOP > t2.a",
"filesort": {
"sort_key": "t2.a",
"r_loops": 1,
Expand Down Expand Up @@ -660,7 +660,7 @@ ANALYZE
"buffer_type": "incremental",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t2.b = `<subquery2>`.a)",
"attached_condition": "t2.b = `<subquery2>`.a",
"r_filtered": 0
}
}
Expand Down Expand Up @@ -722,7 +722,7 @@ ANALYZE
"volatile parameter": "REPLACED",
"filtered": 100,
"r_filtered": 0,
"attached_condition": "(t3.f3 in (1,2))"
"attached_condition": "t3.f3 in (1,2)"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
Expand Down Expand Up @@ -758,7 +758,7 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t2.f2 = t3.f3)",
"attached_condition": "t2.f2 = t3.f3",
"r_filtered": null
}
}
Expand Down
24 changes: 12 additions & 12 deletions mysql-test/r/analyze_stmt_orderby.result
Expand Up @@ -79,7 +79,7 @@ EXPLAIN
"key_length": "5",
"used_key_parts": ["a"],
"rows": 8,
"attached_condition": "(t2.a < 10)"
"attached_condition": "t2.a < 10"
}
}
}
Expand All @@ -104,7 +104,7 @@ ANALYZE
"r_rows": 10,
"r_filtered": 100,
"r_total_time_ms": "REPLACED",
"attached_condition": "(t2.a < 10)"
"attached_condition": "t2.a < 10"
}
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 10,
"filtered": 100,
"attached_condition": "(t0.a is not null)"
"attached_condition": "t0.a is not null"
},
"table": {
"table_name": "t2",
Expand Down Expand Up @@ -221,7 +221,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"attached_condition": "(t0.a is not null)"
"attached_condition": "t0.a is not null"
},
"table": {
"table_name": "t2",
Expand Down Expand Up @@ -264,7 +264,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 10,
"filtered": 100,
"attached_condition": "(t0.a is not null)"
"attached_condition": "t0.a is not null"
}
}
},
Expand Down Expand Up @@ -307,7 +307,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 1,
"attached_condition": "(t0.a is not null)"
"attached_condition": "t0.a is not null"
}
}
},
Expand Down Expand Up @@ -365,7 +365,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 50,
"attached_condition": "((t2.a % 2) = 0)"
"attached_condition": "t2.a % 2 = 0"
}
}
}
Expand Down Expand Up @@ -428,7 +428,7 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t3.a = t0.a)",
"attached_condition": "t3.a = t0.a",
"r_filtered": 10
}
}
Expand Down Expand Up @@ -483,7 +483,7 @@ ANALYZE
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 80,
"attached_condition": "((t6.b > 0) and (t6.a <= 5))"
"attached_condition": "t6.b > 0 and t6.a <= 5"
},
"block-nl-join": {
"table": {
Expand All @@ -499,7 +499,7 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t5.a = t6.a)",
"attached_condition": "t5.a = t6.a",
"r_filtered": 21.429
}
}
Expand Down Expand Up @@ -527,7 +527,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 5,
"filtered": 100,
"attached_condition": "((t6.b > 0) and (t6.a <= 5))"
"attached_condition": "t6.b > 0 and t6.a <= 5"
},
"block-nl-join": {
"table": {
Expand All @@ -539,7 +539,7 @@ EXPLAIN
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t5.a = t6.a)"
"attached_condition": "t5.a = t6.a"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/r/bigint.result
Expand Up @@ -420,22 +420,22 @@ UPDATE t1 SET b = a;
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 18446744073709551615 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 18446744073709551615) and ('18446744073709551615' = `test`.`t1`.`b`))
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 18446744073709551615 and '18446744073709551615' = `test`.`t1`.`b`
# 8000000000000000
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775808 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775808) and ('9223372036854775808' = `test`.`t1`.`b`))
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 9223372036854775808 and '9223372036854775808' = `test`.`t1`.`b`
# 7FFFFFFFFFFFFFFF
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775807 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775807) and ('9223372036854775807' = `test`.`t1`.`b`))
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 9223372036854775807 and '9223372036854775807' = `test`.`t1`.`b`
# 0
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 0 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 0) and ('0' = `test`.`t1`.`b`))
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 0 and '0' = `test`.`t1`.`b`
DROP TABLE t1;
# End of 5.1 tests
#
Expand Down

0 comments on commit 180065e

Please sign in to comment.