mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Item::print(): remove redundant parentheses
by introducing new Item::precedence() method and using it to decide whether parentheses are required
This commit is contained in:
@ -49,7 +49,7 @@ explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-1) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-1,2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
|
||||
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp(log(sqrt(10)) * 2) AS `exp(log(sqrt(10))*2)`,log(-1) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-1,2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
|
||||
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
||||
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
|
||||
10 10.000000000000002 NULL NULL NULL
|
||||
@ -57,7 +57,7 @@ explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-1) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
|
||||
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp(ln(sqrt(10)) * 2) AS `exp(ln(sqrt(10))*2)`,ln(-1) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
|
||||
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
||||
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
|
||||
3 3.9068905956085187 NULL NULL NULL
|
||||
@ -98,7 +98,7 @@ explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format(cot(1),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
|
||||
Note 1003 select pi() AS `pi()`,format(sin(pi() / 2),6) AS `format(sin(pi()/2),6)`,format(cos(pi() / 2),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format(cot(1),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
|
||||
select degrees(pi()),radians(360);
|
||||
degrees(pi()) radians(360)
|
||||
180 6.283185307179586
|
||||
@ -486,13 +486,13 @@ Warning 1292 Truncated incorrect INTEGER value: 'a'
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
SELECT 1e308 + 1e308;
|
||||
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
|
||||
ERROR 22003: DOUBLE value is out of range in '1e308 + 1e308'
|
||||
SELECT -1e308 - 1e308;
|
||||
ERROR 22003: DOUBLE value is out of range in '(-1e308 - 1e308)'
|
||||
ERROR 22003: DOUBLE value is out of range in '-1e308 - 1e308'
|
||||
SELECT 1e300 * 1e300;
|
||||
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
|
||||
ERROR 22003: DOUBLE value is out of range in '1e300 * 1e300'
|
||||
SELECT 1e300 / 1e-300;
|
||||
ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)'
|
||||
ERROR 22003: DOUBLE value is out of range in '1e300 / 1e-300'
|
||||
SELECT EXP(750);
|
||||
ERROR 22003: DOUBLE value is out of range in 'exp(750)'
|
||||
SELECT POW(10, 309);
|
||||
@ -519,9 +519,9 @@ DROP TABLE t1;
|
||||
# Bug#57477 SIGFPE when dividing a huge number a negative number
|
||||
#
|
||||
SELECT -9999999999999999991 DIV -1;
|
||||
ERROR 22003: BIGINT value is out of range in '(-9999999999999999991 DIV -1)'
|
||||
ERROR 22003: BIGINT value is out of range in '-9999999999999999991 DIV -1'
|
||||
SELECT -9223372036854775808 DIV -1;
|
||||
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 DIV -1)'
|
||||
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV -1'
|
||||
SELECT -9223372036854775808 MOD -1;
|
||||
-9223372036854775808 MOD -1
|
||||
0
|
||||
@ -529,13 +529,13 @@ SELECT -9223372036854775808999 MOD -1;
|
||||
-9223372036854775808999 MOD -1
|
||||
0
|
||||
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
|
||||
ERROR 22003: BIGINT value is out of range in '(123456789012345678901234567890.123456789012345678901234567890 DIV 1)'
|
||||
ERROR 22003: BIGINT value is out of range in '123456789012345678901234567890.123456789012345678901234567890 DIV 1'
|
||||
select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
|
||||
ERROR 22003: BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)'
|
||||
ERROR 22003: BIGINT value is out of range in ''123456789012345678901234567890.123456789012345678901234567890' DIV 1'
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
Warning 1916 Got overflow when converting '123456789012345678901234567890' to INT. Value truncated
|
||||
Error 1690 BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)'
|
||||
Error 1690 BIGINT value is out of range in ''123456789012345678901234567890.123456789012345678901234567890' DIV 1'
|
||||
#
|
||||
# Bug#57810 case/when/then : Assertion failed: length || !scale
|
||||
#
|
||||
@ -589,13 +589,13 @@ End of 5.1 tests
|
||||
# Bug #8433: Overflow must be an error
|
||||
#
|
||||
SELECT 1e308 + 1e308;
|
||||
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
|
||||
ERROR 22003: DOUBLE value is out of range in '1e308 + 1e308'
|
||||
SELECT -1e308 - 1e308;
|
||||
ERROR 22003: DOUBLE value is out of range in '(-1e308 - 1e308)'
|
||||
ERROR 22003: DOUBLE value is out of range in '-1e308 - 1e308'
|
||||
SELECT 1e300 * 1e300;
|
||||
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
|
||||
ERROR 22003: DOUBLE value is out of range in '1e300 * 1e300'
|
||||
SELECT 1e300 / 1e-300;
|
||||
ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)'
|
||||
ERROR 22003: DOUBLE value is out of range in '1e300 / 1e-300'
|
||||
SELECT EXP(750);
|
||||
ERROR 22003: DOUBLE value is out of range in 'exp(750)'
|
||||
SELECT POW(10, 309);
|
||||
@ -605,86 +605,86 @@ ERROR 22003: DOUBLE value is out of range in 'cot(0)'
|
||||
SELECT DEGREES(1e307);
|
||||
ERROR 22003: DOUBLE value is out of range in 'degrees(1e307)'
|
||||
SELECT 9223372036854775808 + 9223372036854775808;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 + 9223372036854775808)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 + 9223372036854775808'
|
||||
SELECT 18446744073709551615 + 1;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 + 1'
|
||||
SELECT 1 + 18446744073709551615;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(1 + 18446744073709551615)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '1 + 18446744073709551615'
|
||||
SELECT -2 + CAST(1 AS UNSIGNED);
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-2 + cast(1 as unsigned))'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '-2 + cast(1 as unsigned)'
|
||||
SELECT CAST(1 AS UNSIGNED) + -2;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -2)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(1 as unsigned) + -2'
|
||||
SELECT -9223372036854775808 + -9223372036854775808;
|
||||
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 + -9223372036854775808)'
|
||||
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 + -9223372036854775808'
|
||||
SELECT 9223372036854775807 + 9223372036854775807;
|
||||
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)'
|
||||
ERROR 22003: BIGINT value is out of range in '9223372036854775807 + 9223372036854775807'
|
||||
SELECT CAST(0 AS UNSIGNED) - 9223372036854775809;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(0 as unsigned) - 9223372036854775809)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(0 as unsigned) - 9223372036854775809'
|
||||
SELECT 9223372036854775808 - 9223372036854775809;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 - 9223372036854775809)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 - 9223372036854775809'
|
||||
SELECT CAST(1 AS UNSIGNED) - 2;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) - 2)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(1 as unsigned) - 2'
|
||||
SELECT 18446744073709551615 - (-1);
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -1)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 - -1'
|
||||
SELECT -1 - 9223372036854775808;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-1 - 9223372036854775808)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '-1 - 9223372036854775808'
|
||||
SELECT -1 - CAST(1 AS UNSIGNED);
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-1 - cast(1 as unsigned))'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '-1 - cast(1 as unsigned)'
|
||||
SELECT -9223372036854775808 - 1;
|
||||
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 - 1)'
|
||||
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 - 1'
|
||||
SELECT 9223372036854775807 - -9223372036854775808;
|
||||
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -9223372036854775808)'
|
||||
ERROR 22003: BIGINT value is out of range in '9223372036854775807 - -9223372036854775808'
|
||||
set SQL_MODE='NO_UNSIGNED_SUBTRACTION';
|
||||
SELECT 18446744073709551615 - 1;
|
||||
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - 1)'
|
||||
ERROR 22003: BIGINT value is out of range in '18446744073709551615 - 1'
|
||||
SELECT 18446744073709551615 - CAST(1 AS UNSIGNED);
|
||||
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - cast(1 as unsigned))'
|
||||
ERROR 22003: BIGINT value is out of range in '18446744073709551615 - cast(1 as unsigned)'
|
||||
SELECT 18446744073709551614 - (-1);
|
||||
ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -1)'
|
||||
ERROR 22003: BIGINT value is out of range in '18446744073709551614 - -1'
|
||||
SELECT 9223372036854775807 - -1;
|
||||
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -1)'
|
||||
ERROR 22003: BIGINT value is out of range in '9223372036854775807 - -1'
|
||||
set SQL_MODE=default;
|
||||
SELECT 4294967296 * 4294967296;
|
||||
ERROR 22003: BIGINT value is out of range in '(4294967296 * 4294967296)'
|
||||
ERROR 22003: BIGINT value is out of range in '4294967296 * 4294967296'
|
||||
SELECT 9223372036854775808 * 2;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 * 2'
|
||||
SELECT 9223372036854775808 * 2;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 * 2'
|
||||
SELECT 7158278827 * 3221225472;
|
||||
ERROR 22003: BIGINT value is out of range in '(7158278827 * 3221225472)'
|
||||
ERROR 22003: BIGINT value is out of range in '7158278827 * 3221225472'
|
||||
SELECT 9223372036854775807 * (-2);
|
||||
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -2)'
|
||||
ERROR 22003: BIGINT value is out of range in '9223372036854775807 * -2'
|
||||
SELECT CAST(1 as UNSIGNED) * (-1);
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -1)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(1 as unsigned) * -1'
|
||||
SELECT 9223372036854775807 * 2;
|
||||
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * 2)'
|
||||
ERROR 22003: BIGINT value is out of range in '9223372036854775807 * 2'
|
||||
SELECT ABS(-9223372036854775808);
|
||||
ERROR 22003: BIGINT value is out of range in 'abs(-9223372036854775808)'
|
||||
SELECT -9223372036854775808 DIV -1;
|
||||
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 DIV -1)'
|
||||
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV -1'
|
||||
SELECT 18446744073709551615 DIV -1;
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -1)'
|
||||
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 DIV -1'
|
||||
CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED);
|
||||
INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809);
|
||||
SELECT -a FROM t1;
|
||||
ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`a`)'
|
||||
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`a`'
|
||||
SELECT -b FROM t1;
|
||||
ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`b`)'
|
||||
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`b`'
|
||||
INSERT INTO t1 VALUES(0,0);
|
||||
SELECT -a FROM t1;
|
||||
ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`a`)'
|
||||
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`a`'
|
||||
SELECT -b FROM t1;
|
||||
ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`b`)'
|
||||
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`b`'
|
||||
DROP TABLE t1;
|
||||
SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999;
|
||||
SELECT @a + @a;
|
||||
ERROR 22003: DECIMAL value is out of range in '((@`a`) + (@`a`))'
|
||||
ERROR 22003: DECIMAL value is out of range in '@`a` + @`a`'
|
||||
SELECT @a * @a;
|
||||
ERROR 22003: DECIMAL value is out of range in '((@`a`) * (@`a`))'
|
||||
ERROR 22003: DECIMAL value is out of range in '@`a` * @`a`'
|
||||
SELECT -@a - @a;
|
||||
ERROR 22003: DECIMAL value is out of range in '(-((@`a`)) - (@`a`))'
|
||||
ERROR 22003: DECIMAL value is out of range in '-@`a` - @`a`'
|
||||
SELECT @a / 0.5;
|
||||
ERROR 22003: DECIMAL value is out of range in '((@`a`) / 0.5)'
|
||||
ERROR 22003: DECIMAL value is out of range in '@`a` / 0.5'
|
||||
SELECT COT(1/0);
|
||||
COT(1/0)
|
||||
NULL
|
||||
|
Reference in New Issue
Block a user