Skip to content

Commit 180065e

Browse files
committed
Item::print(): remove redundant parentheses
by introducing new Item::precedence() method and using it to decide whether parentheses are required
1 parent 1db438c commit 180065e

File tree

188 files changed

+2684
-2553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+2684
-2553
lines changed

mysql-test/r/alter_table.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,8 +2073,8 @@ Table Create Table
20732073
t1 CREATE TABLE `t1` (
20742074
`a` int(11) DEFAULT NULL,
20752075
`b` int(11) DEFAULT NULL,
2076-
CONSTRAINT `min` CHECK (((`a` + `b`) > 100)),
2077-
CONSTRAINT `mini` CHECK (((`a` + `b`) > 100))
2076+
CONSTRAINT `min` CHECK (`a` + `b` > 100),
2077+
CONSTRAINT `mini` CHECK (`a` + `b` > 100)
20782078
) ENGINE=MyISAM DEFAULT CHARSET=latin1
20792079
DROP TABLE t1;
20802080
CREATE TABLE t1(a INT, b INT, CONSTRAINT min check (a>5),

mysql-test/r/analyze_format_json.result

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ANALYZE
1818
"r_total_time_ms": "REPLACED",
1919
"filtered": 100,
2020
"r_filtered": 30,
21-
"attached_condition": "(t0.a < 3)"
21+
"attached_condition": "t0.a < 3"
2222
}
2323
}
2424
}
@@ -46,7 +46,7 @@ ANALYZE
4646
"r_total_time_ms": "REPLACED",
4747
"filtered": 100,
4848
"r_filtered": 0,
49-
"attached_condition": "((t0.a > 9) and (t0.a is not null))"
49+
"attached_condition": "t0.a > 9 and t0.a is not null"
5050
},
5151
"table": {
5252
"table_name": "t1",
@@ -86,7 +86,7 @@ ANALYZE
8686
"r_total_time_ms": "REPLACED",
8787
"filtered": 100,
8888
"r_filtered": 100,
89-
"attached_condition": "(t0.a is not null)"
89+
"attached_condition": "t0.a is not null"
9090
},
9191
"table": {
9292
"table_name": "t1",
@@ -102,7 +102,7 @@ ANALYZE
102102
"r_total_time_ms": "REPLACED",
103103
"filtered": 100,
104104
"r_filtered": 40,
105-
"attached_condition": "(t1.b < 4)"
105+
"attached_condition": "t1.b < 4"
106106
}
107107
}
108108
}
@@ -128,7 +128,7 @@ ANALYZE
128128
"r_total_time_ms": "REPLACED",
129129
"filtered": 100,
130130
"r_filtered": 20,
131-
"attached_condition": "(tbl1.b < 20)"
131+
"attached_condition": "tbl1.b < 20"
132132
},
133133
"block-nl-join": {
134134
"table": {
@@ -140,7 +140,7 @@ ANALYZE
140140
"r_total_time_ms": "REPLACED",
141141
"filtered": 100,
142142
"r_filtered": 60,
143-
"attached_condition": "(tbl2.b < 60)"
143+
"attached_condition": "tbl2.b < 60"
144144
},
145145
"buffer_type": "flat",
146146
"buffer_size": "256Kb",
@@ -166,7 +166,7 @@ ANALYZE
166166
"r_total_time_ms": "REPLACED",
167167
"filtered": 100,
168168
"r_filtered": 20,
169-
"attached_condition": "(tbl1.b < 20)"
169+
"attached_condition": "tbl1.b < 20"
170170
},
171171
"block-nl-join": {
172172
"table": {
@@ -178,12 +178,12 @@ ANALYZE
178178
"r_total_time_ms": "REPLACED",
179179
"filtered": 100,
180180
"r_filtered": 60,
181-
"attached_condition": "(tbl2.b < 60)"
181+
"attached_condition": "tbl2.b < 60"
182182
},
183183
"buffer_type": "flat",
184184
"buffer_size": "256Kb",
185185
"join_type": "BNL",
186-
"attached_condition": "(tbl1.c > tbl2.c)",
186+
"attached_condition": "tbl1.c > tbl2.c",
187187
"r_filtered": 15.833
188188
}
189189
}
@@ -213,7 +213,7 @@ ANALYZE
213213
"r_total_time_ms": "REPLACED",
214214
"filtered": 100,
215215
"r_filtered": 100,
216-
"attached_condition": "(t1.a is not null)"
216+
"attached_condition": "t1.a is not null"
217217
},
218218
"table": {
219219
"table_name": "t2",
@@ -263,7 +263,7 @@ ANALYZE
263263
"r_total_time_ms": "REPLACED",
264264
"filtered": 100,
265265
"r_filtered": 50,
266-
"attached_condition": "(test.t1.a < 5)"
266+
"attached_condition": "test.t1.a < 5"
267267
}
268268
}
269269
}
@@ -320,8 +320,8 @@ ANALYZE
320320
"r_total_time_ms": "REPLACED",
321321
"filtered": 100,
322322
"r_filtered": 50,
323-
"index_condition": "(t1.pk < 10)",
324-
"attached_condition": "(t1.b > 4)"
323+
"index_condition": "t1.pk < 10",
324+
"attached_condition": "t1.b > 4"
325325
}
326326
}
327327
}
@@ -344,7 +344,7 @@ ANALYZE
344344
"r_rows": 10,
345345
"r_filtered": 50,
346346
"r_total_time_ms": "REPLACED",
347-
"attached_condition": "((t1.pk < 10) and (t1.b > 4))"
347+
"attached_condition": "t1.pk < 10 and t1.b > 4"
348348
}
349349
}
350350
}
@@ -444,7 +444,7 @@ ANALYZE
444444
"r_total_time_ms": "REPLACED",
445445
"filtered": 100,
446446
"r_filtered": 50,
447-
"attached_condition": "(tbl1.a < 5)"
447+
"attached_condition": "tbl1.a < 5"
448448
}
449449
}
450450
},
@@ -462,7 +462,7 @@ ANALYZE
462462
"r_total_time_ms": "REPLACED",
463463
"filtered": 100,
464464
"r_filtered": 20,
465-
"attached_condition": "(tbl2.a in (2,3))"
465+
"attached_condition": "tbl2.a in (2,3)"
466466
}
467467
}
468468
}
@@ -492,7 +492,7 @@ ANALYZE
492492
"select_id": 1,
493493
"r_loops": 1,
494494
"volatile parameter": "REPLACED",
495-
"having_condition": "(TOP > t2.a)",
495+
"having_condition": "TOP > t2.a",
496496
"filesort": {
497497
"sort_key": "t2.a",
498498
"r_loops": 1,
@@ -660,7 +660,7 @@ ANALYZE
660660
"buffer_type": "incremental",
661661
"buffer_size": "256Kb",
662662
"join_type": "BNL",
663-
"attached_condition": "(t2.b = `<subquery2>`.a)",
663+
"attached_condition": "t2.b = `<subquery2>`.a",
664664
"r_filtered": 0
665665
}
666666
}
@@ -722,7 +722,7 @@ ANALYZE
722722
"volatile parameter": "REPLACED",
723723
"filtered": 100,
724724
"r_filtered": 0,
725-
"attached_condition": "(t3.f3 in (1,2))"
725+
"attached_condition": "t3.f3 in (1,2)"
726726
},
727727
"buffer_type": "flat",
728728
"buffer_size": "256Kb",
@@ -758,7 +758,7 @@ ANALYZE
758758
"buffer_type": "flat",
759759
"buffer_size": "256Kb",
760760
"join_type": "BNL",
761-
"attached_condition": "(t2.f2 = t3.f3)",
761+
"attached_condition": "t2.f2 = t3.f3",
762762
"r_filtered": null
763763
}
764764
}

mysql-test/r/analyze_stmt_orderby.result

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ EXPLAIN
7979
"key_length": "5",
8080
"used_key_parts": ["a"],
8181
"rows": 8,
82-
"attached_condition": "(t2.a < 10)"
82+
"attached_condition": "t2.a < 10"
8383
}
8484
}
8585
}
@@ -104,7 +104,7 @@ ANALYZE
104104
"r_rows": 10,
105105
"r_filtered": 100,
106106
"r_total_time_ms": "REPLACED",
107-
"attached_condition": "(t2.a < 10)"
107+
"attached_condition": "t2.a < 10"
108108
}
109109
}
110110
}
@@ -179,7 +179,7 @@ EXPLAIN
179179
"access_type": "ALL",
180180
"rows": 10,
181181
"filtered": 100,
182-
"attached_condition": "(t0.a is not null)"
182+
"attached_condition": "t0.a is not null"
183183
},
184184
"table": {
185185
"table_name": "t2",
@@ -221,7 +221,7 @@ ANALYZE
221221
"r_total_time_ms": "REPLACED",
222222
"filtered": 100,
223223
"r_filtered": 100,
224-
"attached_condition": "(t0.a is not null)"
224+
"attached_condition": "t0.a is not null"
225225
},
226226
"table": {
227227
"table_name": "t2",
@@ -264,7 +264,7 @@ EXPLAIN
264264
"access_type": "ALL",
265265
"rows": 10,
266266
"filtered": 100,
267-
"attached_condition": "(t0.a is not null)"
267+
"attached_condition": "t0.a is not null"
268268
}
269269
}
270270
},
@@ -307,7 +307,7 @@ ANALYZE
307307
"r_total_time_ms": "REPLACED",
308308
"filtered": 100,
309309
"r_filtered": 1,
310-
"attached_condition": "(t0.a is not null)"
310+
"attached_condition": "t0.a is not null"
311311
}
312312
}
313313
},
@@ -365,7 +365,7 @@ ANALYZE
365365
"r_total_time_ms": "REPLACED",
366366
"filtered": 100,
367367
"r_filtered": 50,
368-
"attached_condition": "((t2.a % 2) = 0)"
368+
"attached_condition": "t2.a % 2 = 0"
369369
}
370370
}
371371
}
@@ -428,7 +428,7 @@ ANALYZE
428428
"buffer_type": "flat",
429429
"buffer_size": "256Kb",
430430
"join_type": "BNL",
431-
"attached_condition": "(t3.a = t0.a)",
431+
"attached_condition": "t3.a = t0.a",
432432
"r_filtered": 10
433433
}
434434
}
@@ -483,7 +483,7 @@ ANALYZE
483483
"r_total_time_ms": "REPLACED",
484484
"filtered": 100,
485485
"r_filtered": 80,
486-
"attached_condition": "((t6.b > 0) and (t6.a <= 5))"
486+
"attached_condition": "t6.b > 0 and t6.a <= 5"
487487
},
488488
"block-nl-join": {
489489
"table": {
@@ -499,7 +499,7 @@ ANALYZE
499499
"buffer_type": "flat",
500500
"buffer_size": "256Kb",
501501
"join_type": "BNL",
502-
"attached_condition": "(t5.a = t6.a)",
502+
"attached_condition": "t5.a = t6.a",
503503
"r_filtered": 21.429
504504
}
505505
}
@@ -527,7 +527,7 @@ EXPLAIN
527527
"access_type": "ALL",
528528
"rows": 5,
529529
"filtered": 100,
530-
"attached_condition": "((t6.b > 0) and (t6.a <= 5))"
530+
"attached_condition": "t6.b > 0 and t6.a <= 5"
531531
},
532532
"block-nl-join": {
533533
"table": {
@@ -539,7 +539,7 @@ EXPLAIN
539539
"buffer_type": "flat",
540540
"buffer_size": "256Kb",
541541
"join_type": "BNL",
542-
"attached_condition": "(t5.a = t6.a)"
542+
"attached_condition": "t5.a = t6.a"
543543
}
544544
}
545545
}

mysql-test/r/bigint.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,22 +420,22 @@ UPDATE t1 SET b = a;
420420
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 18446744073709551615 AND TRIM(a) = b;
421421
SHOW WARNINGS;
422422
Level Code Message
423-
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 18446744073709551615) and ('18446744073709551615' = `test`.`t1`.`b`))
423+
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 18446744073709551615 and '18446744073709551615' = `test`.`t1`.`b`
424424
# 8000000000000000
425425
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775808 AND TRIM(a) = b;
426426
SHOW WARNINGS;
427427
Level Code Message
428-
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775808) and ('9223372036854775808' = `test`.`t1`.`b`))
428+
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 9223372036854775808 and '9223372036854775808' = `test`.`t1`.`b`
429429
# 7FFFFFFFFFFFFFFF
430430
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775807 AND TRIM(a) = b;
431431
SHOW WARNINGS;
432432
Level Code Message
433-
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775807) and ('9223372036854775807' = `test`.`t1`.`b`))
433+
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 9223372036854775807 and '9223372036854775807' = `test`.`t1`.`b`
434434
# 0
435435
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 0 AND TRIM(a) = b;
436436
SHOW WARNINGS;
437437
Level Code Message
438-
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 0) and ('0' = `test`.`t1`.`b`))
438+
Note 1003 select 1 AS `1` from `test`.`t1` where `test`.`t1`.`a` = 0 and '0' = `test`.`t1`.`b`
439439
DROP TABLE t1;
440440
# End of 5.1 tests
441441
#

0 commit comments

Comments
 (0)