move test folder
This commit is contained in:
@ -0,0 +1,504 @@
|
||||
drop table if exists coll_test;
|
||||
create table coll_test(pk bigint primary key, uc varchar(10) collate utf8_general_ci, ub varchar(10) collate utf8_bin, b varbinary(10));
|
||||
show create table coll_test;
|
||||
Table Create Table
|
||||
coll_test CREATE TABLE `coll_test` (
|
||||
`pk` bigint(20) NOT NULL,
|
||||
`uc` varchar(10) DEFAULT NULL,
|
||||
`ub` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`b` varbinary(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`pk`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
insert into coll_test values (1314, 'abc', 'def', 'xyz');
|
||||
select * from coll_test;
|
||||
pk uc ub b
|
||||
1314 abc def xyz
|
||||
select collation(concat(null)) from coll_test;
|
||||
collation(concat(null))
|
||||
binary
|
||||
select collation(concat(uc, ub)) from coll_test;
|
||||
collation(concat(uc, ub))
|
||||
utf8mb4_bin
|
||||
select collation(concat(uc, b)) from coll_test;
|
||||
collation(concat(uc, b))
|
||||
binary
|
||||
select collation(concat(uc, x'41')) from coll_test;
|
||||
collation(concat(uc, x'41'))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat('abc', x'41')) from coll_test;
|
||||
collation(concat('abc', x'41'))
|
||||
binary
|
||||
select collation(concat('abc' collate utf8mb4_general_ci, x'41')) from coll_test;
|
||||
collation(concat('abc' collate utf8mb4_general_ci, x'41'))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat(1, 2)) from coll_test;
|
||||
collation(concat(1, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat(1, null)) from coll_test;
|
||||
collation(concat(1, null))
|
||||
utf8mb4_general_ci
|
||||
select collation(group_concat(null)) from coll_test;
|
||||
collation(group_concat(null))
|
||||
binary
|
||||
select collation(group_concat(uc, ub)) from coll_test;
|
||||
collation(group_concat(uc, ub))
|
||||
utf8mb4_bin
|
||||
select collation(group_concat(uc, b)) from coll_test;
|
||||
collation(group_concat(uc, b))
|
||||
binary
|
||||
select collation(group_concat(uc, x'41')) from coll_test;
|
||||
collation(group_concat(uc, x'41'))
|
||||
utf8mb4_general_ci
|
||||
select collation(group_concat('abc', x'41')) from coll_test;
|
||||
collation(group_concat('abc', x'41'))
|
||||
binary
|
||||
select collation(group_concat('abc' collate utf8mb4_general_ci, x'41')) from coll_test;
|
||||
collation(group_concat('abc' collate utf8mb4_general_ci, x'41'))
|
||||
utf8mb4_general_ci
|
||||
select collation(group_concat(1, 2)) from coll_test;
|
||||
collation(group_concat(1, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(group_concat(1, null)) from coll_test;
|
||||
collation(group_concat(1, null))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat_ws(',', null)) from coll_test;
|
||||
collation(concat_ws(',', null))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat_ws(',', uc, ub)) from coll_test;
|
||||
collation(concat_ws(',', uc, ub))
|
||||
utf8mb4_bin
|
||||
select collation(concat_ws(',', uc, b)) from coll_test;
|
||||
collation(concat_ws(',', uc, b))
|
||||
binary
|
||||
select collation(concat_ws(',', uc, x'41')) from coll_test;
|
||||
collation(concat_ws(',', uc, x'41'))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat_ws(',', 'abc', x'41')) from coll_test;
|
||||
collation(concat_ws(',', 'abc', x'41'))
|
||||
binary
|
||||
select collation(concat_ws(',', 'abc' collate utf8mb4_general_ci, x'41')) from coll_test;
|
||||
collation(concat_ws(',', 'abc' collate utf8mb4_general_ci, x'41'))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat_ws(',', 1, 2)) from coll_test;
|
||||
collation(concat_ws(',', 1, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(concat_ws(',', 1, null)) from coll_test;
|
||||
collation(concat_ws(',', 1, null))
|
||||
utf8mb4_general_ci
|
||||
select collation(reverse(null)) from coll_test;
|
||||
collation(reverse(null))
|
||||
binary
|
||||
select collation(reverse(uc)) from coll_test;
|
||||
collation(reverse(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(reverse(ub)) from coll_test;
|
||||
collation(reverse(ub))
|
||||
utf8mb4_bin
|
||||
select collation(reverse(b)) from coll_test;
|
||||
collation(reverse(b))
|
||||
binary
|
||||
select collation(reverse(pk)) from coll_test;
|
||||
collation(reverse(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(reverse(X'41')) from coll_test;
|
||||
collation(reverse(X'41'))
|
||||
binary
|
||||
select collation(lower(null)) from coll_test;
|
||||
collation(lower(null))
|
||||
binary
|
||||
select collation(lower(uc)) from coll_test;
|
||||
collation(lower(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(lower(ub)) from coll_test;
|
||||
collation(lower(ub))
|
||||
utf8mb4_bin
|
||||
select collation(lower(b)) from coll_test;
|
||||
collation(lower(b))
|
||||
binary
|
||||
select collation(lower(pk)) from coll_test;
|
||||
collation(lower(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(lower(X'41')) from coll_test;
|
||||
collation(lower(X'41'))
|
||||
binary
|
||||
select collation(upper(null)) from coll_test;
|
||||
collation(upper(null))
|
||||
binary
|
||||
select collation(upper(uc)) from coll_test;
|
||||
collation(upper(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(upper(ub)) from coll_test;
|
||||
collation(upper(ub))
|
||||
utf8mb4_bin
|
||||
select collation(upper(b)) from coll_test;
|
||||
collation(upper(b))
|
||||
binary
|
||||
select collation(upper(pk)) from coll_test;
|
||||
collation(upper(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(upper(X'41')) from coll_test;
|
||||
collation(upper(X'41'))
|
||||
binary
|
||||
select collation(right(null, 2)) from coll_test;
|
||||
collation(right(null, 2))
|
||||
binary
|
||||
select collation(right(uc, 2)) from coll_test;
|
||||
collation(right(uc, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(right(ub, 2)) from coll_test;
|
||||
collation(right(ub, 2))
|
||||
utf8mb4_bin
|
||||
select collation(right(b, 2)) from coll_test;
|
||||
collation(right(b, 2))
|
||||
binary
|
||||
select collation(right(pk, 2)) from coll_test;
|
||||
collation(right(pk, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(right(X'41', 2)) from coll_test;
|
||||
collation(right(X'41', 2))
|
||||
binary
|
||||
select collation(substr(null, 2)) from coll_test;
|
||||
collation(substr(null, 2))
|
||||
binary
|
||||
select collation(substr(uc, 2)) from coll_test;
|
||||
collation(substr(uc, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(substr(ub, 2)) from coll_test;
|
||||
collation(substr(ub, 2))
|
||||
utf8mb4_bin
|
||||
select collation(substr(b, 2)) from coll_test;
|
||||
collation(substr(b, 2))
|
||||
binary
|
||||
select collation(substr(pk, 2)) from coll_test;
|
||||
collation(substr(pk, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(substr(X'41', 2)) from coll_test;
|
||||
collation(substr(X'41', 2))
|
||||
binary
|
||||
select collation(trim('a' from null)) from coll_test;
|
||||
collation(trim('a' from null))
|
||||
binary
|
||||
select collation(trim('a' from uc)) from coll_test;
|
||||
collation(trim('a' from uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(trim('a' from ub)) from coll_test;
|
||||
collation(trim('a' from ub))
|
||||
utf8mb4_bin
|
||||
select collation(trim('a' from b)) from coll_test;
|
||||
collation(trim('a' from b))
|
||||
binary
|
||||
select collation(trim('a' from pk)) from coll_test;
|
||||
collation(trim('a' from pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(trim('a' from X'41')) from coll_test;
|
||||
collation(trim('a' from X'41'))
|
||||
binary
|
||||
select collation(repeat(null, 2)) from coll_test;
|
||||
collation(repeat(null, 2))
|
||||
binary
|
||||
select collation(repeat(uc, 2)) from coll_test;
|
||||
collation(repeat(uc, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(repeat(ub, 2)) from coll_test;
|
||||
collation(repeat(ub, 2))
|
||||
utf8mb4_bin
|
||||
select collation(repeat(b, 2)) from coll_test;
|
||||
collation(repeat(b, 2))
|
||||
binary
|
||||
select collation(repeat(pk, 2)) from coll_test;
|
||||
collation(repeat(pk, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(repeat(X'41', 2)) from coll_test;
|
||||
collation(repeat(X'41', 2))
|
||||
binary
|
||||
select collation(rpad(null, 2, 'a')) from coll_test;
|
||||
collation(rpad(null, 2, 'a'))
|
||||
utf8mb4_general_ci
|
||||
select collation(rpad(uc, 2, ub)) from coll_test;
|
||||
collation(rpad(uc, 2, ub))
|
||||
utf8mb4_bin
|
||||
select collation(rpad(ub, 2, b)) from coll_test;
|
||||
collation(rpad(ub, 2, b))
|
||||
binary
|
||||
select collation(rpad(b, 2, uc)) from coll_test;
|
||||
collation(rpad(b, 2, uc))
|
||||
binary
|
||||
select collation(rpad(pk, 2, uc)) from coll_test;
|
||||
collation(rpad(pk, 2, uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(rpad(X'41', 2, uc)) from coll_test;
|
||||
collation(rpad(X'41', 2, uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(replace(null, b, 'a')) from coll_test;
|
||||
collation(replace(null, b, 'a'))
|
||||
binary
|
||||
select collation(replace(uc, b, ub)) from coll_test;
|
||||
collation(replace(uc, b, ub))
|
||||
binary
|
||||
select collation(replace(ub, uc, ub)) from coll_test;
|
||||
collation(replace(ub, uc, ub))
|
||||
utf8mb4_bin
|
||||
select collation(replace(uc, 'a', 'b')) from coll_test;
|
||||
collation(replace(uc, 'a', 'b'))
|
||||
utf8mb4_general_ci
|
||||
select collation(replace(pk, 1, 2)) from coll_test;
|
||||
collation(replace(pk, 1, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(replace(X'41', 'a', 'b')) from coll_test;
|
||||
collation(replace(X'41', 'a', 'b'))
|
||||
binary
|
||||
select collation(replace(null, b, 'a')) from coll_test;
|
||||
collation(replace(null, b, 'a'))
|
||||
binary
|
||||
select collation(replace(uc, b, ub)) from coll_test;
|
||||
collation(replace(uc, b, ub))
|
||||
binary
|
||||
select collation(replace(ub, uc, ub)) from coll_test;
|
||||
collation(replace(ub, uc, ub))
|
||||
utf8mb4_bin
|
||||
select collation(replace(uc, 'a', 'b')) from coll_test;
|
||||
collation(replace(uc, 'a', 'b'))
|
||||
utf8mb4_general_ci
|
||||
select collation(replace(pk, 1, 2)) from coll_test;
|
||||
collation(replace(pk, 1, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(replace(X'41', 'a', 'b')) from coll_test;
|
||||
collation(replace(X'41', 'a', 'b'))
|
||||
binary
|
||||
select collation(substring_index(null, b, 2)) from coll_test;
|
||||
collation(substring_index(null, b, 2))
|
||||
binary
|
||||
select collation(substring_index(uc, b, 2)) from coll_test;
|
||||
collation(substring_index(uc, b, 2))
|
||||
binary
|
||||
select collation(substring_index(ub, uc, 2)) from coll_test;
|
||||
collation(substring_index(ub, uc, 2))
|
||||
utf8mb4_bin
|
||||
select collation(substring_index(ub, b, 2)) from coll_test;
|
||||
collation(substring_index(ub, b, 2))
|
||||
binary
|
||||
select collation(substring_index(uc, 'a', 2)) from coll_test;
|
||||
collation(substring_index(uc, 'a', 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(substring_index(pk, 1, 2)) from coll_test;
|
||||
collation(substring_index(pk, 1, 2))
|
||||
utf8mb4_general_ci
|
||||
select collation(substring_index(X'41', 'a', 2)) from coll_test;
|
||||
collation(substring_index(X'41', 'a', 2))
|
||||
binary
|
||||
select cmp_meta(locate('b' collate utf8mb4_general_ci, 'aBc' collate utf8mb4_general_ci));
|
||||
cmp_meta(locate('b' collate utf8mb4_general_ci, 'aBc' collate utf8mb4_general_ci))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate('b' collate utf8mb4_bin, 'aBc' collate utf8mb4_bin));
|
||||
cmp_meta(locate('b' collate utf8mb4_bin, 'aBc' collate utf8mb4_bin))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate('b', 'aBc'));
|
||||
cmp_meta(locate('b', 'aBc'))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate('b' collate utf8mb4_general_ci, 'aBc' collate utf8mb4_general_ci, 1));
|
||||
cmp_meta(locate('b' collate utf8mb4_general_ci, 'aBc' collate utf8mb4_general_ci, 1))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate('b' collate utf8mb4_bin, 'aBc' collate utf8mb4_bin, 1));
|
||||
cmp_meta(locate('b' collate utf8mb4_bin, 'aBc' collate utf8mb4_bin, 1))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate('b', 'aBc', 1));
|
||||
cmp_meta(locate('b', 'aBc', 1))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate(uc, ub)) from coll_test;
|
||||
cmp_meta(locate(uc, ub))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate(uc, b)) from coll_test;
|
||||
cmp_meta(locate(uc, b))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate(b, b)) from coll_test;
|
||||
cmp_meta(locate(b, b))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(locate(b, pk)) from coll_test;
|
||||
cmp_meta(locate(b, pk))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(instr('abc' collate utf8_bin, 'B' collate utf8_bin));
|
||||
cmp_meta(instr('abc' collate utf8_bin, 'B' collate utf8_bin))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(instr('abc' collate utf8_general_ci, 'B' collate utf8_general_ci));
|
||||
cmp_meta(instr('abc' collate utf8_general_ci, 'B' collate utf8_general_ci))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(instr('abc', 'B'));
|
||||
cmp_meta(instr('abc', 'B'))
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select collation(current_user());
|
||||
collation(current_user())
|
||||
utf8mb4_general_ci
|
||||
select coercibility(current_user());
|
||||
coercibility(current_user())
|
||||
3
|
||||
select collation(database());
|
||||
collation(database())
|
||||
utf8mb4_general_ci
|
||||
select coercibility(database());
|
||||
coercibility(database())
|
||||
3
|
||||
select collation(conv(null, 10, 8));
|
||||
collation(conv(null, 10, 8))
|
||||
utf8mb4_general_ci
|
||||
select collation(conv(1024, 10, 8));
|
||||
collation(conv(1024, 10, 8))
|
||||
utf8mb4_general_ci
|
||||
select collation(bin(null));
|
||||
collation(bin(null))
|
||||
utf8mb4_general_ci
|
||||
select collation(bin(uc)) from coll_test;
|
||||
collation(bin(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(bin(pk)) from coll_test;
|
||||
collation(bin(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(bin(b)) from coll_test;
|
||||
collation(bin(b))
|
||||
utf8mb4_general_ci
|
||||
select collation(effective_tenant());
|
||||
collation(effective_tenant())
|
||||
utf8mb4_general_ci
|
||||
select coercibility(effective_tenant());
|
||||
coercibility(effective_tenant())
|
||||
3
|
||||
select collation(uc like b) from coll_test;
|
||||
collation(uc like b)
|
||||
binary
|
||||
select cmp_meta(uc like b) from coll_test;
|
||||
cmp_meta(uc like b)
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(uc like ub) from coll_test;
|
||||
cmp_meta(uc like ub)
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(b like b) from coll_test;
|
||||
cmp_meta(b like b)
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(uc like b) from coll_test;
|
||||
cmp_meta(uc like b)
|
||||
{type:"BIGINT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select collation(cast(uc as binary)) from coll_test;
|
||||
collation(cast(uc as binary))
|
||||
binary
|
||||
select collation(cast(pk as char)) from coll_test;
|
||||
collation(cast(pk as char))
|
||||
utf8mb4_general_ci
|
||||
select uc, collation(binary uc) from coll_test;
|
||||
uc collation(binary uc)
|
||||
abc binary
|
||||
select collation(binary binary uc collate utf8_bin) from coll_test;
|
||||
collation(binary binary uc collate utf8_bin)
|
||||
binary
|
||||
select collation(user());
|
||||
collation(user())
|
||||
utf8mb4_general_ci
|
||||
select coercibility(user());
|
||||
coercibility(user())
|
||||
3
|
||||
select collation(version());
|
||||
collation(version())
|
||||
utf8mb4_general_ci
|
||||
select coercibility(version());
|
||||
coercibility(version())
|
||||
3
|
||||
select collation(unhex('42'));
|
||||
collation(unhex('42'))
|
||||
binary
|
||||
select collation(unhex(null));
|
||||
collation(unhex(null))
|
||||
binary
|
||||
select collation(uc regexp b) from coll_test;
|
||||
collation(uc regexp b)
|
||||
binary
|
||||
select cmp_meta(uc regexp b) from coll_test;
|
||||
cmp_meta(uc regexp b)
|
||||
{type:"INT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(uc regexp ub) from coll_test;
|
||||
cmp_meta(uc regexp ub)
|
||||
{type:"INT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(b regexp b) from coll_test;
|
||||
cmp_meta(b regexp b)
|
||||
{type:"INT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(uc regexp b) from coll_test;
|
||||
cmp_meta(uc regexp b)
|
||||
{type:"INT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select cmp_meta(uc regexp 'abc') from coll_test;
|
||||
cmp_meta(uc regexp 'abc')
|
||||
{type:"INT", collation:"binary", coercibility:"NUMERIC"}
|
||||
select collation(quote(uc)) from coll_test;
|
||||
collation(quote(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(quote(ub)) from coll_test;
|
||||
collation(quote(ub))
|
||||
utf8mb4_bin
|
||||
select collation(quote(b)) from coll_test;
|
||||
collation(quote(b))
|
||||
binary
|
||||
select collation(quote(pk)) from coll_test;
|
||||
collation(quote(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(quote(null)) from coll_test;
|
||||
collation(quote(null))
|
||||
binary
|
||||
select collation(md5(uc)) from coll_test;
|
||||
collation(md5(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(md5(ub)) from coll_test;
|
||||
collation(md5(ub))
|
||||
utf8mb4_general_ci
|
||||
select collation(md5(b)) from coll_test;
|
||||
collation(md5(b))
|
||||
utf8mb4_general_ci
|
||||
select collation(md5(pk)) from coll_test;
|
||||
collation(md5(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(md5(null)) from coll_test;
|
||||
collation(md5(null))
|
||||
utf8mb4_general_ci
|
||||
select collation(dump(null)) from coll_test;
|
||||
collation(dump(null))
|
||||
binary
|
||||
select collation(hex(uc)) from coll_test;
|
||||
collation(hex(uc))
|
||||
utf8mb4_general_ci
|
||||
select collation(hex(ub)) from coll_test;
|
||||
collation(hex(ub))
|
||||
utf8mb4_general_ci
|
||||
select collation(hex(b)) from coll_test;
|
||||
collation(hex(b))
|
||||
utf8mb4_general_ci
|
||||
select collation(hex(pk)) from coll_test;
|
||||
collation(hex(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(hex(null)) from coll_test;
|
||||
collation(hex(null))
|
||||
utf8mb4_general_ci
|
||||
select collation(int2ip(pk)) from coll_test;
|
||||
collation(int2ip(pk))
|
||||
utf8mb4_general_ci
|
||||
select collation(int2ip(null)) from coll_test;
|
||||
collation(int2ip(null))
|
||||
utf8mb4_general_ci
|
||||
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
|
||||
collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'))
|
||||
utf8mb4_general_ci
|
||||
set collation_connection = utf8mb4_general_ci;
|
||||
select collation(cast(1 as char));
|
||||
collation(cast(1 as char))
|
||||
utf8mb4_general_ci
|
||||
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
|
||||
collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'))
|
||||
utf8mb4_general_ci
|
||||
select collation(cast('A' as char)), cast('A' as char) < 'a';
|
||||
collation(cast('A' as char)) cast('A' as char) < 'a'
|
||||
utf8mb4_general_ci 0
|
||||
set collation_connection = utf8mb4_bin;
|
||||
select collation(cast(1 as char));
|
||||
collation(cast(1 as char))
|
||||
utf8mb4_bin
|
||||
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
|
||||
collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'))
|
||||
utf8mb4_bin
|
||||
select collation(cast('A' as char)), cast('A' as char) < 'a';
|
||||
collation(cast('A' as char)) cast('A' as char) < 'a'
|
||||
utf8mb4_bin 1
|
||||
drop table coll_test;
|
||||
127
tools/deploy/mysql_test/test_suite/expr/r/mysql/expr_ceil.result
Normal file
127
tools/deploy/mysql_test/test_suite/expr/r/mysql/expr_ceil.result
Normal file
@ -0,0 +1,127 @@
|
||||
================ expression ceil ================
|
||||
drop table if exists test;
|
||||
create table test (pk int primary key, c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 mediumint unsigned, c9 int unsigned, c10 bigint unsigned, c11 float, c12 double, c13 float unsigned, c14 double unsigned, c15 decimal(20, 10), c16 decimal(20, 10) unsigned, c17 datetime(6), c18 timestamp(6) default "2012-01-01 12:00:00", c19 date, c20 time, c21 year , c22 varchar(10000), c23 char(255), c24 varbinary(10000), c25 binary(255));
|
||||
insert into test values (0, -128, 2, -3, 4, -5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '22.5324', '-23.436456', '-24', '25');
|
||||
insert into test values (1, 1, -2, 3, -4, 5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '-22.999999', '23.00001', '24.9999', '-25.00001');
|
||||
insert into test values (2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
select ceil(pk), ceil(c1), ceil(c2), ceil(c3), ceil(c4), ceil(c5), ceil(c6), ceil(c7), ceil(c8), ceil(c9), ceil(c10), ceil(c11), ceil(c12), ceil(c13), ceil(c14), ceil(c15), ceil(c16), ceil(c22), ceil(c23), ceil(c24), ceil(c25) from test;
|
||||
ceil(pk) ceil(c1) ceil(c2) ceil(c3) ceil(c4) ceil(c5) ceil(c6) ceil(c7) ceil(c8) ceil(c9) ceil(c10) ceil(c11) ceil(c12) ceil(c13) ceil(c14) ceil(c15) ceil(c16) ceil(c22) ceil(c23) ceil(c24) ceil(c25)
|
||||
0 -128 2 -3 4 -5 6 7 8 9 10 -11 -12 14 15 16 17 23 -23 -24 25
|
||||
1 1 -2 3 -4 5 6 7 8 9 10 -11 -12 14 15 16 17 -22 24 25 -25
|
||||
2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '25'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '-25.00001'
|
||||
drop table if exists test;
|
||||
select ceil(3.1415926);
|
||||
ceil(3.1415926)
|
||||
4
|
||||
select ceil(-3.1415926);
|
||||
ceil(-3.1415926)
|
||||
-3
|
||||
select ceil(0.00);
|
||||
ceil(0.00)
|
||||
0
|
||||
select ceil(-0.0);
|
||||
ceil(-0.0)
|
||||
0
|
||||
select ceil(0.123456789);
|
||||
ceil(0.123456789)
|
||||
1
|
||||
select ceil(-0.123456789);
|
||||
ceil(-0.123456789)
|
||||
0
|
||||
select ceil(123456789.123456789);
|
||||
ceil(123456789.123456789)
|
||||
123456790
|
||||
select ceil(-99999999.999999999);
|
||||
ceil(-99999999.999999999)
|
||||
-99999999
|
||||
select ceil(999999999.123456789);
|
||||
ceil(999999999.123456789)
|
||||
1000000000
|
||||
select ceil(-999999999.123456789);
|
||||
ceil(-999999999.123456789)
|
||||
-999999999
|
||||
select ceil(-123456789123456789123456789.123456789);
|
||||
ceil(-123456789123456789123456789.123456789)
|
||||
-123456789123456789123456789
|
||||
select ceil(123456789123456789123456789123456789123456789123456789.123456789);
|
||||
ceil(123456789123456789123456789123456789123456789123456789.123456789)
|
||||
123456789123456789123456789123456789123456789123456790
|
||||
select ceil(-123456789123456789123456789123456789123456789123456789.123456789);
|
||||
ceil(-123456789123456789123456789123456789123456789123456789.123456789)
|
||||
-123456789123456789123456789123456789123456789123456789
|
||||
select ceil(123456789123456789123456789.123456789123456789123456789123456789);
|
||||
ceil(123456789123456789123456789.123456789123456789123456789123456789)
|
||||
123456789123456789123456790
|
||||
select ceil(-123456789123456789123456789.123456789123456789123456789123456789);
|
||||
ceil(-123456789123456789123456789.123456789123456789123456789123456789)
|
||||
-123456789123456789123456789
|
||||
select ceil(-123456789123456789123456789.123456789);
|
||||
ceil(-123456789123456789123456789.123456789)
|
||||
-123456789123456789123456789
|
||||
select ceil(999999999999999999999999999999999999999999999.499999999);
|
||||
ceil(999999999999999999999999999999999999999999999.499999999)
|
||||
1000000000000000000000000000000000000000000000
|
||||
select ceil(999999999999999999999999999999999999999999999.500000001);
|
||||
ceil(999999999999999999999999999999999999999999999.500000001)
|
||||
1000000000000000000000000000000000000000000000
|
||||
select ceil(99999999999999999999999999999999999999999999.399999999);
|
||||
ceil(99999999999999999999999999999999999999999999.399999999)
|
||||
100000000000000000000000000000000000000000000
|
||||
select ceil(-99999999999999999999999999999999999999999999.399999999);
|
||||
ceil(-99999999999999999999999999999999999999999999.399999999)
|
||||
-99999999999999999999999999999999999999999999
|
||||
select ceil(-99999999999999999999999999999999999999999999.399999999);
|
||||
ceil(-99999999999999999999999999999999999999999999.399999999)
|
||||
-99999999999999999999999999999999999999999999
|
||||
select ceil(999999999999999999999999999999999999999999999211111.399999999);
|
||||
ceil(999999999999999999999999999999999999999999999211111.399999999)
|
||||
999999999999999999999999999999999999999999999211112
|
||||
select ceil(-999999999999999999999999999999999999999999999211111.399999999);
|
||||
ceil(-999999999999999999999999999999999999999999999211111.399999999)
|
||||
-999999999999999999999999999999999999999999999211111
|
||||
select ceil(-999999999999999999999999999999999999999999999511111.399999999);
|
||||
ceil(-999999999999999999999999999999999999999999999511111.399999999)
|
||||
-999999999999999999999999999999999999999999999511111
|
||||
select ceil(-999999999999999999999999999999999999999999999499999.399999999);
|
||||
ceil(-999999999999999999999999999999999999999999999499999.399999999)
|
||||
-999999999999999999999999999999999999999999999499999
|
||||
select ceil(-1);
|
||||
ceil(-1)
|
||||
-1
|
||||
select ceil(-161);
|
||||
ceil(-161)
|
||||
-161
|
||||
select ceil(null);
|
||||
ceil(null)
|
||||
NULL
|
||||
select ceil("13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.0000135473702135473702135473702135473702135473702135473702135473702135473702013547370213547370201354737021354737021354737021354737021354737021354737021354737021.0000135473702135473702135473702135473702135473702111111111111111111");
|
||||
ceil("13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.000013547370213547370213547370213547370213547370213547370213547370213547370201354737021354737
|
||||
13547370213547370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.0000135473702135473702135473702135473702135473702135473702135473702135473702013547370213547370201354737021354737021354737021354737021354737021354737021354737021.0000135473702135473702135473702135473702135473702111111111111111111'
|
||||
select ceil("13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.0000135473702135473702135473702135473702135473702135473702135473702135473702013547370213547370201354737021354737021354737021354737021354737021354737021354737021.0000135473702135473702135473702135473702135473702catters billet chloroplast's'");
|
||||
ceil("13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.000013547370213547370213547370213547370213547370213547370213547370213547370201354737021354737
|
||||
13547370213547370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.0000135473702135473702135473702135473702135473702135473702135473702135473702013547370213547370201354737021354737021354737021354737021354737021354737021354737021.0000135473702135473702135473702135473702135473702catters billet chloroplast's''
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1(id int,consumer char(20), price varchar(20),sal int,datetime1 DATE,datetime2 bigint);
|
||||
INSERT INTO t1 VALUES(1,'苹果','6500',5000,'2020-09-22 12:11:59',20200923121200);
|
||||
INSERT INTO t1 VALUES(2,'小米','3000',4000,'2020-09-21 10:11:59',20200921101159);
|
||||
INSERT INTO t1 VALUES(3,'OPPO','5000',3000,'2020-08-21 10:11:59',20190821101159);
|
||||
INSERT INTO t1 VALUES(4,'华为','9111',10000,'2020-02-29 10:11:59',20200228101159);
|
||||
SELECT CEIL(rpad(price,20,sal)) FROM t1 ORDER BY id;
|
||||
CEIL(rpad(price,20,sal))
|
||||
65005000500050000000
|
||||
30004000400040006000
|
||||
50003000300030000000
|
||||
91111000010000100000
|
||||
SELECT rpad(CEIL(sal),20,CEIL(price)) FROM t1 ORDER BY id;
|
||||
rpad(CEIL(sal),20,CEIL(price))
|
||||
50006500650065006500
|
||||
40003000300030003000
|
||||
30005000500050005000
|
||||
10000911191119111911
|
||||
@ -0,0 +1,287 @@
|
||||
================ expression convert_tz ================
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+00:00','+08:00');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','+00:00','+08:00')
|
||||
2021-01-01 20:00:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+08:00');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','+01:00','+08:00')
|
||||
2021-01-01 19:00:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+06:30');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','+01:00','+06:30')
|
||||
2021-01-01 17:30:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+10:10');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','+01:00','+10:10')
|
||||
2021-01-01 21:10:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:30','+13:00');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','+01:30','+13:00')
|
||||
2021-01-01 23:30:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','-11:30','+13:00');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','-11:30','+13:00')
|
||||
2021-01-02 12:30:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','-12:00','+13:00');
|
||||
CONVERT_TZ('2021-01-01 12:00:00','-12:00','+13:00')
|
||||
2021-01-02 13:00:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 00:00:00','-12:00','+13:00');
|
||||
CONVERT_TZ('2021-01-01 00:00:00','-12:00','+13:00')
|
||||
2021-01-02 01:00:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 23:59:59','-12:00','+13:00');
|
||||
CONVERT_TZ('2021-01-01 23:59:59','-12:00','+13:00')
|
||||
2021-01-03 00:59:59.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 13:19:38','-10:38','+10:12');
|
||||
CONVERT_TZ('2021-01-01 13:19:38','-10:38','+10:12')
|
||||
2021-01-02 10:09:38.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 12:23:35','-09:23','-11:11');
|
||||
CONVERT_TZ('2021-01-01 12:23:35','-09:23','-11:11')
|
||||
2021-01-01 10:35:35.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 00:01:00','+10:00','-11:00');
|
||||
CONVERT_TZ('2021-01-01 00:01:00','+10:00','-11:00')
|
||||
2020-12-31 03:01:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 00:11:00','+00:00','-11:00');
|
||||
CONVERT_TZ('2021-01-01 00:11:00','+00:00','-11:00')
|
||||
2020-12-31 13:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-03-01 00:11:00','+00:00','-11:00');
|
||||
CONVERT_TZ('2021-03-01 00:11:00','+00:00','-11:00')
|
||||
2021-02-28 13:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-06-01 00:11:00','+00:00','-11:00');
|
||||
CONVERT_TZ('2021-06-01 00:11:00','+00:00','-11:00')
|
||||
2021-05-31 13:11:00.000000
|
||||
SELECT CONVERT_TZ('2020-03-01 00:11:00','+00:00','-11:00');
|
||||
CONVERT_TZ('2020-03-01 00:11:00','+00:00','-11:00')
|
||||
2020-02-29 13:11:00.000000
|
||||
SELECT CONVERT_TZ('2020-02-28 23:11:00','-00:00','+11:00');
|
||||
CONVERT_TZ('2020-02-28 23:11:00','-00:00','+11:00')
|
||||
2020-02-29 10:11:00.000000
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00','-05:00','+11:00');
|
||||
CONVERT_TZ('2020-12-31 23:11:00','-05:00','+11:00')
|
||||
2021-01-01 15:11:00.000000
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00',null,'+11:00');
|
||||
CONVERT_TZ('2020-12-31 23:11:00',null,'+11:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00','+11:00', null);
|
||||
CONVERT_TZ('2020-12-31 23:11:00','+11:00', null)
|
||||
NULL
|
||||
SELECT CONVERT_TZ(null,'-13:00','+11:00');
|
||||
CONVERT_TZ(null,'-13:00','+11:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ(null, null,'+11:00');
|
||||
CONVERT_TZ(null, null,'+11:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ(null, null, null);
|
||||
CONVERT_TZ(null, null, null)
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00','America/Merida','Asia/Tokyo');
|
||||
CONVERT_TZ('2020-12-31 23:11:00','America/Merida','Asia/Tokyo')
|
||||
2021-01-01 14:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Australia/Darwin');
|
||||
CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Australia/Darwin')
|
||||
2021-01-01 15:41:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Europe/Amsterdam');
|
||||
CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Europe/Amsterdam')
|
||||
2021-01-01 07:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','America/Merida');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','America/Merida')
|
||||
2021-01-01 00:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','MET','Libya');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','MET','Libya')
|
||||
2021-01-01 08:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','MET','MST');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','MET','MST')
|
||||
2020-12-31 23:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','PRC','MST');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','PRC','MST')
|
||||
2020-12-31 16:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','PRC','ROC');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','PRC','ROC')
|
||||
2021-01-01 07:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','UCT','ROC');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','UCT','ROC')
|
||||
2021-01-01 15:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','Universal','ROC');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','Universal','ROC')
|
||||
2021-01-01 15:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','Pacific/Marquesas','ROC');
|
||||
CONVERT_TZ('2021-01-01 07:11:00','Pacific/Marquesas','ROC')
|
||||
2021-01-02 00:41:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','GMT+0','ROC');
|
||||
CONVERT_TZ('2021-02-28 17:11:00','GMT+0','ROC')
|
||||
2021-03-01 01:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','GMT+0','Singapore');
|
||||
CONVERT_TZ('2021-02-28 17:11:00','GMT+0','Singapore')
|
||||
2021-03-01 01:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan','ROC');
|
||||
CONVERT_TZ('2021-02-28 17:11:00','US/Michigan','ROC')
|
||||
2021-03-01 06:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', null,'ROC');
|
||||
CONVERT_TZ('2021-02-28 17:11:00', null,'ROC')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', null);
|
||||
CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', null)
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', null, null);
|
||||
CONVERT_TZ('2021-02-28 17:11:00', null, null)
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', '+00:00','ROC');
|
||||
CONVERT_TZ('2021-02-28 17:11:00', '+00:00','ROC')
|
||||
2021-03-01 01:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', '+00:00','US/Michigan');
|
||||
CONVERT_TZ('2021-02-28 17:11:00', '+00:00','US/Michigan')
|
||||
2021-02-28 12:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+00:00');
|
||||
CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+00:00')
|
||||
2021-02-28 09:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'US/Michigan', '+00:00');
|
||||
CONVERT_TZ('2021-02-28 17:11:00', 'US/Michigan', '+00:00')
|
||||
2021-02-28 22:11:00.000000
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+12:58');
|
||||
CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+12:58')
|
||||
2021-02-28 22:09:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', 'UCT','-12:58');
|
||||
CONVERT_TZ('2021-01-01 07:11:00', 'UCT','-12:58')
|
||||
2020-12-31 18:13:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '-12:58','UCT');
|
||||
CONVERT_TZ('2021-01-01 07:11:00', '-12:58','UCT')
|
||||
2021-01-01 20:09:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '-12:58','US/Michigan');
|
||||
CONVERT_TZ('2021-01-01 07:11:00', '-12:58','US/Michigan')
|
||||
2021-01-01 15:09:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+05:12','MET');
|
||||
CONVERT_TZ('2021-01-01 07:11:00', '+05:12','MET')
|
||||
2021-01-01 02:59:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+03:32','PRC');
|
||||
CONVERT_TZ('2021-01-01 07:11:00', '+03:32','PRC')
|
||||
2021-01-01 11:39:00.000000
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+11:32','PRC');
|
||||
CONVERT_TZ('2021-01-01 07:11:00', '+11:32','PRC')
|
||||
2021-01-01 03:39:00.000000
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-13:00','+10:00');
|
||||
CONVERT_TZ('2004-01-01 12:00:00','-13:00','+10:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-12:00','+14:00');
|
||||
CONVERT_TZ('2004-01-01 12:00:00','-12:00','+14:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-13:00','ABC');
|
||||
CONVERT_TZ('2004-01-01 12:00:00','-13:00','ABC')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-12:00','OK');
|
||||
CONVERT_TZ('2004-01-01 12:00:00','-12:00','OK')
|
||||
NULL
|
||||
drop table if exists t;
|
||||
create table t(c1 timestamp);
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-13:00','+10:00'));
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-12:00','+14:00'));
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-13:00','ABC'));
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-12:00','OK'));
|
||||
select * from t;
|
||||
c1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
delete from t;
|
||||
select convert_tz('9999-12-31 20:00:00', '+02:00', '+06:00');
|
||||
convert_tz('9999-12-31 20:00:00', '+02:00', '+06:00')
|
||||
NULL
|
||||
select convert_tz('0000-01-01 01:00:00', '+00:00', '-02:00');
|
||||
convert_tz('0000-01-01 01:00:00', '+00:00', '-02:00')
|
||||
NULL
|
||||
insert into t values(convert_tz('9999-12-31 20:00:00', '+02:00', '+06:00'));
|
||||
insert into t values(convert_tz('0000-01-01 01:00:00', '+00:00', '-02:00'));
|
||||
select * from t;
|
||||
c1
|
||||
NULL
|
||||
NULL
|
||||
SELECT CONVERT_TZ(123456,'-12:00','+10:00');
|
||||
CONVERT_TZ(123456,'-12:00','+10:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('','-12:00','+10:00');
|
||||
CONVERT_TZ('','-12:00','+10:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('aa','-12:00','+10:00');
|
||||
CONVERT_TZ('aa','-12:00','+10:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('张三','-12:00','+10:00');
|
||||
CONVERT_TZ('张三','-12:00','+10:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('1asd561ad','-12:00','+10:00');
|
||||
CONVERT_TZ('1asd561ad','-12:00','+10:00')
|
||||
NULL
|
||||
SELECT CONVERT_TZ('¥¥%……&*¥','-12:00','+10:00');
|
||||
CONVERT_TZ('¥¥%……&*¥','-12:00','+10:00')
|
||||
NULL
|
||||
drop table t;
|
||||
create table t(c1 year);
|
||||
insert into t values('1901'),('2155'), ('0000'), ('0001');
|
||||
SELECT c1, CONVERT_TZ(c1,'+00:00','+00:00') from t;
|
||||
c1 CONVERT_TZ(c1,'+00:00','+00:00')
|
||||
1901 NULL
|
||||
2155 NULL
|
||||
0000 NULL
|
||||
2001 NULL
|
||||
drop table t;
|
||||
create table t(a1 int,a2 year,c1 timestamp,c2 timestamp);
|
||||
insert into t values(1,'1998','1998-12-12 12:12:12','2038-01-19 03:14:07');
|
||||
insert into t values(2,'2002','2002-02-02 10:00:00','2034-02-22 00:50:20');
|
||||
insert into t values(3,'2006','2006-04-15 06:06:20','2038-01-19 03:14:07');
|
||||
insert into t values(4,'2012','2012-12-12 12:12:12','2030-08-16 14:05:50');
|
||||
select c1,c2 ,case c1 when convert_tz(c1,'+06:00','+00:00')<'2006-04-15 06:06:20' then convert_tz('2020-02-02 02:02:02','+00:00','+00:00') else convert_tz('1999-09-09 09:09:09','+00:00','+00:00') end as c1 from t;
|
||||
c1 c2 c1
|
||||
1998-12-12 12:12:12 2038-01-19 03:14:07 1999-09-09 09:09:09.000000
|
||||
2002-02-02 10:00:00 2034-02-22 00:50:20 1999-09-09 09:09:09.000000
|
||||
2006-04-15 06:06:20 2038-01-19 03:14:07 1999-09-09 09:09:09.000000
|
||||
2012-12-12 12:12:12 2030-08-16 14:05:50 1999-09-09 09:09:09.000000
|
||||
drop table t;
|
||||
create table t(c1 timestamp(0), c2 timestamp(3), c3 decimal(20,4));
|
||||
insert into t values('2020-01-01 12:00:00.123456', '2020-01-01 12:00:00.123456', '20200101120000.123456');
|
||||
select c1, convert_tz(c1, '+00:00', '+08:00') from t;
|
||||
c1 convert_tz(c1, '+00:00', '+08:00')
|
||||
2020-01-01 12:00:00 2020-01-01 20:00:00
|
||||
select c2, convert_tz(c2, '+00:00', '+08:00') from t;
|
||||
c2 convert_tz(c2, '+00:00', '+08:00')
|
||||
2020-01-01 12:00:00.123 2020-01-01 20:00:00.123
|
||||
select c3, convert_tz(c3, '+00:00', '+08:00') from t;
|
||||
c3 convert_tz(c3, '+00:00', '+08:00')
|
||||
20200101120000.1235 2020-01-01 20:00:00.1235
|
||||
drop table t;
|
||||
SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central') AS time1,
|
||||
CONVERT_TZ('2007-03-11 2:00:01','US/Eastern','US/Central') AS time2,
|
||||
CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central') AS time3,
|
||||
CONVERT_TZ('2007-03-11 3:00:01','US/Eastern','US/Central') AS time4;
|
||||
time1 time2 time3 time4
|
||||
NULL NULL 2007-03-11 01:00:00.000000 2007-03-11 01:00:01.000000
|
||||
SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','+00:00') AS time1,
|
||||
CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','+00:00') AS time2,
|
||||
CONVERT_TZ('2007-03-11 3:00:01','US/Eastern','+00:00') AS time3;
|
||||
time1 time2 time3
|
||||
NULL 2007-03-11 07:00:00.000000 2007-03-11 07:00:01.000000
|
||||
SELECT CONVERT_TZ('2007-11-04 01:00:00','US/Eastern','+00:00') AS time1,
|
||||
CONVERT_TZ('2007-11-04 01:00:01','US/Eastern','+00:00') AS time2,
|
||||
CONVERT_TZ('2007-11-04 02:00:00','US/Eastern','+00:00') AS time3,
|
||||
CONVERT_TZ('2007-11-04 02:00:01','US/Eastern','+00:00') AS time4;
|
||||
time1 time2 time3 time4
|
||||
2007-11-04 05:00:00.000000 2007-11-04 05:00:01.000000 2007-11-04 07:00:00.000000 2007-11-04 07:00:01.000000
|
||||
create table t(c1 datetime);
|
||||
insert into t values('2007-03-11 2:00:00'), ('2007-03-11 2:00:01'), ('2007-03-11 3:00:00'), ('2007-03-11 3:00:01');
|
||||
insert into t values('2007-11-04 1:00:00'), ('2007-11-04 1:00:01'), ('2007-11-04 2:00:00'), ('2007-11-04 2:00:01');
|
||||
select convert_tz(c1, 'US/Eastern', '+00:00') from t;
|
||||
convert_tz(c1, 'US/Eastern', '+00:00')
|
||||
NULL
|
||||
NULL
|
||||
2007-03-11 07:00:00
|
||||
2007-03-11 07:00:01
|
||||
2007-11-04 05:00:00
|
||||
2007-11-04 05:00:01
|
||||
2007-11-04 07:00:00
|
||||
2007-11-04 07:00:01
|
||||
drop table t;
|
||||
create table t(c1 timestamp);
|
||||
insert into t values('2007-03-11 1:59:59'), ('2007-03-11 3:00:00'), ('2007-03-11 3:00:01');
|
||||
insert into t values('2007-11-04 1:00:00'), ('2007-11-04 1:00:01'), ('2007-11-04 2:00:00'), ('2007-11-04 2:00:01');
|
||||
select convert_tz(c1, 'US/Eastern', '+00:00') from t;
|
||||
convert_tz(c1, 'US/Eastern', '+00:00')
|
||||
2007-03-11 06:59:59
|
||||
2007-03-11 07:00:00
|
||||
2007-03-11 07:00:01
|
||||
2007-11-04 05:00:00
|
||||
2007-11-04 05:00:01
|
||||
2007-11-04 07:00:00
|
||||
2007-11-04 07:00:01
|
||||
drop table t;
|
||||
@ -0,0 +1,337 @@
|
||||
================ expression export_set ================
|
||||
select export_set(0,"Y","N","-",5);
|
||||
export_set(0,"Y","N","-",5)
|
||||
N-N-N-N-N
|
||||
select export_set(7,"Y","N","-",5);
|
||||
export_set(7,"Y","N","-",5)
|
||||
Y-Y-Y-N-N
|
||||
select export_set(11,"Y","N","-",5);
|
||||
export_set(11,"Y","N","-",5)
|
||||
Y-Y-N-Y-N
|
||||
select export_set(20,"Y","N","-",5);
|
||||
export_set(20,"Y","N","-",5)
|
||||
N-N-Y-N-Y
|
||||
select export_set(9,"","","-",5);
|
||||
export_set(9,"","","-",5)
|
||||
----
|
||||
select export_set(9,"Y","N","-",5);
|
||||
export_set(9,"Y","N","-",5)
|
||||
Y-N-N-Y-N
|
||||
select export_set(9,"左","右","-",5);
|
||||
export_set(9,"左","右","-",5)
|
||||
左-右-右-左-右
|
||||
select export_set(9,"上","下","-",5);
|
||||
export_set(9,"上","下","-",5)
|
||||
上-下-下-上-下
|
||||
select export_set(5,"Y","N",".",5);
|
||||
export_set(5,"Y","N",".",5)
|
||||
Y.N.Y.N.N
|
||||
select export_set(5,"Y","N","=",5);
|
||||
export_set(5,"Y","N","=",5)
|
||||
Y=N=Y=N=N
|
||||
select export_set(5,"Y","N","????????",5);
|
||||
export_set(5,"Y","N","????????",5)
|
||||
Y????????N????????Y????????N????????N
|
||||
select export_set(100,"Y","N",".",3);
|
||||
export_set(100,"Y","N",".",3)
|
||||
N.N.Y
|
||||
select export_set(100,"Y","N",".",5);
|
||||
export_set(100,"Y","N",".",5)
|
||||
N.N.Y.N.N
|
||||
select export_set(100,"Y","N",".",7);
|
||||
export_set(100,"Y","N",".",7)
|
||||
N.N.Y.N.N.Y.Y
|
||||
select export_set(100,"Y","N",".",10);
|
||||
export_set(100,"Y","N",".",10)
|
||||
N.N.Y.N.N.Y.Y.N.N.N
|
||||
select export_set(null,"Y","N",".",5);
|
||||
export_set(null,"Y","N",".",5)
|
||||
NULL
|
||||
select export_set(0,"Y","N",".",5);
|
||||
export_set(0,"Y","N",".",5)
|
||||
N.N.N.N.N
|
||||
select export_set(5,null,"N",".",5);
|
||||
export_set(5,null,"N",".",5)
|
||||
NULL
|
||||
select export_set(5,'',"N",".",5);
|
||||
export_set(5,'',"N",".",5)
|
||||
.N..N.N
|
||||
select export_set(5,"Y",null,".",5);
|
||||
export_set(5,"Y",null,".",5)
|
||||
NULL
|
||||
select export_set(5,"Y",'',".",5);
|
||||
export_set(5,"Y",'',".",5)
|
||||
Y..Y..
|
||||
select export_set(5,"Y","N",null,5);
|
||||
export_set(5,"Y","N",null,5)
|
||||
NULL
|
||||
select export_set(5,"Y","N",'',5);
|
||||
export_set(5,"Y","N",'',5)
|
||||
YNYNN
|
||||
select export_set(5,"Y","N",".",null);
|
||||
export_set(5,"Y","N",".",null)
|
||||
NULL
|
||||
select export_set(5,"Y","N",".",0);
|
||||
export_set(5,"Y","N",".",0)
|
||||
|
||||
select export_set(55555555555555,"YY","NN",".",0);
|
||||
export_set(55555555555555,"YY","NN",".",0)
|
||||
|
||||
select export_set(55555555555555,"YY","NN",".......",0);
|
||||
export_set(55555555555555,"YY","NN",".......",0)
|
||||
|
||||
select export_set(100,'',1);
|
||||
export_set(100,'',1)
|
||||
1,1,,1,1,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||
select export_set(100,1,'');
|
||||
export_set(100,1,'')
|
||||
,,1,,,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
select export_set(100,1,0,'');
|
||||
export_set(100,1,0,'')
|
||||
0010011000000000000000000000000000000000000000000000000000000000
|
||||
select export_set(1000,'',1);
|
||||
export_set(1000,'',1)
|
||||
1,1,1,,1,,,,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||
select export_set(1000,1,'');
|
||||
export_set(1000,1,'')
|
||||
,,,1,,1,1,1,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
select export_set(1000,1,0,'');
|
||||
export_set(1000,1,0,'')
|
||||
0001011111000000000000000000000000000000000000000000000000000000
|
||||
select export_set(8,"Y","N");
|
||||
export_set(8,"Y","N")
|
||||
N,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
select export_set(88,"Y","N");
|
||||
export_set(88,"Y","N")
|
||||
N,N,N,Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
select export_set(888,"Y","N");
|
||||
export_set(888,"Y","N")
|
||||
N,N,N,Y,Y,Y,Y,N,Y,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
select export_set(8888,"Y","N");
|
||||
export_set(8888,"Y","N")
|
||||
N,N,N,Y,Y,Y,N,Y,N,Y,N,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
select export_set(8,"1","0");
|
||||
export_set(8,"1","0")
|
||||
0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(8,"X","Y");
|
||||
export_set(8,"X","Y")
|
||||
Y,Y,Y,X,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y
|
||||
select export_set(8,"Y","N",'+');
|
||||
export_set(8,"Y","N",'+')
|
||||
N+N+N+Y+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N
|
||||
select export_set(8,"1","0",'*');
|
||||
export_set(8,"1","0",'*')
|
||||
0*0*0*1*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0
|
||||
select export_set(8,"X","Y",'*');
|
||||
export_set(8,"X","Y",'*')
|
||||
Y*Y*Y*X*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y
|
||||
select export_set(7,1,0,"-",5);
|
||||
export_set(7,1,0,"-",5)
|
||||
1-1-1-0-0
|
||||
select export_set(7,11,00,"-",5);
|
||||
export_set(7,11,00,"-",5)
|
||||
11-11-11-0-0
|
||||
select export_set(7,111,000,"-",5);
|
||||
export_set(7,111,000,"-",5)
|
||||
111-111-111-0-0
|
||||
select export_set(7,111,000,5,5);
|
||||
export_set(7,111,000,5,5)
|
||||
111511151115050
|
||||
select export_set(true,1,0);
|
||||
export_set(true,1,0)
|
||||
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(true,"1","0");
|
||||
export_set(true,"1","0")
|
||||
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(false,1,0);
|
||||
export_set(false,1,0)
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(false,"1","0");
|
||||
export_set(false,"1","0")
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(1.4,1,0);
|
||||
export_set(1.4,1,0)
|
||||
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(2.4,1,0);
|
||||
export_set(2.4,1,0)
|
||||
0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
select export_set(1.4,"y","n");
|
||||
export_set(1.4,"y","n")
|
||||
y,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n
|
||||
select export_set(2.4,"y","n");
|
||||
export_set(2.4,"y","n")
|
||||
n,y,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n
|
||||
select export_set(9223372036854775808,"Y","N");
|
||||
export_set(9223372036854775808,"Y","N")
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(9223372036854775809,"Y","N");
|
||||
export_set(9223372036854775809,"Y","N")
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(-9223372036854775808,"Y","N");
|
||||
export_set(-9223372036854775808,"Y","N")
|
||||
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
|
||||
select export_set(18446744073709551615,"Y","N");
|
||||
export_set(18446744073709551615,"Y","N")
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(9223372036854775808,"Y","N",",",92233720368547758080000000000);
|
||||
export_set(9223372036854775808,"Y","N",",",92233720368547758080000000000)
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(9223372036854775808,"Y","N",",",9223372036854775808);
|
||||
export_set(9223372036854775808,"Y","N",",",9223372036854775808)
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(9223372036854775809,"Y","N",",",9223372036854775809);
|
||||
export_set(9223372036854775809,"Y","N",",",9223372036854775809)
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(9223372036854775809,"Y","N",",",9223372036854775809000000000000);
|
||||
export_set(9223372036854775809,"Y","N",",",9223372036854775809000000000000)
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(-9223372036854775808,"Y","N",",",-9223372036854775808);
|
||||
export_set(-9223372036854775808,"Y","N",",",-9223372036854775808)
|
||||
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
|
||||
select export_set(-9223372036854775808,"Y","N",",",-9223372036854775808000000000);
|
||||
export_set(-9223372036854775808,"Y","N",",",-9223372036854775808000000000)
|
||||
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
|
||||
select export_set(18446744073709551615,"Y","N",",",18446744073709551615);
|
||||
export_set(18446744073709551615,"Y","N",",",18446744073709551615)
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set(18446744073709551615,"Y","N",",",1844674407370955161500000000000);
|
||||
export_set(18446744073709551615,"Y","N",",",1844674407370955161500000000000)
|
||||
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N
|
||||
select export_set();
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set(1);
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set(1,2);
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set("");
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set("","");
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set(5,5);
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set(a,2,3);
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
select export_set(1,2,3,a);
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
select export_set(1,2,3,4,a);
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
drop table if exists test;
|
||||
create table test(c1 int, c2 varchar(20), c3 varchar(20), c4 varchar(20), c5 int);
|
||||
insert into test values(11,"Y","N",",",10);
|
||||
insert into test values(null,"Y","N",",",10);
|
||||
insert into test values(11,null,"N",",",10);
|
||||
insert into test values(11,"Y",null,",",10);
|
||||
insert into test values(11,"Y","N",null,10);
|
||||
insert into test values(11,"Y","N",",",null);
|
||||
insert into test values(null,null,null,null,null);
|
||||
select export_set(c1,c2,c3,c4,c5) from test;
|
||||
export_set(c1,c2,c3,c4,c5)
|
||||
Y,Y,N,Y,N,N,N,N,N,N
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select export_set(c1,c2,c3,c4) from test;
|
||||
export_set(c1,c2,c3,c4)
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
NULL
|
||||
select export_set(c1,c2,c3) from test;
|
||||
export_set(c1,c2,c3)
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
NULL
|
||||
insert into test values(100000,"+","-",",",1000000);
|
||||
insert into test values(55555555,"+","-",",",100000);
|
||||
insert into test values(7777777,"+","-",",",10000);
|
||||
select export_set(c1,c2,c3,c4,5) from test;
|
||||
export_set(c1,c2,c3,c4,5)
|
||||
Y,Y,N,Y,N
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
Y,Y,N,Y,N
|
||||
NULL
|
||||
-,-,-,-,-
|
||||
+,+,-,-,-
|
||||
+,-,-,-,+
|
||||
select export_set(c1,c2,c3,'??',5) from test;
|
||||
export_set(c1,c2,c3,'??',5)
|
||||
Y??Y??N??Y??N
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
Y??Y??N??Y??N
|
||||
Y??Y??N??Y??N
|
||||
NULL
|
||||
-??-??-??-??-
|
||||
+??+??-??-??-
|
||||
+??-??-??-??+
|
||||
select export_set(c1,c2,c3) from test;
|
||||
export_set(c1,c2,c3)
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
|
||||
NULL
|
||||
-,-,-,-,-,+,-,+,-,+,+,-,-,-,-,+,+,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-
|
||||
+,+,-,-,-,+,+,+,+,-,+,-,+,+,-,+,+,+,+,+,-,-,+,-,+,+,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-
|
||||
+,-,-,-,+,+,+,+,+,-,+,+,-,+,-,+,-,+,+,-,+,+,+,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-
|
||||
select export_set(c1) from test;
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set(c1,c2) from test;
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
select export_set() from test;
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
|
||||
drop table test;
|
||||
drop table if exists t1;
|
||||
create table t1 as select export_set(0,"Y","N","-",5);
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
export_set(0,"Y","N","-",5) varchar(127) YES NULL
|
||||
drop table t1;
|
||||
create table t1 as select export_set(99,"YYY","NX","---",77);
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
export_set(99,"YYY","NX","---",77) varchar(381) YES NULL
|
||||
drop table t1;
|
||||
create table t1 as select export_set(99,"1","11","111",77);
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
export_set(99,"1","11","111",77) varchar(317) YES NULL
|
||||
drop table t1;
|
||||
drop table if exists T_36895309;
|
||||
CREATE TABLE T_36895309(A_0 INT,A_1 INT,A_2 VARCHAR(20),A_3 FLOAT,A_4 DATE);
|
||||
INSERT INTO T_36895309 VALUES(1,1,'A',1.23,'1999-09-09'),(2,-1,'nb',3.21,'1111-11-11'),(3,0,'#',6666.6666,'11-11-11'),(4,NULL,NULL,NULL,NULL);
|
||||
SELECT EXPORT_SET(A_2,'Y','N',',',5) FROM T_36895309 ;
|
||||
EXPORT_SET(A_2,'Y','N',',',5)
|
||||
N,N,N,N,N
|
||||
N,N,N,N,N
|
||||
N,N,N,N,N
|
||||
NULL
|
||||
SELECT EXPORT_SET(A_3,'Y','N',',',5) FROM T_36895309 ;
|
||||
EXPORT_SET(A_3,'Y','N',',',5)
|
||||
Y,N,N,N,N
|
||||
Y,Y,N,N,N
|
||||
Y,Y,N,Y,N
|
||||
NULL
|
||||
SELECT EXPORT_SET(A_4,'Y','N',',',5) FROM T_36895309 ;
|
||||
EXPORT_SET(A_4,'Y','N',',',5)
|
||||
Y,N,Y,Y,Y
|
||||
Y,Y,Y,N,N
|
||||
Y,Y,Y,N,N
|
||||
NULL
|
||||
drop table T_36895309;
|
||||
@ -0,0 +1,265 @@
|
||||
================ expression floor ================
|
||||
select floor(null);
|
||||
floor(null)
|
||||
NULL
|
||||
select floor(-123);
|
||||
floor(-123)
|
||||
-123
|
||||
select floor(-123.123);
|
||||
floor(-123.123)
|
||||
-124
|
||||
select floor(123);
|
||||
floor(123)
|
||||
123
|
||||
select floor(3.1415926);
|
||||
floor(3.1415926)
|
||||
3
|
||||
select floor(-3.1415926);
|
||||
floor(-3.1415926)
|
||||
-4
|
||||
select floor(0.00);
|
||||
floor(0.00)
|
||||
0
|
||||
select floor(-0.0);
|
||||
floor(-0.0)
|
||||
0
|
||||
select floor(0.123456789);
|
||||
floor(0.123456789)
|
||||
0
|
||||
select floor(-0.123456789);
|
||||
floor(-0.123456789)
|
||||
-1
|
||||
select floor(123456789.123456789);
|
||||
floor(123456789.123456789)
|
||||
123456789
|
||||
select floor(-99999999.999999999);
|
||||
floor(-99999999.999999999)
|
||||
-100000000
|
||||
select floor(999999999.123456789);
|
||||
floor(999999999.123456789)
|
||||
999999999
|
||||
select floor(-999999999.123456789);
|
||||
floor(-999999999.123456789)
|
||||
-1000000000
|
||||
select floor(-123456789123456789123456789.123456789);
|
||||
floor(-123456789123456789123456789.123456789)
|
||||
-123456789123456789123456790
|
||||
select floor(123456789123456789123456789123456789123456789123456789.123456789);
|
||||
floor(123456789123456789123456789123456789123456789123456789.123456789)
|
||||
123456789123456789123456789123456789123456789123456789
|
||||
select floor(-123456789123456789123456789123456789123456789123456789.123456789);
|
||||
floor(-123456789123456789123456789123456789123456789123456789.123456789)
|
||||
-123456789123456789123456789123456789123456789123456790
|
||||
select floor(123456789123456789123456789.123456789123456789123456789123456789);
|
||||
floor(123456789123456789123456789.123456789123456789123456789123456789)
|
||||
123456789123456789123456789
|
||||
select floor(-123456789123456789123456789.123456789123456789123456789123456789);
|
||||
floor(-123456789123456789123456789.123456789123456789123456789123456789)
|
||||
-123456789123456789123456790
|
||||
select floor(-123456789123456789123456789.123456789);
|
||||
floor(-123456789123456789123456789.123456789)
|
||||
-123456789123456789123456790
|
||||
select floor(999999999999999999999999999999999999999999999.499999999);
|
||||
floor(999999999999999999999999999999999999999999999.499999999)
|
||||
999999999999999999999999999999999999999999999
|
||||
select floor(999999999999999999999999999999999999999999999.500000001);
|
||||
floor(999999999999999999999999999999999999999999999.500000001)
|
||||
999999999999999999999999999999999999999999999
|
||||
select floor(99999999999999999999999999999999999999999999.399999999);
|
||||
floor(99999999999999999999999999999999999999999999.399999999)
|
||||
99999999999999999999999999999999999999999999
|
||||
select floor(-99999999999999999999999999999999999999999999.399999999);
|
||||
floor(-99999999999999999999999999999999999999999999.399999999)
|
||||
-100000000000000000000000000000000000000000000
|
||||
select floor(-99999999999999999999999999999999999999999999.399999999);
|
||||
floor(-99999999999999999999999999999999999999999999.399999999)
|
||||
-100000000000000000000000000000000000000000000
|
||||
select floor(999999999999999999999999999999999999999999999211111.399999999);
|
||||
floor(999999999999999999999999999999999999999999999211111.399999999)
|
||||
999999999999999999999999999999999999999999999211111
|
||||
select floor(-999999999999999999999999999999999999999999999211111.399999999);
|
||||
floor(-999999999999999999999999999999999999999999999211111.399999999)
|
||||
-999999999999999999999999999999999999999999999211112
|
||||
select floor(-999999999999999999999999999999999999999999999511111.399999999);
|
||||
floor(-999999999999999999999999999999999999999999999511111.399999999)
|
||||
-999999999999999999999999999999999999999999999511112
|
||||
select floor(-999999999999999999999999999999999999999999999499999.399999999);
|
||||
floor(-999999999999999999999999999999999999999999999499999.399999999)
|
||||
-999999999999999999999999999999999999999999999500000
|
||||
select floor(0.00000000000),ceil(0.00000);
|
||||
floor(0.00000000000) ceil(0.00000)
|
||||
0 0
|
||||
drop table if exists tbl1;
|
||||
create table tbl1 (i1 int, v2 varchar(80), i3 char(20),i4 float, d4 datetime(6),i5 decimal(5,3), primary key(i1));
|
||||
insert into tbl1 values(1,'now','haha1',1.6256,'2014-05-04 12:00:00',-10.235);
|
||||
insert into tbl1 values(2,'now','haha2',-1.6256,'2014-05-04 12:00:00',1.243);
|
||||
insert into tbl1 values(3,'now','haha3',1.156,'2014-05-04 12:00:00',-1.45);
|
||||
insert into tbl1 values(4,'now','haha1',5.9256,'2014-05-04 12:00:00',3.45);
|
||||
insert into tbl1 values(5,'now1','haha2',1.2356,'2014-05-04 12:00:00',-0.25);
|
||||
insert into tbl1 values(6,'now2','haha3',-10.4256,'2014-05-04 12:00:00',0.253);
|
||||
insert into tbl1 values(7,'now3','haha4',0.6256,'2014-05-04 12:00:00',1.677);
|
||||
select floor(i4),floor(i5) from tbl1;
|
||||
floor(i4) floor(i5)
|
||||
1 -11
|
||||
-2 1
|
||||
1 -2
|
||||
5 3
|
||||
1 -1
|
||||
-11 0
|
||||
0 1
|
||||
select max(floor(i4)),max(floor(i5)) from tbl1;
|
||||
max(floor(i4)) max(floor(i5))
|
||||
5 3
|
||||
select min(floor(i4)),min(floor(i5)) from tbl1;
|
||||
min(floor(i4)) min(floor(i5))
|
||||
-11 -11
|
||||
select max(ceil(i4)),max(ceil(i5)) from tbl1;
|
||||
max(ceil(i4)) max(ceil(i5))
|
||||
6 4
|
||||
select min(ceil(i4)),min(ceil(i5)) from tbl1;
|
||||
min(ceil(i4)) min(ceil(i5))
|
||||
-10 -10
|
||||
select avg(ceil(i4)),avg(ceil(i5)) from tbl1;
|
||||
avg(ceil(i4)) avg(ceil(i5))
|
||||
0.2857 -0.2857
|
||||
select avg(ceil(i5)),avg(floor(i5)) from tbl1;
|
||||
avg(ceil(i5)) avg(floor(i5))
|
||||
-0.2857 -1.2857
|
||||
select sum(ceil(i4)),sum(ceil(i5)) from tbl1;
|
||||
sum(ceil(i4)) sum(ceil(i5))
|
||||
2 -2
|
||||
select count(ceil(i4)),count(ceil(i5)) from tbl1;
|
||||
count(ceil(i4)) count(ceil(i5))
|
||||
7 7
|
||||
select ceil(count(ceil(i4))),floor(count(ceil(i5))) from tbl1;
|
||||
ceil(count(ceil(i4))) floor(count(ceil(i5)))
|
||||
7 7
|
||||
select ceil(avg(ceil(i4))),floor(avg(ceil(i5))) from tbl1;
|
||||
ceil(avg(ceil(i4))) floor(avg(ceil(i5)))
|
||||
1 -1
|
||||
select ceil(avg(ceil(i4))),ceil(avg(ceil(i5))) from tbl1;
|
||||
ceil(avg(ceil(i4))) ceil(avg(ceil(i5)))
|
||||
1 0
|
||||
select * from tbl1 where floor(i4)=2;
|
||||
i1 v2 i3 i4 d4 i5
|
||||
select * from tbl1 where floor(i4)=ceil(i4)-1;
|
||||
i1 v2 i3 i4 d4 i5
|
||||
1 now haha1 1.6256 2014-05-04 12:00:00.000000 -10.235
|
||||
2 now haha2 -1.6256 2014-05-04 12:00:00.000000 1.243
|
||||
3 now haha3 1.156 2014-05-04 12:00:00.000000 -1.450
|
||||
4 now haha1 5.9256 2014-05-04 12:00:00.000000 3.450
|
||||
5 now1 haha2 1.2356 2014-05-04 12:00:00.000000 -0.250
|
||||
6 now2 haha3 -10.4256 2014-05-04 12:00:00.000000 0.253
|
||||
7 now3 haha4 0.6256 2014-05-04 12:00:00.000000 1.677
|
||||
select * from tbl1 where floor(i1)=ceil(i1);
|
||||
i1 v2 i3 i4 d4 i5
|
||||
1 now haha1 1.6256 2014-05-04 12:00:00.000000 -10.235
|
||||
2 now haha2 -1.6256 2014-05-04 12:00:00.000000 1.243
|
||||
3 now haha3 1.156 2014-05-04 12:00:00.000000 -1.450
|
||||
4 now haha1 5.9256 2014-05-04 12:00:00.000000 3.450
|
||||
5 now1 haha2 1.2356 2014-05-04 12:00:00.000000 -0.250
|
||||
6 now2 haha3 -10.4256 2014-05-04 12:00:00.000000 0.253
|
||||
7 now3 haha4 0.6256 2014-05-04 12:00:00.000000 1.677
|
||||
select floor(i1/10*8),i1/10*8 from tbl1;
|
||||
floor(i1/10*8) i1/10*8
|
||||
0 0.8000
|
||||
1 1.6000
|
||||
2 2.4000
|
||||
3 3.2000
|
||||
4 4.0000
|
||||
4 4.8000
|
||||
5 5.6000
|
||||
select * from tbl1 order by floor(i4);
|
||||
i1 v2 i3 i4 d4 i5
|
||||
6 now2 haha3 -10.4256 2014-05-04 12:00:00.000000 0.253
|
||||
2 now haha2 -1.6256 2014-05-04 12:00:00.000000 1.243
|
||||
7 now3 haha4 0.6256 2014-05-04 12:00:00.000000 1.677
|
||||
1 now haha1 1.6256 2014-05-04 12:00:00.000000 -10.235
|
||||
3 now haha3 1.156 2014-05-04 12:00:00.000000 -1.450
|
||||
5 now1 haha2 1.2356 2014-05-04 12:00:00.000000 -0.250
|
||||
4 now haha1 5.9256 2014-05-04 12:00:00.000000 3.450
|
||||
select * from tbl1 order by floor(i4) desc;
|
||||
i1 v2 i3 i4 d4 i5
|
||||
4 now haha1 5.9256 2014-05-04 12:00:00.000000 3.450
|
||||
1 now haha1 1.6256 2014-05-04 12:00:00.000000 -10.235
|
||||
3 now haha3 1.156 2014-05-04 12:00:00.000000 -1.450
|
||||
5 now1 haha2 1.2356 2014-05-04 12:00:00.000000 -0.250
|
||||
7 now3 haha4 0.6256 2014-05-04 12:00:00.000000 1.677
|
||||
2 now haha2 -1.6256 2014-05-04 12:00:00.000000 1.243
|
||||
6 now2 haha3 -10.4256 2014-05-04 12:00:00.000000 0.253
|
||||
select floor(i4) abc from tbl1 order by abc desc;
|
||||
abc
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
-2
|
||||
-11
|
||||
select floor(v2) from tbl1;
|
||||
floor(v2)
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now1'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now2'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'now3'
|
||||
select floor(i3) from tbl1;
|
||||
floor(i3)
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha1'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha2'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha3'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha1'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha2'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha3'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'haha4'
|
||||
select floor(d4) from tbl1;
|
||||
floor(d4)
|
||||
20140504120000
|
||||
20140504120000
|
||||
20140504120000
|
||||
20140504120000
|
||||
20140504120000
|
||||
20140504120000
|
||||
20140504120000
|
||||
drop table if exists tbl2;
|
||||
create table tbl2 (i1 int, v2 varchar(80), primary key(i1));
|
||||
insert into tbl2 values(1,'1');
|
||||
insert into tbl2 values(2,'2.5');
|
||||
insert into tbl2 values(3,'-3.2');
|
||||
select floor(v2),ceil(v2) from tbl2;
|
||||
floor(v2) ceil(v2)
|
||||
1 1
|
||||
2 3
|
||||
-4 -3
|
||||
drop table if exists test;
|
||||
create table test (pk int primary key, c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 mediumint unsigned, c9 int unsigned, c10 bigint unsigned, c11 float, c12 double, c13 float unsigned, c14 double unsigned, c15 decimal(20, 10), c16 decimal(20, 10) unsigned, c17 datetime(6), c18 timestamp(6) default "2012-01-01 12:00:00", c19 date, c20 time, c21 year , c22 varchar(10000), c23 char(255), c24 varbinary(10000), c25 binary(255));
|
||||
insert into test values (0, -128, 2, -3, 4, -5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '22.5324', '-23.436456', '-24', '25');
|
||||
insert into test values (1, 1, -2, 3, -4, 5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '-22.999999', '23.00001', '24.9999', '-25.00001');
|
||||
insert into test values (2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
select floor(pk), floor(c1), floor(c2), floor(c3), floor(c4), floor(c5), floor(c6), floor(c7), floor(c8), floor(c9), floor(c10), floor(c11), floor(c12), floor(c13), floor(c14), floor(c15), floor(c16), floor(c22), floor(c23), floor(c24), floor(c25) from test;
|
||||
floor(pk) floor(c1) floor(c2) floor(c3) floor(c4) floor(c5) floor(c6) floor(c7) floor(c8) floor(c9) floor(c10) floor(c11) floor(c12) floor(c13) floor(c14) floor(c15) floor(c16) floor(c22) floor(c23) floor(c24) floor(c25)
|
||||
0 -128 2 -3 4 -5 6 7 8 9 10 -12 -13 13 14 15 16 22 -24 -24 25
|
||||
1 1 -2 3 -4 5 6 7 8 9 10 -12 -13 13 14 15 16 -23 23 24 -26
|
||||
2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '25'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '-25.00001'
|
||||
drop table if exists test;
|
||||
@ -0,0 +1,167 @@
|
||||
================ expression instr ================
|
||||
select instr('abc', '');
|
||||
instr('abc', '')
|
||||
1
|
||||
select instr('', '');
|
||||
instr('', '')
|
||||
1
|
||||
select instr('', 'abc');
|
||||
instr('', 'abc')
|
||||
0
|
||||
select instr('abc', 'abcd');
|
||||
instr('abc', 'abcd')
|
||||
0
|
||||
select instr('abc', 'abc');
|
||||
instr('abc', 'abc')
|
||||
1
|
||||
select instr('abc', 'a');
|
||||
instr('abc', 'a')
|
||||
1
|
||||
select instr('abc', 'b');
|
||||
instr('abc', 'b')
|
||||
2
|
||||
select instr('abc', 'c');
|
||||
instr('abc', 'c')
|
||||
3
|
||||
select instr('abc', 'bc');
|
||||
instr('abc', 'bc')
|
||||
2
|
||||
select instr('abcbc', 'bc');
|
||||
instr('abcbc', 'bc')
|
||||
2
|
||||
select instr('阿里巴巴', '阿里');
|
||||
instr('阿里巴巴', '阿里')
|
||||
1
|
||||
select instr('阿里巴巴', '巴巴');
|
||||
instr('阿里巴巴', '巴巴')
|
||||
3
|
||||
select instr('阿里巴巴巴巴', '巴巴');
|
||||
instr('阿里巴巴巴巴', '巴巴')
|
||||
3
|
||||
select instr('阿里巴巴', '阿里巴巴');
|
||||
instr('阿里巴巴', '阿里巴巴')
|
||||
1
|
||||
select instr('123', true);
|
||||
instr('123', true)
|
||||
1
|
||||
select instr('23', true);
|
||||
instr('23', true)
|
||||
0
|
||||
select instr(123, '23');
|
||||
instr(123, '23')
|
||||
2
|
||||
select instr('123', 123);
|
||||
instr('123', 123)
|
||||
1
|
||||
select instr('123.400000', 23.4);
|
||||
instr('123.400000', 23.4)
|
||||
2
|
||||
select instr('123.400000', 123.4);
|
||||
instr('123.400000', 123.4)
|
||||
1
|
||||
select instr('123.400000', null);
|
||||
instr('123.400000', null)
|
||||
NULL
|
||||
select instr(null, '巴巴');
|
||||
instr(null, '巴巴')
|
||||
NULL
|
||||
select instr('巴巴', null);
|
||||
instr('巴巴', null)
|
||||
NULL
|
||||
select instr(null, null);
|
||||
instr(null, null)
|
||||
NULL
|
||||
select instr(true, false);
|
||||
instr(true, false)
|
||||
0
|
||||
select instr(true, true);
|
||||
instr(true, true)
|
||||
1
|
||||
select instr(123, true);
|
||||
instr(123, true)
|
||||
1
|
||||
select instr(123, false);
|
||||
instr(123, false)
|
||||
0
|
||||
select instr(0123, false);
|
||||
instr(0123, false)
|
||||
0
|
||||
select instr(1023, false);
|
||||
instr(1023, false)
|
||||
2
|
||||
select instr(1023.4, false);
|
||||
instr(1023.4, false)
|
||||
2
|
||||
select instr(1023.4, true);
|
||||
instr(1023.4, true)
|
||||
1
|
||||
select instr(null, true);
|
||||
instr(null, true)
|
||||
NULL
|
||||
select instr(true, null);
|
||||
instr(true, null)
|
||||
NULL
|
||||
select instr(123, 23);
|
||||
instr(123, 23)
|
||||
2
|
||||
select instr(123, 23456);
|
||||
instr(123, 23456)
|
||||
0
|
||||
select instr(123.4, 123);
|
||||
instr(123.4, 123)
|
||||
1
|
||||
select instr(1234, 123.4);
|
||||
instr(1234, 123.4)
|
||||
0
|
||||
select instr(1234, null);
|
||||
instr(1234, null)
|
||||
NULL
|
||||
select instr(null, 123);
|
||||
instr(null, 123)
|
||||
NULL
|
||||
select instr(123.400000, 123.4);
|
||||
instr(123.400000, 123.4)
|
||||
1
|
||||
select instr(123.400000, 123.41);
|
||||
instr(123.400000, 123.41)
|
||||
0
|
||||
select instr(123.400000, null);
|
||||
instr(123.400000, null)
|
||||
NULL
|
||||
select instr(null, 123.41);
|
||||
instr(null, 123.41)
|
||||
NULL
|
||||
drop table if exists test;
|
||||
create table test(c1 datetime primary key);
|
||||
insert into test values('2015-5-5');
|
||||
select instr(c1, '201') from test;
|
||||
instr(c1, '201')
|
||||
1
|
||||
select instr(c1, '') from test;
|
||||
instr(c1, '')
|
||||
1
|
||||
select instr(c1, 'haha') from test;
|
||||
instr(c1, 'haha')
|
||||
0
|
||||
select instr(c1, '-5') from test;
|
||||
instr(c1, '-5')
|
||||
0
|
||||
select instr(c1, '2015-5-5') from test;
|
||||
instr(c1, '2015-5-5')
|
||||
0
|
||||
select instr(c1, true) from test;
|
||||
instr(c1, true)
|
||||
3
|
||||
select instr(c1, 201) from test;
|
||||
instr(c1, 201)
|
||||
1
|
||||
select instr(c1, 201.1) from test;
|
||||
instr(c1, 201.1)
|
||||
0
|
||||
select instr(c1, null) from test;
|
||||
instr(c1, null)
|
||||
NULL
|
||||
select instr(null, c1) from test;
|
||||
instr(null, c1)
|
||||
NULL
|
||||
drop table if exists test;
|
||||
@ -0,0 +1,481 @@
|
||||
================ expression locate ================
|
||||
select locate('', 'abc');
|
||||
locate('', 'abc')
|
||||
1
|
||||
select locate('', '');
|
||||
locate('', '')
|
||||
1
|
||||
select locate('abcd', 'abc');
|
||||
locate('abcd', 'abc')
|
||||
0
|
||||
select locate('abc', 'abc');
|
||||
locate('abc', 'abc')
|
||||
1
|
||||
select locate('a', 'abc');
|
||||
locate('a', 'abc')
|
||||
1
|
||||
select locate('b', 'abc');
|
||||
locate('b', 'abc')
|
||||
2
|
||||
select locate('c', 'abc');
|
||||
locate('c', 'abc')
|
||||
3
|
||||
select locate('bc', 'abc');
|
||||
locate('bc', 'abc')
|
||||
2
|
||||
select locate('bc', 'abcbc');
|
||||
locate('bc', 'abcbc')
|
||||
2
|
||||
select locate('阿里', '阿里巴巴');
|
||||
locate('阿里', '阿里巴巴')
|
||||
1
|
||||
select locate('巴巴', '阿里巴巴巴巴');
|
||||
locate('巴巴', '阿里巴巴巴巴')
|
||||
3
|
||||
select locate('阿里巴巴', '阿里巴巴');
|
||||
locate('阿里巴巴', '阿里巴巴')
|
||||
1
|
||||
select locate(true, '123');
|
||||
locate(true, '123')
|
||||
1
|
||||
select locate(true, '23');
|
||||
locate(true, '23')
|
||||
0
|
||||
select locate(23, 123);
|
||||
locate(23, 123)
|
||||
2
|
||||
select locate('', 23);
|
||||
locate('', 23)
|
||||
1
|
||||
select locate('23', 123);
|
||||
locate('23', 123)
|
||||
2
|
||||
select locate(123.4, '123.400000');
|
||||
locate(123.4, '123.400000')
|
||||
1
|
||||
select locate('123.400000', 123.4);
|
||||
locate('123.400000', 123.4)
|
||||
0
|
||||
select locate('123.400000', null);
|
||||
locate('123.400000', null)
|
||||
NULL
|
||||
select locate(null, '巴巴');
|
||||
locate(null, '巴巴')
|
||||
NULL
|
||||
select locate('巴巴', null);
|
||||
locate('巴巴', null)
|
||||
NULL
|
||||
select locate(null, null);
|
||||
locate(null, null)
|
||||
NULL
|
||||
select locate(false, true);
|
||||
locate(false, true)
|
||||
0
|
||||
select locate(true, true);
|
||||
locate(true, true)
|
||||
1
|
||||
select locate(true, 123);
|
||||
locate(true, 123)
|
||||
1
|
||||
select locate(false, 123);
|
||||
locate(false, 123)
|
||||
0
|
||||
select locate(false, 0123);
|
||||
locate(false, 0123)
|
||||
0
|
||||
select locate(false, 1023);
|
||||
locate(false, 1023)
|
||||
2
|
||||
select locate(false,1023.4);
|
||||
locate(false,1023.4)
|
||||
2
|
||||
select locate(true, 1023.4);
|
||||
locate(true, 1023.4)
|
||||
1
|
||||
select locate(true, null);
|
||||
locate(true, null)
|
||||
NULL
|
||||
select locate(null, true);
|
||||
locate(null, true)
|
||||
NULL
|
||||
select locate(23, 123);
|
||||
locate(23, 123)
|
||||
2
|
||||
select locate(123456, 123);
|
||||
locate(123456, 123)
|
||||
0
|
||||
select locate(123, 123.4);
|
||||
locate(123, 123.4)
|
||||
1
|
||||
select locate(123.4, 1234);
|
||||
locate(123.4, 1234)
|
||||
0
|
||||
select locate(123, null);
|
||||
locate(123, null)
|
||||
NULL
|
||||
select locate(null, 123);
|
||||
locate(null, 123)
|
||||
NULL
|
||||
select locate(123.4, 123.400000);
|
||||
locate(123.4, 123.400000)
|
||||
1
|
||||
select locate(123.41, 123.400000);
|
||||
locate(123.41, 123.400000)
|
||||
0
|
||||
select locate(123.400000, null);
|
||||
locate(123.400000, null)
|
||||
NULL
|
||||
select locate(null, 123.41);
|
||||
locate(null, 123.41)
|
||||
NULL
|
||||
drop table if exists test;
|
||||
drop table if exists t1;
|
||||
create table t1(c1 bigint unsigned);
|
||||
insert into t1 values(locate('a','b',9223372036854775807));
|
||||
insert into t1 values(locate('a','b',9223372036854775808));
|
||||
insert into t1 values(locate('a','b',12233720368547758000));
|
||||
select * from t1;
|
||||
c1
|
||||
0
|
||||
0
|
||||
0
|
||||
create table test(c1 datetime primary key);
|
||||
insert into test values('2015-5-5');
|
||||
select locate('201', c1) from test;
|
||||
locate('201', c1)
|
||||
1
|
||||
select locate('', c1) from test;
|
||||
locate('', c1)
|
||||
1
|
||||
select locate('haha', c1) from test;
|
||||
locate('haha', c1)
|
||||
0
|
||||
select locate('-5',c1) from test;
|
||||
locate('-5',c1)
|
||||
0
|
||||
select locate('2015-5-5', c1) from test;
|
||||
locate('2015-5-5', c1)
|
||||
0
|
||||
select locate(true, c1) from test;
|
||||
locate(true, c1)
|
||||
3
|
||||
select locate(201, c1) from test;
|
||||
locate(201, c1)
|
||||
1
|
||||
select locate(201.1, c1) from test;
|
||||
locate(201.1, c1)
|
||||
0
|
||||
select locate(c1, null) from test;
|
||||
locate(c1, null)
|
||||
NULL
|
||||
select locate(null, c1) from test;
|
||||
locate(null, c1)
|
||||
NULL
|
||||
drop table if exists test,t1;
|
||||
select locate('', 'abc', 0);
|
||||
locate('', 'abc', 0)
|
||||
0
|
||||
select locate('', 'abc', 1);
|
||||
locate('', 'abc', 1)
|
||||
1
|
||||
select locate('', 'abc', -1);
|
||||
locate('', 'abc', -1)
|
||||
0
|
||||
select locate('', '', 0);
|
||||
locate('', '', 0)
|
||||
0
|
||||
select locate('', '', 1);
|
||||
locate('', '', 1)
|
||||
1
|
||||
select locate('', '', -1);
|
||||
locate('', '', -1)
|
||||
0
|
||||
select locate('abc', '', 0);
|
||||
locate('abc', '', 0)
|
||||
0
|
||||
select locate('abc', '', -1);
|
||||
locate('abc', '', -1)
|
||||
0
|
||||
select locate('abc', '', 1);
|
||||
locate('abc', '', 1)
|
||||
0
|
||||
select locate('abcd', 'abc', 1);
|
||||
locate('abcd', 'abc', 1)
|
||||
0
|
||||
select locate('abc', 'abc', 1);
|
||||
locate('abc', 'abc', 1)
|
||||
1
|
||||
select locate('abc', 'abc', 2);
|
||||
locate('abc', 'abc', 2)
|
||||
0
|
||||
select locate('a', 'abc', 1);
|
||||
locate('a', 'abc', 1)
|
||||
1
|
||||
select locate('a', 'abc', 2);
|
||||
locate('a', 'abc', 2)
|
||||
0
|
||||
select locate('a', 'abac', 1);
|
||||
locate('a', 'abac', 1)
|
||||
1
|
||||
select locate('a', 'abac', 2);
|
||||
locate('a', 'abac', 2)
|
||||
3
|
||||
select locate('b', 'abc', 1);
|
||||
locate('b', 'abc', 1)
|
||||
2
|
||||
select locate('b', 'abc', 2);
|
||||
locate('b', 'abc', 2)
|
||||
2
|
||||
select locate('b', 'abc', 3);
|
||||
locate('b', 'abc', 3)
|
||||
0
|
||||
select locate('c', 'abc', 1);
|
||||
locate('c', 'abc', 1)
|
||||
3
|
||||
select locate('c', 'abc', 3);
|
||||
locate('c', 'abc', 3)
|
||||
3
|
||||
select locate('c', 'abc', 4);
|
||||
locate('c', 'abc', 4)
|
||||
0
|
||||
select locate('bc', 'abc', 1);
|
||||
locate('bc', 'abc', 1)
|
||||
2
|
||||
select locate('bc', 'abc', 3);
|
||||
locate('bc', 'abc', 3)
|
||||
0
|
||||
select locate('', 'abc', 3);
|
||||
locate('', 'abc', 3)
|
||||
3
|
||||
select locate('', 'abc', 4);
|
||||
locate('', 'abc', 4)
|
||||
4
|
||||
select locate('', 'abc', 5);
|
||||
locate('', 'abc', 5)
|
||||
0
|
||||
select locate('阿里', '阿里巴巴', 1);
|
||||
locate('阿里', '阿里巴巴', 1)
|
||||
1
|
||||
select locate('阿里', '阿里巴巴', 2);
|
||||
locate('阿里', '阿里巴巴', 2)
|
||||
0
|
||||
select locate('巴巴', '阿里巴巴', 1);
|
||||
locate('巴巴', '阿里巴巴', 1)
|
||||
3
|
||||
select locate('巴巴', '阿里巴巴', 3);
|
||||
locate('巴巴', '阿里巴巴', 3)
|
||||
3
|
||||
select locate('巴巴', '阿里巴巴', 4);
|
||||
locate('巴巴', '阿里巴巴', 4)
|
||||
0
|
||||
select locate('巴巴', '阿里巴巴', 5);
|
||||
locate('巴巴', '阿里巴巴', 5)
|
||||
0
|
||||
select locate('', '阿里阿里', 3);
|
||||
locate('', '阿里阿里', 3)
|
||||
7
|
||||
select locate('', '阿里阿里', 4);
|
||||
locate('', '阿里阿里', 4)
|
||||
10
|
||||
select locate('', '阿里阿里', 5);
|
||||
locate('', '阿里阿里', 5)
|
||||
13
|
||||
select locate('阿里巴巴', '阿里巴巴', 0);
|
||||
locate('阿里巴巴', '阿里巴巴', 0)
|
||||
0
|
||||
select locate('阿里巴巴', '阿里巴巴', 1);
|
||||
locate('阿里巴巴', '阿里巴巴', 1)
|
||||
1
|
||||
select locate(23, 123, 1);
|
||||
locate(23, 123, 1)
|
||||
2
|
||||
select locate('', 23, 1);
|
||||
locate('', 23, 1)
|
||||
1
|
||||
select locate('23', 123, 1);
|
||||
locate('23', 123, 1)
|
||||
2
|
||||
select locate(true, '123', 1);
|
||||
locate(true, '123', 1)
|
||||
1
|
||||
select locate(true, '123', 2);
|
||||
locate(true, '123', 2)
|
||||
0
|
||||
select locate(true, '123', 2);
|
||||
locate(true, '123', 2)
|
||||
0
|
||||
select locate(true, '123', 2);
|
||||
locate(true, '123', 2)
|
||||
0
|
||||
select locate(true, '1', 1);
|
||||
locate(true, '1', 1)
|
||||
1
|
||||
select locate('1', true, 1);
|
||||
locate('1', true, 1)
|
||||
1
|
||||
select locate(1.3, '1.300000', 2);
|
||||
locate(1.3, '1.300000', 2)
|
||||
0
|
||||
select locate(1.3, '2321.300000', 2);
|
||||
locate(1.3, '2321.300000', 2)
|
||||
4
|
||||
select locate(1.3, '2321.3', 2);
|
||||
locate(1.3, '2321.3', 2)
|
||||
4
|
||||
select locate('1.3000', 451.3, 2);
|
||||
locate('1.3000', 451.3, 2)
|
||||
0
|
||||
select locate(null, '巴巴', 3);
|
||||
locate(null, '巴巴', 3)
|
||||
NULL
|
||||
select locate(null, '巴巴', 2);
|
||||
locate(null, '巴巴', 2)
|
||||
NULL
|
||||
select locate('巴巴', null, 3);
|
||||
locate('巴巴', null, 3)
|
||||
NULL
|
||||
select locate('巴巴', null, 2);
|
||||
locate('巴巴', null, 2)
|
||||
NULL
|
||||
select locate('巴巴', '阿里巴巴', null);
|
||||
locate('巴巴', '阿里巴巴', null)
|
||||
0
|
||||
select locate(null, null, 0);
|
||||
locate(null, null, 0)
|
||||
NULL
|
||||
select locate(null, null, 1);
|
||||
locate(null, null, 1)
|
||||
NULL
|
||||
select locate(false, true, 1);
|
||||
locate(false, true, 1)
|
||||
0
|
||||
select locate(false, true, 2);
|
||||
locate(false, true, 2)
|
||||
0
|
||||
select locate(true, true, 1);
|
||||
locate(true, true, 1)
|
||||
1
|
||||
select locate(true, 123, 1);
|
||||
locate(true, 123, 1)
|
||||
1
|
||||
select locate(true, 123, 2);
|
||||
locate(true, 123, 2)
|
||||
0
|
||||
select locate(false, 1023.4, 2);
|
||||
locate(false, 1023.4, 2)
|
||||
2
|
||||
select locate(false, 1023.4, 3);
|
||||
locate(false, 1023.4, 3)
|
||||
0
|
||||
select locate(true, null, 0);
|
||||
locate(true, null, 0)
|
||||
NULL
|
||||
select locate(true, null, 1);
|
||||
locate(true, null, 1)
|
||||
NULL
|
||||
select locate(null, true, 0);
|
||||
locate(null, true, 0)
|
||||
NULL
|
||||
select locate(null, true, 3);
|
||||
locate(null, true, 3)
|
||||
NULL
|
||||
select locate(true, true, null);
|
||||
locate(true, true, null)
|
||||
0
|
||||
select locate(23, 123, 1);
|
||||
locate(23, 123, 1)
|
||||
2
|
||||
select locate(23, 123, 3);
|
||||
locate(23, 123, 3)
|
||||
0
|
||||
select locate(123456, 123, 9);
|
||||
locate(123456, 123, 9)
|
||||
0
|
||||
select locate(123, 123.4, 1);
|
||||
locate(123, 123.4, 1)
|
||||
1
|
||||
select locate(123, 123.4, 2);
|
||||
locate(123, 123.4, 2)
|
||||
0
|
||||
select locate(123.4, 1234, 4);
|
||||
locate(123.4, 1234, 4)
|
||||
0
|
||||
select locate(123, null, 1);
|
||||
locate(123, null, 1)
|
||||
NULL
|
||||
select locate(123, null, null);
|
||||
locate(123, null, null)
|
||||
NULL
|
||||
select locate(null, 123, 1);
|
||||
locate(null, 123, 1)
|
||||
NULL
|
||||
select locate(null, 123, null);
|
||||
locate(null, 123, null)
|
||||
NULL
|
||||
select locate(123.4, 123.400000, 1);
|
||||
locate(123.4, 123.400000, 1)
|
||||
1
|
||||
select locate(123.4, 123.400000, 2);
|
||||
locate(123.4, 123.400000, 2)
|
||||
0
|
||||
select locate(123.41, 123.400000, 3);
|
||||
locate(123.41, 123.400000, 3)
|
||||
0
|
||||
select locate(123.400000, null, 3);
|
||||
locate(123.400000, null, 3)
|
||||
NULL
|
||||
select locate(null, 123.41, 3);
|
||||
locate(null, 123.41, 3)
|
||||
NULL
|
||||
select locate(null, 123.41, null);
|
||||
locate(null, 123.41, null)
|
||||
NULL
|
||||
select locate(null, 123.41, 126);
|
||||
locate(null, 123.41, 126)
|
||||
NULL
|
||||
drop table if exists test;
|
||||
create table test(c1 datetime primary key);
|
||||
insert into test values('2015-5-5');
|
||||
select locate('201', c1, 1) from test;
|
||||
locate('201', c1, 1)
|
||||
1
|
||||
select locate('', c1 , 1) from test;
|
||||
locate('', c1 , 1)
|
||||
1
|
||||
select locate('haha', c1 , 1) from test;
|
||||
locate('haha', c1 , 1)
|
||||
0
|
||||
select locate('-5',c1 , 1) from test;
|
||||
locate('-5',c1 , 1)
|
||||
0
|
||||
select locate('2015-5-5', c1 , 1) from test;
|
||||
locate('2015-5-5', c1 , 1)
|
||||
0
|
||||
select locate(true, c1 , 1) from test;
|
||||
locate(true, c1 , 1)
|
||||
3
|
||||
select locate(true, c1 , 4) from test;
|
||||
locate(true, c1 , 4)
|
||||
0
|
||||
select locate(201, c1 , 1) from test;
|
||||
locate(201, c1 , 1)
|
||||
1
|
||||
select locate(201.1, c1 , 1) from test;
|
||||
locate(201.1, c1 , 1)
|
||||
0
|
||||
select locate(null, c1 , 1) from test;
|
||||
locate(null, c1 , 1)
|
||||
NULL
|
||||
select locate(c1, null, 1) from test;
|
||||
locate(c1, null, 1)
|
||||
NULL
|
||||
select locate(c1, null, null) from test;
|
||||
locate(c1, null, null)
|
||||
NULL
|
||||
select mod(locate('a','b'),1.000);
|
||||
mod(locate('a','b'),1.000)
|
||||
0.000
|
||||
select ifnull(locate('a','a'),2.345 );
|
||||
ifnull(locate('a','a'),2.345 )
|
||||
1.000
|
||||
drop table if exists test;
|
||||
@ -0,0 +1,81 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1(a int, b int, c int, d int, primary key(a));
|
||||
insert into t1 values(1,2,3,4);
|
||||
insert into t1 values(2,null,3,4);
|
||||
insert into t1 values(3,null,null,4);
|
||||
insert into t1 values(4,2,null,null);
|
||||
create table t2(a int, b int, c int, d int, primary key(a,b));
|
||||
insert into t2 values(1,2,3,4);
|
||||
insert into t2 values(2,2,3,4);
|
||||
insert into t2 values(3,3,null,4);
|
||||
insert into t2 values(4,2,null,null);
|
||||
select 1<=>1;
|
||||
1<=>1
|
||||
1
|
||||
select 1<=>null;
|
||||
1<=>null
|
||||
0
|
||||
select null<=>1;
|
||||
null<=>1
|
||||
0
|
||||
select null<=>null;
|
||||
null<=>null
|
||||
1
|
||||
select 1.0<=>1.0;
|
||||
1.0<=>1.0
|
||||
1
|
||||
select 1.0<=>null;
|
||||
1.0<=>null
|
||||
0
|
||||
select null<=>1.0;
|
||||
null<=>1.0
|
||||
0
|
||||
select 'abc'<=>null;
|
||||
'abc'<=>null
|
||||
0
|
||||
select 'abc'<=>'abc';
|
||||
'abc'<=>'abc'
|
||||
1
|
||||
select 'null'<=>null;
|
||||
'null'<=>null
|
||||
0
|
||||
select (1,2,3)<=>(1,2,3);
|
||||
(1,2,3)<=>(1,2,3)
|
||||
1
|
||||
select (1,null, 3) <=> (1,null,3);
|
||||
(1,null, 3) <=> (1,null,3)
|
||||
1
|
||||
select (1,null,'abc')<=>(1,null,'abc');
|
||||
(1,null,'abc')<=>(1,null,'abc')
|
||||
1
|
||||
select * from t1 where b<=>null;
|
||||
a b c d
|
||||
2 NULL 3 4
|
||||
3 NULL NULL 4
|
||||
select * from t1 where a<=>2;
|
||||
a b c d
|
||||
2 NULL 3 4
|
||||
select * from t1 where a<=>2 and b<=>null;
|
||||
a b c d
|
||||
2 NULL 3 4
|
||||
select * from t1 where b<=>null and c<=>null;
|
||||
a b c d
|
||||
3 NULL NULL 4
|
||||
select * from t1 where b=null and c=null;
|
||||
a b c d
|
||||
select * from t1 where b<=>null and c=null;
|
||||
a b c d
|
||||
select * from t1 join t2 on t1.a=t2.a;
|
||||
a b c d a b c d
|
||||
1 2 3 4 1 2 3 4
|
||||
2 NULL 3 4 2 2 3 4
|
||||
3 NULL NULL 4 3 3 NULL 4
|
||||
4 2 NULL NULL 4 2 NULL NULL
|
||||
select * from t1 join t2 on t1.a=t2.a where t1.b<=>null and t2.b<=>null;
|
||||
a b c d a b c d
|
||||
select * from t1 join t2 on t1.a<=>t2.a;
|
||||
a b c d a b c d
|
||||
1 2 3 4 1 2 3 4
|
||||
2 NULL 3 4 2 2 3 4
|
||||
3 NULL NULL 4 3 3 NULL 4
|
||||
4 2 NULL NULL 4 2 NULL NULL
|
||||
@ -0,0 +1,143 @@
|
||||
================ expression position ================
|
||||
select position(' ' in 'abc');
|
||||
position(' ' in 'abc')
|
||||
0
|
||||
select position('abcd' in 'abc');
|
||||
position('abcd' in 'abc')
|
||||
0
|
||||
select position('abc' in 'abc');
|
||||
position('abc' in 'abc')
|
||||
1
|
||||
select position('a' in 'abc');
|
||||
position('a' in 'abc')
|
||||
1
|
||||
select position('b' in 'abc');
|
||||
position('b' in 'abc')
|
||||
2
|
||||
select position('c' in 'abc');
|
||||
position('c' in 'abc')
|
||||
3
|
||||
select position('bc' in 'abc');
|
||||
position('bc' in 'abc')
|
||||
2
|
||||
select position('bc' in 'abcbc');
|
||||
position('bc' in 'abcbc')
|
||||
2
|
||||
select position('BC' in 'abcbc');
|
||||
position('BC' in 'abcbc')
|
||||
2
|
||||
select position('bC' in 'abcbc');
|
||||
position('bC' in 'abcbc')
|
||||
2
|
||||
select position('阿里' in '阿里巴巴');
|
||||
position('阿里' in '阿里巴巴')
|
||||
1
|
||||
select position('巴巴' in '阿里巴巴巴巴');
|
||||
position('巴巴' in '阿里巴巴巴巴')
|
||||
3
|
||||
select position('阿里巴巴' in '阿里巴巴');
|
||||
position('阿里巴巴' in '阿里巴巴')
|
||||
1
|
||||
select position(true in '123');
|
||||
position(true in '123')
|
||||
1
|
||||
select position(true in '23');
|
||||
position(true in '23')
|
||||
0
|
||||
select position(23 in 123);
|
||||
position(23 in 123)
|
||||
2
|
||||
select position('' in 23);
|
||||
position('' in 23)
|
||||
1
|
||||
select position('23' in 123);
|
||||
position('23' in 123)
|
||||
2
|
||||
select position(123.4 in '123.400000');
|
||||
position(123.4 in '123.400000')
|
||||
1
|
||||
select position('123.400000' in 123.4);
|
||||
position('123.400000' in 123.4)
|
||||
0
|
||||
select position('123.400000' in null);
|
||||
position('123.400000' in null)
|
||||
NULL
|
||||
select position(null in '巴巴');
|
||||
position(null in '巴巴')
|
||||
NULL
|
||||
select position('巴巴' in null);
|
||||
position('巴巴' in null)
|
||||
NULL
|
||||
select position(null in null);
|
||||
position(null in null)
|
||||
NULL
|
||||
select position(false in true);
|
||||
position(false in true)
|
||||
0
|
||||
select position(true in true);
|
||||
position(true in true)
|
||||
1
|
||||
select position(true in 123);
|
||||
position(true in 123)
|
||||
1
|
||||
select position(false in 123);
|
||||
position(false in 123)
|
||||
0
|
||||
select position(false in 0123);
|
||||
position(false in 0123)
|
||||
0
|
||||
select position(false in 1023);
|
||||
position(false in 1023)
|
||||
2
|
||||
select position(23 in 123);
|
||||
position(23 in 123)
|
||||
2
|
||||
select position(123456 in 123);
|
||||
position(123456 in 123)
|
||||
0
|
||||
select position(123 in 123.4);
|
||||
position(123 in 123.4)
|
||||
1
|
||||
select position(123.4 in 1234);
|
||||
position(123.4 in 1234)
|
||||
0
|
||||
select position(123 in null);
|
||||
position(123 in null)
|
||||
NULL
|
||||
select position(null in 123);
|
||||
position(null in 123)
|
||||
NULL
|
||||
drop table if exists test;
|
||||
create table test(c1 datetime primary key);
|
||||
insert into test values('2015-5-5');
|
||||
select position('201' in c1) from test;
|
||||
position('201' in c1)
|
||||
1
|
||||
select position('' in c1) from test;
|
||||
position('' in c1)
|
||||
1
|
||||
select position('haha' in c1) from test;
|
||||
position('haha' in c1)
|
||||
0
|
||||
select position('-5' in c1) from test;
|
||||
position('-5' in c1)
|
||||
0
|
||||
select position('2015-5-5' in c1) from test;
|
||||
position('2015-5-5' in c1)
|
||||
0
|
||||
select position(true in c1) from test;
|
||||
position(true in c1)
|
||||
3
|
||||
select position(201 in c1) from test;
|
||||
position(201 in c1)
|
||||
1
|
||||
select position(201.1 in c1) from test;
|
||||
position(201.1 in c1)
|
||||
0
|
||||
select position(c1 in null) from test;
|
||||
position(c1 in null)
|
||||
NULL
|
||||
select position(null in c1) from test;
|
||||
position(null in c1)
|
||||
NULL
|
||||
drop table if exists test;
|
||||
@ -0,0 +1,57 @@
|
||||
drop table if exists t1,t2;
|
||||
select 0<=>0,0.0<=>0.0,0E0=0E0,'A'<=>'A',NULL<=>NULL;
|
||||
0<=>0 0.0<=>0.0 0E0=0E0 'A'<=>'A' NULL<=>NULL
|
||||
1 1 1 1 1
|
||||
select 1<=>0,0<=>NULL,NULL<=>0;
|
||||
1<=>0 0<=>NULL NULL<=>0
|
||||
0 0 0
|
||||
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
|
||||
1.0<=>0.0 0.0<=>NULL NULL<=>0.0
|
||||
0 0 0
|
||||
select 'A'<=>'B','A'<=>NULL,NULL<=>'A';
|
||||
'A'<=>'B' 'A'<=>NULL NULL<=>'A'
|
||||
0 0 0
|
||||
select 0<=>0.0, 0.0<=>0E0, 0E0<=>'0', 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
|
||||
0<=>0.0 0.0<=>0E0 0E0<=>'0' 10.0<=>1E1 10<=>10.0 10<=>1E1
|
||||
1 1 1 1 1 1
|
||||
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;
|
||||
1.0<=>0E1 10<=>NULL NULL<=>0.0 NULL<=>0E0
|
||||
0 0 0 0
|
||||
create table t1 (id int primary key, value int);
|
||||
create table t2 (id int primary key, value int);
|
||||
insert into t1 values (1,null);
|
||||
insert into t2 values (1,null);
|
||||
select t1.*, t2.*, t1.value=t2.value from t1, t2 where t1.id=t2.id and t1.id=1;
|
||||
id value id value t1.value=t2.value
|
||||
1 NULL 1 NULL NULL
|
||||
select * from t1 where id =id;
|
||||
id value
|
||||
1 NULL
|
||||
select * from t1 where value = value;
|
||||
id value
|
||||
select * from t1 where id = value or value=id;
|
||||
id value
|
||||
select * from t1 where value = null;
|
||||
id value
|
||||
select * from t1 where (value) = (null);
|
||||
id value
|
||||
select * from t1 where ROW(value) = ROW(null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near ') = ROW(null)' at line 1
|
||||
select * from t1 where (id, value) = (1, null);
|
||||
id value
|
||||
drop table t1,t2;
|
||||
create table t1 (a bigint primary key);
|
||||
insert into t1 values (4828532208463511553);
|
||||
select * from t1 where a = '4828532208463511553';
|
||||
a
|
||||
4828532208463511553
|
||||
select * from t1 where a = 4828532208463511553;
|
||||
a
|
||||
4828532208463511553
|
||||
select * from t1 where a in ('4828532208463511553');
|
||||
a
|
||||
4828532208463511553
|
||||
select * from t1 where a in (4828532208463511553,1);
|
||||
a
|
||||
4828532208463511553
|
||||
drop table t1;
|
||||
@ -0,0 +1,100 @@
|
||||
select length('ab');
|
||||
length('ab')
|
||||
2
|
||||
select length('ab ');
|
||||
length('ab ')
|
||||
3
|
||||
select length('ab\t');
|
||||
length('ab\t')
|
||||
3
|
||||
select length('ab\0');
|
||||
length('ab\0')
|
||||
3
|
||||
select length('\_');
|
||||
length('\_')
|
||||
2
|
||||
select length('\%');
|
||||
length('\%')
|
||||
2
|
||||
select length('\\');
|
||||
length('\\')
|
||||
1
|
||||
select length('\z');
|
||||
length('\z')
|
||||
1
|
||||
select length('\n\t\r\b\0\_\%\\');
|
||||
length('\n\t\r\b\0\_\%\\')
|
||||
10
|
||||
select length('\a');
|
||||
length('\a')
|
||||
1
|
||||
select length('\m');
|
||||
length('\m')
|
||||
1
|
||||
select length(12.466);
|
||||
length(12.466)
|
||||
6
|
||||
select length(4334);
|
||||
length(4334)
|
||||
4
|
||||
select length(0.00);
|
||||
length(0.00)
|
||||
4
|
||||
select length('好');
|
||||
length('好')
|
||||
3
|
||||
select length(13bd);
|
||||
ERROR 42S22: Unknown column '13bd' in 'field list'
|
||||
select length(db24);
|
||||
ERROR 42S22: Unknown column 'db24' in 'field list'
|
||||
select length(00.000);
|
||||
length(00.000)
|
||||
5
|
||||
select length(00.000);
|
||||
length(00.000)
|
||||
5
|
||||
select length(1.00000);
|
||||
length(1.00000)
|
||||
7
|
||||
select length(10000.10);
|
||||
length(10000.10)
|
||||
8
|
||||
create database if not exists db1;
|
||||
use db1;
|
||||
drop table if exists utf,tx,gbk;
|
||||
create table utf(c1 int primary key, c2 char(10)) collate 'utf8mb4_bin';
|
||||
insert into utf values(1, '好');
|
||||
select length(c2) from utf;
|
||||
length(c2)
|
||||
3
|
||||
create table tx(s int(255) zerofill);
|
||||
insert into tx values (2);
|
||||
select * from tx;
|
||||
s
|
||||
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
|
||||
select * from tx;
|
||||
s
|
||||
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
|
||||
select * from tx;
|
||||
s
|
||||
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
|
||||
select length(s) from tx;
|
||||
length(s)
|
||||
255
|
||||
drop table tx;
|
||||
create table tx(s int(121) zerofill);
|
||||
insert into tx values (1234);
|
||||
select * from tx;
|
||||
s
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234
|
||||
select * from tx;
|
||||
s
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234
|
||||
select * from tx;
|
||||
s
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234
|
||||
select length(s) from tx;
|
||||
length(s)
|
||||
121
|
||||
drop table tx;
|
||||
drop database db1;
|
||||
6289
tools/deploy/mysql_test/test_suite/expr/r/mysql/func_regexp.result
Normal file
6289
tools/deploy/mysql_test/test_suite/expr/r/mysql/func_regexp.result
Normal file
File diff suppressed because it is too large
Load Diff
256
tools/deploy/mysql_test/test_suite/expr/t/collation_expr.test
Normal file
256
tools/deploy/mysql_test/test_suite/expr/t/collation_expr.test
Normal file
@ -0,0 +1,256 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
# owner: luofan.zp
|
||||
# owner group: SQL3
|
||||
# description: collation of all expression operator
|
||||
# Author: zhuweng.yzf
|
||||
# ....yzf....Fri, 21 Aug 2015....17:55....
|
||||
|
||||
# set-up
|
||||
--disable_warnings
|
||||
drop table if exists coll_test;
|
||||
--enable_warnings
|
||||
create table coll_test(pk bigint primary key, uc varchar(10) collate utf8_general_ci, ub varchar(10) collate utf8_bin, b varbinary(10));
|
||||
--source mysql_test/include/show_create_table_old_version.inc
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table coll_test;
|
||||
insert into coll_test values (1314, 'abc', 'def', 'xyz');
|
||||
select * from coll_test;
|
||||
################################################################
|
||||
# concat
|
||||
select collation(concat(null)) from coll_test;
|
||||
select collation(concat(uc, ub)) from coll_test;
|
||||
select collation(concat(uc, b)) from coll_test;
|
||||
select collation(concat(uc, x'41')) from coll_test;
|
||||
select collation(concat('abc', x'41')) from coll_test;
|
||||
select collation(concat('abc' collate utf8mb4_general_ci, x'41')) from coll_test;
|
||||
select collation(concat(1, 2)) from coll_test;
|
||||
select collation(concat(1, null)) from coll_test;
|
||||
|
||||
# group_concat
|
||||
select collation(group_concat(null)) from coll_test;
|
||||
select collation(group_concat(uc, ub)) from coll_test;
|
||||
select collation(group_concat(uc, b)) from coll_test;
|
||||
select collation(group_concat(uc, x'41')) from coll_test;
|
||||
select collation(group_concat('abc', x'41')) from coll_test;
|
||||
select collation(group_concat('abc' collate utf8mb4_general_ci, x'41')) from coll_test;
|
||||
select collation(group_concat(1, 2)) from coll_test;
|
||||
select collation(group_concat(1, null)) from coll_test;
|
||||
|
||||
# concat_ws
|
||||
select collation(concat_ws(',', null)) from coll_test;
|
||||
select collation(concat_ws(',', uc, ub)) from coll_test;
|
||||
select collation(concat_ws(',', uc, b)) from coll_test;
|
||||
select collation(concat_ws(',', uc, x'41')) from coll_test;
|
||||
select collation(concat_ws(',', 'abc', x'41')) from coll_test;
|
||||
select collation(concat_ws(',', 'abc' collate utf8mb4_general_ci, x'41')) from coll_test;
|
||||
select collation(concat_ws(',', 1, 2)) from coll_test;
|
||||
select collation(concat_ws(',', 1, null)) from coll_test;
|
||||
|
||||
# reverse
|
||||
select collation(reverse(null)) from coll_test;
|
||||
select collation(reverse(uc)) from coll_test;
|
||||
select collation(reverse(ub)) from coll_test;
|
||||
select collation(reverse(b)) from coll_test;
|
||||
select collation(reverse(pk)) from coll_test;
|
||||
select collation(reverse(X'41')) from coll_test;
|
||||
|
||||
# lower
|
||||
select collation(lower(null)) from coll_test;
|
||||
select collation(lower(uc)) from coll_test;
|
||||
select collation(lower(ub)) from coll_test;
|
||||
select collation(lower(b)) from coll_test;
|
||||
select collation(lower(pk)) from coll_test;
|
||||
select collation(lower(X'41')) from coll_test;
|
||||
|
||||
# upper
|
||||
select collation(upper(null)) from coll_test;
|
||||
select collation(upper(uc)) from coll_test;
|
||||
select collation(upper(ub)) from coll_test;
|
||||
select collation(upper(b)) from coll_test;
|
||||
select collation(upper(pk)) from coll_test;
|
||||
select collation(upper(X'41')) from coll_test;
|
||||
|
||||
# right
|
||||
select collation(right(null, 2)) from coll_test;
|
||||
select collation(right(uc, 2)) from coll_test;
|
||||
select collation(right(ub, 2)) from coll_test;
|
||||
select collation(right(b, 2)) from coll_test;
|
||||
select collation(right(pk, 2)) from coll_test;
|
||||
select collation(right(X'41', 2)) from coll_test;
|
||||
|
||||
#substr
|
||||
select collation(substr(null, 2)) from coll_test;
|
||||
select collation(substr(uc, 2)) from coll_test;
|
||||
select collation(substr(ub, 2)) from coll_test;
|
||||
select collation(substr(b, 2)) from coll_test;
|
||||
select collation(substr(pk, 2)) from coll_test;
|
||||
select collation(substr(X'41', 2)) from coll_test;
|
||||
|
||||
#trim
|
||||
select collation(trim('a' from null)) from coll_test;
|
||||
select collation(trim('a' from uc)) from coll_test;
|
||||
select collation(trim('a' from ub)) from coll_test;
|
||||
select collation(trim('a' from b)) from coll_test;
|
||||
select collation(trim('a' from pk)) from coll_test;
|
||||
select collation(trim('a' from X'41')) from coll_test;
|
||||
|
||||
#repeat
|
||||
select collation(repeat(null, 2)) from coll_test;
|
||||
select collation(repeat(uc, 2)) from coll_test;
|
||||
select collation(repeat(ub, 2)) from coll_test;
|
||||
select collation(repeat(b, 2)) from coll_test;
|
||||
select collation(repeat(pk, 2)) from coll_test;
|
||||
select collation(repeat(X'41', 2)) from coll_test;
|
||||
|
||||
# rpad
|
||||
select collation(rpad(null, 2, 'a')) from coll_test;
|
||||
select collation(rpad(uc, 2, ub)) from coll_test;
|
||||
select collation(rpad(ub, 2, b)) from coll_test;
|
||||
select collation(rpad(b, 2, uc)) from coll_test;
|
||||
select collation(rpad(pk, 2, uc)) from coll_test;
|
||||
select collation(rpad(X'41', 2, uc)) from coll_test;
|
||||
|
||||
#replace
|
||||
select collation(replace(null, b, 'a')) from coll_test;
|
||||
select collation(replace(uc, b, ub)) from coll_test;
|
||||
select collation(replace(ub, uc, ub)) from coll_test;
|
||||
select collation(replace(uc, 'a', 'b')) from coll_test;
|
||||
select collation(replace(pk, 1, 2)) from coll_test;
|
||||
select collation(replace(X'41', 'a', 'b')) from coll_test;
|
||||
|
||||
#replace
|
||||
select collation(replace(null, b, 'a')) from coll_test;
|
||||
select collation(replace(uc, b, ub)) from coll_test;
|
||||
select collation(replace(ub, uc, ub)) from coll_test;
|
||||
select collation(replace(uc, 'a', 'b')) from coll_test;
|
||||
select collation(replace(pk, 1, 2)) from coll_test;
|
||||
select collation(replace(X'41', 'a', 'b')) from coll_test;
|
||||
|
||||
#substring_index
|
||||
select collation(substring_index(null, b, 2)) from coll_test;
|
||||
select collation(substring_index(uc, b, 2)) from coll_test;
|
||||
select collation(substring_index(ub, uc, 2)) from coll_test;
|
||||
select collation(substring_index(ub, b, 2)) from coll_test;
|
||||
select collation(substring_index(uc, 'a', 2)) from coll_test;
|
||||
select collation(substring_index(pk, 1, 2)) from coll_test;
|
||||
select collation(substring_index(X'41', 'a', 2)) from coll_test;
|
||||
|
||||
# locate
|
||||
select cmp_meta(locate('b' collate utf8mb4_general_ci, 'aBc' collate utf8mb4_general_ci));
|
||||
select cmp_meta(locate('b' collate utf8mb4_bin, 'aBc' collate utf8mb4_bin));
|
||||
select cmp_meta(locate('b', 'aBc'));
|
||||
select cmp_meta(locate('b' collate utf8mb4_general_ci, 'aBc' collate utf8mb4_general_ci, 1));
|
||||
select cmp_meta(locate('b' collate utf8mb4_bin, 'aBc' collate utf8mb4_bin, 1));
|
||||
select cmp_meta(locate('b', 'aBc', 1));
|
||||
select cmp_meta(locate(uc, ub)) from coll_test;
|
||||
select cmp_meta(locate(uc, b)) from coll_test;
|
||||
select cmp_meta(locate(b, b)) from coll_test;
|
||||
select cmp_meta(locate(b, pk)) from coll_test;
|
||||
|
||||
# instr
|
||||
select cmp_meta(instr('abc' collate utf8_bin, 'B' collate utf8_bin));
|
||||
select cmp_meta(instr('abc' collate utf8_general_ci, 'B' collate utf8_general_ci));
|
||||
select cmp_meta(instr('abc', 'B'));
|
||||
|
||||
# current_user
|
||||
select collation(current_user());
|
||||
select coercibility(current_user());
|
||||
|
||||
# database
|
||||
select collation(database());
|
||||
select coercibility(database());
|
||||
|
||||
# conv
|
||||
select collation(conv(null, 10, 8));
|
||||
select collation(conv(1024, 10, 8));
|
||||
|
||||
# bin
|
||||
select collation(bin(null));
|
||||
select collation(bin(uc)) from coll_test;
|
||||
select collation(bin(pk)) from coll_test;
|
||||
select collation(bin(b)) from coll_test;
|
||||
|
||||
# effective_tenant
|
||||
select collation(effective_tenant());
|
||||
select coercibility(effective_tenant());
|
||||
|
||||
# like
|
||||
select collation(uc like b) from coll_test;
|
||||
select cmp_meta(uc like b) from coll_test;
|
||||
select cmp_meta(uc like ub) from coll_test;
|
||||
select cmp_meta(b like b) from coll_test;
|
||||
select cmp_meta(uc like b) from coll_test;
|
||||
|
||||
# cast
|
||||
select collation(cast(uc as binary)) from coll_test;
|
||||
select collation(cast(pk as char)) from coll_test;
|
||||
select uc, collation(binary uc) from coll_test;
|
||||
select collation(binary binary uc collate utf8_bin) from coll_test;
|
||||
|
||||
# user
|
||||
select collation(user());
|
||||
select coercibility(user());
|
||||
|
||||
# version
|
||||
select collation(version());
|
||||
select coercibility(version());
|
||||
|
||||
# unhex
|
||||
select collation(unhex('42'));
|
||||
select collation(unhex(null));
|
||||
|
||||
# regexp
|
||||
select collation(uc regexp b) from coll_test;
|
||||
select cmp_meta(uc regexp b) from coll_test;
|
||||
select cmp_meta(uc regexp ub) from coll_test;
|
||||
select cmp_meta(b regexp b) from coll_test;
|
||||
select cmp_meta(uc regexp b) from coll_test;
|
||||
select cmp_meta(uc regexp 'abc') from coll_test;
|
||||
|
||||
# quote
|
||||
select collation(quote(uc)) from coll_test;
|
||||
select collation(quote(ub)) from coll_test;
|
||||
select collation(quote(b)) from coll_test;
|
||||
select collation(quote(pk)) from coll_test;
|
||||
select collation(quote(null)) from coll_test;
|
||||
|
||||
# md5
|
||||
select collation(md5(uc)) from coll_test;
|
||||
select collation(md5(ub)) from coll_test;
|
||||
select collation(md5(b)) from coll_test;
|
||||
select collation(md5(pk)) from coll_test;
|
||||
select collation(md5(null)) from coll_test;
|
||||
|
||||
# dump
|
||||
select collation(dump(null)) from coll_test;
|
||||
|
||||
# hex
|
||||
select collation(hex(uc)) from coll_test;
|
||||
select collation(hex(ub)) from coll_test;
|
||||
select collation(hex(b)) from coll_test;
|
||||
select collation(hex(pk)) from coll_test;
|
||||
select collation(hex(null)) from coll_test;
|
||||
|
||||
# int2ip
|
||||
select collation(int2ip(pk)) from coll_test;
|
||||
select collation(int2ip(null)) from coll_test;
|
||||
|
||||
# date_format
|
||||
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
|
||||
|
||||
# all implicit cast should use the connection_collation as the result collation
|
||||
set collation_connection = utf8mb4_general_ci;
|
||||
select collation(cast(1 as char));
|
||||
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
|
||||
select collation(cast('A' as char)), cast('A' as char) < 'a';
|
||||
|
||||
set collation_connection = utf8mb4_bin;
|
||||
select collation(cast(1 as char));
|
||||
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
|
||||
select collation(cast('A' as char)), cast('A' as char) < 'a';
|
||||
|
||||
################################################################
|
||||
# tear-down
|
||||
drop table coll_test;
|
||||
61
tools/deploy/mysql_test/test_suite/expr/t/expr_ceil.test
Normal file
61
tools/deploy/mysql_test/test_suite/expr/t/expr_ceil.test
Normal file
@ -0,0 +1,61 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: peihan.dph
|
||||
#### owner group: sql3
|
||||
#### description: 测试向上取整函数(天花板函数)
|
||||
--echo ================ expression ceil ================
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
create table test (pk int primary key, c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 mediumint unsigned, c9 int unsigned, c10 bigint unsigned, c11 float, c12 double, c13 float unsigned, c14 double unsigned, c15 decimal(20, 10), c16 decimal(20, 10) unsigned, c17 datetime(6), c18 timestamp(6) default "2012-01-01 12:00:00", c19 date, c20 time, c21 year , c22 varchar(10000), c23 char(255), c24 varbinary(10000), c25 binary(255));
|
||||
insert into test values (0, -128, 2, -3, 4, -5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '22.5324', '-23.436456', '-24', '25');
|
||||
insert into test values (1, 1, -2, 3, -4, 5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '-22.999999', '23.00001', '24.9999', '-25.00001');
|
||||
insert into test values (2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
select ceil(pk), ceil(c1), ceil(c2), ceil(c3), ceil(c4), ceil(c5), ceil(c6), ceil(c7), ceil(c8), ceil(c9), ceil(c10), ceil(c11), ceil(c12), ceil(c13), ceil(c14), ceil(c15), ceil(c16), ceil(c22), ceil(c23), ceil(c24), ceil(c25) from test;
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
select ceil(3.1415926);
|
||||
select ceil(-3.1415926);
|
||||
select ceil(0.00);
|
||||
select ceil(-0.0);
|
||||
select ceil(0.123456789);
|
||||
select ceil(-0.123456789);
|
||||
select ceil(123456789.123456789);
|
||||
select ceil(-99999999.999999999);
|
||||
select ceil(999999999.123456789);
|
||||
select ceil(-999999999.123456789);
|
||||
select ceil(-123456789123456789123456789.123456789);
|
||||
select ceil(123456789123456789123456789123456789123456789123456789.123456789);
|
||||
select ceil(-123456789123456789123456789123456789123456789123456789.123456789);
|
||||
select ceil(123456789123456789123456789.123456789123456789123456789123456789);
|
||||
select ceil(-123456789123456789123456789.123456789123456789123456789123456789);
|
||||
select ceil(-123456789123456789123456789.123456789);
|
||||
select ceil(999999999999999999999999999999999999999999999.499999999);
|
||||
select ceil(999999999999999999999999999999999999999999999.500000001);
|
||||
select ceil(99999999999999999999999999999999999999999999.399999999);
|
||||
select ceil(-99999999999999999999999999999999999999999999.399999999);
|
||||
select ceil(-99999999999999999999999999999999999999999999.399999999);
|
||||
select ceil(999999999999999999999999999999999999999999999211111.399999999);
|
||||
select ceil(-999999999999999999999999999999999999999999999211111.399999999);
|
||||
select ceil(-999999999999999999999999999999999999999999999511111.399999999);
|
||||
select ceil(-999999999999999999999999999999999999999999999499999.399999999);
|
||||
select ceil(-1);
|
||||
select ceil(-161);
|
||||
select ceil(null);
|
||||
select ceil("13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.0000135473702135473702135473702135473702135473702135473702135473702135473702013547370213547370201354737021354737021354737021354737021354737021354737021354737021.0000135473702135473702135473702135473702135473702111111111111111111");
|
||||
select ceil("13547370213547370213547370213547370201354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737021354737020.0000135473702135473702135473702135473702135473702135473702135473702135473702013547370213547370201354737021354737021354737021354737021354737021354737021354737021.0000135473702135473702135473702135473702135473702catters billet chloroplast's'");
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
CREATE TABLE t1(id int,consumer char(20), price varchar(20),sal int,datetime1 DATE,datetime2 bigint);
|
||||
INSERT INTO t1 VALUES(1,'苹果','6500',5000,'2020-09-22 12:11:59',20200923121200);
|
||||
INSERT INTO t1 VALUES(2,'小米','3000',4000,'2020-09-21 10:11:59',20200921101159);
|
||||
INSERT INTO t1 VALUES(3,'OPPO','5000',3000,'2020-08-21 10:11:59',20190821101159);
|
||||
INSERT INTO t1 VALUES(4,'华为','9111',10000,'2020-02-29 10:11:59',20200228101159);
|
||||
|
||||
|
||||
SELECT CEIL(rpad(price,20,sal)) FROM t1 ORDER BY id;
|
||||
SELECT rpad(CEIL(sal),20,CEIL(price)) FROM t1 ORDER BY id;
|
||||
155
tools/deploy/mysql_test/test_suite/expr/t/expr_convert_tz.test
Normal file
155
tools/deploy/mysql_test/test_suite/expr/t/expr_convert_tz.test
Normal file
@ -0,0 +1,155 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=on;
|
||||
--enable_query_log
|
||||
# owner: dachuan.sdc
|
||||
# owner group: SQL2
|
||||
# Test of functions convert_tz
|
||||
|
||||
|
||||
--echo ================ expression convert_tz ================
|
||||
--source mysql_test/test_suite/otimestamp/t/otimestamp_import_time_zone_mysql.inc
|
||||
# 直接时刻类型
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+00:00','+08:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+08:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+06:30');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+10:10');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:30','+13:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','-11:30','+13:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:00:00','-12:00','+13:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 00:00:00','-12:00','+13:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 23:59:59','-12:00','+13:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 13:19:38','-10:38','+10:12');
|
||||
SELECT CONVERT_TZ('2021-01-01 12:23:35','-09:23','-11:11');
|
||||
SELECT CONVERT_TZ('2021-01-01 00:01:00','+10:00','-11:00');
|
||||
SELECT CONVERT_TZ('2021-01-01 00:11:00','+00:00','-11:00');
|
||||
SELECT CONVERT_TZ('2021-03-01 00:11:00','+00:00','-11:00');
|
||||
SELECT CONVERT_TZ('2021-06-01 00:11:00','+00:00','-11:00');
|
||||
SELECT CONVERT_TZ('2020-03-01 00:11:00','+00:00','-11:00');
|
||||
SELECT CONVERT_TZ('2020-02-28 23:11:00','-00:00','+11:00');
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00','-05:00','+11:00');
|
||||
|
||||
#直接时刻类型异常
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00',null,'+11:00');
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00','+11:00', null);
|
||||
SELECT CONVERT_TZ(null,'-13:00','+11:00');
|
||||
SELECT CONVERT_TZ(null, null,'+11:00');
|
||||
SELECT CONVERT_TZ(null, null, null);
|
||||
|
||||
#时区类型
|
||||
SELECT CONVERT_TZ('2020-12-31 23:11:00','America/Merida','Asia/Tokyo');
|
||||
SELECT CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Australia/Darwin');
|
||||
SELECT CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Europe/Amsterdam');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','America/Merida');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','MET','Libya');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','MET','MST');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','PRC','MST');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','PRC','ROC');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','UCT','ROC');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','Universal','ROC');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00','Pacific/Marquesas','ROC');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','GMT+0','ROC');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','GMT+0','Singapore');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan','ROC');
|
||||
|
||||
#时区类型异常
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', null,'ROC');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', null);
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', null, null);
|
||||
|
||||
#混合类型
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', '+00:00','ROC');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', '+00:00','US/Michigan');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+00:00');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'US/Michigan', '+00:00');
|
||||
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+12:58');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', 'UCT','-12:58');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '-12:58','UCT');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '-12:58','US/Michigan');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+05:12','MET');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+03:32','PRC');
|
||||
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+11:32','PRC');
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/37089894
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-13:00','+10:00');
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-12:00','+14:00');
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-13:00','ABC');
|
||||
SELECT CONVERT_TZ('2004-01-01 12:00:00','-12:00','OK');
|
||||
--disable_warnings
|
||||
drop table if exists t;
|
||||
--enable_warnings
|
||||
create table t(c1 timestamp);
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-13:00','+10:00'));
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-12:00','+14:00'));
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-13:00','ABC'));
|
||||
insert into t values(CONVERT_TZ('2004-01-01 12:00:00','-12:00','OK'));
|
||||
select * from t;
|
||||
delete from t;
|
||||
|
||||
## test result out of range
|
||||
select convert_tz('9999-12-31 20:00:00', '+02:00', '+06:00');
|
||||
select convert_tz('0000-01-01 01:00:00', '+00:00', '-02:00');
|
||||
insert into t values(convert_tz('9999-12-31 20:00:00', '+02:00', '+06:00'));
|
||||
insert into t values(convert_tz('0000-01-01 01:00:00', '+00:00', '-02:00'));
|
||||
select * from t;
|
||||
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/37089982
|
||||
SELECT CONVERT_TZ(123456,'-12:00','+10:00');
|
||||
SELECT CONVERT_TZ('','-12:00','+10:00');
|
||||
SELECT CONVERT_TZ('aa','-12:00','+10:00');
|
||||
SELECT CONVERT_TZ('张三','-12:00','+10:00');
|
||||
SELECT CONVERT_TZ('1asd561ad','-12:00','+10:00');
|
||||
SELECT CONVERT_TZ('¥¥%……&*¥','-12:00','+10:00');
|
||||
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/37090102
|
||||
drop table t;
|
||||
create table t(c1 year);
|
||||
insert into t values('1901'),('2155'), ('0000'), ('0001');
|
||||
SELECT c1, CONVERT_TZ(c1,'+00:00','+00:00') from t;
|
||||
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/37090351
|
||||
drop table t;
|
||||
create table t(a1 int,a2 year,c1 timestamp,c2 timestamp);
|
||||
insert into t values(1,'1998','1998-12-12 12:12:12','2038-01-19 03:14:07');
|
||||
insert into t values(2,'2002','2002-02-02 10:00:00','2034-02-22 00:50:20');
|
||||
insert into t values(3,'2006','2006-04-15 06:06:20','2038-01-19 03:14:07');
|
||||
insert into t values(4,'2012','2012-12-12 12:12:12','2030-08-16 14:05:50');
|
||||
select c1,c2 ,case c1 when convert_tz(c1,'+06:00','+00:00')<'2006-04-15 06:06:20' then convert_tz('2020-02-02 02:02:02','+00:00','+00:00') else convert_tz('1999-09-09 09:09:09','+00:00','+00:00') end as c1 from t;
|
||||
drop table t;
|
||||
|
||||
create table t(c1 timestamp(0), c2 timestamp(3), c3 decimal(20,4));
|
||||
insert into t values('2020-01-01 12:00:00.123456', '2020-01-01 12:00:00.123456', '20200101120000.123456');
|
||||
select c1, convert_tz(c1, '+00:00', '+08:00') from t;
|
||||
select c2, convert_tz(c2, '+00:00', '+08:00') from t;
|
||||
select c3, convert_tz(c3, '+00:00', '+08:00') from t;
|
||||
drop table t;
|
||||
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/38186028
|
||||
SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central') AS time1,
|
||||
CONVERT_TZ('2007-03-11 2:00:01','US/Eastern','US/Central') AS time2,
|
||||
CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central') AS time3,
|
||||
CONVERT_TZ('2007-03-11 3:00:01','US/Eastern','US/Central') AS time4;
|
||||
|
||||
SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','+00:00') AS time1,
|
||||
CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','+00:00') AS time2,
|
||||
CONVERT_TZ('2007-03-11 3:00:01','US/Eastern','+00:00') AS time3;
|
||||
|
||||
SELECT CONVERT_TZ('2007-11-04 01:00:00','US/Eastern','+00:00') AS time1,
|
||||
CONVERT_TZ('2007-11-04 01:00:01','US/Eastern','+00:00') AS time2,
|
||||
CONVERT_TZ('2007-11-04 02:00:00','US/Eastern','+00:00') AS time3,
|
||||
CONVERT_TZ('2007-11-04 02:00:01','US/Eastern','+00:00') AS time4;
|
||||
|
||||
create table t(c1 datetime);
|
||||
insert into t values('2007-03-11 2:00:00'), ('2007-03-11 2:00:01'), ('2007-03-11 3:00:00'), ('2007-03-11 3:00:01');
|
||||
insert into t values('2007-11-04 1:00:00'), ('2007-11-04 1:00:01'), ('2007-11-04 2:00:00'), ('2007-11-04 2:00:01');
|
||||
select convert_tz(c1, 'US/Eastern', '+00:00') from t;
|
||||
drop table t;
|
||||
|
||||
create table t(c1 timestamp);
|
||||
insert into t values('2007-03-11 1:59:59'), ('2007-03-11 3:00:00'), ('2007-03-11 3:00:01');
|
||||
insert into t values('2007-11-04 1:00:00'), ('2007-11-04 1:00:01'), ('2007-11-04 2:00:00'), ('2007-11-04 2:00:01');
|
||||
select convert_tz(c1, 'US/Eastern', '+00:00') from t;
|
||||
drop table t;
|
||||
162
tools/deploy/mysql_test/test_suite/expr/t/expr_export_set.test
Normal file
162
tools/deploy/mysql_test/test_suite/expr/t/expr_export_set.test
Normal file
@ -0,0 +1,162 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#/--disableabortonerror/
|
||||
#/test for export_set function in ob_expr_export_set.cpp/
|
||||
--enable_abort_on_error
|
||||
--echo ================ expression export_set ================
|
||||
|
||||
# 基本检查
|
||||
select export_set(0,"Y","N","-",5);
|
||||
select export_set(7,"Y","N","-",5);
|
||||
select export_set(11,"Y","N","-",5);
|
||||
select export_set(20,"Y","N","-",5);
|
||||
select export_set(9,"","","-",5);
|
||||
select export_set(9,"Y","N","-",5);
|
||||
select export_set(9,"左","右","-",5);
|
||||
select export_set(9,"上","下","-",5);
|
||||
select export_set(5,"Y","N",".",5);
|
||||
select export_set(5,"Y","N","=",5);
|
||||
select export_set(5,"Y","N","????????",5);
|
||||
select export_set(100,"Y","N",".",3);
|
||||
select export_set(100,"Y","N",".",5);
|
||||
select export_set(100,"Y","N",".",7);
|
||||
select export_set(100,"Y","N",".",10);
|
||||
|
||||
# 参数NULL检查
|
||||
select export_set(null,"Y","N",".",5);
|
||||
select export_set(0,"Y","N",".",5);
|
||||
select export_set(5,null,"N",".",5);
|
||||
select export_set(5,'',"N",".",5);
|
||||
select export_set(5,"Y",null,".",5);
|
||||
select export_set(5,"Y",'',".",5);
|
||||
select export_set(5,"Y","N",null,5);
|
||||
select export_set(5,"Y","N",'',5);
|
||||
select export_set(5,"Y","N",".",null);
|
||||
select export_set(5,"Y","N",".",0);
|
||||
select export_set(55555555555555,"YY","NN",".",0);
|
||||
select export_set(55555555555555,"YY","NN",".......",0);
|
||||
select export_set(100,'',1);
|
||||
select export_set(100,1,'');
|
||||
select export_set(100,1,0,'');
|
||||
select export_set(1000,'',1);
|
||||
select export_set(1000,1,'');
|
||||
select export_set(1000,1,0,'');
|
||||
|
||||
# 默认参数检查
|
||||
select export_set(8,"Y","N");
|
||||
select export_set(88,"Y","N");
|
||||
select export_set(888,"Y","N");
|
||||
select export_set(8888,"Y","N");
|
||||
select export_set(8,"1","0");
|
||||
select export_set(8,"X","Y");
|
||||
select export_set(8,"Y","N",'+');
|
||||
select export_set(8,"1","0",'*');
|
||||
select export_set(8,"X","Y",'*');
|
||||
|
||||
# 参数类型不同
|
||||
select export_set(7,1,0,"-",5);
|
||||
select export_set(7,11,00,"-",5);
|
||||
select export_set(7,111,000,"-",5);
|
||||
select export_set(7,111,000,5,5);
|
||||
select export_set(true,1,0);
|
||||
select export_set(true,"1","0");
|
||||
select export_set(false,1,0);
|
||||
select export_set(false,"1","0");
|
||||
select export_set(1.4,1,0);
|
||||
select export_set(2.4,1,0);
|
||||
select export_set(1.4,"y","n");
|
||||
select export_set(2.4,"y","n");
|
||||
|
||||
# 边界检查
|
||||
# 超过uint64的上界,int64的下界,ob对溢出的处理和mysql不同,这是mysql的bug,不兼容
|
||||
# 目前保证-9223372036854775808到18446744073709551615与mysql兼容
|
||||
# select export_set(1111111111111111111111111111111111111111111111111111,"Y","N");
|
||||
select export_set(9223372036854775808,"Y","N");
|
||||
select export_set(9223372036854775809,"Y","N");
|
||||
select export_set(-9223372036854775808,"Y","N");
|
||||
select export_set(18446744073709551615,"Y","N");
|
||||
select export_set(9223372036854775808,"Y","N",",",92233720368547758080000000000);
|
||||
select export_set(9223372036854775808,"Y","N",",",9223372036854775808);
|
||||
select export_set(9223372036854775809,"Y","N",",",9223372036854775809);
|
||||
select export_set(9223372036854775809,"Y","N",",",9223372036854775809000000000000);
|
||||
select export_set(-9223372036854775808,"Y","N",",",-9223372036854775808);
|
||||
select export_set(-9223372036854775808,"Y","N",",",-9223372036854775808000000000);
|
||||
select export_set(18446744073709551615,"Y","N",",",18446744073709551615);
|
||||
select export_set(18446744073709551615,"Y","N",",",1844674407370955161500000000000);
|
||||
|
||||
# 参数错误检查
|
||||
--error 1582
|
||||
select export_set();
|
||||
--error 1582
|
||||
select export_set(1);
|
||||
--error 1582
|
||||
select export_set(1,2);
|
||||
--error 1582
|
||||
select export_set("");
|
||||
--error 1582
|
||||
select export_set("","");
|
||||
--error 1582
|
||||
select export_set(5,5);
|
||||
--error 1054
|
||||
select export_set(a,2,3);
|
||||
--error 1054
|
||||
select export_set(1,2,3,a);
|
||||
--error 1054
|
||||
select export_set(1,2,3,4,a);
|
||||
|
||||
# 用表数据做参数
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
create table test(c1 int, c2 varchar(20), c3 varchar(20), c4 varchar(20), c5 int);
|
||||
insert into test values(11,"Y","N",",",10);
|
||||
insert into test values(null,"Y","N",",",10);
|
||||
insert into test values(11,null,"N",",",10);
|
||||
insert into test values(11,"Y",null,",",10);
|
||||
insert into test values(11,"Y","N",null,10);
|
||||
insert into test values(11,"Y","N",",",null);
|
||||
insert into test values(null,null,null,null,null);
|
||||
select export_set(c1,c2,c3,c4,c5) from test;
|
||||
select export_set(c1,c2,c3,c4) from test;
|
||||
select export_set(c1,c2,c3) from test;
|
||||
insert into test values(100000,"+","-",",",1000000);
|
||||
insert into test values(55555555,"+","-",",",100000);
|
||||
insert into test values(7777777,"+","-",",",10000);
|
||||
select export_set(c1,c2,c3,c4,5) from test;
|
||||
select export_set(c1,c2,c3,'??',5) from test;
|
||||
select export_set(c1,c2,c3) from test;
|
||||
--error 1582
|
||||
select export_set(c1) from test;
|
||||
--error 1582
|
||||
select export_set(c1,c2) from test;
|
||||
--error 1582
|
||||
select export_set() from test;
|
||||
|
||||
drop table test;
|
||||
|
||||
# ctas cases
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 as select export_set(0,"Y","N","-",5);
|
||||
desc t1;
|
||||
drop table t1;
|
||||
create table t1 as select export_set(99,"YYY","NX","---",77);
|
||||
desc t1;
|
||||
drop table t1;
|
||||
create table t1 as select export_set(99,"1","11","111",77);
|
||||
desc t1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
## bugfix#https://work.aone.alibaba-inc.com/issue/36895309
|
||||
--disable_warnings
|
||||
drop table if exists T_36895309;
|
||||
--enable_warnings
|
||||
CREATE TABLE T_36895309(A_0 INT,A_1 INT,A_2 VARCHAR(20),A_3 FLOAT,A_4 DATE);
|
||||
INSERT INTO T_36895309 VALUES(1,1,'A',1.23,'1999-09-09'),(2,-1,'nb',3.21,'1111-11-11'),(3,0,'#',6666.6666,'11-11-11'),(4,NULL,NULL,NULL,NULL);
|
||||
SELECT EXPORT_SET(A_2,'Y','N',',',5) FROM T_36895309 ;
|
||||
SELECT EXPORT_SET(A_3,'Y','N',',',5) FROM T_36895309 ;
|
||||
SELECT EXPORT_SET(A_4,'Y','N',',',5) FROM T_36895309 ;
|
||||
drop table T_36895309;
|
||||
92
tools/deploy/mysql_test/test_suite/expr/t/expr_floor.test
Normal file
92
tools/deploy/mysql_test/test_suite/expr/t/expr_floor.test
Normal file
@ -0,0 +1,92 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: yuchen.wyc
|
||||
#### owner group: sql3
|
||||
#### description: 测试地板函数(向下取整函数,高斯函数)
|
||||
#/--disableabortonerror/
|
||||
#/test for floor function in ob_expr_func_floor.cpp/
|
||||
--enable_abort_on_error
|
||||
--echo ================ expression floor ================
|
||||
select floor(null);
|
||||
select floor(-123);
|
||||
select floor(-123.123);
|
||||
select floor(123);
|
||||
select floor(3.1415926);
|
||||
select floor(-3.1415926);
|
||||
select floor(0.00);
|
||||
select floor(-0.0);
|
||||
select floor(0.123456789);
|
||||
select floor(-0.123456789);
|
||||
select floor(123456789.123456789);
|
||||
select floor(-99999999.999999999);
|
||||
select floor(999999999.123456789);
|
||||
select floor(-999999999.123456789);
|
||||
select floor(-123456789123456789123456789.123456789);
|
||||
select floor(123456789123456789123456789123456789123456789123456789.123456789);
|
||||
select floor(-123456789123456789123456789123456789123456789123456789.123456789);
|
||||
select floor(123456789123456789123456789.123456789123456789123456789123456789);
|
||||
select floor(-123456789123456789123456789.123456789123456789123456789123456789);
|
||||
select floor(-123456789123456789123456789.123456789);
|
||||
select floor(999999999999999999999999999999999999999999999.499999999);
|
||||
select floor(999999999999999999999999999999999999999999999.500000001);
|
||||
select floor(99999999999999999999999999999999999999999999.399999999);
|
||||
select floor(-99999999999999999999999999999999999999999999.399999999);
|
||||
select floor(-99999999999999999999999999999999999999999999.399999999);
|
||||
select floor(999999999999999999999999999999999999999999999211111.399999999);
|
||||
select floor(-999999999999999999999999999999999999999999999211111.399999999);
|
||||
select floor(-999999999999999999999999999999999999999999999511111.399999999);
|
||||
select floor(-999999999999999999999999999999999999999999999499999.399999999);
|
||||
select floor(0.00000000000),ceil(0.00000);
|
||||
--disable_warnings
|
||||
drop table if exists tbl1;
|
||||
--enable_warnings
|
||||
create table tbl1 (i1 int, v2 varchar(80), i3 char(20),i4 float, d4 datetime(6),i5 decimal(5,3), primary key(i1));
|
||||
insert into tbl1 values(1,'now','haha1',1.6256,'2014-05-04 12:00:00',-10.235);
|
||||
insert into tbl1 values(2,'now','haha2',-1.6256,'2014-05-04 12:00:00',1.243);
|
||||
insert into tbl1 values(3,'now','haha3',1.156,'2014-05-04 12:00:00',-1.45);
|
||||
insert into tbl1 values(4,'now','haha1',5.9256,'2014-05-04 12:00:00',3.45);
|
||||
insert into tbl1 values(5,'now1','haha2',1.2356,'2014-05-04 12:00:00',-0.25);
|
||||
insert into tbl1 values(6,'now2','haha3',-10.4256,'2014-05-04 12:00:00',0.253);
|
||||
insert into tbl1 values(7,'now3','haha4',0.6256,'2014-05-04 12:00:00',1.677);
|
||||
select floor(i4),floor(i5) from tbl1;
|
||||
select max(floor(i4)),max(floor(i5)) from tbl1;
|
||||
select min(floor(i4)),min(floor(i5)) from tbl1;
|
||||
select max(ceil(i4)),max(ceil(i5)) from tbl1;
|
||||
select min(ceil(i4)),min(ceil(i5)) from tbl1;
|
||||
select avg(ceil(i4)),avg(ceil(i5)) from tbl1;
|
||||
select avg(ceil(i5)),avg(floor(i5)) from tbl1;
|
||||
select sum(ceil(i4)),sum(ceil(i5)) from tbl1;
|
||||
select count(ceil(i4)),count(ceil(i5)) from tbl1;
|
||||
select ceil(count(ceil(i4))),floor(count(ceil(i5))) from tbl1;
|
||||
select ceil(avg(ceil(i4))),floor(avg(ceil(i5))) from tbl1;
|
||||
select ceil(avg(ceil(i4))),ceil(avg(ceil(i5))) from tbl1;
|
||||
select * from tbl1 where floor(i4)=2;
|
||||
select * from tbl1 where floor(i4)=ceil(i4)-1;
|
||||
select * from tbl1 where floor(i1)=ceil(i1);
|
||||
select floor(i1/10*8),i1/10*8 from tbl1;
|
||||
select * from tbl1 order by floor(i4);
|
||||
select * from tbl1 order by floor(i4) desc;
|
||||
select floor(i4) abc from tbl1 order by abc desc;
|
||||
select floor(v2) from tbl1;
|
||||
select floor(i3) from tbl1;
|
||||
select floor(d4) from tbl1;
|
||||
--disable_warnings
|
||||
drop table if exists tbl2;
|
||||
--enable_warnings
|
||||
create table tbl2 (i1 int, v2 varchar(80), primary key(i1));
|
||||
insert into tbl2 values(1,'1');
|
||||
insert into tbl2 values(2,'2.5');
|
||||
insert into tbl2 values(3,'-3.2');
|
||||
select floor(v2),ceil(v2) from tbl2;
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
create table test (pk int primary key, c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 mediumint unsigned, c9 int unsigned, c10 bigint unsigned, c11 float, c12 double, c13 float unsigned, c14 double unsigned, c15 decimal(20, 10), c16 decimal(20, 10) unsigned, c17 datetime(6), c18 timestamp(6) default "2012-01-01 12:00:00", c19 date, c20 time, c21 year , c22 varchar(10000), c23 char(255), c24 varbinary(10000), c25 binary(255));
|
||||
insert into test values (0, -128, 2, -3, 4, -5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '22.5324', '-23.436456', '-24', '25');
|
||||
insert into test values (1, 1, -2, 3, -4, 5, 6, 7, 8, 9, 10, -11.49, -12.5, 13.5, 14.49, 15.99, 16.1, '2017-01-01 00:01:10.123456', '2018-02-02 00:02:20.123456', '2019-03-03', '20:04:40.123456', '2021', '-22.999999', '23.00001', '24.9999', '-25.00001');
|
||||
insert into test values (2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
select floor(pk), floor(c1), floor(c2), floor(c3), floor(c4), floor(c5), floor(c6), floor(c7), floor(c8), floor(c9), floor(c10), floor(c11), floor(c12), floor(c13), floor(c14), floor(c15), floor(c16), floor(c22), floor(c23), floor(c24), floor(c25) from test;
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
74
tools/deploy/mysql_test/test_suite/expr/t/expr_instr.test
Normal file
74
tools/deploy/mysql_test/test_suite/expr/t/expr_instr.test
Normal file
@ -0,0 +1,74 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: yuchen.wyc
|
||||
#### owner group: sql3
|
||||
#### description: 测试instr函数
|
||||
--echo ================ expression instr ================
|
||||
select instr('abc', '');
|
||||
select instr('', '');
|
||||
select instr('', 'abc');
|
||||
select instr('abc', 'abcd');
|
||||
select instr('abc', 'abc');
|
||||
select instr('abc', 'a');
|
||||
select instr('abc', 'b');
|
||||
select instr('abc', 'c');
|
||||
select instr('abc', 'bc');
|
||||
select instr('abcbc', 'bc');
|
||||
select instr('阿里巴巴', '阿里');
|
||||
select instr('阿里巴巴', '巴巴');
|
||||
select instr('阿里巴巴巴巴', '巴巴');
|
||||
select instr('阿里巴巴', '阿里巴巴');
|
||||
select instr('123', true);
|
||||
select instr('23', true);
|
||||
select instr(123, '23');
|
||||
select instr('123', 123);
|
||||
select instr('123.400000', 23.4);
|
||||
select instr('123.400000', 123.4);
|
||||
select instr('123.400000', null);
|
||||
select instr(null, '巴巴');
|
||||
select instr('巴巴', null);
|
||||
select instr(null, null);
|
||||
|
||||
select instr(true, false);
|
||||
select instr(true, true);
|
||||
select instr(123, true);
|
||||
select instr(123, false);
|
||||
select instr(0123, false);
|
||||
select instr(1023, false);
|
||||
select instr(1023.4, false);
|
||||
select instr(1023.4, true);
|
||||
select instr(null, true);
|
||||
select instr(true, null);
|
||||
|
||||
select instr(123, 23);
|
||||
select instr(123, 23456);
|
||||
select instr(123.4, 123);
|
||||
select instr(1234, 123.4);
|
||||
select instr(1234, null);
|
||||
select instr(null, 123);
|
||||
|
||||
select instr(123.400000, 123.4);
|
||||
select instr(123.400000, 123.41);
|
||||
select instr(123.400000, null);
|
||||
select instr(null, 123.41);
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
create table test(c1 datetime primary key);
|
||||
sleep 5;
|
||||
insert into test values('2015-5-5');
|
||||
select instr(c1, '201') from test;
|
||||
select instr(c1, '') from test;
|
||||
select instr(c1, 'haha') from test;
|
||||
select instr(c1, '-5') from test;
|
||||
select instr(c1, '2015-5-5') from test;
|
||||
select instr(c1, true) from test;
|
||||
select instr(c1, 201) from test;
|
||||
select instr(c1, 201.1) from test;
|
||||
select instr(c1, null) from test;
|
||||
select instr(null, c1) from test;
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
198
tools/deploy/mysql_test/test_suite/expr/t/expr_locate.test
Normal file
198
tools/deploy/mysql_test/test_suite/expr/t/expr_locate.test
Normal file
@ -0,0 +1,198 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: yuchen.wyc
|
||||
#### owner group: sql3
|
||||
#### description: 测试locate函数
|
||||
# tags: expr, datatype
|
||||
|
||||
--echo ================ expression locate ================
|
||||
|
||||
select locate('', 'abc');
|
||||
select locate('', '');
|
||||
select locate('abcd', 'abc');
|
||||
select locate('abc', 'abc');
|
||||
select locate('a', 'abc');
|
||||
select locate('b', 'abc');
|
||||
select locate('c', 'abc');
|
||||
select locate('bc', 'abc');
|
||||
select locate('bc', 'abcbc');
|
||||
select locate('阿里', '阿里巴巴');
|
||||
select locate('巴巴', '阿里巴巴巴巴');
|
||||
select locate('阿里巴巴', '阿里巴巴');
|
||||
select locate(true, '123');
|
||||
select locate(true, '23');
|
||||
select locate(23, 123);
|
||||
select locate('', 23);
|
||||
select locate('23', 123);
|
||||
select locate(123.4, '123.400000');
|
||||
select locate('123.400000', 123.4);
|
||||
select locate('123.400000', null);
|
||||
select locate(null, '巴巴');
|
||||
select locate('巴巴', null);
|
||||
select locate(null, null);
|
||||
|
||||
|
||||
select locate(false, true);
|
||||
select locate(true, true);
|
||||
select locate(true, 123);
|
||||
select locate(false, 123);
|
||||
select locate(false, 0123);
|
||||
select locate(false, 1023);
|
||||
select locate(false,1023.4);
|
||||
select locate(true, 1023.4);
|
||||
select locate(true, null);
|
||||
select locate(null, true);
|
||||
|
||||
select locate(23, 123);
|
||||
select locate(123456, 123);
|
||||
select locate(123, 123.4);
|
||||
select locate(123.4, 1234);
|
||||
select locate(123, null);
|
||||
select locate(null, 123);
|
||||
|
||||
select locate(123.4, 123.400000);
|
||||
select locate(123.41, 123.400000);
|
||||
select locate(123.400000, null);
|
||||
select locate(null, 123.41);
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 bigint unsigned);
|
||||
insert into t1 values(locate('a','b',9223372036854775807));
|
||||
insert into t1 values(locate('a','b',9223372036854775808));
|
||||
insert into t1 values(locate('a','b',12233720368547758000));
|
||||
select * from t1;
|
||||
create table test(c1 datetime primary key);
|
||||
sleep 5;
|
||||
insert into test values('2015-5-5');
|
||||
select locate('201', c1) from test;
|
||||
select locate('', c1) from test;
|
||||
select locate('haha', c1) from test;
|
||||
select locate('-5',c1) from test;
|
||||
select locate('2015-5-5', c1) from test;
|
||||
select locate(true, c1) from test;
|
||||
select locate(201, c1) from test;
|
||||
select locate(201.1, c1) from test;
|
||||
select locate(c1, null) from test;
|
||||
select locate(null, c1) from test;
|
||||
--disable_warnings
|
||||
drop table if exists test,t1;
|
||||
--enable_warnings
|
||||
|
||||
select locate('', 'abc', 0);
|
||||
select locate('', 'abc', 1);
|
||||
select locate('', 'abc', -1);
|
||||
select locate('', '', 0);
|
||||
select locate('', '', 1);
|
||||
select locate('', '', -1);
|
||||
select locate('abc', '', 0);
|
||||
select locate('abc', '', -1);
|
||||
select locate('abc', '', 1);
|
||||
select locate('abcd', 'abc', 1);
|
||||
select locate('abc', 'abc', 1);
|
||||
select locate('abc', 'abc', 2);
|
||||
select locate('a', 'abc', 1);
|
||||
select locate('a', 'abc', 2);
|
||||
select locate('a', 'abac', 1);
|
||||
select locate('a', 'abac', 2);
|
||||
select locate('b', 'abc', 1);
|
||||
select locate('b', 'abc', 2);
|
||||
select locate('b', 'abc', 3);
|
||||
select locate('c', 'abc', 1);
|
||||
select locate('c', 'abc', 3);
|
||||
select locate('c', 'abc', 4);
|
||||
select locate('bc', 'abc', 1);
|
||||
select locate('bc', 'abc', 3);
|
||||
select locate('', 'abc', 3);
|
||||
select locate('', 'abc', 4);
|
||||
select locate('', 'abc', 5);
|
||||
select locate('阿里', '阿里巴巴', 1);
|
||||
select locate('阿里', '阿里巴巴', 2);
|
||||
select locate('巴巴', '阿里巴巴', 1);
|
||||
select locate('巴巴', '阿里巴巴', 3);
|
||||
select locate('巴巴', '阿里巴巴', 4);
|
||||
select locate('巴巴', '阿里巴巴', 5);
|
||||
select locate('', '阿里阿里', 3);
|
||||
select locate('', '阿里阿里', 4);
|
||||
select locate('', '阿里阿里', 5);
|
||||
select locate('阿里巴巴', '阿里巴巴', 0);
|
||||
select locate('阿里巴巴', '阿里巴巴', 1);
|
||||
select locate(23, 123, 1);
|
||||
select locate('', 23, 1);
|
||||
select locate('23', 123, 1);
|
||||
select locate(true, '123', 1);
|
||||
select locate(true, '123', 2);
|
||||
select locate(true, '123', 2);
|
||||
select locate(true, '123', 2);
|
||||
select locate(true, '1', 1);
|
||||
select locate('1', true, 1);
|
||||
select locate(1.3, '1.300000', 2);
|
||||
select locate(1.3, '2321.300000', 2);
|
||||
select locate(1.3, '2321.3', 2);
|
||||
select locate('1.3000', 451.3, 2);
|
||||
select locate(null, '巴巴', 3);
|
||||
select locate(null, '巴巴', 2);
|
||||
select locate('巴巴', null, 3);
|
||||
select locate('巴巴', null, 2);
|
||||
select locate('巴巴', '阿里巴巴', null);
|
||||
select locate(null, null, 0);
|
||||
select locate(null, null, 1);
|
||||
|
||||
select locate(false, true, 1);
|
||||
select locate(false, true, 2);
|
||||
select locate(true, true, 1);
|
||||
select locate(true, 123, 1);
|
||||
select locate(true, 123, 2);
|
||||
select locate(false, 1023.4, 2);
|
||||
select locate(false, 1023.4, 3);
|
||||
select locate(true, null, 0);
|
||||
select locate(true, null, 1);
|
||||
select locate(null, true, 0);
|
||||
select locate(null, true, 3);
|
||||
select locate(true, true, null);
|
||||
|
||||
select locate(23, 123, 1);
|
||||
select locate(23, 123, 3);
|
||||
select locate(123456, 123, 9);
|
||||
select locate(123, 123.4, 1);
|
||||
select locate(123, 123.4, 2);
|
||||
select locate(123.4, 1234, 4);
|
||||
select locate(123, null, 1);
|
||||
select locate(123, null, null);
|
||||
select locate(null, 123, 1);
|
||||
select locate(null, 123, null);
|
||||
|
||||
select locate(123.4, 123.400000, 1);
|
||||
select locate(123.4, 123.400000, 2);
|
||||
select locate(123.41, 123.400000, 3);
|
||||
select locate(123.400000, null, 3);
|
||||
select locate(null, 123.41, 3);
|
||||
select locate(null, 123.41, null);
|
||||
select locate(null, 123.41, 126);
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
create table test(c1 datetime primary key);
|
||||
sleep 5;
|
||||
insert into test values('2015-5-5');
|
||||
select locate('201', c1, 1) from test;
|
||||
select locate('', c1 , 1) from test;
|
||||
select locate('haha', c1 , 1) from test;
|
||||
select locate('-5',c1 , 1) from test;
|
||||
select locate('2015-5-5', c1 , 1) from test;
|
||||
select locate(true, c1 , 1) from test;
|
||||
select locate(true, c1 , 4) from test;
|
||||
select locate(201, c1 , 1) from test;
|
||||
select locate(201.1, c1 , 1) from test;
|
||||
select locate(null, c1 , 1) from test;
|
||||
select locate(c1, null, 1) from test;
|
||||
select locate(c1, null, null) from test;
|
||||
select mod(locate('a','b'),1.000);
|
||||
select ifnull(locate('a','a'),2.345 );
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
45
tools/deploy/mysql_test/test_suite/expr/t/expr_nseq.test
Normal file
45
tools/deploy/mysql_test/test_suite/expr/t/expr_nseq.test
Normal file
@ -0,0 +1,45 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: yuchen.wyc
|
||||
#### owner group: sql3
|
||||
#### description: 测试<=>运算符
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
create table t1(a int, b int, c int, d int, primary key(a));
|
||||
insert into t1 values(1,2,3,4);
|
||||
insert into t1 values(2,null,3,4);
|
||||
insert into t1 values(3,null,null,4);
|
||||
insert into t1 values(4,2,null,null);
|
||||
create table t2(a int, b int, c int, d int, primary key(a,b));
|
||||
insert into t2 values(1,2,3,4);
|
||||
insert into t2 values(2,2,3,4);
|
||||
insert into t2 values(3,3,null,4);
|
||||
insert into t2 values(4,2,null,null);
|
||||
|
||||
|
||||
select 1<=>1;
|
||||
select 1<=>null;
|
||||
select null<=>1;
|
||||
select null<=>null;
|
||||
select 1.0<=>1.0;
|
||||
select 1.0<=>null;
|
||||
select null<=>1.0;
|
||||
select 'abc'<=>null;
|
||||
select 'abc'<=>'abc';
|
||||
select 'null'<=>null;
|
||||
select (1,2,3)<=>(1,2,3);
|
||||
select (1,null, 3) <=> (1,null,3);
|
||||
select (1,null,'abc')<=>(1,null,'abc');
|
||||
select * from t1 where b<=>null;
|
||||
select * from t1 where a<=>2;
|
||||
select * from t1 where a<=>2 and b<=>null;
|
||||
select * from t1 where b<=>null and c<=>null;
|
||||
select * from t1 where b=null and c=null;
|
||||
select * from t1 where b<=>null and c=null;
|
||||
select * from t1 join t2 on t1.a=t2.a;
|
||||
select * from t1 join t2 on t1.a=t2.a where t1.b<=>null and t2.b<=>null;
|
||||
|
||||
|
||||
select * from t1 join t2 on t1.a<=>t2.a;
|
||||
65
tools/deploy/mysql_test/test_suite/expr/t/expr_position.test
Normal file
65
tools/deploy/mysql_test/test_suite/expr/t/expr_position.test
Normal file
@ -0,0 +1,65 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: yuchen.wyc
|
||||
#### owner group: sql3
|
||||
#### description: 测试position函数
|
||||
--echo ================ expression position ================
|
||||
select position(' ' in 'abc');
|
||||
select position('abcd' in 'abc');
|
||||
select position('abc' in 'abc');
|
||||
select position('a' in 'abc');
|
||||
select position('b' in 'abc');
|
||||
select position('c' in 'abc');
|
||||
select position('bc' in 'abc');
|
||||
select position('bc' in 'abcbc');
|
||||
select position('BC' in 'abcbc');
|
||||
select position('bC' in 'abcbc');
|
||||
select position('阿里' in '阿里巴巴');
|
||||
select position('巴巴' in '阿里巴巴巴巴');
|
||||
select position('阿里巴巴' in '阿里巴巴');
|
||||
select position(true in '123');
|
||||
select position(true in '23');
|
||||
select position(23 in 123);
|
||||
select position('' in 23);
|
||||
select position('23' in 123);
|
||||
select position(123.4 in '123.400000');
|
||||
select position('123.400000' in 123.4);
|
||||
select position('123.400000' in null);
|
||||
select position(null in '巴巴');
|
||||
select position('巴巴' in null);
|
||||
select position(null in null);
|
||||
|
||||
|
||||
select position(false in true);
|
||||
select position(true in true);
|
||||
select position(true in 123);
|
||||
select position(false in 123);
|
||||
select position(false in 0123);
|
||||
select position(false in 1023);
|
||||
select position(23 in 123);
|
||||
select position(123456 in 123);
|
||||
select position(123 in 123.4);
|
||||
select position(123.4 in 1234);
|
||||
select position(123 in null);
|
||||
select position(null in 123);
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
create table test(c1 datetime primary key);
|
||||
sleep 5;
|
||||
insert into test values('2015-5-5');
|
||||
select position('201' in c1) from test;
|
||||
select position('' in c1) from test;
|
||||
select position('haha' in c1) from test;
|
||||
select position('-5' in c1) from test;
|
||||
select position('2015-5-5' in c1) from test;
|
||||
select position(true in c1) from test;
|
||||
select position(201 in c1) from test;
|
||||
select position(201.1 in c1) from test;
|
||||
select position(c1 in null) from test;
|
||||
select position(null in c1) from test;
|
||||
--disable_warnings
|
||||
drop table if exists test;
|
||||
--enable_warnings
|
||||
59
tools/deploy/mysql_test/test_suite/expr/t/func_equal.test
Normal file
59
tools/deploy/mysql_test/test_suite/expr/t/func_equal.test
Normal file
@ -0,0 +1,59 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#### owner: yuchen.wyc
|
||||
#### owner group: sql3
|
||||
#### description: 测试相等比较运算符
|
||||
# Initialise
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
#
|
||||
##
|
||||
## Testing of the <=> operator
|
||||
##
|
||||
#
|
||||
##
|
||||
## First some simple tests
|
||||
##
|
||||
#
|
||||
select 0<=>0,0.0<=>0.0,0E0=0E0,'A'<=>'A',NULL<=>NULL;
|
||||
select 1<=>0,0<=>NULL,NULL<=>0;
|
||||
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
|
||||
select 'A'<=>'B','A'<=>NULL,NULL<=>'A';
|
||||
select 0<=>0.0, 0.0<=>0E0, 0E0<=>'0', 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
|
||||
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;
|
||||
#
|
||||
##
|
||||
## Test with tables
|
||||
##
|
||||
#
|
||||
create table t1 (id int primary key, value int);
|
||||
create table t2 (id int primary key, value int);
|
||||
#
|
||||
insert into t1 values (1,null);
|
||||
insert into t2 values (1,null);
|
||||
#
|
||||
select t1.*, t2.*, t1.value=t2.value from t1, t2 where t1.id=t2.id and t1.id=1;
|
||||
select * from t1 where id =id;
|
||||
select * from t1 where value = value;
|
||||
select * from t1 where id = value or value=id;
|
||||
select * from t1 where value = null;
|
||||
select * from t1 where (value) = (null);
|
||||
--error 1064
|
||||
select * from t1 where ROW(value) = ROW(null);
|
||||
select * from t1 where (id, value) = (1, null);
|
||||
drop table t1,t2;
|
||||
#
|
||||
##
|
||||
## Bug #12612: quoted bigint unsigned value and the use of 'in' in where clause
|
||||
##
|
||||
create table t1 (a bigint primary key);
|
||||
insert into t1 values (4828532208463511553);
|
||||
select * from t1 where a = '4828532208463511553';
|
||||
select * from t1 where a = 4828532208463511553;
|
||||
select * from t1 where a in ('4828532208463511553');
|
||||
select * from t1 where a in (4828532208463511553,1);
|
||||
drop table t1;
|
||||
#
|
||||
## End of 4.1 tests
|
||||
72
tools/deploy/mysql_test/test_suite/expr/t/func_length.test
Normal file
72
tools/deploy/mysql_test/test_suite/expr/t/func_length.test
Normal file
@ -0,0 +1,72 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
#owner: guoping.wgp
|
||||
#owner group: sql1
|
||||
|
||||
--disable_abort_on_error
|
||||
--disable_warnings
|
||||
|
||||
select length('ab');
|
||||
select length('ab ');
|
||||
select length('ab\t');
|
||||
select length('ab\0');
|
||||
#特殊处理
|
||||
select length('\_');
|
||||
select length('\%');
|
||||
#转义字符
|
||||
select length('\\');
|
||||
select length('\z');
|
||||
select length('\n\t\r\b\0\_\%\\');
|
||||
#直接忽略'\'
|
||||
select length('\a');
|
||||
select length('\m');
|
||||
#数字转换
|
||||
select length(12.466);
|
||||
select length(4334);
|
||||
select length(0.00);
|
||||
#根据collation判断
|
||||
select length('好');
|
||||
|
||||
#作为列名
|
||||
select length(13bd);
|
||||
select length(db24);
|
||||
|
||||
###带小数点且以0结尾
|
||||
select length(00.000);
|
||||
select length(00.000);
|
||||
select length(1.00000);
|
||||
select length(10000.10);
|
||||
|
||||
|
||||
create database if not exists db1;
|
||||
use db1;
|
||||
--disable_warnings
|
||||
drop table if exists utf,tx,gbk;
|
||||
--enable_warnings
|
||||
|
||||
create table utf(c1 int primary key, c2 char(10)) collate 'utf8mb4_bin';
|
||||
insert into utf values(1, '好');
|
||||
select length(c2) from utf;
|
||||
|
||||
create table tx(s int(255) zerofill);
|
||||
insert into tx values (2);
|
||||
select * from tx;
|
||||
select * from tx;
|
||||
select * from tx;
|
||||
select length(s) from tx;
|
||||
|
||||
drop table tx;
|
||||
create table tx(s int(121) zerofill);
|
||||
insert into tx values (1234);
|
||||
select * from tx;
|
||||
select * from tx;
|
||||
select * from tx;
|
||||
select length(s) from tx;
|
||||
|
||||
drop table tx;
|
||||
|
||||
#create table gbk(c1 int primary key, c2 char(10)) collate 'gbk_bin';
|
||||
#insert into gbk values (1, '好');
|
||||
#select length(c2) from gbk;
|
||||
drop database db1;
|
||||
444
tools/deploy/mysql_test/test_suite/expr/t/func_regexp.test
Normal file
444
tools/deploy/mysql_test/test_suite/expr/t/func_regexp.test
Normal file
@ -0,0 +1,444 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
# owner: guoyun.lgy
|
||||
# modifier: jiangxiu.wt
|
||||
# owner group: SQL1
|
||||
# description: regexp的测试
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
##
|
||||
#--real_sleep 10
|
||||
create table t1 (a varchar(10) primary key, b int default 0);
|
||||
#--real_sleep 10
|
||||
insert into t1 (a) values ('a'),('abc'),('abcd'),('hello'),('test');
|
||||
|
||||
--error 5813
|
||||
select * from t1 where a regexp 'a(';
|
||||
--error 5813
|
||||
select * from t1 where a regexp 'a(b';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '*';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '+';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '?';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '(*a)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '(+a)';
|
||||
--error 5824
|
||||
select * from t1 where a regexp '(?a)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '({1}a)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '(a|*b)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '(a|+b)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '(a|?b)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '(a|{1}b)';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '^*';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '^+';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '^?';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '^{1}';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '{1';
|
||||
--error 5820
|
||||
select * from t1 where a regexp '{1}';
|
||||
--error 5818
|
||||
select * from t1 where a regexp 'a{1';
|
||||
--error 5819
|
||||
select * from t1 where a regexp 'a{1a';
|
||||
--error 5819
|
||||
select * from t1 where a regexp 'a{1a}';
|
||||
--error 5819
|
||||
select * from t1 where a regexp 'a{1,x}';
|
||||
--error 5819
|
||||
select * from t1 where a regexp 'a{1,x';
|
||||
--error 5819
|
||||
select * from t1 where a regexp 'a{300}';
|
||||
--error 5819
|
||||
select * from t1 where a regexp 'a{1,0}';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a++';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a*+';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a+*';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a?*';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a?+';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a{1}{1}';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a*{1}';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a+{1}';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a?{1}';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a{1}*';
|
||||
--error 5820
|
||||
select * from t1 where a regexp 'a{1}+';
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
#--real_sleep 10
|
||||
create table t1 (a datetime primary key);
|
||||
#--real_sleep 10
|
||||
insert into t1 values ('2004-03-11 12:00:21');
|
||||
select * from t1 where a regexp '2004-03-11 12:00:21';
|
||||
select * from t1 where a regexp '2004-03-11 ';
|
||||
drop table t1;
|
||||
|
||||
# A case
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(id int primary key, name varchar(100));
|
||||
insert into t1 values(1, 'hello');
|
||||
insert into t1 values(2, 'hell');
|
||||
insert into t1 values(3, 'hel');
|
||||
insert into t1 values(4, 'hello1');
|
||||
insert into t1 values(5, 'hell1');
|
||||
insert into t1 values(6, 'hel1');
|
||||
insert into t1 values(7, 'hel\n1');
|
||||
insert into t1 values(8, 'he\bl1');
|
||||
insert into t1 values(9, 'hel\t1');
|
||||
insert into t1 values(10, 'hel\r\n1o');
|
||||
insert into t1 values(11, '111 <title>Hello World</title> 222');
|
||||
|
||||
insert into t1 values (138, 'abc');
|
||||
insert into t1 values (139, 'abc');
|
||||
insert into t1 values (142, 'abc');
|
||||
insert into t1 values (146, 'a(');
|
||||
insert into t1 values (152, 'a)');
|
||||
insert into t1 values (153, ')');
|
||||
insert into t1 values (158, 'ab');
|
||||
insert into t1 values (163, 'a^b');
|
||||
insert into t1 values (165, 'a$b');
|
||||
insert into t1 values (170, '""');
|
||||
insert into t1 values (173, '""');
|
||||
insert into t1 values (174, '""');
|
||||
insert into t1 values (192, 'b');
|
||||
insert into t1 values (203, 'abc');
|
||||
insert into t1 values (272, 'abc');
|
||||
insert into t1 values (273, 'abc');
|
||||
insert into t1 values (287, 'ab');
|
||||
insert into t1 values (289, 'ab');
|
||||
insert into t1 values (291, 'aab');
|
||||
insert into t1 values (299, 'a{,2}');
|
||||
insert into t1 values (301, 'a{,}');
|
||||
insert into t1 values (311, 'abcac');
|
||||
insert into t1 values (313, 'abcac');
|
||||
insert into t1 values (315, 'abbcac');
|
||||
insert into t1 values (317, 'acabc');
|
||||
insert into t1 values (319, 'acabc');
|
||||
insert into t1 values (321, 'abcabbc');
|
||||
insert into t1 values (323, 'abcabbc');
|
||||
insert into t1 values (325, 'a');
|
||||
insert into t1 values (344, 'a{b}');
|
||||
insert into t1 values (384, '-%@a?X-');
|
||||
insert into t1 values (385, '-%@aX0-');
|
||||
insert into t1 values (386, 'aSSTb');
|
||||
insert into t1 values (387, 'aNTb');
|
||||
insert into t1 values (388, 'a019b');
|
||||
insert into t1 values (389, 'Sa%bS');
|
||||
insert into t1 values (390, 'AabC');
|
||||
insert into t1 values (391, 'NaSbN');
|
||||
insert into t1 values (392, 'S%-&T');
|
||||
insert into t1 values (393, 'aSNTb');
|
||||
insert into t1 values (394, 'aBCd');
|
||||
insert into t1 values (395, 'p0f3Cq');
|
||||
insert into t1 values (405, 'abc');
|
||||
insert into t1 values (406, 'abd');
|
||||
insert into t1 values (407, 'abbd');
|
||||
insert into t1 values (409, 'aaaaabaaaabaaaabaaaab');
|
||||
insert into t1 values (411, 'aaaaabaaaabaaaabaaaab');
|
||||
insert into t1 values (413, 'aaaaabaaaabaaaabaaaabweeknights');
|
||||
insert into t1 values (415, 'a12345678901234567890123456789b');
|
||||
insert into t1 values (416, 'a123456789012345678901234567890b');
|
||||
insert into t1 values (417, 'a1234567890123456789012345678901b');
|
||||
insert into t1 values (418, 'a12345678901234567890123456789012b');
|
||||
insert into t1 values (419, 'a123456789012345678901234567890123b');
|
||||
insert into t1 values (421, 'a1234567890123456789012345678901234567890123456789012345678901234567890b');
|
||||
insert into t1 values (423, 'xacegikmoq');
|
||||
insert into t1 values (424, 'xacegikmoq');
|
||||
insert into t1 values (425, 'xacegikmoqy');
|
||||
insert into t1 values (426, 'xacegikmoqy');
|
||||
insert into t1 values (438, 'abc');
|
||||
insert into t1 values (439, 'aba');
|
||||
insert into t1 values (440, 'abc');
|
||||
insert into t1 values (441, 'abd');
|
||||
insert into t1 values (442, 'accd');
|
||||
insert into t1 values (443, 'weeknights');
|
||||
insert into t1 values (444, 'weeknights');
|
||||
insert into t1 values (445, 'xyzaaabcaababdacd');
|
||||
insert into t1 values (446, 'aaabc');
|
||||
insert into t1 values (452, '/*x*/');
|
||||
insert into t1 values (454, '/*x*/y/*z*/');
|
||||
insert into t1 values (456, '/*x*/');
|
||||
insert into t1 values (457, '/*x*/y/*z*/');
|
||||
insert into t1 values (459, '/*x**/y/*z*/');
|
||||
insert into t1 values (461, '/*x*/');
|
||||
insert into t1 values (462, '/*x*/y/*z*/');
|
||||
insert into t1 values (463, '/*x**/y/*z*/');
|
||||
insert into t1 values (464, '/*x****/y/*z*/');
|
||||
insert into t1 values (465, '/*x**x*/y/*z*/');
|
||||
insert into t1 values (466, '/*x***x/y/*z*/');
|
||||
insert into t1 values (469, 'abcd');
|
||||
insert into t1 values (470, 'abc');
|
||||
insert into t1 values (471, 'abd');
|
||||
insert into t1 values (472, 'abbd');
|
||||
insert into t1 values (473, 'acd');
|
||||
insert into t1 values (474, 'ad');
|
||||
insert into t1 values (475, 'abc');
|
||||
insert into t1 values (476, 'ac');
|
||||
insert into t1 values (477, 'abc');
|
||||
insert into t1 values (478, 'abbbc');
|
||||
insert into t1 values (479, 'ac');
|
||||
insert into t1 values (480, 'abcdef');
|
||||
insert into t1 values (482, 'abcdefghijk');
|
||||
insert into t1 values (483, 'abcdefghijkl');
|
||||
insert into t1 values (484, 'abc');
|
||||
insert into t1 values (485, 'ac');
|
||||
insert into t1 values (486, 'abc');
|
||||
insert into t1 values (487, 'abcc');
|
||||
insert into t1 values (488, 'abcbc');
|
||||
insert into t1 values (489, 'abb');
|
||||
insert into t1 values (490, 'abb');
|
||||
insert into t1 values (491, 'abbb');
|
||||
insert into t1 values (492, 'abbb');
|
||||
insert into t1 values (493, 'abcdef');
|
||||
insert into t1 values (494, 'bc');
|
||||
insert into t1 values (497, 'ad');
|
||||
insert into t1 values (498, 'abcd');
|
||||
insert into t1 values (499, 'abd');
|
||||
insert into t1 values (500, 'abcd');
|
||||
insert into t1 values (501, 'ad');
|
||||
insert into t1 values (502, 'abcd');
|
||||
insert into t1 values (503, 'ad');
|
||||
insert into t1 values (504, 'ad');
|
||||
insert into t1 values (505, 'abd');
|
||||
insert into t1 values (506, 'ad');
|
||||
insert into t1 values (507, 'abcd');
|
||||
insert into t1 values (508, 'ad');
|
||||
insert into t1 values (509, 'abcd');
|
||||
insert into t1 values (510, 'abd');
|
||||
insert into t1 values (511, 'acd');
|
||||
insert into t1 values (512, 'abd');
|
||||
insert into t1 values (513, 'abcd');
|
||||
insert into t1 values (514, 'abd');
|
||||
insert into t1 values (515, 'abcd');
|
||||
insert into t1 values (516, 'acbd');
|
||||
insert into t1 values (517, 'abcd');
|
||||
insert into t1 values (518, 'abcd');
|
||||
insert into t1 values (519, 'abcbd');
|
||||
insert into t1 values (520, 'abcbcd');
|
||||
insert into t1 values (521, 'abcd');
|
||||
insert into t1 values (522, 'abcbd');
|
||||
insert into t1 values (523, 'abd');
|
||||
insert into t1 values (524, 'abcd');
|
||||
insert into t1 values (567, 'A1');
|
||||
insert into t1 values (571, 'CC11');
|
||||
insert into t1 values (573, 'ab');
|
||||
select * from t1 where name rlike '.*h.*';
|
||||
select * from t1 where name rlike '.*hel.*';
|
||||
select * from t1 where name rlike '.*hell.*';
|
||||
select * from t1 where name regexp '.*hello.*';
|
||||
select * from t1 where name regexp '^h.*';
|
||||
|
||||
select * from t1 where name rlike null;
|
||||
|
||||
select * from t1 where name regexp 'abc|de';
|
||||
select * from t1 where name regexp 'a|b|c';
|
||||
select * from t1 where name regexp 'a(b)c';
|
||||
select * from t1 where name regexp 'a\\(';
|
||||
select * from t1 where name regexp 'a()b';
|
||||
select * from t1 where name regexp 'a^b';
|
||||
select * from t1 where name regexp 'a$b';
|
||||
select * from t1 where name regexp '$^';
|
||||
select * from t1 where name regexp '^^';
|
||||
select * from t1 where name regexp '$$';
|
||||
select * from t1 where name regexp 'a*(^b$)c*';
|
||||
select * from t1 where name regexp '()';
|
||||
select * from t1 where name regexp 'ab+c';
|
||||
select * from t1 where name regexp 'ab?c';
|
||||
select * from t1 where name regexp 'a{1}b';
|
||||
select * from t1 where name regexp 'a{1,}b';
|
||||
select * from t1 where name regexp 'a{1,2}b';
|
||||
select * from t1 where name regexp 'a{,2}';
|
||||
select * from t1 where name regexp 'a{,}';
|
||||
select * from t1 where name regexp 'ab{0,0}c';
|
||||
select * from t1 where name regexp 'ab{0,1}c';
|
||||
select * from t1 where name regexp 'ab{0,3}c';
|
||||
select * from t1 where name regexp 'ab{1,1}c';
|
||||
select * from t1 where name regexp 'ab{1,3}c';
|
||||
select * from t1 where name regexp 'ab{2,2}c';
|
||||
select * from t1 where name regexp 'ab{2,4}c';
|
||||
select * from t1 where name regexp '((a{1,10}){1,10}){1,10}';
|
||||
select * from t1 where name regexp 'a*{b}';
|
||||
select * from t1 where name regexp '[[:alnum:]]+';
|
||||
select * from t1 where name regexp '[[:alpha:]]+';
|
||||
select * from t1 where name regexp '[[:blank:]]+';
|
||||
select * from t1 where name regexp '[[:cntrl:]]+';
|
||||
select * from t1 where name regexp '[[:digit:]]+';
|
||||
select * from t1 where name regexp '[[:graph:]]+';
|
||||
select * from t1 where name regexp '[[:lower:]]+';
|
||||
select * from t1 where name regexp '[[:print:]]+';
|
||||
select * from t1 where name regexp '[[:punct:]]+';
|
||||
select * from t1 where name regexp '[[:space:]]+';
|
||||
select * from t1 where name regexp '[[:upper:]]+';
|
||||
select * from t1 where name regexp '[[:xdigit:]]+';
|
||||
select * from t1 where name regexp 'a(((b)))c';
|
||||
select * from t1 where name regexp 'a(b|(c))d';
|
||||
select * from t1 where name regexp 'a(b*|c)d';
|
||||
select * from t1 where name regexp 'a[ab]{20}';
|
||||
select * from t1 where name regexp 'a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]';
|
||||
select * from t1 where name regexp 'a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)';
|
||||
select * from t1 where name regexp '12345678901234567890123456789';
|
||||
select * from t1 where name regexp '123456789012345678901234567890';
|
||||
select * from t1 where name regexp '1234567890123456789012345678901';
|
||||
select * from t1 where name regexp '12345678901234567890123456789012';
|
||||
select * from t1 where name regexp '123456789012345678901234567890123';
|
||||
select * from t1 where name regexp '1234567890123456789012345678901234567890123456789012345678901234567890';
|
||||
select * from t1 where name regexp '[ab][cd][ef][gh][ij][kl][mn]';
|
||||
select * from t1 where name regexp '[ab][cd][ef][gh][ij][kl][mn][op]';
|
||||
select * from t1 where name regexp '[ab][cd][ef][gh][ij][kl][mn][op][qr]';
|
||||
select * from t1 where name regexp '[ab][cd][ef][gh][ij][kl][mn][op][q]';
|
||||
select * from t1 where name regexp '[a]b[c]';
|
||||
select * from t1 where name regexp '[a]b[a]';
|
||||
select * from t1 where name regexp '[abc]b[abc]';
|
||||
select * from t1 where name regexp '[abc]b[abd]';
|
||||
select * from t1 where name regexp 'a(b?c)+d';
|
||||
select * from t1 where name regexp '(wee|week)(knights|night)';
|
||||
select * from t1 where name regexp '(we|wee|week|frob)(knights|night|day)';
|
||||
select * from t1 where name regexp 'a[bc]d';
|
||||
select * from t1 where name regexp 'a[ab]c';
|
||||
|
||||
select * from t1 where name regexp null;
|
||||
|
||||
select * from t1 where name regexp '/\\*.*\\*/';
|
||||
select * from t1 where name regexp '/\\*.*\\*/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*[^/])*\\*/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*[^/])*\\*/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*[^/])*\\*/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*+[^*/])*\\*+/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*+[^*/])*\\*+/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*+[^*/])*\\*+/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*+[^*/])*\\*+/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*+[^*/])*\\*+/';
|
||||
select * from t1 where name regexp '/\\*([^*]|\\*+[^*/])*\\*+/';
|
||||
select * from t1 where name regexp 'a(b)(c)d';
|
||||
select * from t1 where name regexp 'a(((b)))c';
|
||||
select * from t1 where name regexp 'a(b|(c))d';
|
||||
select * from t1 where name regexp 'a(b*|c|e)d';
|
||||
select * from t1 where name regexp 'a(b*|c|e)d';
|
||||
select * from t1 where name regexp 'a(b*|c|e)d';
|
||||
select * from t1 where name regexp 'a(b?)c';
|
||||
select * from t1 where name regexp 'a(b?)c';
|
||||
select * from t1 where name regexp 'a(b+)c';
|
||||
select * from t1 where name regexp 'a(b+)c';
|
||||
select * from t1 where name regexp 'a(b*)c';
|
||||
select * from t1 where name regexp '(a|ab)(bc([de]+)f|cde)';
|
||||
select * from t1 where name regexp 'a(b)(c)(d)(e)(f)(g)(h)(i)(j)k';
|
||||
select * from t1 where name regexp 'a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l';
|
||||
select * from t1 where name regexp 'a([bc]?)c';
|
||||
select * from t1 where name regexp 'a([bc]?)c';
|
||||
select * from t1 where name regexp 'a([bc]+)c';
|
||||
select * from t1 where name regexp 'a([bc]+)c';
|
||||
select * from t1 where name regexp 'a([bc]+)bc';
|
||||
select * from t1 where name regexp 'a(bb+|b)b';
|
||||
select * from t1 where name regexp 'a(bbb+|bb+|b)b';
|
||||
select * from t1 where name regexp 'a(bbb+|bb+|b)b';
|
||||
select * from t1 where name regexp 'a(bbb+|bb+|b)bb';
|
||||
select * from t1 where name regexp '(.*).*';
|
||||
select * from t1 where name regexp '(a*)*';
|
||||
select * from t1 where name regexp 'a(b|c)*d';
|
||||
select * from t1 where name regexp 'a(b|c)*d';
|
||||
select * from t1 where name regexp 'a(b|c)+d';
|
||||
select * from t1 where name regexp 'a(b|c)+d';
|
||||
select * from t1 where name regexp 'a(b|c?)+d';
|
||||
select * from t1 where name regexp 'a(b|c?)+d';
|
||||
select * from t1 where name regexp 'a(b|c){0,0}d';
|
||||
select * from t1 where name regexp 'a(b|c){0,1}d';
|
||||
select * from t1 where name regexp 'a(b|c){0,1}d';
|
||||
select * from t1 where name regexp 'a(b|c){0,2}d';
|
||||
select * from t1 where name regexp 'a(b|c){0,2}d';
|
||||
select * from t1 where name regexp 'a(b|c){0,}d';
|
||||
select * from t1 where name regexp 'a(b|c){0,}d';
|
||||
select * from t1 where name regexp 'a(b|c){1,1}d';
|
||||
select * from t1 where name regexp 'a(b|c){1,1}d';
|
||||
select * from t1 where name regexp 'a(b|c){1,2}d';
|
||||
select * from t1 where name regexp 'a(b|c){1,2}d';
|
||||
select * from t1 where name regexp 'a(b|c){1,}d';
|
||||
select * from t1 where name regexp 'a(b|c){1,}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,2}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,2}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,4}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,4}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,4}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,}d';
|
||||
select * from t1 where name regexp 'a(b|c){2,}d';
|
||||
select * from t1 where name regexp 'a(b+|((c)*))+d';
|
||||
select * from t1 where name regexp 'a(b+|((c)*))+d';
|
||||
select * from t1 where name regexp '(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A])';
|
||||
select * from t1 where name regexp 'CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a';
|
||||
select * from t1 where name regexp 'a?b';
|
||||
|
||||
##bug:https://aone.alibaba-inc.com/req/34761589
|
||||
select * from t1 where name regexp 'a' "bc" '|de';
|
||||
select * from t1 where name regexp "a" '|' "b" '|' "c";
|
||||
select * from t1 where name regexp "a"'()'"b";
|
||||
select * from t1 where name regexp "$" "$";
|
||||
select * from t1 where name regexp 'a' "*" '(' "^" 'b' "$" ')' "c" '*';
|
||||
select * from t1 where name regexp 'a' "b" "{" "0" ',' "0" '}' "c";
|
||||
select * from t1 where name regexp '[' "[" ':' "a" "lnum" ':' "]" ']' "+";
|
||||
select * from t1 where name regexp 'a' "(" "(" '(' "b" ')' ")" ')' 'c';
|
||||
select * from t1 where name regexp 'a'"("'b'"|"'('"c"')'")"'d';
|
||||
select * from t1 where name regexp 'a'""'('"b"'*'"|"'c'")"'d';
|
||||
select * from t1 where name regexp '[ab]'"[cd]"'[ef]'"[gh]"'[ij]'"[kl]"'[mn]';
|
||||
select * from t1 where name regexp '[a]'"b"'[c]';
|
||||
select * from t1 where name regexp '[abc]'"b"'[abc]';
|
||||
select * from t1 where name regexp 'a'"(b?c)"'+'"d";
|
||||
select * from t1 where name regexp '(wee|week)'"(knights"'|'"night)";
|
||||
select * from t1 where name regexp 'a'"[ab]"'c';
|
||||
select * from t1 where name regexp '(a|ab)'"(bc([de]+)"'f|cde)';
|
||||
select * from t1 where name regexp 'a(bbb'"+"'|bb'"+"'|b'")b";
|
||||
select * from t1 where name regexp 'a'"("'b'"|"'c'")"'{'"1"','"}"'d';
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (a varchar(50) primary key) ;
|
||||
insert into t1 values('abcdef');
|
||||
insert into t1 values('_bcdef');
|
||||
insert into t1 values('a_cdef');
|
||||
insert into t1 values('ab_def');
|
||||
insert into t1 values('abc_ef');
|
||||
insert into t1 values('abcd_f');
|
||||
insert into t1 values('abcde_');
|
||||
# should return ab_def
|
||||
select a as c1u from t1 where a rlike 'ab\_def';
|
||||
drop table t1;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t;
|
||||
--enable_warnings
|
||||
|
||||
create table t (c1 char(20));
|
||||
insert into t values ('');
|
||||
select c1 regexp 'ddd' from t;
|
||||
Reference in New Issue
Block a user