提交 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 { ...@@ -78,8 +78,57 @@ public class TestScript extends TestBase {
} }
reconnectOften = !config.memory && config.big; reconnectOften = !config.memory && config.big;
testScript("testScript.sql"); testScript("testScript.sql");
testScript("functions-system-rownum.sql"); testScript("commands-dml-script.sql");
testScript("datatypes-enum.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"); deleteDb("script");
System.out.flush(); System.out.flush();
} }
...@@ -132,6 +181,9 @@ public class TestScript extends TestBase { ...@@ -132,6 +181,9 @@ public class TestScript extends TestBase {
private void testFile(String inFile) throws Exception { private void testFile(String inFile) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(inFile); InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
if (is == null) {
throw new IOException("could not find " + inFile);
}
in = new LineNumberReader(new InputStreamReader(is, "Cp1252")); in = new LineNumberReader(new InputStreamReader(is, "Cp1252"));
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
while (true) { 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
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论