mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
494bccf044
mysql-test/ndb/ndbcluster.sh: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/t/func_math.test: Auto merged mysql-test/t/type_float.test: Auto merged sql/spatial.h: Auto merged mysql-test/r/type_float.result: merging sql/item_func.cc: merging
143 lines
4.2 KiB
Text
143 lines
4.2 KiB
Text
#
|
|
# Test of math functions
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
select floor(5.5),floor(-5.5);
|
|
explain extended select floor(5.5),floor(-5.5);
|
|
select ceiling(5.5),ceiling(-5.5);
|
|
explain extended select ceiling(5.5),ceiling(-5.5);
|
|
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
|
explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
|
select round(5.5),round(-5.5);
|
|
explain extended select round(5.5),round(-5.5);
|
|
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
|
|
select abs(-10), sign(-5), sign(5), sign(0);
|
|
explain extended select abs(-10), sign(-5), sign(5), sign(0);
|
|
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
|
|
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
|
|
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
|
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
|
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
|
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
|
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
|
|
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
|
|
select pow(10,log10(10)),power(2,4);
|
|
explain extended select pow(10,log10(10)),power(2,4);
|
|
set @@rand_seed1=10000000,@@rand_seed2=1000000;
|
|
select rand(999999),rand();
|
|
explain extended select rand(999999),rand();
|
|
select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
|
|
explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
|
|
select degrees(pi()),radians(360);
|
|
|
|
#
|
|
# Bug #2338 Trignometric arithmatic problems
|
|
#
|
|
|
|
SELECT ACOS(1.0);
|
|
SELECT ASIN(1.0);
|
|
SELECT ACOS(0.2*5.0);
|
|
SELECT ACOS(0.5*2.0);
|
|
SELECT ASIN(0.8+0.2);
|
|
SELECT ASIN(1.2-0.2);
|
|
|
|
#
|
|
# Bug #3051 FLOOR returns invalid
|
|
#
|
|
|
|
# This can't be tested as it's not portable
|
|
#select floor(log(4)/log(2));
|
|
#select floor(log(8)/log(2));
|
|
#select floor(log(16)/log(2));
|
|
|
|
#
|
|
# Bug #9060 (format returns incorrect result)
|
|
#
|
|
select format(4.55, 1), format(4.551, 1);
|
|
|
|
explain extended select degrees(pi()),radians(360);
|
|
|
|
#
|
|
# Bug #7281: problem with rand()
|
|
#
|
|
|
|
--error 1054
|
|
select rand(rand);
|
|
|
|
# End of 4.1 tests
|
|
|
|
#
|
|
# Bug #8459 (FORMAT returns incorrect result)
|
|
#
|
|
create table t1 (col1 int, col2 decimal(60,30));
|
|
insert into t1 values(1,1234567890.12345);
|
|
select format(col2,7) from t1;
|
|
select format(col2,8) from t1;
|
|
insert into t1 values(7,1234567890123456.12345);
|
|
select format(col2,6) from t1 where col1=7;
|
|
drop table t1;
|
|
|
|
|
|
#
|
|
# Bug #10083 (round doesn't increase decimals)
|
|
#
|
|
select round(150, 2);
|
|
|
|
#
|
|
# Bug @10632 (Ceiling function returns wrong answer)
|
|
#
|
|
select ceil(0.09);
|
|
select ceil(0.000000000000000009);
|
|
|
|
#
|
|
# Bug #9837: problem with round()
|
|
#
|
|
|
|
create table t1 select round(1, 6);
|
|
show create table t1;
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Bug #11402: abs() forces rest of calculation to unsigned
|
|
#
|
|
select abs(-2) * -2;
|
|
|
|
#
|
|
# Bug #6172 RAND(a) should only accept constant values as arguments
|
|
#
|
|
create table t1 (i int);
|
|
insert into t1 values (1);
|
|
--error 1210
|
|
select rand(i) from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Bug #14009: use of abs() on null value causes problems with filesort
|
|
#
|
|
# InnoDB is required to reproduce the fault, but it is okay if we default to
|
|
# MyISAM when testing.
|
|
--disable_warnings
|
|
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
|
|
--enable_warnings
|
|
insert into t1 values ('http://www.foo.com/', now());
|
|
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
|
|
drop table t1;
|
|
|
|
# End of 4.1 tests
|
|
|
|
#
|
|
# Bug #13820 (No warning on log(negative)
|
|
#
|
|
set sql_mode='traditional';
|
|
select ln(-1);
|
|
select log10(-1);
|
|
select log2(-1);
|
|
select log(2,-1);
|
|
select log(-2,1);
|
|
set sql_mode='';
|
|
|