-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(mtr):add cast_data_types.result and time_function.test(#497)
- Loading branch information
1 parent
bfb68a0
commit 782f249
Showing
4 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# | ||
# CAST Data types | ||
# Author: ysw | ||
# | ||
DROP DATABASE IF EXISTS cast_data_types; | ||
CREATE DATABASE cast_data_types; | ||
USE cast_data_types; | ||
CREATE TABLE t1(t1_int INT, t1_decimal DECIMAL(5,3), t1_char CHAR(10), t1_text TEXT, t1_varchar VARCHAR(50))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES(NULL, NULL, '', '', ''); | ||
INSERT INTO t1 VALUES(512762, 86.722, 'A', repeat('a',50), repeat('b',50)); | ||
INSERT INTO t1 VALUES(-512762, -86.722, '123456', repeat('1',50), repeat('2',50)); | ||
SELECT * FROM t1; | ||
t1_int t1_decimal t1_char t1_text t1_varchar | ||
NULL NULL | ||
512762 86.722 A aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
-512762 -86.722 123456 11111111111111111111111111111111111111111111111111 22222222222222222222222222222222222222222222222222 | ||
SELECT CAST(t1_int AS SIGNED), CAST(t1_decimal AS SIGNED), CAST(t1_char AS SIGNED), CAST(t1_text AS SIGNED), CAST(t1_varchar AS SIGNED) FROM t1; | ||
CAST(t1_int AS SIGNED) CAST(t1_decimal AS SIGNED) CAST(t1_char AS SIGNED) CAST(t1_text AS SIGNED) CAST(t1_varchar AS SIGNED) | ||
NULL NULL 0 0 0 | ||
512762 87 0 0 0 | ||
-512762 -87 123456 -1 -1 | ||
Warnings: | ||
Warning 1292 Truncated incorrect INTEGER value: '' | ||
Warning 1292 Truncated incorrect INTEGER value: '' | ||
Warning 1292 Truncated incorrect INTEGER value: '' | ||
Warning 1292 Truncated incorrect INTEGER value: 'A' | ||
Warning 1292 Truncated incorrect INTEGER value: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' | ||
Warning 1292 Truncated incorrect INTEGER value: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' | ||
Warning 1292 Truncated incorrect INTEGER value: '11111111111111111111111111111111111111111111111111' | ||
Warning 1292 Truncated incorrect INTEGER value: '22222222222222222222222222222222222222222222222222' | ||
SELECT CAST(t1_int AS CHAR(10)), CAST(t1_decimal AS CHAR(10)), CAST(t1_char AS CHAR(10)), CAST(t1_text AS CHAR(10)), CAST(t1_varchar AS CHAR(10)) FROM t1; | ||
CAST(t1_int AS CHAR(10)) CAST(t1_decimal AS CHAR(10)) CAST(t1_char AS CHAR(10)) CAST(t1_text AS CHAR(10)) CAST(t1_varchar AS CHAR(10)) | ||
NULL NULL | ||
512762 86.722 A aaaaaaaaaa bbbbbbbbbb | ||
-512762 -86.722 123456 1111111111 2222222222 | ||
Warnings: | ||
Warning 1292 Truncated incorrect CHAR(10) value: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' | ||
Warning 1292 Truncated incorrect CHAR(10) value: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' | ||
Warning 1292 Truncated incorrect CHAR(10) value: '11111111111111111111111111111111111111111111111111' | ||
Warning 1292 Truncated incorrect CHAR(10) value: '22222222222222222222222222222222222222222222222222' | ||
SELECT CAST(t1_int AS DECIMAL(6,5)), CAST(t1_decimal AS DECIMAL(6,5)), CAST(t1_char AS DECIMAL(6,5)), CAST(t1_text AS DECIMAL(6,5)), CAST(t1_varchar AS DECIMAL(6,5)) FROM t1; | ||
CAST(t1_int AS DECIMAL(6,5)) CAST(t1_decimal AS DECIMAL(6,5)) CAST(t1_char AS DECIMAL(6,5)) CAST(t1_text AS DECIMAL(6,5)) CAST(t1_varchar AS DECIMAL(6,5)) | ||
NULL NULL 0.00000 0.00000 0.00000 | ||
9.99999 9.99999 0.00000 0.00000 0.00000 | ||
-9.99999 -9.99999 9.99999 9.99999 9.99999 | ||
Warnings: | ||
Warning 1292 Truncated incorrect DECIMAL value: '' | ||
Warning 1292 Truncated incorrect DECIMAL value: '' | ||
Warning 1292 Truncated incorrect DECIMAL value: '' | ||
Warning 1264 Out of range value for column 'CAST(t1_int AS DECIMAL(6,5))' at row 1 | ||
Warning 1264 Out of range value for column 'CAST(t1_decimal AS DECIMAL(6,5))' at row 1 | ||
Warning 1292 Truncated incorrect DECIMAL value: 'A' | ||
Warning 1292 Truncated incorrect DECIMAL value: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' | ||
Warning 1292 Truncated incorrect DECIMAL value: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' | ||
Warning 1264 Out of range value for column 'CAST(t1_int AS DECIMAL(6,5))' at row 1 | ||
Warning 1264 Out of range value for column 'CAST(t1_decimal AS DECIMAL(6,5))' at row 1 | ||
Warning 1264 Out of range value for column 'CAST(t1_char AS DECIMAL(6,5))' at row 1 | ||
Warning 1264 Out of range value for column 'CAST(t1_text AS DECIMAL(6,5))' at row 1 | ||
Warning 1264 Out of range value for column 'CAST(t1_varchar AS DECIMAL(6,5))' at row 1 | ||
SELECT CAST(t1_int AS DECIMAL(4,5)) FROM t1; | ||
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column ''). | ||
SELECT CAST(t1_int AS DECIMAL(66,6)) FROM t1; | ||
ERROR 42000: Too-big precision 66 specified for 't1_int'. Maximum is 65. | ||
SELECT CAST(t1_int AS DECIMAL(64,63)) FROM t1; | ||
ERROR 42000: Too big scale 63 specified for column 't1_int'. Maximum is 30. | ||
DROP DATABASE cast_data_types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# TIME() function | ||
# Author: ysw | ||
# | ||
DROP DATABASE IF EXISTS time_function; | ||
CREATE DATABASE time_function; | ||
USE time_function; | ||
CREATE TABLE t1 | ||
( | ||
t1_DATE DATE, | ||
t1_TIME TIME, | ||
t1_DATETIME DATETIME | ||
)ENGINE=tianmu; | ||
INSERT INTO t1 VALUES('1560-08-27', '22:12:02', '1997-12-12 22:12:02'); | ||
INSERT INTO t1 VALUES('1982-02-19', '23:59:59', '2001-1-1 23:59:59.65'); | ||
INSERT INTO t1 VALUES('3291-05-30', '01:37:50.871', '09-12-11 01:08:59'); | ||
SELECT TIME('112233') FROM t1 LIMIT 1; | ||
TIME('112233') | ||
11:22:33 | ||
SELECT TIME('11:22:33.4455') FROM t1 LIMIT 1; | ||
TIME('11:22:33.4455') | ||
11:22:33.0000 | ||
SELECT TIME('1811/2/2 3:34:45.5') FROM t1 LIMIT 1; | ||
TIME('1811/2/2 3:34:45.5') | ||
03:34:45.0 | ||
SELECT TIME('1811/2/2') FROM t1 LIMIT 1; | ||
TIME('1811/2/2') | ||
00:18:11 | ||
Warnings: | ||
Warning 1292 Truncated incorrect time value: '1811/2/2' | ||
SELECT t1_DATE, TIME(t1_DATE) FROM t1 ORDER BY 1; | ||
t1_DATE TIME(t1_DATE) | ||
1560-08-27 00:00:00 | ||
1982-02-19 00:00:00 | ||
3291-05-30 00:00:00 | ||
SELECT t1_TIME, TIME(t1_TIME) FROM t1 ORDER BY 1; | ||
t1_TIME TIME(t1_TIME) | ||
01:37:51 01:37:51 | ||
22:12:02 22:12:02 | ||
23:59:59 23:59:59 | ||
SELECT t1_DATETIME, TIME(t1_DATETIME) FROM t1 ORDER BY 1; | ||
t1_DATETIME TIME(t1_DATETIME) | ||
1997-12-12 22:12:02 22:12:02 | ||
2001-01-02 00:00:00 00:00:00 | ||
2009-12-11 01:08:59 01:08:59 | ||
DROP DATABASE time_function; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--echo # | ||
--echo # CAST Data types | ||
--echo # Author: ysw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS cast_data_types; | ||
--enable_warnings | ||
|
||
CREATE DATABASE cast_data_types; | ||
USE cast_data_types; | ||
|
||
CREATE TABLE t1(t1_int INT, t1_decimal DECIMAL(5,3), t1_char CHAR(10), t1_text TEXT, t1_varchar VARCHAR(50))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES(NULL, NULL, '', '', ''); | ||
INSERT INTO t1 VALUES(512762, 86.722, 'A', repeat('a',50), repeat('b',50)); | ||
INSERT INTO t1 VALUES(-512762, -86.722, '123456', repeat('1',50), repeat('2',50)); | ||
|
||
SELECT * FROM t1; | ||
SELECT CAST(t1_int AS SIGNED), CAST(t1_decimal AS SIGNED), CAST(t1_char AS SIGNED), CAST(t1_text AS SIGNED), CAST(t1_varchar AS SIGNED) FROM t1; | ||
#UNSIGNED:stonedb is not supported, to be released after support(2022-10-26) | ||
#SELECT CAST(t1_int AS UNSIGNED), CAST(t1_decimal AS UNSIGNED), CAST(t1_char AS UNSIGNED), CAST(t1_text AS UNSIGNED), CAST(t1_varchar AS UNSIGNED) FROM t1; | ||
SELECT CAST(t1_int AS CHAR(10)), CAST(t1_decimal AS CHAR(10)), CAST(t1_char AS CHAR(10)), CAST(t1_text AS CHAR(10)), CAST(t1_varchar AS CHAR(10)) FROM t1; | ||
SELECT CAST(t1_int AS DECIMAL(6,5)), CAST(t1_decimal AS DECIMAL(6,5)), CAST(t1_char AS DECIMAL(6,5)), CAST(t1_text AS DECIMAL(6,5)), CAST(t1_varchar AS DECIMAL(6,5)) FROM t1; | ||
|
||
--error ER_M_BIGGER_THAN_D | ||
SELECT CAST(t1_int AS DECIMAL(4,5)) FROM t1; | ||
--error ER_TOO_BIG_PRECISION | ||
SELECT CAST(t1_int AS DECIMAL(66,6)) FROM t1; | ||
--error ER_TOO_BIG_SCALE | ||
SELECT CAST(t1_int AS DECIMAL(64,63)) FROM t1; | ||
|
||
# Clean UP | ||
DROP DATABASE cast_data_types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--echo # | ||
--echo # TIME() function | ||
--echo # Author: ysw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS time_function; | ||
--enable_warnings | ||
|
||
CREATE DATABASE time_function; | ||
USE time_function; | ||
|
||
CREATE TABLE t1 | ||
( | ||
t1_DATE DATE, | ||
t1_TIME TIME, | ||
t1_DATETIME DATETIME | ||
)ENGINE=tianmu; | ||
INSERT INTO t1 VALUES('1560-08-27', '22:12:02', '1997-12-12 22:12:02'); | ||
INSERT INTO t1 VALUES('1982-02-19', '23:59:59', '2001-1-1 23:59:59.65'); | ||
INSERT INTO t1 VALUES('3291-05-30', '01:37:50.871', '09-12-11 01:08:59'); | ||
|
||
SELECT TIME('112233') FROM t1 LIMIT 1; | ||
SELECT TIME('11:22:33.4455') FROM t1 LIMIT 1; | ||
SELECT TIME('1811/2/2 3:34:45.5') FROM t1 LIMIT 1; | ||
SELECT TIME('1811/2/2') FROM t1 LIMIT 1; | ||
|
||
SELECT t1_DATE, TIME(t1_DATE) FROM t1 ORDER BY 1; | ||
SELECT t1_TIME, TIME(t1_TIME) FROM t1 ORDER BY 1; | ||
SELECT t1_DATETIME, TIME(t1_DATETIME) FROM t1 ORDER BY 1; | ||
|
||
# Clean UP | ||
DROP DATABASE time_function; |