提交 d439e6df authored 作者: Noel Grandin's avatar Noel Grandin

boom!

begin the process of exploding the test script into smaller, more maintainable pieces
上级 8013da33
......@@ -78,8 +78,57 @@ public class TestScript extends TestBase {
}
reconnectOften = !config.memory && config.big;
testScript("testScript.sql");
testScript("functions-system-rownum.sql");
testScript("datatypes-enum.sql");
testScript("commands-dml-script.sql");
for (String s : new String[] { "array", "bigint", "binary", "blob",
"boolean", "char", "clob", "date", "decimal", "double", "enum",
"geometry", "identity", "int", "other", "real", "smallint",
"time", "timestamp-with-timezone", "timestamp", "tinyint",
"uuid", "varchar", "varchar-ignorecase" }) {
testScript("datatypes/" + s + ".sql");
}
for (String s : new String[] { "avg", "bit-and", "bit-or", "count",
"group-concat", "max", "min", "selectivity", "stddev-pop",
"stddev-samp", "sum", "var-pop", "var-samp" }) {
testScript("functions/aggregate/" + s + ".sql");
}
for (String s : new String[] { "abs", "acos", "asin", "atan", "atan2",
"bitand", "bitget", "bitor", "bitxor", "ceil", "compress",
"cos", "cosh", "cot", "decrypt", "degrees", "encrypt", "exp",
"expand", "floor", "hash", "length", "log", "mod", "pi",
"power", "radians", "rand", "random-uuid", "round",
"roundmagic", "secure-rand", "sign", "sin", "sinh", "sqrt",
"tan", "tanh", "trunc", "truncate", "zero" }) {
testScript("functions/numeric/" + s + ".sql");
}
for (String s : new String[] { "ascii", "bit-length", "char", "concat",
"concat-ws", "difference", "hextoraw", "insert", "instr",
"left", "length", "locate", "lower", "lpad", "ltrim",
"octet-length", "position", "rawtohex", "regexp-like",
"regex-replace", "repeat", "replace", "right", "rpad", "rtrim",
"soundex", "space", "stringdecode", "stringencode",
"stringtoutf8", "substring", "to-char", "translate", "trim",
"upper", "utf8tostring", "xmlattr", "xmlcdata", "xmlcomment",
"xmlnode", "xmlstartdoc", "xmltext" }) {
testScript("functions/string/" + s + ".sql");
}
for (String s : new String[] { "array-contains", "array-get",
"array-length", "autocommit", "cancel-session", "casewhen",
"cast", "coalesce", "convert", "csvread", "csvwrite", "currval",
"database-path", "datebase", "decode", "disk-space-used",
"file-read", "file-write", "greatest", "h2version", "identity",
"ifnull", "least", "link-schema", "lock-mode", "lock-timeout",
"memory-free", "memory-used", "nextval", "nullif", "nvl2",
"readonly", "rownum", "schema", "scope-identity", "session-id",
"set", "table", "transaction-id", "truncate-value", "user" }) {
testScript("functions/system/" + s + ".sql");
}
for (String s : new String[] { "current_date", "current_timestamp",
"current-time", "dateadd", "datediff", "dayname",
"day-of-month", "day-of-week", "day-of-year", "extract",
"formatdatetime", "hour", "minute", "month", "monthname",
"parsedatetime", "quarter", "second", "week", "year" }) {
testScript("functions/timeanddate/" + s + ".sql");
}
deleteDb("script");
System.out.flush();
}
......@@ -132,6 +181,9 @@ public class TestScript extends TestBase {
private void testFile(String inFile) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
if (is == null) {
throw new IOException("could not find " + inFile);
}
in = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
StringBuilder buff = new StringBuilder();
while (true) {
......
create memory table test(id int primary key, name varchar(255));
> ok
INSERT INTO TEST VALUES(2, STRINGDECODE('abcsond\344rzeich\344 ') || char(22222) || STRINGDECODE(' \366\344\374\326\304\334\351\350\340\361!'));
> update count: 1
script nopasswords nosettings;
> SCRIPT
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
> -- 1 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
> ALTER TABLE PUBLIC.TEST ADD CONSTRAINT PUBLIC.CONSTRAINT_2 PRIMARY KEY(ID);
> CREATE MEMORY TABLE PUBLIC.TEST( ID INT NOT NULL, NAME VARCHAR(255) );
> CREATE USER IF NOT EXISTS SA PASSWORD '' ADMIN;
> INSERT INTO PUBLIC.TEST(ID, NAME) VALUES (2, STRINGDECODE('abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!'));
> rows: 5
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select abs(-1) r1, abs(id) r1b from test;
> R1 R1B
> -- ---
> 1 1
> rows: 1
select abs(sum(id)) r1 from test;
> R1
> --
> 1
> rows: 1
select abs(null) vn, abs(-1) r1, abs(1) r2, abs(0) r3, abs(-0.1) r4, abs(0.1) r5 from test;
> VN R1 R2 R3 R4 R5
> ---- -- -- -- --- ---
> null 1 1 0 0.1 0.1
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select acos(null) vn, acos(-1) r1 from test;
> VN R1
> ---- -----------------
> null 3.141592653589793
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select asin(null) vn, asin(-1) r1 from test;
> VN R1
> ---- -------------------
> null -1.5707963267948966
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select atan(null) vn, atan(-1) r1 from test;
> VN R1
> ---- -------------------
> null -0.7853981633974483
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select atan2(null, null) vn, atan2(10, 1) r1 from test;
> VN R1
> ---- ------------------
> null 1.4711276743037347
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select bitand(null, 1) vn, bitand(1, null) vn1, bitand(null, null) vn2, bitand(3, 6) e2 from test;
> VN VN1 VN2 E2
> ---- ---- ---- --
> null null null 2
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select bitor(null, 1) vn, bitor(1, null) vn1, bitor(null, null) vn2, bitor(3, 6) e7 from test;
> VN VN1 VN2 E7
> ---- ---- ---- --
> null null null 7
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select bitxor(null, 1) vn, bitxor(1, null) vn1, bitxor(null, null) vn2, bitxor(3, 6) e5 from test;
> VN VN1 VN2 E5
> ---- ---- ---- --
> null null null 5
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select ceil(null) vn, ceil(1) v1, ceiling(1.1) v2, ceil(-1.1) v3, ceiling(1.9) v4, ceiling(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- --- ---- --- ----
> null 1.0 2.0 -1.0 2.0 -1.0
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select cos(null) vn, cos(-1) r1 from test;
> VN R1
> ---- ------------------
> null 0.5403023058681398
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select cot(null) vn, cot(-1) r1 from test;
> VN R1
> ---- -------------------
> null -0.6420926159343306
> rows: 1
call utf8tostring(decrypt('AES', '00000000000000000000000000000000', 'dbd42d55d4b923c4b03eba0396fac98e'));
> 'Hello World Test'
> ------------------
> Hello World Test
> rows: 1
call utf8tostring(decrypt('AES', hash('sha256', stringtoutf8('Hello'), 1000), encrypt('AES', hash('sha256', stringtoutf8('Hello'), 1000), stringtoutf8('Hello World Test'))));
> 'Hello World Test'
> ------------------
> Hello World Test
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select degrees(null) vn, degrees(1) v1, degrees(1.1) v2, degrees(-1.1) v3, degrees(1.9) v4, degrees(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- ----------------- ----------------- ------------------ ------------------ -------------------
> null 57.29577951308232 63.02535746439057 -63.02535746439057 108.86198107485642 -108.86198107485642
> rows: 1
call encrypt('AES', '00000000000000000000000000000000', stringtoutf8('Hello World Test'));
> X'dbd42d55d4b923c4b03eba0396fac98e'
> -----------------------------------
> dbd42d55d4b923c4b03eba0396fac98e
> rows: 1
CALL ENCRYPT('XTEA', '00', STRINGTOUTF8('Test'));
> X'8bc9a4601b3062692a72a5941072425f'
> -----------------------------------
> 8bc9a4601b3062692a72a5941072425f
> rows: 1
call encrypt('XTEA', '000102030405060708090a0b0c0d0e0f', '4142434445464748');
> X'dea0b0b40966b0669fbae58ab503765f'
> -----------------------------------
> dea0b0b40966b0669fbae58ab503765f
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select exp(null) vn, left(exp(1), 4) v1, left(exp(1.1), 4) v2, left(exp(-1.1), 4) v3, left(exp(1.9), 4) v4, left(exp(-1.9), 4) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- ---- ---- ---- ---- ----
> null 2.71 3.00 0.33 6.68 0.14
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select floor(null) vn, floor(1) v1, floor(1.1) v2, floor(-1.1) v3, floor(1.9) v4, floor(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- --- ---- --- ----
> null 1.0 1.0 -2.0 1.0 -2.0
> rows: 1
call hash('SHA256', stringtoutf8('Hello'), 1);
> X'185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969'
> -------------------------------------------------------------------
> 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
> rows: 1
CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000);
> X'c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0'
> -------------------------------------------------------------------
> c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select bit_length(null) en, bit_length('') e0, bit_length('ab') e32 from test;
> EN E0 E32
> ---- -- ---
> null 0 32
> rows: 1
select length(null) en, length('') e0, length('ab') e2 from test;
> EN E0 E2
> ---- -- --
> null 0 2
> rows: 1
select char_length(null) en, char_length('') e0, char_length('ab') e2 from test;
> EN E0 E2
> ---- -- --
> null 0 2
> rows: 1
select character_length(null) en, character_length('') e0, character_length('ab') e2 from test;
> EN E0 E2
> ---- -- --
> null 0 2
> rows: 1
select octet_length(null) en, octet_length('') e0, octet_length('ab') e4 from test;
> EN E0 E4
> ---- -- --
> null 0 4
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select log(null) vn, log(1) v1, ln(1.1) v2, log(-1.1) v3, log(1.9) v4, log(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- ------------------- --- ------------------ ---
> null 0.0 0.09531017980432493 NaN 0.6418538861723947 NaN
> rows: 1
select log10(null) vn, log10(0) v1, log10(10) v2, log10(0.0001) v3, log10(1000000) v4, log10(1) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --------- --- ---- --- ---
> null -Infinity 1.0 -4.0 6.0 0.0
> rows: 1
select log(null) vn, log(1) v1, log(1.1) v2, log(-1.1) v3, log(1.9) v4, log(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- ------------------- --- ------------------ ---
> null 0.0 0.09531017980432493 NaN 0.6418538861723947 NaN
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select mod(null, 1) vn, mod(1, null) vn1, mod(null, null) vn2, mod(10, 2) e1 from test;
> VN VN1 VN2 E1
> ---- ---- ---- --
> null null null 0
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select pi() pi from test;
> PI
> -----------------
> 3.141592653589793
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select power(null, null) en, power(2, 3) e8, power(16, 0.5) e4 from test;
> EN E8 E4
> ---- --- ---
> null 8.0 4.0
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select radians(null) vn, radians(1) v1, radians(1.1) v2, radians(-1.1) v3, radians(1.9) v4, radians(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- -------------------- -------------------- --------------------- ------------------- --------------------
> null 0.017453292519943295 0.019198621771937624 -0.019198621771937624 0.03316125578789226 -0.03316125578789226
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select rand(1) e, random() f from test;
> E F
> ------------------ -------------------
> 0.7308781907032909 0.41008081149220166
> rows: 1
select rand() e from test;
> E
> -------------------
> 0.20771484130971707
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select round(null, null) en, round(10.49, 0) e10, round(10.05, 1) e101 from test;
> EN E10 E101
> ---- ---- ----
> null 10.0 10.1
> rows: 1
select round(null) en, round(0.6, null) en2, round(1.05) e1, round(-1.51) em2 from test;
> EN EN2 E1 EM2
> ---- ---- --- ----
> null null 1.0 -2.0
> rows: 1
select roundmagic(null) en, roundmagic(cast(3.11 as double) - 3.1) e001, roundmagic(3.11-3.1-0.01) e000, roundmagic(2000000000000) e20x from test;
> EN E001 E000 E20X
> ---- ---- ---- ------
> null 0.01 0.0 2.0E12
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select sign(null) en, sign(10) e1, sign(0) e0, sign(-0.1) em1 from test;
> EN E1 E0 EM1
> ---- -- -- ---
> null 1 0 -1
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select sin(null) vn, sin(-1) r1 from test;
> VN R1
> ---- -------------------
> null -0.8414709848078965
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select sqrt(null) vn, sqrt(0) e0, sqrt(1) e1, sqrt(4) e2, sqrt(100) e10, sqrt(0.25) e05 from test;
> VN E0 E1 E2 E10 E05
> ---- --- --- --- ---- ---
> null 0.0 1.0 2.0 10.0 0.5
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select tan(null) vn, tan(-1) r1 from test;
> VN R1
> ---- -------------------
> null -1.5574077246549023
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select truncate(null, null) en, truncate(1.99, 0) e1, truncate(-10.9, 0) em10 from test;
> EN E1 EM10
> ---- --- -----
> null 1.0 -10.0
> rows: 1
select trunc(null, null) en, trunc(1.99, 0) e1, trunc(-10.9, 0) em10 from test;
> EN E1 EM10
> ---- --- -----
> null 1.0 -10.0
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select ascii(null) en, ascii('') en, ascii('Abc') e65 from test;
> EN EN E65
> ---- ---- ---
> null null 65
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
select char(null) en, char(65) ea from test;
> EN EA
> ---- --
> null A
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
select concat(null, null) en, concat(null, 'a') ea, concat('b', null) eb, concat('ab', 'c') abc from test;
> EN EA EB ABC
> ---- -- -- ---
> null a b abc
> rows: 1
SELECT CONCAT('a', 'b', 'c', 'd') AS test;
> TEST
> ----
> abcd
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
select difference(null, null) en, difference('a', null) en1, difference(null, 'a') en2 from test;
> EN EN1 EN2
> ---- ---- ----
> null null null
> rows: 1
select difference('abc', 'abc') e0, difference('Thomas', 'Tom') e1 from test;
> E0 E1
> -- --
> 4 3
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select hextoraw(null) en, rawtohex(null) en1, hextoraw(rawtohex('abc')) abc from test;
> EN EN1 ABC
> ---- ---- ---
> null null abc
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select insert(null, null, null, null) en, insert('Rund', 1, 0, 'o') e_round, insert(null, 1, 1, 'a') ea from test;
> EN E_ROUND EA
> ---- ------- --
> null Rund a
> rows: 1
select insert('World', 2, 4, 'e') welt, insert('Hello', 2, 1, 'a') hallo from test;
> WELT HALLO
> ---- -----
> We Hallo
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select instr('Hello World', 'World') e7, instr('abchihihi', 'hi', 2) e3, instr('abcooo', 'o') e2 from test;
> E7 E3 E2
> -- -- --
> 7 4 4
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select left(null, 10) en, left('abc', null) en2, left('boat', 2) e_bo, left('', 1) ee, left('a', -1) ee2 from test;
> EN EN2 E_BO EE EE2
> ---- ---- ---- -- ---
> null null bo
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select locate(null, null) en, locate(null, null, null) en1 from test;
> EN EN1
> ---- ----
> null null
> rows: 1
select locate('World', 'Hello World') e7, locate('hi', 'abchihihi', 2) e3 from test;
> E7 E3
> -- --
> 7 4
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select lower(null) en, lower('Hello') hello, lower('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null hello abc
> rows: 1
select lcase(null) en, lcase('Hello') hello, lcase('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null hello abc
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select ltrim(null) en, '>' || ltrim('a') || '<' ea, '>' || ltrim(' a ') || '<' e_as from test;
> EN EA E_AS
> ---- --- ----
> null >a< >a <
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select position(null, null) en, position(null, 'abc') en1, position('World', 'Hello World') e7, position('hi', 'abchihihi') e1 from test;
> EN EN1 E7 E1
> ---- ---- -- --
> null null 7 4
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select repeat(null, null) en, repeat('Ho', 2) abcehoho , repeat('abc', 0) ee from test;
> EN ABCEHOHO EE
> ---- -------- --
> null HoHo
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select replace(null, null) en, replace(null, null, null) en1 from test;
> EN EN1
> ---- ----
> null null
> rows: 1
select replace('abchihihi', 'i', 'o') abcehohoho, replace('that is tom', 'i') abcethstom from test;
> ABCEHOHOHO ABCETHSTOM
> ---------- ----------
> abchohoho that s tom
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select right(null, 10) en, right('abc', null) en2, right('boat-trip', 2) e_ip, right('', 1) ee, right('a', -1) ee2 from test;
> EN EN2 E_IP EE EE2
> ---- ---- ---- -- ---
> null null ip
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select rtrim(null) en, '>' || rtrim('a') || '<' ea, '>' || rtrim(' a ') || '<' es from test;
> EN EA ES
> ---- --- ----
> null >a< > a<
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
select soundex(null) en, soundex('tom') et from test;
> EN ET
> ---- ----
> null t500
> rows: 1
select
soundex('Washington') W252, soundex('Lee') L000,
soundex('Gutierrez') G362, soundex('Pfister') P236,
soundex('Jackson') J250, soundex('Tymczak') T522,
soundex('VanDeusen') V532, soundex('Ashcraft') A261 from test;
> W252 L000 G362 P236 J250 T522 V532 A261
> ---- ---- ---- ---- ---- ---- ---- ----
> W252 L000 G362 P236 J250 T522 V532 A261
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select space(null) en, '>' || space(1) || '<' es, '>' || space(3) || '<' e2 from test;
> EN ES E2
> ---- --- ---
> null > < > <
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
INSERT INTO TEST VALUES(2, STRINGDECODE('abcsond\344rzeich\344 ') || char(22222) || STRINGDECODE(' \366\344\374\326\304\334\351\350\340\361!'));
> update count: 1
call STRINGENCODE(STRINGDECODE('abcsond\344rzeich\344 \u56ce \366\344\374\326\304\334\351\350\340\361!'));
> 'abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!'
> ------------------------------------------------------------------------------------------------
> abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!
> rows: 1
CALL STRINGENCODE(STRINGDECODE('Lines 1\nLine 2'));
> 'Lines 1\nLine 2'
> -----------------
> Lines 1\nLine 2
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select substr(null, null) en, substr(null, null, null) e1, substr('bob', 2) e_ob, substr('bob', 2, 1) eo from test;
> EN E1 E_OB EO
> ---- ---- ---- --
> null null ob o
> rows: 1
select substring(null, null) en, substring(null, null, null) e1, substring('bob', 2) e_ob, substring('bob', 2, 1) eo from test;
> EN E1 E_OB EO
> ---- ---- ---- --
> null null ob o
> rows: 1
select substring(null from null) en, substring(null from null for null) e1, substring('bob' from 2) e_ob, substring('bob' from 2 for 1) eo from test;
> EN E1 E_OB EO
> ---- ---- ---- --
> null null ob o
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select TRIM(BOTH '_' FROM '__A__') A, TRIM(LEADING FROM ' B ') BS, TRIM(TRAILING 'x' FROM 'xAx') XA from test;
> A BS XA
> - -- --
> A B xA
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select ucase(null) en, ucase('Hello') hello, ucase('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null HELLO ABC
> rows: 1
select upper(null) en, upper('Hello') hello, upper('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null HELLO ABC
> rows: 1
CALL UTF8TOSTRING(STRINGTOUTF8('This is a test'));
> 'This is a test'
> ----------------
> This is a test
> rows: 1
CALL XMLCDATA('<characters>');
> '<![CDATA[<characters>]]>'
> --------------------------
> <![CDATA[<characters>]]>
> rows: 1
CALL XMLCDATA('special text ]]>');
> 'special text ]]&gt;'
> ---------------------
> special text ]]&gt;
> rows: 1
CALL XMLCOMMENT('Test');
> STRINGDECODE('<!-- Test -->\n')
> -------------------------------
> <!-- Test -->
> rows: 1
CALL XMLCOMMENT('--- test ---');
> STRINGDECODE('<!-- - - - test - - - -->\n')
> -------------------------------------------
> <!-- - - - test - - - -->
> rows: 1
CALL XMLNODE('a', XMLATTR('href', 'http://h2database.com'));
> STRINGDECODE('<a href=\"http://h2database.com\"/>\n')
> -----------------------------------------------------
> <a href="http://h2database.com"/>
> rows: 1
CALL XMLNODE('br');
> STRINGDECODE('<br/>\n')
> -----------------------
> <br/>
> rows: 1
CALL XMLNODE('p', null, 'Hello World');
> STRINGDECODE('<p>Hello World</p>\n')
> ------------------------------------
> <p>Hello World</p>
> rows: 1
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World') X;
> X
> ---------------------
> <p> Hello World </p>
> rows: 1
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World', false) X;
> X
> -------------------
> <p>Hello World</p>
> rows: 1
CALL XMLSTARTDOC();
> STRINGDECODE('<?xml version=\"1.0\"?>\n')
> -----------------------------------------
> <?xml version="1.0"?>
> rows: 1
CALL XMLTEXT('test');
> 'test'
> ------
> test
> rows: 1
CALL XMLTEXT('<test>');
> '&lt;test&gt;'
> --------------
> &lt;test&gt;
> rows: 1
SELECT XMLTEXT('hello' || chr(10) || 'world') X;
> X
> -----------
> hello world
> rows: 1
CALL XMLTEXT('hello' || chr(10) || 'world', true);
> 'hello&#xa;world'
> -----------------
> hello&#xa;world
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select autocommit() x_true from test;
> X_TRUE
> ------
> TRUE
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select casewhen(null, '1', '2') xn, casewhen(1>0, 'n', 'y') xy, casewhen(0<1, 'a', 'b') xa from test;
> XN XY XA
> -- -- --
> 2 n a
> rows: 1
select x, case when x=0 then 'zero' else 'not zero' end y from system_range(0, 2);
> X Y
> - --------
> 0 zero
> 1 not zero
> 2 not zero
> rows: 3
select x, case when x=0 then 'zero' end y from system_range(0, 1);
> X Y
> - ----
> 0 zero
> 1 null
> rows: 2
select x, case x when 0 then 'zero' else 'not zero' end y from system_range(0, 1);
> X Y
> - --------
> 0 zero
> 1 not zero
> rows: 2
select x, case x when 0 then 'zero' when 1 then 'one' end y from system_range(0, 2);
> X Y
> - ----
> 0 zero
> 1 one
> 2 null
> rows: 3
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int) x20 from test;
> XN X10 X20
> ---- --- ---
> null 10 20
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select coalesce(null, null) xn, coalesce(null, 'a') xa, coalesce('1', '2') x1 from test;
> XN XA X1
> ---- -- --
> null a 1
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select convert(null, varchar(255)) xn, convert(' 10', int) x10, convert(' 20 ', int) x20 from test;
> XN X10 X20
> ---- --- ---
> null 10 20
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select right(database(), 6) x_script from test;
> X_SCRIPT
> --------
> SCRIPT
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select ifnull(null, '1') x1, ifnull(null, null) xn, ifnull('a', 'b') xa from test;
> X1 XN XA
> -- ---- --
> 1 null a
> rows: 1
select isnull(null, '1') x1, isnull(null, null) xn, isnull('a', 'b') xa from test;
> X1 XN XA
> -- ---- --
> 1 null a
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select nullif(null, null) xn, nullif('a', 'a') xn, nullif('1', '2') x1 from test;
> XN XN X1
> ---- ---- --
> null null 1
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select readonly() x_false from test;
> X_FALSE
> -------
> FALSE
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select user() x_sa, current_user() x_sa2 from test;
> X_SA X_SA2
> ---- -----
> SA SA
> rows: 1
select current_user() x_sa from test;
> X_SA
> ----
> SA
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select length(curtime())>=8 c1, length(current_time())>=8 c2, substring(curtime(), 3, 1) c3 from test;
> C1 C2 C3
> ---- ---- --
> TRUE TRUE :
> rows: 1
select length(now())>20 c1, length(current_timestamp())>20 c2, length(now(0))>20 c3, length(now(2))>20 c4, substring(now(5), 20, 1) c5 from test;
> C1 C2 C3 C4 C5
> ---- ---- ---- ---- --
> TRUE TRUE TRUE TRUE .
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select length(curdate()) c1, length(current_date()) c2, substring(curdate(), 5, 1) c3 from test;
> C1 C2 C3
> -- -- --
> 10 10 -
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select dateadd('month', 1, timestamp '2003-01-31 10:20:30.012345678') d1 from test;
> D1
> -----------------------------
> 2003-02-28 10:20:30.012345678
> rows: 1
select dateadd('year', -1, timestamp '2000-02-29 10:20:30.012345678') d1 from test;
> D1
> -----------------------------
> 1999-02-28 10:20:30.012345678
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select datediff('yy', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('year', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('mm', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d2 from test;
> D2
> --
> 2
> rows: 1
select datediff('month', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d2 from test;
> D2
> --
> 2
> rows: 1
select datediff('dd', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') d4 from test;
> D4
> --
> 4
> rows: 1
select datediff('day', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') d4 from test;
> D4
> --
> 4
> rows: 1
select datediff('hh', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') d24 from test;
> D24
> ---
> 24
> rows: 1
select datediff('hour', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') d24 from test;
> D24
> ---
> 24
> rows: 1
select datediff('mi', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d20 from test;
> D20
> ---
> -20
> rows: 1
select datediff('minute', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d20 from test;
> D20
> ---
> -20
> rows: 1
select datediff('ss', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('second', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('ms', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d50x from test;
> D50X
> ----
> 500
> rows: 1
select datediff('millisecond', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d50x from test;
> D50X
> ----
> 500
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select dayofmonth(date '2005-09-12') d12 from test;
> D12
> ---
> 12
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select dayofweek(date '2005-09-12') d2 from test;
> D2
> --
> 2
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select dayofyear(date '2005-01-01') d1 from test;
> D1
> --
> 1
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select dayname(date '2005-09-12') d_monday from test;
> D_MONDAY
> --------
> Monday
> rows: 1
CALL FORMATDATETIME(PARSEDATETIME('2001-02-03 04:05:06 GMT', 'yyyy-MM-dd HH:mm:ss z', 'en', 'GMT'), 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT');
> 'Sat, 3 Feb 2001 04:05:06 GMT'
> ------------------------------
> Sat, 3 Feb 2001 04:05:06 GMT
> rows: 1
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'yyyy-MM-dd HH:mm:ss');
> '2001-02-03 04:05:06'
> ---------------------
> 2001-02-03 04:05:06
> rows: 1
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'MM/dd/yyyy HH:mm:ss');
> '02/03/2001 04:05:06'
> ---------------------
> 02/03/2001 04:05:06
> rows: 1
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'd. MMMM yyyy', 'de');
> '3. Februar 2001'
> -----------------
> 3. Februar 2001
> rows: 1
CALL FORMATDATETIME(PARSEDATETIME('Sat, 3 Feb 2001 04:05:06 GMT', 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT'), 'yyyy-MM-dd HH:mm:ss', 'en', 'GMT');
> '2001-02-03 04:05:06'
> ---------------------
> 2001-02-03 04:05:06
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select hour(time '23:10:59') d23 from test;
> D23
> ---
> 23
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select minute(timestamp '2005-01-01 23:10:59') d10 from test;
> D10
> ---
> 10
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select month(date '2005-09-25') d9 from test;
> D9
> --
> 9
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select monthname(date '2005-09-12') d_sept from test;
> D_SEPT
> ---------
> September
> rows: 1
CALL PARSEDATETIME('3. Februar 2001', 'd. MMMM yyyy', 'de');
> TIMESTAMP '2001-02-03 00:00:00.0'
> ---------------------------------
> 2001-02-03 00:00:00.0
> rows: 1
CALL PARSEDATETIME('02/03/2001 04:05:06', 'MM/dd/yyyy HH:mm:ss');
> TIMESTAMP '2001-02-03 04:05:06.0'
> ---------------------------------
> 2001-02-03 04:05:06.0
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select quarter(date '2005-09-01') d3 from test;
> D3
> --
> 3
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select second(timestamp '2005-01-01 23:10:59') d59 from test;
> D59
> ---
> 59
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select week(date '2003-01-09') d1 from test;
> D1
> --
> 2
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select year(date '2005-01-01') d2005 from test;
> D2005
> -----
> 2005
> rows: 1
......@@ -9240,936 +9240,6 @@ SET AUTOCOMMIT TRUE;
DROP USER SECURE;
> ok
--- functions ----------------------------------------------------------------------------------------------
CALL FORMATDATETIME(PARSEDATETIME('2001-02-03 04:05:06 GMT', 'yyyy-MM-dd HH:mm:ss z', 'en', 'GMT'), 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT');
> 'Sat, 3 Feb 2001 04:05:06 GMT'
> ------------------------------
> Sat, 3 Feb 2001 04:05:06 GMT
> rows: 1
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'yyyy-MM-dd HH:mm:ss');
> '2001-02-03 04:05:06'
> ---------------------
> 2001-02-03 04:05:06
> rows: 1
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'MM/dd/yyyy HH:mm:ss');
> '02/03/2001 04:05:06'
> ---------------------
> 02/03/2001 04:05:06
> rows: 1
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'd. MMMM yyyy', 'de');
> '3. Februar 2001'
> -----------------
> 3. Februar 2001
> rows: 1
CALL FORMATDATETIME(PARSEDATETIME('Sat, 3 Feb 2001 04:05:06 GMT', 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT'), 'yyyy-MM-dd HH:mm:ss', 'en', 'GMT');
> '2001-02-03 04:05:06'
> ---------------------
> 2001-02-03 04:05:06
> rows: 1
CALL PARSEDATETIME('3. Februar 2001', 'd. MMMM yyyy', 'de');
> TIMESTAMP '2001-02-03 00:00:00.0'
> ---------------------------------
> 2001-02-03 00:00:00.0
> rows: 1
CALL PARSEDATETIME('02/03/2001 04:05:06', 'MM/dd/yyyy HH:mm:ss');
> TIMESTAMP '2001-02-03 04:05:06.0'
> ---------------------------------
> 2001-02-03 04:05:06.0
> rows: 1
CALL XMLNODE('a', XMLATTR('href', 'http://h2database.com'));
> STRINGDECODE('<a href=\"http://h2database.com\"/>\n')
> -----------------------------------------------------
> <a href="http://h2database.com"/>
> rows: 1
CALL XMLNODE('br');
> STRINGDECODE('<br/>\n')
> -----------------------
> <br/>
> rows: 1
CALL XMLNODE('p', null, 'Hello World');
> STRINGDECODE('<p>Hello World</p>\n')
> ------------------------------------
> <p>Hello World</p>
> rows: 1
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World') X;
> X
> ---------------------
> <p> Hello World </p>
> rows: 1
SELECT XMLNODE('p', null, 'Hello' || chr(10) || 'World', false) X;
> X
> -------------------
> <p>Hello World</p>
> rows: 1
CALL XMLCOMMENT('Test');
> STRINGDECODE('<!-- Test -->\n')
> -------------------------------
> <!-- Test -->
> rows: 1
CALL XMLCOMMENT('--- test ---');
> STRINGDECODE('<!-- - - - test - - - -->\n')
> -------------------------------------------
> <!-- - - - test - - - -->
> rows: 1
CALL XMLCDATA('<characters>');
> '<![CDATA[<characters>]]>'
> --------------------------
> <![CDATA[<characters>]]>
> rows: 1
CALL XMLCDATA('special text ]]>');
> 'special text ]]&gt;'
> ---------------------
> special text ]]&gt;
> rows: 1
CALL XMLSTARTDOC();
> STRINGDECODE('<?xml version=\"1.0\"?>\n')
> -----------------------------------------
> <?xml version="1.0"?>
> rows: 1
CALL XMLTEXT('test');
> 'test'
> ------
> test
> rows: 1
CALL XMLTEXT('<test>');
> '&lt;test&gt;'
> --------------
> &lt;test&gt;
> rows: 1
SELECT XMLTEXT('hello' || chr(10) || 'world') X;
> X
> -----------
> hello world
> rows: 1
CALL XMLTEXT('hello' || chr(10) || 'world', true);
> 'hello&#xa;world'
> -----------------
> hello&#xa;world
> rows: 1
create memory table test(id int primary key, name varchar(255));
> ok
INSERT INTO TEST VALUES(2, STRINGDECODE('abcsond\344rzeich\344 ') || char(22222) || STRINGDECODE(' \366\344\374\326\304\334\351\350\340\361!'));
> update count: 1
script nopasswords nosettings;
> SCRIPT
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
> -- 1 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
> ALTER TABLE PUBLIC.TEST ADD CONSTRAINT PUBLIC.CONSTRAINT_2 PRIMARY KEY(ID);
> CREATE MEMORY TABLE PUBLIC.TEST( ID INT NOT NULL, NAME VARCHAR(255) );
> CREATE USER IF NOT EXISTS SA PASSWORD '' ADMIN;
> INSERT INTO PUBLIC.TEST(ID, NAME) VALUES (2, STRINGDECODE('abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!'));
> rows: 5
call STRINGENCODE(STRINGDECODE('abcsond\344rzeich\344 \u56ce \366\344\374\326\304\334\351\350\340\361!'));
> 'abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!'
> ------------------------------------------------------------------------------------------------
> abcsond\u00e4rzeich\u00e4 \u56ce \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e9\u00e8\u00e0\u00f1!
> rows: 1
delete from test;
> update count: 1
insert into test values(1, 'Hello');
> update count: 1
select abs(-1) r1, abs(id) r1b from test;
> R1 R1B
> -- ---
> 1 1
> rows: 1
select abs(sum(id)) r1 from test;
> R1
> --
> 1
> rows: 1
select abs(null) vn, abs(-1) r1, abs(1) r2, abs(0) r3, abs(-0.1) r4, abs(0.1) r5 from test;
> VN R1 R2 R3 R4 R5
> ---- -- -- -- --- ---
> null 1 1 0 0.1 0.1
> rows: 1
select acos(null) vn, acos(-1) r1 from test;
> VN R1
> ---- -----------------
> null 3.141592653589793
> rows: 1
select asin(null) vn, asin(-1) r1 from test;
> VN R1
> ---- -------------------
> null -1.5707963267948966
> rows: 1
select atan(null) vn, atan(-1) r1 from test;
> VN R1
> ---- -------------------
> null -0.7853981633974483
> rows: 1
select cos(null) vn, cos(-1) r1 from test;
> VN R1
> ---- ------------------
> null 0.5403023058681398
> rows: 1
select cot(null) vn, cot(-1) r1 from test;
> VN R1
> ---- -------------------
> null -0.6420926159343306
> rows: 1
select sin(null) vn, sin(-1) r1 from test;
> VN R1
> ---- -------------------
> null -0.8414709848078965
> rows: 1
select tan(null) vn, tan(-1) r1 from test;
> VN R1
> ---- -------------------
> null -1.5574077246549023
> rows: 1
select atan2(null, null) vn, atan2(10, 1) r1 from test;
> VN R1
> ---- ------------------
> null 1.4711276743037347
> rows: 1
select bitand(null, 1) vn, bitand(1, null) vn1, bitand(null, null) vn2, bitand(3, 6) e2 from test;
> VN VN1 VN2 E2
> ---- ---- ---- --
> null null null 2
> rows: 1
select bitor(null, 1) vn, bitor(1, null) vn1, bitor(null, null) vn2, bitor(3, 6) e7 from test;
> VN VN1 VN2 E7
> ---- ---- ---- --
> null null null 7
> rows: 1
select bitxor(null, 1) vn, bitxor(1, null) vn1, bitxor(null, null) vn2, bitxor(3, 6) e5 from test;
> VN VN1 VN2 E5
> ---- ---- ---- --
> null null null 5
> rows: 1
select mod(null, 1) vn, mod(1, null) vn1, mod(null, null) vn2, mod(10, 2) e1 from test;
> VN VN1 VN2 E1
> ---- ---- ---- --
> null null null 0
> rows: 1
select ceil(null) vn, ceil(1) v1, ceiling(1.1) v2, ceil(-1.1) v3, ceiling(1.9) v4, ceiling(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- --- ---- --- ----
> null 1.0 2.0 -1.0 2.0 -1.0
> rows: 1
select floor(null) vn, floor(1) v1, floor(1.1) v2, floor(-1.1) v3, floor(1.9) v4, floor(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- --- ---- --- ----
> null 1.0 1.0 -2.0 1.0 -2.0
> rows: 1
select log(null) vn, log(1) v1, ln(1.1) v2, log(-1.1) v3, log(1.9) v4, log(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- ------------------- --- ------------------ ---
> null 0.0 0.09531017980432493 NaN 0.6418538861723947 NaN
> rows: 1
select log10(null) vn, log10(0) v1, log10(10) v2, log10(0.0001) v3, log10(1000000) v4, log10(1) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --------- --- ---- --- ---
> null -Infinity 1.0 -4.0 6.0 0.0
> rows: 1
select log(null) vn, log(1) v1, log(1.1) v2, log(-1.1) v3, log(1.9) v4, log(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- --- ------------------- --- ------------------ ---
> null 0.0 0.09531017980432493 NaN 0.6418538861723947 NaN
> rows: 1
select degrees(null) vn, degrees(1) v1, degrees(1.1) v2, degrees(-1.1) v3, degrees(1.9) v4, degrees(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- ----------------- ----------------- ------------------ ------------------ -------------------
> null 57.29577951308232 63.02535746439057 -63.02535746439057 108.86198107485642 -108.86198107485642
> rows: 1
select exp(null) vn, left(exp(1), 4) v1, left(exp(1.1), 4) v2, left(exp(-1.1), 4) v3, left(exp(1.9), 4) v4, left(exp(-1.9), 4) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- ---- ---- ---- ---- ----
> null 2.71 3.00 0.33 6.68 0.14
> rows: 1
select radians(null) vn, radians(1) v1, radians(1.1) v2, radians(-1.1) v3, radians(1.9) v4, radians(-1.9) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- -------------------- -------------------- --------------------- ------------------- --------------------
> null 0.017453292519943295 0.019198621771937624 -0.019198621771937624 0.03316125578789226 -0.03316125578789226
> rows: 1
select sqrt(null) vn, sqrt(0) e0, sqrt(1) e1, sqrt(4) e2, sqrt(100) e10, sqrt(0.25) e05 from test;
> VN E0 E1 E2 E10 E05
> ---- --- --- --- ---- ---
> null 0.0 1.0 2.0 10.0 0.5
> rows: 1
select pi() pi from test;
> PI
> -----------------
> 3.141592653589793
> rows: 1
select power(null, null) en, power(2, 3) e8, power(16, 0.5) e4 from test;
> EN E8 E4
> ---- --- ---
> null 8.0 4.0
> rows: 1
SET AUTOCOMMIT FALSE;
> ok
select rand(1) e, random() f from test;
> E F
> ------------------ -------------------
> 0.7308781907032909 0.41008081149220166
> rows: 1
select rand() e from test;
> E
> -------------------
> 0.20771484130971707
> rows: 1
SET AUTOCOMMIT TRUE;
> ok
select round(null, null) en, round(10.49, 0) e10, round(10.05, 1) e101 from test;
> EN E10 E101
> ---- ---- ----
> null 10.0 10.1
> rows: 1
select round(null) en, round(0.6, null) en2, round(1.05) e1, round(-1.51) em2 from test;
> EN EN2 E1 EM2
> ---- ---- --- ----
> null null 1.0 -2.0
> rows: 1
select roundmagic(null) en, roundmagic(cast(3.11 as double) - 3.1) e001, roundmagic(3.11-3.1-0.01) e000, roundmagic(2000000000000) e20x from test;
> EN E001 E000 E20X
> ---- ---- ---- ------
> null 0.01 0.0 2.0E12
> rows: 1
select sign(null) en, sign(10) e1, sign(0) e0, sign(-0.1) em1 from test;
> EN E1 E0 EM1
> ---- -- -- ---
> null 1 0 -1
> rows: 1
select truncate(null, null) en, truncate(1.99, 0) e1, truncate(-10.9, 0) em10 from test;
> EN E1 EM10
> ---- --- -----
> null 1.0 -10.0
> rows: 1
select trunc(null, null) en, trunc(1.99, 0) e1, trunc(-10.9, 0) em10 from test;
> EN E1 EM10
> ---- --- -----
> null 1.0 -10.0
> rows: 1
select ascii(null) en, ascii('') en, ascii('Abc') e65 from test;
> EN EN E65
> ---- ---- ---
> null null 65
> rows: 1
select bit_length(null) en, bit_length('') e0, bit_length('ab') e32 from test;
> EN E0 E32
> ---- -- ---
> null 0 32
> rows: 1
select length(null) en, length('') e0, length('ab') e2 from test;
> EN E0 E2
> ---- -- --
> null 0 2
> rows: 1
select char_length(null) en, char_length('') e0, char_length('ab') e2 from test;
> EN E0 E2
> ---- -- --
> null 0 2
> rows: 1
select character_length(null) en, character_length('') e0, character_length('ab') e2 from test;
> EN E0 E2
> ---- -- --
> null 0 2
> rows: 1
select octet_length(null) en, octet_length('') e0, octet_length('ab') e4 from test;
> EN E0 E4
> ---- -- --
> null 0 4
> rows: 1
select char(null) en, char(65) ea from test;
> EN EA
> ---- --
> null A
> rows: 1
select concat(null, null) en, concat(null, 'a') ea, concat('b', null) eb, concat('ab', 'c') abc from test;
> EN EA EB ABC
> ---- -- -- ---
> null a b abc
> rows: 1
SELECT CONCAT('a', 'b', 'c', 'd') AS test;
> TEST
> ----
> abcd
> rows: 1
select difference(null, null) en, difference('a', null) en1, difference(null, 'a') en2 from test;
> EN EN1 EN2
> ---- ---- ----
> null null null
> rows: 1
select difference('abc', 'abc') e0, difference('Thomas', 'Tom') e1 from test;
> E0 E1
> -- --
> 4 3
> rows: 1
select hextoraw(null) en, rawtohex(null) en1, hextoraw(rawtohex('abc')) abc from test;
> EN EN1 ABC
> ---- ---- ---
> null null abc
> rows: 1
select insert(null, null, null, null) en, insert('Rund', 1, 0, 'o') e_round, insert(null, 1, 1, 'a') ea from test;
> EN E_ROUND EA
> ---- ------- --
> null Rund a
> rows: 1
select insert('World', 2, 4, 'e') welt, insert('Hello', 2, 1, 'a') hallo from test;
> WELT HALLO
> ---- -----
> We Hallo
> rows: 1
select lcase(null) en, lcase('Hello') hello, lcase('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null hello abc
> rows: 1
select lower(null) en, lower('Hello') hello, lower('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null hello abc
> rows: 1
select ucase(null) en, ucase('Hello') hello, ucase('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null HELLO ABC
> rows: 1
select upper(null) en, upper('Hello') hello, upper('ABC') abc from test;
> EN HELLO ABC
> ---- ----- ---
> null HELLO ABC
> rows: 1
select left(null, 10) en, left('abc', null) en2, left('boat', 2) e_bo, left('', 1) ee, left('a', -1) ee2 from test;
> EN EN2 E_BO EE EE2
> ---- ---- ---- -- ---
> null null bo
> rows: 1
select right(null, 10) en, right('abc', null) en2, right('boat-trip', 2) e_ip, right('', 1) ee, right('a', -1) ee2 from test;
> EN EN2 E_IP EE EE2
> ---- ---- ---- -- ---
> null null ip
> rows: 1
select locate(null, null) en, locate(null, null, null) en1 from test;
> EN EN1
> ---- ----
> null null
> rows: 1
select locate('World', 'Hello World') e7, locate('hi', 'abchihihi', 2) e3 from test;
> E7 E3
> -- --
> 7 4
> rows: 1
select instr('Hello World', 'World') e7, instr('abchihihi', 'hi', 2) e3, instr('abcooo', 'o') e2 from test;
> E7 E3 E2
> -- -- --
> 7 4 4
> rows: 1
select position(null, null) en, position(null, 'abc') en1, position('World', 'Hello World') e7, position('hi', 'abchihihi') e1 from test;
> EN EN1 E7 E1
> ---- ---- -- --
> null null 7 4
> rows: 1
select ltrim(null) en, '>' || ltrim('a') || '<' ea, '>' || ltrim(' a ') || '<' e_as from test;
> EN EA E_AS
> ---- --- ----
> null >a< >a <
> rows: 1
select TRIM(BOTH '_' FROM '__A__') A, TRIM(LEADING FROM ' B ') BS, TRIM(TRAILING 'x' FROM 'xAx') XA from test;
> A BS XA
> - -- --
> A B xA
> rows: 1
select rtrim(null) en, '>' || rtrim('a') || '<' ea, '>' || rtrim(' a ') || '<' es from test;
> EN EA ES
> ---- --- ----
> null >a< > a<
> rows: 1
select repeat(null, null) en, repeat('Ho', 2) abcehoho , repeat('abc', 0) ee from test;
> EN ABCEHOHO EE
> ---- -------- --
> null HoHo
> rows: 1
select replace(null, null) en, replace(null, null, null) en1 from test;
> EN EN1
> ---- ----
> null null
> rows: 1
select replace('abchihihi', 'i', 'o') abcehohoho, replace('that is tom', 'i') abcethstom from test;
> ABCEHOHOHO ABCETHSTOM
> ---------- ----------
> abchohoho that s tom
> rows: 1
select soundex(null) en, soundex('tom') et from test;
> EN ET
> ---- ----
> null t500
> rows: 1
select
soundex('Washington') W252, soundex('Lee') L000,
soundex('Gutierrez') G362, soundex('Pfister') P236,
soundex('Jackson') J250, soundex('Tymczak') T522,
soundex('VanDeusen') V532, soundex('Ashcraft') A261 from test;
> W252 L000 G362 P236 J250 T522 V532 A261
> ---- ---- ---- ---- ---- ---- ---- ----
> W252 L000 G362 P236 J250 T522 V532 A261
> rows: 1
select space(null) en, '>' || space(1) || '<' es, '>' || space(3) || '<' e2 from test;
> EN ES E2
> ---- --- ---
> null > < > <
> rows: 1
select substr(null, null) en, substr(null, null, null) e1, substr('bob', 2) e_ob, substr('bob', 2, 1) eo from test;
> EN E1 E_OB EO
> ---- ---- ---- --
> null null ob o
> rows: 1
select substring(null, null) en, substring(null, null, null) e1, substring('bob', 2) e_ob, substring('bob', 2, 1) eo from test;
> EN E1 E_OB EO
> ---- ---- ---- --
> null null ob o
> rows: 1
select substring(null from null) en, substring(null from null for null) e1, substring('bob' from 2) e_ob, substring('bob' from 2 for 1) eo from test;
> EN E1 E_OB EO
> ---- ---- ---- --
> null null ob o
> rows: 1
call hash('SHA256', stringtoutf8('Hello'), 1);
> X'185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969'
> -------------------------------------------------------------------
> 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
> rows: 1
CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000);
> X'c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0'
> -------------------------------------------------------------------
> c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0
> rows: 1
CALL UTF8TOSTRING(STRINGTOUTF8('This is a test'));
> 'This is a test'
> ----------------
> This is a test
> rows: 1
CALL STRINGENCODE(STRINGDECODE('Lines 1\nLine 2'));
> 'Lines 1\nLine 2'
> -----------------
> Lines 1\nLine 2
> rows: 1
call encrypt('AES', '00000000000000000000000000000000', stringtoutf8('Hello World Test'));
> X'dbd42d55d4b923c4b03eba0396fac98e'
> -----------------------------------
> dbd42d55d4b923c4b03eba0396fac98e
> rows: 1
call utf8tostring(decrypt('AES', '00000000000000000000000000000000', 'dbd42d55d4b923c4b03eba0396fac98e'));
> 'Hello World Test'
> ------------------
> Hello World Test
> rows: 1
CALL ENCRYPT('XTEA', '00', STRINGTOUTF8('Test'));
> X'8bc9a4601b3062692a72a5941072425f'
> -----------------------------------
> 8bc9a4601b3062692a72a5941072425f
> rows: 1
call encrypt('XTEA', '000102030405060708090a0b0c0d0e0f', '4142434445464748');
> X'dea0b0b40966b0669fbae58ab503765f'
> -----------------------------------
> dea0b0b40966b0669fbae58ab503765f
> rows: 1
call utf8tostring(decrypt('AES', hash('sha256', stringtoutf8('Hello'), 1000), encrypt('AES', hash('sha256', stringtoutf8('Hello'), 1000), stringtoutf8('Hello World Test'))));
> 'Hello World Test'
> ------------------
> Hello World Test
> rows: 1
select length(curdate()) c1, length(current_date()) c2, substring(curdate(), 5, 1) c3 from test;
> C1 C2 C3
> -- -- --
> 10 10 -
> rows: 1
select length(curtime())>=8 c1, length(current_time())>=8 c2, substring(curtime(), 3, 1) c3 from test;
> C1 C2 C3
> ---- ---- --
> TRUE TRUE :
> rows: 1
select length(now())>20 c1, length(current_timestamp())>20 c2, length(now(0))>20 c3, length(now(2))>20 c4, substring(now(5), 20, 1) c5 from test;
> C1 C2 C3 C4 C5
> ---- ---- ---- ---- --
> TRUE TRUE TRUE TRUE .
> rows: 1
select dateadd('month', 1, timestamp '2003-01-31 10:20:30.012345678') d1 from test;
> D1
> -----------------------------
> 2003-02-28 10:20:30.012345678
> rows: 1
select dateadd('year', -1, timestamp '2000-02-29 10:20:30.012345678') d1 from test;
> D1
> -----------------------------
> 1999-02-28 10:20:30.012345678
> rows: 1
select datediff('yy', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('year', timestamp '2003-12-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('mm', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d2 from test;
> D2
> --
> 2
> rows: 1
select datediff('month', timestamp '2003-11-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d2 from test;
> D2
> --
> 2
> rows: 1
select datediff('dd', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') d4 from test;
> D4
> --
> 4
> rows: 1
select datediff('day', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-05 10:00:00.0') d4 from test;
> D4
> --
> 4
> rows: 1
select datediff('hh', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') d24 from test;
> D24
> ---
> 24
> rows: 1
select datediff('hour', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-02 10:00:00.0') d24 from test;
> D24
> ---
> 24
> rows: 1
select datediff('mi', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d20 from test;
> D20
> ---
> -20
> rows: 1
select datediff('minute', timestamp '2004-01-01 10:20:30.0', timestamp '2004-01-01 10:00:00.0') d20 from test;
> D20
> ---
> -20
> rows: 1
select datediff('ss', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('second', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d1 from test;
> D1
> --
> 1
> rows: 1
select datediff('ms', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d50x from test;
> D50X
> ----
> 500
> rows: 1
select datediff('millisecond', timestamp '2004-01-01 10:00:00.5', timestamp '2004-01-01 10:00:01.0') d50x from test;
> D50X
> ----
> 500
> rows: 1
select dayname(date '2005-09-12') d_monday from test;
> D_MONDAY
> --------
> Monday
> rows: 1
select monthname(date '2005-09-12') d_sept from test;
> D_SEPT
> ---------
> September
> rows: 1
select dayofmonth(date '2005-09-12') d12 from test;
> D12
> ---
> 12
> rows: 1
select dayofweek(date '2005-09-12') d2 from test;
> D2
> --
> 2
> rows: 1
select dayofyear(date '2005-01-01') d1 from test;
> D1
> --
> 1
> rows: 1
select year(date '2005-01-01') d2005 from test;
> D2005
> -----
> 2005
> rows: 1
select quarter(date '2005-09-01') d3 from test;
> D3
> --
> 3
> rows: 1
select month(date '2005-09-25') d9 from test;
> D9
> --
> 9
> rows: 1
select week(date '2003-01-09') d1 from test;
> D1
> --
> 2
> rows: 1
select hour(time '23:10:59') d23 from test;
> D23
> ---
> 23
> rows: 1
select minute(timestamp '2005-01-01 23:10:59') d10 from test;
> D10
> ---
> 10
> rows: 1
select second(timestamp '2005-01-01 23:10:59') d59 from test;
> D59
> ---
> 59
> rows: 1
select right(database(), 6) x_script from test;
> X_SCRIPT
> --------
> SCRIPT
> rows: 1
select user() x_sa, current_user() x_sa2 from test;
> X_SA X_SA2
> ---- -----
> SA SA
> rows: 1
select current_user() x_sa from test;
> X_SA
> ----
> SA
> rows: 1
select autocommit() x_true from test;
> X_TRUE
> ------
> TRUE
> rows: 1
select readonly() x_false from test;
> X_FALSE
> -------
> FALSE
> rows: 1
select ifnull(null, '1') x1, ifnull(null, null) xn, ifnull('a', 'b') xa from test;
> X1 XN XA
> -- ---- --
> 1 null a
> rows: 1
select isnull(null, '1') x1, isnull(null, null) xn, isnull('a', 'b') xa from test;
> X1 XN XA
> -- ---- --
> 1 null a
> rows: 1
select casewhen(null, '1', '2') xn, casewhen(1>0, 'n', 'y') xy, casewhen(0<1, 'a', 'b') xa from test;
> XN XY XA
> -- -- --
> 2 n a
> rows: 1
select x, case when x=0 then 'zero' else 'not zero' end y from system_range(0, 2);
> X Y
> - --------
> 0 zero
> 1 not zero
> 2 not zero
> rows: 3
select x, case when x=0 then 'zero' end y from system_range(0, 1);
> X Y
> - ----
> 0 zero
> 1 null
> rows: 2
select x, case x when 0 then 'zero' else 'not zero' end y from system_range(0, 1);
> X Y
> - --------
> 0 zero
> 1 not zero
> rows: 2
select x, case x when 0 then 'zero' when 1 then 'one' end y from system_range(0, 2);
> X Y
> - ----
> 0 zero
> 1 one
> 2 null
> rows: 3
select convert(null, varchar(255)) xn, convert(' 10', int) x10, convert(' 20 ', int) x20 from test;
> XN X10 X20
> ---- --- ---
> null 10 20
> rows: 1
select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int) x20 from test;
> XN X10 X20
> ---- --- ---
> null 10 20
> rows: 1
select coalesce(null, null) xn, coalesce(null, 'a') xa, coalesce('1', '2') x1 from test;
> XN XA X1
> ---- -- --
> null a 1
> rows: 1
select nullif(null, null) xn, nullif('a', 'a') xn, nullif('1', '2') x1 from test;
> XN XN X1
> ---- ---- --
> null null 1
> rows: 1
drop table test;
> ok
--- sequence with manual value ------------------
drop table if exists test;
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论