init push

This commit is contained in:
oceanbase-admin
2021-05-31 22:56:52 +08:00
commit cea7de1475
7020 changed files with 5689869 additions and 0 deletions

View File

@ -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 ROW_FORMAT = COMPACT COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
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))
utf8mb4_general_ci
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;

View 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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

File diff suppressed because it is too large Load Diff