Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(mtr):add function testcase(#497) #828

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions mysql-test/suite/tianmu/r/hour_function.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# HOUR() function
# Author: syw
#
DROP DATABASE IF EXISTS hour_function;
CREATE DATABASE hour_function;
USE hour_function;
CREATE TABLE t1
(
t1_DATE DATE,
t1_TIME TIME,
t1_DATETIME DATETIME
)ENGINE=tianmu;
INSERT INTO t1 VALUES('1991-05-30', '01:00:50', '2020-12-11 06:08:59');
INSERT INTO t1 VALUES('2991-10-13', '21:19:52', '1987-01-01 17:28:37');
SELECT HOUR('2020-02-21') FROM t1 LIMIT 1;
HOUR('2020-02-21')
0
Warnings:
Warning 1292 Truncated incorrect time value: '2020-02-21'
SELECT HOUR('11:12:13') FROM t1 LIMIT 1;
HOUR('11:12:13')
11
SELECT HOUR('2020/02/11 13:12:13') FROM t1 LIMIT 1;
HOUR('2020/02/11 13:12:13')
13
SELECT t1_DATE, HOUR(t1_DATE) FROM t1 ORDER BY 1;
t1_DATE HOUR(t1_DATE)
1991-05-30 0
2991-10-13 0
SELECT t1_DATETIME, HOUR(t1_DATETIME) FROM t1 ORDER BY 1;
t1_DATETIME HOUR(t1_DATETIME)
1987-01-01 17:28:37 17
2020-12-11 06:08:59 6
SELECT t1_TIME, HOUR(t1_TIME) FROM t1 ORDER BY 1;
t1_TIME HOUR(t1_TIME)
01:00:50 1
21:19:52 21
DROP DATABASE hour_function;
17 changes: 17 additions & 0 deletions mysql-test/suite/tianmu/r/insert_on_duplicate_update.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Test INSERT ON DUPLICATE KEY UPDATE statement
# Author: syw
#
DROP DATABASE IF EXISTS insert_on_duplicate_update;
CREATE DATABASE insert_on_duplicate_update;
USE insert_on_duplicate_update;
CREATE TABLE t1(
c1 INT primary key not null,
c2 CHAR(5)
) ENGINE=tianmu;
INSERT INTO t1 VALUES (123, 'abc');
INSERT INTO t1 VALUES (123, 'abc') ON DUPLICATE KEY UPDATE c1 = VALUES(c1) + 1;
SELECT * FROM t1;
c1 c2
124 abc
DROP DATABASE insert_on_duplicate_update;
37 changes: 37 additions & 0 deletions mysql-test/suite/tianmu/r/last_day_function.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# LAST_DAY() function
# Author: syw
#
DROP DATABASE IF EXISTS lastday_function;
CREATE DATABASE lastday_function;
USE lastday_function;
CREATE TABLE t1
(
t1_DATE DATE,
t1_TIMESTAMP TIMESTAMP,
t1_DATETIME DATETIME
)ENGINE=tianmu;
INSERT INTO t1 VALUES('1991-05-30', '1999-10-28 01:00:50', '2020-12-11 01:08:59');
INSERT INTO t1 VALUES('2991-10-13', '1972-11-22 11:19:52', '1987-01-01 05:28:37');
SELECT LAST_DAY('2020-02-21') FROM t1 LIMIT 1;
LAST_DAY('2020-02-21')
2020-02-29
SELECT LAST_DAY('11:12:13') FROM t1 LIMIT 1;
LAST_DAY('11:12:13')
2011-12-31
SELECT LAST_DAY('2020/02/11 11:12:13') FROM t1 LIMIT 1;
LAST_DAY('2020/02/11 11:12:13')
2020-02-29
SELECT t1_DATE, LAST_DAY(t1_DATE) FROM t1 ORDER BY 1;
t1_DATE LAST_DAY(t1_DATE)
1991-05-30 1991-05-31
2991-10-13 2991-10-31
SELECT t1_DATETIME, LAST_DAY(t1_DATETIME) FROM t1 ORDER BY 1;
t1_DATETIME LAST_DAY(t1_DATETIME)
1987-01-01 05:28:37 1987-01-31
2020-12-11 01:08:59 2020-12-31
SELECT t1_TIMESTAMP, LAST_DAY(t1_TIMESTAMP) FROM t1 ORDER BY 1;
t1_TIMESTAMP LAST_DAY(t1_TIMESTAMP)
1972-11-22 11:19:52 1972-11-30
1999-10-28 01:00:50 1999-10-31
DROP DATABASE lastday_function;
49 changes: 49 additions & 0 deletions mysql-test/suite/tianmu/r/left_function.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# LEFT() function
# Author: syw
#
DROP DATABASE IF EXISTS left_function;
CREATE DATABASE left_function;
USE left_function;
CREATE TABLE t1 (a INT, b CHAR(15))ENGINE=tianmu;
INSERT INTO t1 VALUES (NULL, ''),(1, 'tianmu22222'),(2, 'tianmu'),(3, 'Innodb');
SELECT LEFT('tianmu22222 cs', 7) FROM t1 LIMIT 1;
LEFT('tianmu22222 cs', 7)
tianmu2
SELECT LEFT('tianmu22222 cs', 8) FROM t1 LIMIT 1;
LEFT('tianmu22222 cs', 8)
tianmu22
SELECT LEFT('tianmu22222 cs', 9) FROM t1 LIMIT 1;
LEFT('tianmu22222 cs', 9)
tianmu222
SELECT b, LEFT(b, 0) FROM t1 ORDER BY 1;
b LEFT(b, 0)

Innodb
tianmu
tianmu22222
SELECT b, LEFT(b, -1) FROM t1 ORDER BY 1;
b LEFT(b, -1)

Innodb
tianmu
tianmu22222
SELECT b, LEFT(b, 6) FROM t1 ORDER BY 1;
b LEFT(b, 6)

Innodb Innodb
tianmu tianmu
tianmu22222 tianmu
SELECT b, LEFT(b, 9) FROM t1 ORDER BY 1;
b LEFT(b, 9)

Innodb Innodb
tianmu tianmu
tianmu22222 tianmu222
SELECT b, LEFT(concat('mmm_', b), 10) FROM t1 ORDER BY 1;
b LEFT(concat('mmm_', b), 10)
mmm_
Innodb mmm_Innodb
tianmu mmm_tianmu
tianmu22222 mmm_tianmu
DROP DATABASE left_function;
80 changes: 80 additions & 0 deletions mysql-test/suite/tianmu/r/mid_function.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#
# Test MID() function
# Author: ysw
#
DROP DATABASE IF EXISTS mid_function;
CREATE DATABASE mid_function;
USE mid_function;
CREATE TABLE t1 (a INT, b CHAR(35))ENGINE=tianmu;
INSERT INTO t1 VALUES (NULL, ''),(1, 'tianmu engine'),(2, 'tianmu database');
SELECT b, MID(b,4,5) FROM t1;
b MID(b,4,5)

tianmu engine nmu e
tianmu database nmu d
SELECT b, MID(b,12,5) FROM t1;
b MID(b,12,5)

tianmu engine ne
tianmu database base
SELECT b, MID(b,5,15) FROM t1;
b MID(b,5,15)

tianmu engine mu engine
tianmu database mu database
SELECT b, MID(b,12,15) FROM t1;
b MID(b,12,15)

tianmu engine ne
tianmu database base
SELECT b, MID(b,1,1) FROM t1;
b MID(b,1,1)

tianmu engine t
tianmu database t
SELECT b, MID(b,1,2) FROM t1;
b MID(b,1,2)

tianmu engine ti
tianmu database ti
SELECT b, MID(b,5,5) FROM t1;
b MID(b,5,5)

tianmu engine mu en
tianmu database mu da
SELECT b, MID(b,-2,5) FROM t1;
b MID(b,-2,5)

tianmu engine ne
tianmu database se
SELECT b, MID(b,-5,15) FROM t1;
b MID(b,-5,15)

tianmu engine ngine
tianmu database abase
SELECT b, MID(b,-15,15) FROM t1;
b MID(b,-15,15)

tianmu engine
tianmu database tianmu database
SELECT b, MID(b,0,0) FROM t1;
b MID(b,0,0)

tianmu engine
tianmu database
SELECT b, MID(b,1,0) FROM t1;
b MID(b,1,0)

tianmu engine
tianmu database
SELECT b, MID(b,0,1) FROM t1;
b MID(b,0,1)

tianmu engine
tianmu database
SELECT b, MID(b,-1,0) FROM t1;
b MID(b,-1,0)

tianmu engine
tianmu database
DROP DATABASE mid_function;
49 changes: 49 additions & 0 deletions mysql-test/suite/tianmu/r/right_function.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# RIGHT() function
# Author: syw
#
DROP DATABASE IF EXISTS right_function;
CREATE DATABASE right_function;
USE right_function;
CREATE TABLE t1 (a INT, b CHAR(15))ENGINE=tianmu;
INSERT INTO t1 VALUES (NULL, ''),(1, 'tianmu'),(2, 'tainmu'),(3, 'Innodb');
SELECT RIGHT('tianmu cs', 2) FROM t1 LIMIT 1;
RIGHT('tianmu cs', 2)
cs
SELECT RIGHT('tianmu cs', 3) FROM t1 LIMIT 1;
RIGHT('tianmu cs', 3)
cs
SELECT RIGHT('tianmu cs', 4) FROM t1 LIMIT 1;
RIGHT('tianmu cs', 4)
u cs
SELECT b, RIGHT(b, 0) FROM t1 ORDER BY 1;
b RIGHT(b, 0)

Innodb
tainmu
tianmu
SELECT b, RIGHT(b, -1) FROM t1 ORDER BY 1;
b RIGHT(b, -1)

Innodb
tainmu
tianmu
SELECT b, RIGHT(b, 6) FROM t1 ORDER BY 1;
b RIGHT(b, 6)

Innodb Innodb
tainmu tainmu
tianmu tianmu
SELECT b, RIGHT(b, 9) FROM t1 ORDER BY 1;
b RIGHT(b, 9)

Innodb Innodb
tainmu tainmu
tianmu tianmu
SELECT b, RIGHT(concat(b, '_mmm'), 10) FROM t1 ORDER BY 1;
b RIGHT(concat(b, '_mmm'), 10)
_mmm
Innodb Innodb_mmm
tainmu tainmu_mmm
tianmu tianmu_mmm
DROP DATABASE right_function;
100 changes: 100 additions & 0 deletions mysql-test/suite/tianmu/r/substr_function.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#
# SUBSTR() function
# Author: ysw
#
DROP DATABASE IF EXISTS substr_function;
CREATE DATABASE substr_function;
USE substr_function;
CREATE TABLE t1
(
t1_INT INT,
t1_DECIMAL DECIMAL(12,5),
t1_TEXT TEXT,
t1_DATE DATE,
t1_TIME TIME
)ENGINE=tianmu;
INSERT INTO t1 VALUES(103, 1234.5699, 'pqr stu vwx yz', '1997-12-12', '22:12:02');
INSERT INTO t1 VALUES(-7299, 111.99, 'abcde//fghijk//lm', '2001-1-1', '23:59:59');
INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q00', 5), '09-12-11', '01:08:59');
SELECT SUBSTR('123456789', 5, 3) FROM t1 LIMIT 1;
SUBSTR('123456789', 5, 3)
567
SELECT SUBSTR('abcdefghij', 3, 5) FROM t1 LIMIT 1;
SUBSTR('abcdefghij', 3, 5)
cdefg
SELECT SUBSTR('pqr stu vwz', 3, 5) FROM t1 LIMIT 1;
SUBSTR('pqr stu vwz', 3, 5)
r stu
SELECT SUBSTR('pqr stu vwz', 3) FROM t1 LIMIT 1;
SUBSTR('pqr stu vwz', 3)
r stu vwz
SELECT SUBSTR('pqr stu vwz' FROM 3) FROM t1 LIMIT 1;
SUBSTR('pqr stu vwz' FROM 3)
r stu vwz
SELECT SUBSTR('11:12:13' FROM 4 FOR 2) FROM t1 LIMIT 1;
SUBSTR('11:12:13' FROM 4 FOR 2)
12
SELECT SUBSTR('11:12:13', 4, 2) FROM t1 LIMIT 1;
SUBSTR('11:12:13', 4, 2)
12
SELECT SUBSTR(t1_TEXT FROM 3) FROM t1 ORDER BY 1;
SUBSTR(t1_TEXT FROM 3)
0q00q00q00q00
cde//fghijk//lm
r stu vwx yz
SELECT SUBSTR(t1_TEXT, 3) FROM t1 ORDER BY 1;
SUBSTR(t1_TEXT, 3)
0q00q00q00q00
cde//fghijk//lm
r stu vwx yz
SELECT SUBSTR(t1_TEXT FROM 3 FOR 15) FROM t1 ORDER BY 1;
SUBSTR(t1_TEXT FROM 3 FOR 15)
0q00q00q00q00
cde//fghijk//lm
r stu vwx yz
SELECT SUBSTR(t1_TEXT, 3, 15) FROM t1 ORDER BY 1;
SUBSTR(t1_TEXT, 3, 15)
0q00q00q00q00
cde//fghijk//lm
r stu vwx yz
SELECT SUBSTR(t1_DATE FROM 3) FROM t1 ORDER BY 1;
SUBSTR(t1_DATE FROM 3)
01-01-01
09-12-11
97-12-12
SELECT SUBSTR(t1_DATE, 3) FROM t1 ORDER BY 1;
SUBSTR(t1_DATE, 3)
01-01-01
09-12-11
97-12-12
SELECT SUBSTR(t1_DATE FROM 3 FOR 15) FROM t1 ORDER BY 1;
SUBSTR(t1_DATE FROM 3 FOR 15)
01-01-01
09-12-11
97-12-12
SELECT SUBSTR(t1_DATE, 3, 15) FROM t1 ORDER BY 1;
SUBSTR(t1_DATE, 3, 15)
01-01-01
09-12-11
97-12-12
SELECT SUBSTR(t1_TIME FROM 3) FROM t1 ORDER BY 1;
SUBSTR(t1_TIME FROM 3)
:08:59
:12:02
:59:59
SELECT SUBSTR(t1_TIME, 3) FROM t1 ORDER BY 1;
SUBSTR(t1_TIME, 3)
:08:59
:12:02
:59:59
SELECT SUBSTR(t1_TIME FROM 3 FOR 15) FROM t1 ORDER BY 1;
SUBSTR(t1_TIME FROM 3 FOR 15)
:08:59
:12:02
:59:59
SELECT SUBSTR(t1_TIME, 3, 15) FROM t1 ORDER BY 1;
SUBSTR(t1_TIME, 3, 15)
:08:59
:12:02
:59:59
DROP DATABASE substr_function;
Loading