From 2b5040d053ee924429601332e59d8d8002b84b13 Mon Sep 17 00:00:00 2001 From: shangyanwen <18392868125@163.com> Date: Wed, 26 Oct 2022 16:34:18 +0800 Subject: [PATCH 1/2] test(mtr):add x_function.test(#497) --- .../suite/tianmu/r/AddDate_function.result | 68 ++++++++++ .../suite/tianmu/r/AddTime_function.result | 72 +++++++++++ .../suite/tianmu/r/case_function.result | 56 +++++++++ .../tianmu/r/char_length_function.result | 76 +++++++++++ .../suite/tianmu/r/date_function.result | 32 +++++ mysql-test/suite/tianmu/r/day_function.result | 32 +++++ .../suite/tianmu/r/null_functions.result | 118 ++++++++++++++++++ .../suite/tianmu/t/AddDate_function.test | 32 +++++ .../suite/tianmu/t/AddTime_function.test | 32 +++++ mysql-test/suite/tianmu/t/case_function.test | 26 ++++ .../suite/tianmu/t/char_length_function.test | 38 ++++++ mysql-test/suite/tianmu/t/date_function.test | 26 ++++ mysql-test/suite/tianmu/t/day_function.test | 26 ++++ mysql-test/suite/tianmu/t/null_functions.test | 44 +++++++ 14 files changed, 678 insertions(+) create mode 100644 mysql-test/suite/tianmu/r/AddDate_function.result create mode 100644 mysql-test/suite/tianmu/r/AddTime_function.result create mode 100644 mysql-test/suite/tianmu/r/case_function.result create mode 100644 mysql-test/suite/tianmu/r/char_length_function.result create mode 100644 mysql-test/suite/tianmu/r/date_function.result create mode 100644 mysql-test/suite/tianmu/r/day_function.result create mode 100644 mysql-test/suite/tianmu/r/null_functions.result create mode 100644 mysql-test/suite/tianmu/t/AddDate_function.test create mode 100644 mysql-test/suite/tianmu/t/AddTime_function.test create mode 100644 mysql-test/suite/tianmu/t/case_function.test create mode 100644 mysql-test/suite/tianmu/t/char_length_function.test create mode 100644 mysql-test/suite/tianmu/t/date_function.test create mode 100644 mysql-test/suite/tianmu/t/day_function.test create mode 100644 mysql-test/suite/tianmu/t/null_functions.test diff --git a/mysql-test/suite/tianmu/r/AddDate_function.result b/mysql-test/suite/tianmu/r/AddDate_function.result new file mode 100644 index 000000000..d4ee46afa --- /dev/null +++ b/mysql-test/suite/tianmu/r/AddDate_function.result @@ -0,0 +1,68 @@ +# +# Test ADDDATE function +# Author: syw +# +DROP DATABASE IF EXISTS mcs178_db; +CREATE DATABASE mcs178_db; +USE mcs178_db; +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` datetime DEFAULT NULL, + `d` double DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT ADDDATE('2020-02-02 22:22:22', 1); +ADDDATE('2020-02-02 22:22:22', 1) +2020-02-03 22:22:22 +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL 1 DAY); +ADDDATE('2020-02-02 22:22:22', INTERVAL 1 DAY) +2020-02-03 22:22:22 +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL 1 HOUR); +ADDDATE('2020-02-02 22:22:22', INTERVAL 1 HOUR) +2020-02-02 23:22:22 +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL 1 MINUTE); +ADDDATE('2020-02-02 22:22:22', INTERVAL 1 MINUTE) +2020-02-02 22:23:22 +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL -1 SECOND); +ADDDATE('2020-02-02 22:22:22', INTERVAL -1 SECOND) +2020-02-02 22:22:21 +SELECT c, ADDDATE(c, 1) FROM t1; +c ADDDATE(c, 1) +1990-01-01 00:00:00 1990-01-02 00:00:00 +1212-12-12 00:00:00 1212-12-13 00:00:00 +1313-03-13 13:13:13 1313-03-14 13:13:13 +1414-04-14 00:00:00 1414-04-15 00:00:00 +2015-05-15 15:15:15 2015-05-16 15:15:15 +SELECT c, ADDDATE(c, -2) FROM t1; +c ADDDATE(c, -2) +1990-01-01 00:00:00 1989-12-30 00:00:00 +1212-12-12 00:00:00 1212-12-10 00:00:00 +1313-03-13 13:13:13 1313-03-11 13:13:13 +1414-04-14 00:00:00 1414-04-12 00:00:00 +2015-05-15 15:15:15 2015-05-13 15:15:15 +SELECT c, ADDDATE(c, INTERVAL -1 HOUR) FROM t1; +c ADDDATE(c, INTERVAL -1 HOUR) +1990-01-01 00:00:00 1989-12-31 23:00:00 +1212-12-12 00:00:00 1212-12-11 23:00:00 +1313-03-13 13:13:13 1313-03-13 12:13:13 +1414-04-14 00:00:00 1414-04-13 23:00:00 +2015-05-15 15:15:15 2015-05-15 14:15:15 +SELECT c, ADDDATE(c, INTERVAL 1 MINUTE) FROM t1; +c ADDDATE(c, INTERVAL 1 MINUTE) +1990-01-01 00:00:00 1990-01-01 00:01:00 +1212-12-12 00:00:00 1212-12-12 00:01:00 +1313-03-13 13:13:13 1313-03-13 13:14:13 +1414-04-14 00:00:00 1414-04-14 00:01:00 +2015-05-15 15:15:15 2015-05-15 15:16:15 +SELECT c, ADDDATE(c, INTERVAL 1 SECOND) FROM t1; +c ADDDATE(c, INTERVAL 1 SECOND) +1990-01-01 00:00:00 1990-01-01 00:00:01 +1212-12-12 00:00:00 1212-12-12 00:00:01 +1313-03-13 13:13:13 1313-03-13 13:13:14 +1414-04-14 00:00:00 1414-04-14 00:00:01 +2015-05-15 15:15:15 2015-05-15 15:15:16 +DROP DATABASE mcs178_db; diff --git a/mysql-test/suite/tianmu/r/AddTime_function.result b/mysql-test/suite/tianmu/r/AddTime_function.result new file mode 100644 index 000000000..5ab569075 --- /dev/null +++ b/mysql-test/suite/tianmu/r/AddTime_function.result @@ -0,0 +1,72 @@ +# +# Test ADDTIME function +# Author: syw +# +DROP DATABASE IF EXISTS mcs179_db; +CREATE DATABASE mcs179_db; +USE mcs179_db; +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` datetime DEFAULT NULL, + `d` double DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT ADDTIME('2020-02-02 22:22:22', '2 1:1:1'); +ADDTIME('2020-02-02 22:22:22', '2 1:1:1') +2020-02-04 23:23:23 +SELECT ADDTIME('2020-02-02 22:22:22', '2:2:2.1111'); +ADDTIME('2020-02-02 22:22:22', '2:2:2.1111') +2020-02-03 00:24:24.111100 +SELECT ADDTIME('2020-02-02 22:22:22', '-2:2:2'); +ADDTIME('2020-02-02 22:22:22', '-2:2:2') +2020-02-02 20:20:20 +SELECT ADDTIME('22:22:22', '03:11:22'); +ADDTIME('22:22:22', '03:11:22') +25:33:44 +SELECT c, ADDTIME(c, '1 3:3:3') FROM t1; +c ADDTIME(c, '1 3:3:3') +1990-01-01 00:00:00 1990-01-02 03:03:03 +1212-12-12 00:00:00 1212-12-13 03:03:03 +1313-03-13 13:13:13 1313-03-14 16:16:16 +1414-04-14 00:00:00 1414-04-15 03:03:03 +2015-05-15 15:15:15 2015-05-16 18:18:18 +SELECT c, ADDTIME(c, '-2 1:1:1') FROM t1; +c ADDTIME(c, '-2 1:1:1') +1990-01-01 00:00:00 1989-12-29 22:58:59 +1212-12-12 00:00:00 1212-12-09 22:58:59 +1313-03-13 13:13:13 1313-03-11 12:12:12 +1414-04-14 00:00:00 1414-04-11 22:58:59 +2015-05-15 15:15:15 2015-05-13 14:14:14 +SELECT c, ADDTIME(c, '100:11:12') FROM t1; +c ADDTIME(c, '100:11:12') +1990-01-01 00:00:00 1990-01-05 04:11:12 +1212-12-12 00:00:00 1212-12-16 04:11:12 +1313-03-13 13:13:13 1313-03-17 17:24:25 +1414-04-14 00:00:00 1414-04-18 04:11:12 +2015-05-15 15:15:15 2015-05-19 19:26:27 +SELECT c, ADDTIME(c, '-100:11:12') FROM t1; +c ADDTIME(c, '-100:11:12') +1990-01-01 00:00:00 1989-12-27 19:48:48 +1212-12-12 00:00:00 1212-12-07 19:48:48 +1313-03-13 13:13:13 1313-03-09 09:02:01 +1414-04-14 00:00:00 1414-04-09 19:48:48 +2015-05-15 15:15:15 2015-05-11 11:04:03 +SELECT c, ADDTIME(c, '100:11') FROM t1; +c ADDTIME(c, '100:11') +1990-01-01 00:00:00 1990-01-05 04:11:00 +1212-12-12 00:00:00 1212-12-16 04:11:00 +1313-03-13 13:13:13 1313-03-17 17:24:13 +1414-04-14 00:00:00 1414-04-18 04:11:00 +2015-05-15 15:15:15 2015-05-19 19:26:15 +SELECT c, ADDTIME(c, '100') FROM t1; +c ADDTIME(c, '100') +1990-01-01 00:00:00 1990-01-01 00:01:00 +1212-12-12 00:00:00 1212-12-12 00:01:00 +1313-03-13 13:13:13 1313-03-13 13:14:13 +1414-04-14 00:00:00 1414-04-14 00:01:00 +2015-05-15 15:15:15 2015-05-15 15:16:15 +DROP DATABASE mcs179_db; diff --git a/mysql-test/suite/tianmu/r/case_function.result b/mysql-test/suite/tianmu/r/case_function.result new file mode 100644 index 000000000..998fb9f29 --- /dev/null +++ b/mysql-test/suite/tianmu/r/case_function.result @@ -0,0 +1,56 @@ +# +# Test CASE function +# Author: syw +# +DROP DATABASE IF EXISTS mcs174_db; +CREATE DATABASE mcs174_db; +USE mcs174_db; +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` datetime DEFAULT NULL, + `d` double DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT b, c, (CASE WHEN a = 'b' THEN b ELSE c END) FROM t1; +b c (CASE WHEN a = 'b' THEN b ELSE c END) +NULL 1990-01-01 00:00:00 1990-01-01 00:00:00 +12 1212-12-12 00:00:00 1212-12-12 00:00:00 +13 1313-03-13 13:13:13 13 +14 1414-04-14 00:00:00 1414-04-14 00:00:00 +15 2015-05-15 15:15:15 2015-05-15 15:15:15 +SELECT b, a, (CASE WHEN b > 13 THEN b ELSE a END) FROM t1; +b a (CASE WHEN b > 13 THEN b ELSE a END) +NULL +12 a a +13 b b +14 c 14 +15 d 15 +SELECT c, a, (CASE WHEN d > 1 THEN a ELSE c END) FROM t1; +c a (CASE WHEN d > 1 THEN a ELSE c END) +1990-01-01 00:00:00 1990-01-01 00:00:00 +1212-12-12 00:00:00 a a +1313-03-13 13:13:13 b b +1414-04-14 00:00:00 c 1414-04-14 00:00:00 +2015-05-15 15:15:15 d d +SELECT a, c, (CASE WHEN c IS NULL THEN a ELSE c END) FROM t1; +a c (CASE WHEN c IS NULL THEN a ELSE c END) + 1990-01-01 00:00:00 1990-01-01 00:00:00 +a 1212-12-12 00:00:00 1212-12-12 00:00:00 +b 1313-03-13 13:13:13 1313-03-13 13:13:13 +c 1414-04-14 00:00:00 1414-04-14 00:00:00 +d 2015-05-15 15:15:15 2015-05-15 15:15:15 +SELECT (CASE WHEN a = 'a' THEN 0 ELSE 1 END) FROM t1; +(CASE WHEN a = 'a' THEN 0 ELSE 1 END) +1 +0 +1 +1 +1 +SELECT (CASE WHEN 10 > 5 THEN 'True' ELSE 'False' END); +(CASE WHEN 10 > 5 THEN 'True' ELSE 'False' END) +True +DROP DATABASE mcs174_db; diff --git a/mysql-test/suite/tianmu/r/char_length_function.result b/mysql-test/suite/tianmu/r/char_length_function.result new file mode 100644 index 000000000..0170f8af8 --- /dev/null +++ b/mysql-test/suite/tianmu/r/char_length_function.result @@ -0,0 +1,76 @@ +# +# Test CHAR_LENGTH function +# Author: syw +# +DROP DATABASE IF EXISTS mcs182_db; +CREATE DATABASE mcs182_db; +USE mcs182_db; +CREATE TABLE t1 (a VARCHAR(20))engine=tianmu; +INSERT INTO t1 VALUES (repeat('a', 5)), (repeat('b', 10)), (repeat('c', 20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(20) DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT CHAR_LENGTH('MariaDB'); +CHAR_LENGTH('MariaDB') +7 +SELECT CHAR_LENGTH(234); +CHAR_LENGTH(234) +3 +SELECT CHAR_LENGTH('~12ab'); +CHAR_LENGTH('~12ab') +5 +SELECT CHAR_LENGTH('1212-12-12'); +CHAR_LENGTH('1212-12-12') +10 +SELECT a, CHAR_LENGTH(a) FROM t1 ORDER BY a; +a CHAR_LENGTH(a) +aaaaa 5 +bbbbbbbbbb 10 +cccccccccccccccccccc 20 +SELECT a, CHARACTER_LENGTH(a) FROM t1 ORDER BY a; +a CHARACTER_LENGTH(a) +aaaaa 5 +bbbbbbbbbb 10 +cccccccccccccccccccc 20 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` datetime DEFAULT NULL, + `d` double DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT a, CHARACTER_LENGTH(a) FROM t1 ORDER BY a; +a CHARACTER_LENGTH(a) + 0 +a 1 +b 1 +c 1 +d 1 +SELECT b, CHARACTER_LENGTH(b) FROM t1 ORDER BY b; +b CHARACTER_LENGTH(b) +NULL NULL +12 2 +13 2 +14 2 +15 2 +SELECT c, CHARACTER_LENGTH(c) FROM t1 ORDER BY c; +c CHARACTER_LENGTH(c) +1212-12-12 00:00:00 19 +1313-03-13 13:13:13 19 +1414-04-14 00:00:00 19 +1990-01-01 00:00:00 19 +2015-05-15 15:15:15 19 +SELECT d, CHARACTER_LENGTH(d) FROM t1 ORDER BY d; +d CHARACTER_LENGTH(d) +NULL NULL +0.16191 7 +1.971917 8 +2.1961e18 9 +1.19691e100 11 +DROP DATABASE mcs182_db; diff --git a/mysql-test/suite/tianmu/r/date_function.result b/mysql-test/suite/tianmu/r/date_function.result new file mode 100644 index 000000000..addf4f755 --- /dev/null +++ b/mysql-test/suite/tianmu/r/date_function.result @@ -0,0 +1,32 @@ +# +# Test DATE function +# Author: syw +# +DROP DATABASE IF EXISTS mcs183_db; +CREATE DATABASE mcs183_db; +USE mcs183_db; +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-01-01', '1990-01-01 0:0:0'), ('1212-12-12', '1111-11-11 11:11:11'), ('3333-03-03', '3333-3-3 3:33:33'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` date DEFAULT NULL, + `b` datetime DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT DATE('1212-12-12 11:11:11'); +DATE('1212-12-12 11:11:11') +1212-12-12 +SELECT DATE('2020-12-22'); +DATE('2020-12-22') +2020-12-22 +SELECT a, DATE(a) FROM t1 ORDER BY 1; +a DATE(a) +1212-12-12 1212-12-12 +1990-01-01 1990-01-01 +3333-03-03 3333-03-03 +SELECT b, DATE(b) FROM t1 ORDER BY 1; +b DATE(b) +1111-11-11 11:11:11 1111-11-11 +1990-01-01 00:00:00 1990-01-01 +3333-03-03 03:33:33 3333-03-03 +DROP DATABASE mcs183_db; diff --git a/mysql-test/suite/tianmu/r/day_function.result b/mysql-test/suite/tianmu/r/day_function.result new file mode 100644 index 000000000..1219a7986 --- /dev/null +++ b/mysql-test/suite/tianmu/r/day_function.result @@ -0,0 +1,32 @@ +# +# Test DAY function +# Author: syw +# +DROP DATABASE IF EXISTS mcs184_db; +CREATE DATABASE mcs184_db; +USE mcs184_db; +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1111-11-11 11:11:11'), ('3333-03-03', '3333-3-3 3:33:33'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` date DEFAULT NULL, + `b` datetime DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT DAY('1212-12-12 11:11:11'); +DAY('1212-12-12 11:11:11') +12 +SELECT DAY('2020-12-22'); +DAY('2020-12-22') +22 +SELECT a, DAY(a) FROM t1 ORDER BY 1; +a DAY(a) +1212-12-12 12 +1990-10-10 10 +3333-03-03 3 +SELECT b, DAY(b) FROM t1 ORDER BY 1; +b DAY(b) +1111-11-11 11:11:11 11 +1990-10-10 00:00:00 10 +3333-03-03 03:33:33 3 +DROP DATABASE mcs184_db; diff --git a/mysql-test/suite/tianmu/r/null_functions.result b/mysql-test/suite/tianmu/r/null_functions.result new file mode 100644 index 000000000..66e1f8c52 --- /dev/null +++ b/mysql-test/suite/tianmu/r/null_functions.result @@ -0,0 +1,118 @@ +# +# Test NULLIF, IFNULL, ISNULL functions +# Author: syw +# +DROP DATABASE IF EXISTS mcs171_db; +CREATE DATABASE mcs171_db; +USE mcs171_db; +SET default_storage_engine=tianmu; +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE); +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` datetime DEFAULT NULL, + `d` double DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT IFNULL(NULL, 'abc'); +IFNULL(NULL, 'abc') +abc +SELECT IFNULL(NULL, 123); +IFNULL(NULL, 123) +123 +SELECT IFNULL('abc', 123); +IFNULL('abc', 123) +abc +SELECT ISNULL(NULL); +ISNULL(NULL) +1 +SELECT ISNULL(1); +ISNULL(1) +0 +SELECT ISNULL('a'); +ISNULL('a') +0 +SELECT NULLIF(1, 1); +NULLIF(1, 1) +NULL +SELECT NULLIF('abc', 'a'); +NULLIF('abc', 'a') +abc +SELECT NULLIF(1, 'abcd'); +NULLIF(1, 'abcd') +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abcd' +SELECT a, ISNULL(a) FROM t1; +a ISNULL(a) + 0 +a 0 +b 0 +c 0 +d 0 +SELECT b, ISNULL(b) FROM t1; +b ISNULL(b) +NULL 1 +12 0 +13 0 +14 0 +15 0 +SELECT c, ISNULL(c) FROM t1; +c ISNULL(c) +1990-01-01 00:00:00 0 +1212-12-12 00:00:00 0 +1313-03-13 13:13:13 0 +1414-04-14 00:00:00 0 +2015-05-15 15:15:15 0 +SELECT d, ISNULL(d) FROM t1; +d ISNULL(d) +NULL 1 +1.19691e100 0 +2.1961e18 0 +0.16191 0 +1.971917 0 +SELECT a, IFNULL(a, 'Null Char') FROM t1; +a IFNULL(a, 'Null Char') + +a a +b b +c c +d d +SELECT b, IFNULL(b, 'Null Integer') FROM t1; +b IFNULL(b, 'Null Integer') +NULL Null Integer +12 12 +13 13 +14 14 +15 15 +SELECT c, IFNULL(d, 'Null Decimal') FROM t1; +c IFNULL(d, 'Null Decimal') +1990-01-01 00:00:00 Null Decimal +1212-12-12 00:00:00 1.19691e100 +1313-03-13 13:13:13 2.1961e18 +1414-04-14 00:00:00 0.16191 +2015-05-15 15:15:15 1.971917 +SELECT a, NULLIF(a, 'c') FROM t1; +a NULLIF(a, 'c') + +a a +b b +c NULL +d d +SELECT b, NULLIF(b, 15) FROM t1; +b NULLIF(b, 15) +NULL NULL +12 12 +13 13 +14 14 +15 NULL +SELECT c, NULLIF(c, '2015-5-15') FROM t1; +c NULLIF(c, '2015-5-15') +1990-01-01 00:00:00 1990-01-01 00:00:00 +1212-12-12 00:00:00 1212-12-12 00:00:00 +1313-03-13 13:13:13 1313-03-13 13:13:13 +1414-04-14 00:00:00 1414-04-14 00:00:00 +2015-05-15 15:15:15 2015-05-15 15:15:15 +DROP DATABASE mcs171_db; diff --git a/mysql-test/suite/tianmu/t/AddDate_function.test b/mysql-test/suite/tianmu/t/AddDate_function.test new file mode 100644 index 000000000..f5605b1bb --- /dev/null +++ b/mysql-test/suite/tianmu/t/AddDate_function.test @@ -0,0 +1,32 @@ +--echo # +--echo # Test ADDDATE function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs178_db; +--enable_warnings + +CREATE DATABASE mcs178_db; +USE mcs178_db; + +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; + +SELECT ADDDATE('2020-02-02 22:22:22', 1); +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL 1 DAY); +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL 1 HOUR); +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL 1 MINUTE); +SELECT ADDDATE('2020-02-02 22:22:22', INTERVAL -1 SECOND); + +SELECT c, ADDDATE(c, 1) FROM t1; +SELECT c, ADDDATE(c, -2) FROM t1; +SELECT c, ADDDATE(c, INTERVAL -1 HOUR) FROM t1; +SELECT c, ADDDATE(c, INTERVAL 1 MINUTE) FROM t1; +SELECT c, ADDDATE(c, INTERVAL 1 SECOND) FROM t1; + +# Clean UP +DROP DATABASE mcs178_db; diff --git a/mysql-test/suite/tianmu/t/AddTime_function.test b/mysql-test/suite/tianmu/t/AddTime_function.test new file mode 100644 index 000000000..8439e683f --- /dev/null +++ b/mysql-test/suite/tianmu/t/AddTime_function.test @@ -0,0 +1,32 @@ +--echo # +--echo # Test ADDTIME function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs179_db; +--enable_warnings + +CREATE DATABASE mcs179_db; +USE mcs179_db; + +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; + +SELECT ADDTIME('2020-02-02 22:22:22', '2 1:1:1'); +SELECT ADDTIME('2020-02-02 22:22:22', '2:2:2.1111'); +SELECT ADDTIME('2020-02-02 22:22:22', '-2:2:2'); +SELECT ADDTIME('22:22:22', '03:11:22'); + +SELECT c, ADDTIME(c, '1 3:3:3') FROM t1; +SELECT c, ADDTIME(c, '-2 1:1:1') FROM t1; +SELECT c, ADDTIME(c, '100:11:12') FROM t1; +SELECT c, ADDTIME(c, '-100:11:12') FROM t1; +SELECT c, ADDTIME(c, '100:11') FROM t1; +SELECT c, ADDTIME(c, '100') FROM t1; + +# Clean UP +DROP DATABASE mcs179_db; diff --git a/mysql-test/suite/tianmu/t/case_function.test b/mysql-test/suite/tianmu/t/case_function.test new file mode 100644 index 000000000..d7b63b47d --- /dev/null +++ b/mysql-test/suite/tianmu/t/case_function.test @@ -0,0 +1,26 @@ +--echo # +--echo # Test CASE function +--echo # Author: syw +--echo # +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs174_db; +--enable_warnings + +CREATE DATABASE mcs174_db; +USE mcs174_db; + +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; + +SELECT b, c, (CASE WHEN a = 'b' THEN b ELSE c END) FROM t1; +SELECT b, a, (CASE WHEN b > 13 THEN b ELSE a END) FROM t1; +SELECT c, a, (CASE WHEN d > 1 THEN a ELSE c END) FROM t1; +SELECT a, c, (CASE WHEN c IS NULL THEN a ELSE c END) FROM t1; +SELECT (CASE WHEN a = 'a' THEN 0 ELSE 1 END) FROM t1; +SELECT (CASE WHEN 10 > 5 THEN 'True' ELSE 'False' END); + +# Clean UP +DROP DATABASE mcs174_db; diff --git a/mysql-test/suite/tianmu/t/char_length_function.test b/mysql-test/suite/tianmu/t/char_length_function.test new file mode 100644 index 000000000..aa0bc40f7 --- /dev/null +++ b/mysql-test/suite/tianmu/t/char_length_function.test @@ -0,0 +1,38 @@ +--echo # +--echo # Test CHAR_LENGTH function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs182_db; +--enable_warnings + +CREATE DATABASE mcs182_db; +USE mcs182_db; + +CREATE TABLE t1 (a VARCHAR(20))engine=tianmu; +INSERT INTO t1 VALUES (repeat('a', 5)), (repeat('b', 10)), (repeat('c', 20)); +SHOW CREATE TABLE t1; + +SELECT CHAR_LENGTH('MariaDB'); +SELECT CHAR_LENGTH(234); +SELECT CHAR_LENGTH('~12ab'); +SELECT CHAR_LENGTH('1212-12-12'); + +SELECT a, CHAR_LENGTH(a) FROM t1 ORDER BY a; +SELECT a, CHARACTER_LENGTH(a) FROM t1 ORDER BY a; + +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE)engine=tianmu; +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; + +SELECT a, CHARACTER_LENGTH(a) FROM t1 ORDER BY a; +SELECT b, CHARACTER_LENGTH(b) FROM t1 ORDER BY b; +SELECT c, CHARACTER_LENGTH(c) FROM t1 ORDER BY c; +SELECT d, CHARACTER_LENGTH(d) FROM t1 ORDER BY d; + +# Clean UP +DROP DATABASE mcs182_db; diff --git a/mysql-test/suite/tianmu/t/date_function.test b/mysql-test/suite/tianmu/t/date_function.test new file mode 100644 index 000000000..37043a803 --- /dev/null +++ b/mysql-test/suite/tianmu/t/date_function.test @@ -0,0 +1,26 @@ +--echo # +--echo # Test DATE function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs183_db; +--enable_warnings + +CREATE DATABASE mcs183_db; +USE mcs183_db; + +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-01-01', '1990-01-01 0:0:0'), ('1212-12-12', '1111-11-11 11:11:11'), ('3333-03-03', '3333-3-3 3:33:33'); +SHOW CREATE TABLE t1; + +SELECT DATE('1212-12-12 11:11:11'); +SELECT DATE('2020-12-22'); + +SELECT a, DATE(a) FROM t1 ORDER BY 1; +SELECT b, DATE(b) FROM t1 ORDER BY 1; + +# Clean UP +DROP DATABASE mcs183_db; diff --git a/mysql-test/suite/tianmu/t/day_function.test b/mysql-test/suite/tianmu/t/day_function.test new file mode 100644 index 000000000..973245ac0 --- /dev/null +++ b/mysql-test/suite/tianmu/t/day_function.test @@ -0,0 +1,26 @@ +--echo # +--echo # Test DAY function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs184_db; +--enable_warnings + +CREATE DATABASE mcs184_db; +USE mcs184_db; + +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1111-11-11 11:11:11'), ('3333-03-03', '3333-3-3 3:33:33'); +SHOW CREATE TABLE t1; + +SELECT DAY('1212-12-12 11:11:11'); +SELECT DAY('2020-12-22'); + +SELECT a, DAY(a) FROM t1 ORDER BY 1; +SELECT b, DAY(b) FROM t1 ORDER BY 1; + +# Clean UP +DROP DATABASE mcs184_db; diff --git a/mysql-test/suite/tianmu/t/null_functions.test b/mysql-test/suite/tianmu/t/null_functions.test new file mode 100644 index 000000000..0883545c5 --- /dev/null +++ b/mysql-test/suite/tianmu/t/null_functions.test @@ -0,0 +1,44 @@ +--echo # +--echo # Test NULLIF, IFNULL, ISNULL functions +--echo # Author: syw +--echo # +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs171_db; +--enable_warnings + +CREATE DATABASE mcs171_db; +USE mcs171_db; + +SET default_storage_engine=tianmu; + +CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE); +INSERT INTO t1 VALUES ('', NULL, '1990-01-01', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917); +SHOW CREATE TABLE t1; + +SELECT IFNULL(NULL, 'abc'); +SELECT IFNULL(NULL, 123); +SELECT IFNULL('abc', 123); +SELECT ISNULL(NULL); +SELECT ISNULL(1); +SELECT ISNULL('a'); +SELECT NULLIF(1, 1); +SELECT NULLIF('abc', 'a'); +SELECT NULLIF(1, 'abcd'); + +SELECT a, ISNULL(a) FROM t1; +SELECT b, ISNULL(b) FROM t1; +SELECT c, ISNULL(c) FROM t1; +SELECT d, ISNULL(d) FROM t1; + +SELECT a, IFNULL(a, 'Null Char') FROM t1; +SELECT b, IFNULL(b, 'Null Integer') FROM t1; +SELECT c, IFNULL(d, 'Null Decimal') FROM t1; + +SELECT a, NULLIF(a, 'c') FROM t1; +SELECT b, NULLIF(b, 15) FROM t1; +SELECT c, NULLIF(c, '2015-5-15') FROM t1; + +# Clean UP +DROP DATABASE mcs171_db; From 345f4dbd00db6cbd97e8217907a8d153be5f3839 Mon Sep 17 00:00:00 2001 From: shangyanwen <18392868125@163.com> Date: Wed, 26 Oct 2022 17:18:13 +0800 Subject: [PATCH 2/2] test(mtr):add xx_function.test(#497) --- mysql-test/suite/tianmu/r/avg_function.result | 26 ++++++++++ .../suite/tianmu/r/dayname_function.result | 32 +++++++++++++ .../suite/tianmu/r/dayofmonth_function.result | 32 +++++++++++++ .../suite/tianmu/r/dayofyear_function.result | 32 +++++++++++++ mysql-test/suite/tianmu/r/max_function.result | 26 ++++++++++ mysql-test/suite/tianmu/r/md5_function.result | 48 +++++++++++++++++++ mysql-test/suite/tianmu/r/min_function.result | 26 ++++++++++ mysql-test/suite/tianmu/r/sum_function.result | 26 ++++++++++ mysql-test/suite/tianmu/t/avg_function.test | 24 ++++++++++ .../suite/tianmu/t/dayname_function.test | 26 ++++++++++ .../suite/tianmu/t/dayofmonth_function.test | 26 ++++++++++ .../suite/tianmu/t/dayofyear_function.test | 26 ++++++++++ mysql-test/suite/tianmu/t/max_function.test | 24 ++++++++++ mysql-test/suite/tianmu/t/md5_function.test | 38 +++++++++++++++ mysql-test/suite/tianmu/t/min_function.test | 24 ++++++++++ mysql-test/suite/tianmu/t/sum_function.test | 24 ++++++++++ 16 files changed, 460 insertions(+) create mode 100644 mysql-test/suite/tianmu/r/avg_function.result create mode 100644 mysql-test/suite/tianmu/r/dayname_function.result create mode 100644 mysql-test/suite/tianmu/r/dayofmonth_function.result create mode 100644 mysql-test/suite/tianmu/r/dayofyear_function.result create mode 100644 mysql-test/suite/tianmu/r/max_function.result create mode 100644 mysql-test/suite/tianmu/r/md5_function.result create mode 100644 mysql-test/suite/tianmu/r/min_function.result create mode 100644 mysql-test/suite/tianmu/r/sum_function.result create mode 100644 mysql-test/suite/tianmu/t/avg_function.test create mode 100644 mysql-test/suite/tianmu/t/dayname_function.test create mode 100644 mysql-test/suite/tianmu/t/dayofmonth_function.test create mode 100644 mysql-test/suite/tianmu/t/dayofyear_function.test create mode 100644 mysql-test/suite/tianmu/t/max_function.test create mode 100644 mysql-test/suite/tianmu/t/md5_function.test create mode 100644 mysql-test/suite/tianmu/t/min_function.test create mode 100644 mysql-test/suite/tianmu/t/sum_function.test diff --git a/mysql-test/suite/tianmu/r/avg_function.result b/mysql-test/suite/tianmu/r/avg_function.result new file mode 100644 index 000000000..ce41ed9f2 --- /dev/null +++ b/mysql-test/suite/tianmu/r/avg_function.result @@ -0,0 +1,26 @@ +# +# Test AVG as distributed aggregate function +# Author: syw +# +DROP DATABASE IF EXISTS mcs188_db; +CREATE DATABASE mcs188_db; +USE mcs188_db; +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); +SELECT AVG(DISTINCT a) FROM t1; +AVG(DISTINCT a) +4.1667 +SELECT AVG(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +AVG(DISTINCT a) +2.6667 +SELECT b, AVG(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +b AVG(DISTINCT a) +eee 7.0000 +ddd 5.0000 +ccc 1.0000 +aaa 2.6667 + NULL +SELECT AVG(a) FROM t1; +AVG(a) +3.7143 +DROP DATABASE mcs188_db; diff --git a/mysql-test/suite/tianmu/r/dayname_function.result b/mysql-test/suite/tianmu/r/dayname_function.result new file mode 100644 index 000000000..83047cf92 --- /dev/null +++ b/mysql-test/suite/tianmu/r/dayname_function.result @@ -0,0 +1,32 @@ +# +# Test DAYNAME function +# Author: syw +# +DROP DATABASE IF EXISTS mcs185_db; +CREATE DATABASE mcs185_db; +USE mcs185_db; +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` date DEFAULT NULL, + `b` datetime DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT DAYNAME('1212-12-12 11:11:11'); +DAYNAME('1212-12-12 11:11:11') +Wednesday +SELECT DAYNAME('2020-12-22'); +DAYNAME('2020-12-22') +Tuesday +SELECT a, DAYNAME(a) FROM t1 ORDER BY 1; +a DAYNAME(a) +1212-12-12 Wednesday +1990-10-10 Wednesday +3333-03-03 Tuesday +SELECT b, DAYNAME(b) FROM t1 ORDER BY 1; +b DAYNAME(b) +1212-12-11 11:11:11 Tuesday +1990-10-10 00:00:00 Wednesday +3333-03-04 03:33:33 Wednesday +DROP DATABASE mcs185_db; diff --git a/mysql-test/suite/tianmu/r/dayofmonth_function.result b/mysql-test/suite/tianmu/r/dayofmonth_function.result new file mode 100644 index 000000000..9e7110f05 --- /dev/null +++ b/mysql-test/suite/tianmu/r/dayofmonth_function.result @@ -0,0 +1,32 @@ +# +# Test DAYOFMONTH function +# Author: syw +# +DROP DATABASE IF EXISTS mcs187_db; +CREATE DATABASE mcs187_db; +USE mcs187_db; +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-01-01 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` date DEFAULT NULL, + `b` datetime DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT DAYOFMONTH('1212-12-12 11:11:11'); +DAYOFMONTH('1212-12-12 11:11:11') +12 +SELECT DAYOFMONTH('2020-12-22'); +DAYOFMONTH('2020-12-22') +22 +SELECT a, DAYOFMONTH(a) FROM t1 ORDER BY 1; +a DAYOFMONTH(a) +1212-12-12 12 +1990-10-10 10 +3333-03-03 3 +SELECT b, DAYOFMONTH(b) FROM t1 ORDER BY 1; +b DAYOFMONTH(b) +1212-12-11 11:11:11 11 +1990-01-01 00:00:00 1 +3333-03-04 03:33:33 4 +DROP DATABASE mcs187_db; diff --git a/mysql-test/suite/tianmu/r/dayofyear_function.result b/mysql-test/suite/tianmu/r/dayofyear_function.result new file mode 100644 index 000000000..644eb1e8b --- /dev/null +++ b/mysql-test/suite/tianmu/r/dayofyear_function.result @@ -0,0 +1,32 @@ +# +# Test DAYOFYEAR function +# Author: syw +# +DROP DATABASE IF EXISTS mcs186_db; +CREATE DATABASE mcs186_db; +USE mcs186_db; +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` date DEFAULT NULL, + `b` datetime DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +SELECT DAYOFYEAR('1212-12-12 11:11:11'); +DAYOFYEAR('1212-12-12 11:11:11') +347 +SELECT DAYOFYEAR('2020-12-22'); +DAYOFYEAR('2020-12-22') +357 +SELECT a, DAYOFYEAR(a) FROM t1 ORDER BY 1; +a DAYOFYEAR(a) +1212-12-12 347 +1990-10-10 283 +3333-03-03 62 +SELECT b, DAYOFYEAR(b) FROM t1 ORDER BY 1; +b DAYOFYEAR(b) +1212-12-11 11:11:11 346 +1990-10-10 00:00:00 283 +3333-03-04 03:33:33 63 +DROP DATABASE mcs186_db; diff --git a/mysql-test/suite/tianmu/r/max_function.result b/mysql-test/suite/tianmu/r/max_function.result new file mode 100644 index 000000000..cf97c66f3 --- /dev/null +++ b/mysql-test/suite/tianmu/r/max_function.result @@ -0,0 +1,26 @@ +# +# Test MAX as distributed aggregate function +# Author: syw +# +DROP DATABASE IF EXISTS mcs190_db; +CREATE DATABASE mcs190_db; +USE mcs190_db; +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); +SELECT MAX(DISTINCT a) FROM t1; +MAX(DISTINCT a) +7 +SELECT MAX(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +MAX(DISTINCT a) +5 +SELECT b, MAX(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +b MAX(DISTINCT a) +eee 7 +ddd 6 +ccc 1 +aaa 5 + NULL +SELECT MAX(a) FROM t1; +MAX(a) +7 +DROP DATABASE mcs190_db; diff --git a/mysql-test/suite/tianmu/r/md5_function.result b/mysql-test/suite/tianmu/r/md5_function.result new file mode 100644 index 000000000..7f27eae54 --- /dev/null +++ b/mysql-test/suite/tianmu/r/md5_function.result @@ -0,0 +1,48 @@ +# +# Test MD5() function +# Author: syw +# +DROP DATABASE IF EXISTS mcs218_db; +CREATE DATABASE mcs218_db; +USE mcs218_db; +CREATE TABLE t1 +( +t1_BIGINT BIGINT, +t1_DOUBLE DOUBLE, +t1_FLOAT FLOAT, +t1_BLOB BLOB, +t1_TEXT TEXT, +t1_CHAR_1 CHAR(1), +t1_DATETIME DATETIME +)ENGINE=tianmu; +INSERT INTO t1 VALUES(NULL, NULL, NULL, '', '', '', '1990-10-01'); +INSERT INTO t1 VALUES(203685477580676, -3.797693231E+108, -7.402866E+18, repeat('b',10), repeat('b',10), 'b', '2387-11-08 11:22:30.123'); +SELECT t1_BIGINT, MD5(t1_BIGINT) FROM t1 ORDER BY t1_BIGINT; +t1_BIGINT MD5(t1_BIGINT) +NULL NULL +203685477580676 9e05a00575dbbdb0e9c03d479cea5eb9 +SELECT t1_DOUBLE, MD5(t1_DOUBLE) FROM t1 ORDER BY t1_DOUBLE; +t1_DOUBLE MD5(t1_DOUBLE) +NULL NULL +-3.797693231e108 bba02430bfe020a8d8ddffaff6b04004 +SELECT t1_FLOAT, MD5(t1_FLOAT) FROM t1 ORDER BY t1_FLOAT; +t1_FLOAT MD5(t1_FLOAT) +NULL NULL +-7.40287e18 c779664c54f557edbb5360386ff7d8b4 +SELECT t1_TEXT, MD5(t1_TEXT) FROM t1 ORDER BY t1_TEXT; +t1_TEXT MD5(t1_TEXT) + d41d8cd98f00b204e9800998ecf8427e +bbbbbbbbbb 82136b4240d6ce4ea7d03e51469a393b +SELECT t1_CHAR_1, MD5(t1_CHAR_1) FROM t1 ORDER BY t1_CHAR_1; +t1_CHAR_1 MD5(t1_CHAR_1) + d41d8cd98f00b204e9800998ecf8427e +b 92eb5ffee6ae2fec3ad71c777531578f +SELECT t1_DATETIME, MD5(t1_DATETIME) FROM t1 ORDER BY t1_DATETIME; +t1_DATETIME MD5(t1_DATETIME) +1990-10-01 00:00:00 626bab9c604a72a1959951119b91c8b2 +2387-11-08 11:22:30 9cf01b3f830ff29aa3f394fd54ea5a23 +SELECT t1_DATETIME FROM t1 WHERE MD5(t1_DATETIME) <> 0 ORDER BY t1_DATETIME; +t1_DATETIME +1990-10-01 00:00:00 +2387-11-08 11:22:30 +DROP DATABASE mcs218_db; diff --git a/mysql-test/suite/tianmu/r/min_function.result b/mysql-test/suite/tianmu/r/min_function.result new file mode 100644 index 000000000..e8704c38d --- /dev/null +++ b/mysql-test/suite/tianmu/r/min_function.result @@ -0,0 +1,26 @@ +# +# Test MIN as distributed aggregate function +# Author: syw +# +DROP DATABASE IF EXISTS mcs191_db; +CREATE DATABASE mcs191_db; +USE mcs191_db; +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); +SELECT MIN(DISTINCT a) FROM t1; +MIN(DISTINCT a) +1 +SELECT MIN(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +MIN(DISTINCT a) +1 +SELECT b, MIN(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +b MIN(DISTINCT a) +eee 7 +ddd 4 +ccc 1 +aaa 1 + NULL +SELECT MIN(a) FROM t1; +MIN(a) +1 +DROP DATABASE mcs191_db; diff --git a/mysql-test/suite/tianmu/r/sum_function.result b/mysql-test/suite/tianmu/r/sum_function.result new file mode 100644 index 000000000..34cd2d9f4 --- /dev/null +++ b/mysql-test/suite/tianmu/r/sum_function.result @@ -0,0 +1,26 @@ +# +# Test SUM as distributed aggregate function +# Author: syw +# +DROP DATABASE IF EXISTS mcs189_db; +CREATE DATABASE mcs189_db; +USE mcs189_db; +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); +SELECT SUM(DISTINCT a) FROM t1; +SUM(DISTINCT a) +25 +SELECT SUM(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +SUM(DISTINCT a) +8 +SELECT b, SUM(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +b SUM(DISTINCT a) +eee 7 +ddd 10 +ccc 1 +aaa 8 + NULL +SELECT SUM(a) FROM t1; +SUM(a) +26 +DROP DATABASE mcs189_db; diff --git a/mysql-test/suite/tianmu/t/avg_function.test b/mysql-test/suite/tianmu/t/avg_function.test new file mode 100644 index 000000000..5648004b1 --- /dev/null +++ b/mysql-test/suite/tianmu/t/avg_function.test @@ -0,0 +1,24 @@ +--echo # +--echo # Test AVG as distributed aggregate function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs188_db; +--enable_warnings + +CREATE DATABASE mcs188_db; +USE mcs188_db; + +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); + +SELECT AVG(DISTINCT a) FROM t1; +SELECT AVG(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +SELECT b, AVG(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +SELECT AVG(a) FROM t1; + +# Clean UP +DROP DATABASE mcs188_db; diff --git a/mysql-test/suite/tianmu/t/dayname_function.test b/mysql-test/suite/tianmu/t/dayname_function.test new file mode 100644 index 000000000..5e9fc815f --- /dev/null +++ b/mysql-test/suite/tianmu/t/dayname_function.test @@ -0,0 +1,26 @@ +--echo # +--echo # Test DAYNAME function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs185_db; +--enable_warnings + +CREATE DATABASE mcs185_db; +USE mcs185_db; + +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); +SHOW CREATE TABLE t1; + +SELECT DAYNAME('1212-12-12 11:11:11'); +SELECT DAYNAME('2020-12-22'); + +SELECT a, DAYNAME(a) FROM t1 ORDER BY 1; +SELECT b, DAYNAME(b) FROM t1 ORDER BY 1; + +# Clean UP +DROP DATABASE mcs185_db; diff --git a/mysql-test/suite/tianmu/t/dayofmonth_function.test b/mysql-test/suite/tianmu/t/dayofmonth_function.test new file mode 100644 index 000000000..ff951fbed --- /dev/null +++ b/mysql-test/suite/tianmu/t/dayofmonth_function.test @@ -0,0 +1,26 @@ +--echo # +--echo # Test DAYOFMONTH function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs187_db; +--enable_warnings + +CREATE DATABASE mcs187_db; +USE mcs187_db; + +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-01-01 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); +SHOW CREATE TABLE t1; + +SELECT DAYOFMONTH('1212-12-12 11:11:11'); +SELECT DAYOFMONTH('2020-12-22'); + +SELECT a, DAYOFMONTH(a) FROM t1 ORDER BY 1; +SELECT b, DAYOFMONTH(b) FROM t1 ORDER BY 1; + +# Clean UP +DROP DATABASE mcs187_db; diff --git a/mysql-test/suite/tianmu/t/dayofyear_function.test b/mysql-test/suite/tianmu/t/dayofyear_function.test new file mode 100644 index 000000000..e1d6ed48a --- /dev/null +++ b/mysql-test/suite/tianmu/t/dayofyear_function.test @@ -0,0 +1,26 @@ +--echo # +--echo # Test DAYOFYEAR function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs186_db; +--enable_warnings + +CREATE DATABASE mcs186_db; +USE mcs186_db; + +CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; +INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); +SHOW CREATE TABLE t1; + +SELECT DAYOFYEAR('1212-12-12 11:11:11'); +SELECT DAYOFYEAR('2020-12-22'); + +SELECT a, DAYOFYEAR(a) FROM t1 ORDER BY 1; +SELECT b, DAYOFYEAR(b) FROM t1 ORDER BY 1; + +# Clean UP +DROP DATABASE mcs186_db; diff --git a/mysql-test/suite/tianmu/t/max_function.test b/mysql-test/suite/tianmu/t/max_function.test new file mode 100644 index 000000000..d8c7c500c --- /dev/null +++ b/mysql-test/suite/tianmu/t/max_function.test @@ -0,0 +1,24 @@ +--echo # +--echo # Test MAX as distributed aggregate function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs190_db; +--enable_warnings + +CREATE DATABASE mcs190_db; +USE mcs190_db; + +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); + +SELECT MAX(DISTINCT a) FROM t1; +SELECT MAX(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +SELECT b, MAX(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +SELECT MAX(a) FROM t1; + +# Clean UP +DROP DATABASE mcs190_db; diff --git a/mysql-test/suite/tianmu/t/md5_function.test b/mysql-test/suite/tianmu/t/md5_function.test new file mode 100644 index 000000000..2829ccba2 --- /dev/null +++ b/mysql-test/suite/tianmu/t/md5_function.test @@ -0,0 +1,38 @@ +--echo # +--echo # Test MD5() function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs218_db; +--enable_warnings + +CREATE DATABASE mcs218_db; +USE mcs218_db; + +CREATE TABLE t1 +( + t1_BIGINT BIGINT, + t1_DOUBLE DOUBLE, + t1_FLOAT FLOAT, + t1_BLOB BLOB, + t1_TEXT TEXT, + t1_CHAR_1 CHAR(1), + t1_DATETIME DATETIME + )ENGINE=tianmu; + +INSERT INTO t1 VALUES(NULL, NULL, NULL, '', '', '', '1990-10-01'); +INSERT INTO t1 VALUES(203685477580676, -3.797693231E+108, -7.402866E+18, repeat('b',10), repeat('b',10), 'b', '2387-11-08 11:22:30.123'); + +SELECT t1_BIGINT, MD5(t1_BIGINT) FROM t1 ORDER BY t1_BIGINT; +SELECT t1_DOUBLE, MD5(t1_DOUBLE) FROM t1 ORDER BY t1_DOUBLE; +SELECT t1_FLOAT, MD5(t1_FLOAT) FROM t1 ORDER BY t1_FLOAT; +SELECT t1_TEXT, MD5(t1_TEXT) FROM t1 ORDER BY t1_TEXT; +SELECT t1_CHAR_1, MD5(t1_CHAR_1) FROM t1 ORDER BY t1_CHAR_1; +SELECT t1_DATETIME, MD5(t1_DATETIME) FROM t1 ORDER BY t1_DATETIME; +SELECT t1_DATETIME FROM t1 WHERE MD5(t1_DATETIME) <> 0 ORDER BY t1_DATETIME; + +# Clean UP +DROP DATABASE mcs218_db; diff --git a/mysql-test/suite/tianmu/t/min_function.test b/mysql-test/suite/tianmu/t/min_function.test new file mode 100644 index 000000000..9eb4e789a --- /dev/null +++ b/mysql-test/suite/tianmu/t/min_function.test @@ -0,0 +1,24 @@ +--echo # +--echo # Test MIN as distributed aggregate function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs191_db; +--enable_warnings + +CREATE DATABASE mcs191_db; +USE mcs191_db; + +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); + +SELECT MIN(DISTINCT a) FROM t1; +SELECT MIN(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +SELECT b, MIN(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +SELECT MIN(a) FROM t1; + +# Clean UP +DROP DATABASE mcs191_db; diff --git a/mysql-test/suite/tianmu/t/sum_function.test b/mysql-test/suite/tianmu/t/sum_function.test new file mode 100644 index 000000000..9c9faa1c1 --- /dev/null +++ b/mysql-test/suite/tianmu/t/sum_function.test @@ -0,0 +1,24 @@ +--echo # +--echo # Test SUM as distributed aggregate function +--echo # Author: syw +--echo # + +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS mcs189_db; +--enable_warnings + +CREATE DATABASE mcs189_db; +USE mcs189_db; + +CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; +INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); + +SELECT SUM(DISTINCT a) FROM t1; +SELECT SUM(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; +SELECT b, SUM(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; +SELECT SUM(a) FROM t1; + +# Clean UP +DROP DATABASE mcs189_db;