Unverified 提交 1cd6ee15 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1772 from katzyn/tests

Fix newlines in test scripts
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
*/ */
package org.h2.test.scripts; package org.h2.test.scripts;
import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
...@@ -47,6 +49,8 @@ public class TestScript extends TestDb { ...@@ -47,6 +49,8 @@ public class TestScript extends TestDb {
private static final String BASE_DIR = "org/h2/test/scripts/"; private static final String BASE_DIR = "org/h2/test/scripts/";
private static final boolean FIX_OUTPUT = false;
private static final Field COMMAND; private static final Field COMMAND;
private static final Field PREPARED; private static final Field PREPARED;
...@@ -232,7 +236,16 @@ public class TestScript extends TestDb { ...@@ -232,7 +236,16 @@ public class TestScript extends TestDb {
if (statements == null) { if (statements == null) {
println("Running commands in " + scriptFileName); println("Running commands in " + scriptFileName);
} }
final String outFile = "test.out.txt"; String outFile;
if (FIX_OUTPUT) {
outFile = scriptFileName;
int idx = outFile.lastIndexOf('/');
if (idx >= 0) {
outFile = outFile.substring(idx + 1);
}
} else {
outFile = "test.out.txt";
}
conn = getConnection("script"); conn = getConnection("script");
stat = conn.createStatement(); stat = conn.createStatement();
out = new PrintStream(new FileOutputStream(outFile)); out = new PrintStream(new FileOutputStream(outFile));
...@@ -240,10 +253,31 @@ public class TestScript extends TestDb { ...@@ -240,10 +253,31 @@ public class TestScript extends TestDb {
testFile(BASE_DIR + scriptFileName); testFile(BASE_DIR + scriptFileName);
conn.close(); conn.close();
out.close(); out.close();
if (FIX_OUTPUT) {
File file = new File(outFile);
// If there are two trailing newline characters remove one
try (RandomAccessFile r = new RandomAccessFile(file, "rw")) {
byte[] separator = System.lineSeparator().getBytes(StandardCharsets.ISO_8859_1);
int separatorLength = separator.length;
long length = r.length() - (separatorLength * 2);
truncate: if (length >= 0) {
r.seek(length);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < separatorLength; j++) {
if (r.readByte() != separator[j]) {
break truncate;
}
}
}
r.setLength(length + separatorLength);
}
}
file.renameTo(new File("h2/src/test/org/h2/test/scripts/" + scriptFileName));
return;
}
if (errors.length() > 0) { if (errors.length() > 0) {
throw new Exception("errors in " + scriptFileName + " found"); throw new Exception("errors in " + scriptFileName + " found");
} }
// new File(outFile).delete();
} }
private String readLine() throws IOException { private String readLine() throws IOException {
...@@ -253,6 +287,7 @@ public class TestScript extends TestDb { ...@@ -253,6 +287,7 @@ public class TestScript extends TestDb {
private String readNextLine() throws IOException { private String readNextLine() throws IOException {
String s; String s;
boolean comment = false;
while ((s = in.readLine()) != null) { while ((s = in.readLine()) != null) {
if (s.startsWith("#")) { if (s.startsWith("#")) {
int end = s.indexOf('#', 1); int end = s.indexOf('#', 1);
...@@ -276,18 +311,32 @@ public class TestScript extends TestDb { ...@@ -276,18 +311,32 @@ public class TestScript extends TestDb {
switch (flag) { switch (flag) {
case "mvStore": case "mvStore":
if (config.mvStore == val) { if (config.mvStore == val) {
out.print("#" + (val ? '+' : '-') + flag + '#');
break; break;
} else { } else {
if (FIX_OUTPUT) {
write("#" + (val ? '+' : '-') + flag + '#' + s);
}
continue; continue;
} }
default: default:
fail("Unknown flag \"" + flag + '\"'); fail("Unknown flag \"" + flag + '\"');
} }
} else if (s.startsWith("--")) {
write(s);
comment = true;
continue;
} }
if (!FIX_OUTPUT) {
s = s.trim(); s = s.trim();
}
if (!s.isEmpty()) { if (!s.isEmpty()) {
break; break;
} }
if (comment) {
write("");
comment = false;
}
} }
return s; return s;
} }
...@@ -322,14 +371,20 @@ public class TestScript extends TestDb { ...@@ -322,14 +371,20 @@ public class TestScript extends TestDb {
} else { } else {
switch (sql) { switch (sql) {
case "@reconnect": case "@reconnect":
write(sql);
write("");
if (!config.memory) { if (!config.memory) {
reconnect(conn.getAutoCommit()); reconnect(conn.getAutoCommit());
} }
break; break;
case "@reconnect on": case "@reconnect on":
write(sql);
write("");
allowReconnect = true; allowReconnect = true;
break; break;
case "@reconnect off": case "@reconnect off":
write(sql);
write("");
allowReconnect = false; allowReconnect = false;
break; break;
default: default:
......
...@@ -24,4 +24,3 @@ INSERT INTO user_group (ID) VALUES (1); ...@@ -24,4 +24,3 @@ INSERT INTO user_group (ID) VALUES (1);
DELETE FROM user_group; DELETE FROM user_group;
> update count: 1 > update count: 1
...@@ -29,7 +29,6 @@ SELECT * FROM TEST ORDER BY ID; ...@@ -29,7 +29,6 @@ SELECT * FROM TEST ORDER BY ID;
> 3 3000 > 3 3000
> rows (ordered): 2 > rows (ordered): 2
UPDATE TEST SET V = 3 WHERE ID = 3; UPDATE TEST SET V = 3 WHERE ID = 3;
> update count: 1 > update count: 1
......
...@@ -480,7 +480,6 @@ SELECT G / 10 G1, G / 10 G2, SUM(T.V) S FROM TEST T GROUP BY G / 10, G / 10; ...@@ -480,7 +480,6 @@ SELECT G / 10 G1, G / 10 G2, SUM(T.V) S FROM TEST T GROUP BY G / 10, G / 10;
> 2 2 4 > 2 2 4
> rows: 2 > rows: 2
SELECT G / 10 G1, G / 10 G2, SUM(T.V) S FROM TEST T GROUP BY G2; SELECT G / 10 G1, G / 10 G2, SUM(T.V) S FROM TEST T GROUP BY G2;
> G1 G2 S > G1 G2 S
> -- -- - > -- -- -
......
...@@ -44,7 +44,6 @@ explain with recursive "r"(n) as ( ...@@ -44,7 +44,6 @@ explain with recursive "r"(n) as (
select n from "r"; select n from "r";
>> WITH RECURSIVE PUBLIC."r"(N) AS ( (SELECT 1 FROM SYSTEM_RANGE(1, 1) /* PUBLIC.RANGE_INDEX */) UNION ALL (SELECT (N + 1) FROM PUBLIC."r" /* PUBLIC."r".tableScan */ WHERE N < 3) ) SELECT N FROM PUBLIC."r" "r" /* null */ >> WITH RECURSIVE PUBLIC."r"(N) AS ( (SELECT 1 FROM SYSTEM_RANGE(1, 1) /* PUBLIC.RANGE_INDEX */) UNION ALL (SELECT (N + 1) FROM PUBLIC."r" /* PUBLIC."r".tableScan */ WHERE N < 3) ) SELECT N FROM PUBLIC."r" "r" /* null */
select sum(n) from ( select sum(n) from (
with recursive r(n) as ( with recursive r(n) as (
(select 1) union all (select n+1 from r where n < 3) (select 1) union all (select n+1 from r where n < 3)
...@@ -80,6 +79,7 @@ select 0 from ( ...@@ -80,6 +79,7 @@ select 0 from (
> 0 > 0
> - > -
> rows: 0 > rows: 0
with with
r0(n,k) as (select -1, 0), r0(n,k) as (select -1, 0),
r1(n,k) as ((select 1, 0) union all (select n+1,k+1 from r1 where n <= 3)), r1(n,k) as ((select 1, 0) union all (select n+1,k+1 from r1 where n <= 3)),
......
...@@ -23,7 +23,6 @@ select count(*), count(*) filter (where v >= 4) from test; ...@@ -23,7 +23,6 @@ select count(*), count(*) filter (where v >= 4) from test;
> 13 9 > 13 9
> rows: 1 > rows: 1
select count(*), count(*) filter (where v >= 4) from test where v <= 10; select count(*), count(*) filter (where v >= 4) from test where v <= 10;
> COUNT(*) COUNT(*) FILTER (WHERE (V >= 4)) > COUNT(*) COUNT(*) FILTER (WHERE (V >= 4))
> -------- -------------------------------- > -------- --------------------------------
......
...@@ -14,4 +14,3 @@ select acos(null) vn, acos(-1) r1 from test; ...@@ -14,4 +14,3 @@ select acos(null) vn, acos(-1) r1 from test;
> ---- ----------------- > ---- -----------------
> null 3.141592653589793 > null 3.141592653589793
> rows: 1 > rows: 1
...@@ -14,4 +14,3 @@ select asin(null) vn, asin(-1) r1 from test; ...@@ -14,4 +14,3 @@ select asin(null) vn, asin(-1) r1 from test;
> ---- ------------------- > ---- -------------------
> null -1.5707963267948966 > null -1.5707963267948966
> rows: 1 > rows: 1
...@@ -14,4 +14,3 @@ select atan(null) vn, atan(-1) r1 from test; ...@@ -14,4 +14,3 @@ select atan(null) vn, atan(-1) r1 from test;
> ---- ------------------- > ---- -------------------
> null -0.7853981633974483 > null -0.7853981633974483
> rows: 1 > rows: 1
...@@ -14,5 +14,3 @@ select atan2(null, null) vn, atan2(10, 1) r1 from test; ...@@ -14,5 +14,3 @@ select atan2(null, null) vn, atan2(10, 1) r1 from test;
> ---- ------------------ > ---- ------------------
> null 1.4711276743037347 > null 1.4711276743037347
> rows: 1 > rows: 1
...@@ -14,7 +14,3 @@ select bitand(null, 1) vn, bitand(1, null) vn1, bitand(null, null) vn2, bitand(3 ...@@ -14,7 +14,3 @@ select bitand(null, 1) vn, bitand(1, null) vn1, bitand(null, null) vn2, bitand(3
> ---- ---- ---- -- > ---- ---- ---- --
> null null null 2 > null null null 2
> rows: 1 > rows: 1
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
...@@ -14,7 +14,3 @@ select bitor(null, 1) vn, bitor(1, null) vn1, bitor(null, null) vn2, bitor(3, 6) ...@@ -14,7 +14,3 @@ select bitor(null, 1) vn, bitor(1, null) vn1, bitor(null, null) vn2, bitor(3, 6)
> ---- ---- ---- -- > ---- ---- ---- --
> null null null 7 > null null null 7
> rows: 1 > rows: 1
...@@ -14,7 +14,3 @@ select bitxor(null, 1) vn, bitxor(1, null) vn1, bitxor(null, null) vn2, bitxor(3 ...@@ -14,7 +14,3 @@ select bitxor(null, 1) vn, bitxor(1, null) vn1, bitxor(null, null) vn2, bitxor(3
> ---- ---- ---- -- > ---- ---- ---- --
> null null null 5 > null null null 5
> rows: 1 > rows: 1
...@@ -14,8 +14,3 @@ select ceil(null) vn, ceil(1) v1, ceiling(1.1) v2, ceil(-1.1) v3, ceiling(1.9) v ...@@ -14,8 +14,3 @@ select ceil(null) vn, ceil(1) v1, ceiling(1.1) v2, ceil(-1.1) v3, ceiling(1.9) v
> ---- --- --- ---- --- ---- > ---- --- --- ---- --- ----
> null 1.0 2.0 -1.0 2.0 -1.0 > null 1.0 2.0 -1.0 2.0 -1.0
> rows: 1 > rows: 1
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
...@@ -14,5 +14,3 @@ select cos(null) vn, cos(-1) r1 from test; ...@@ -14,5 +14,3 @@ select cos(null) vn, cos(-1) r1 from test;
> ---- ------------------ > ---- ------------------
> null 0.5403023058681398 > null 0.5403023058681398
> rows: 1 > rows: 1
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
...@@ -14,5 +14,3 @@ select cot(null) vn, cot(-1) r1 from test; ...@@ -14,5 +14,3 @@ select cot(null) vn, cot(-1) r1 from test;
> ---- ------------------- > ---- -------------------
> null -0.6420926159343306 > null -0.6420926159343306
> rows: 1 > rows: 1
...@@ -14,6 +14,3 @@ select exp(null) vn, left(exp(1), 4) v1, left(exp(1.1), 4) v2, left(exp(-1.1), 4 ...@@ -14,6 +14,3 @@ select exp(null) vn, left(exp(1), 4) v1, left(exp(1.1), 4) v2, left(exp(-1.1), 4
> ---- ---- ---- ---- ---- ---- > ---- ---- ---- ---- ---- ----
> null 2.71 3.00 0.33 6.68 0.14 > null 2.71 3.00 0.33 6.68 0.14
> rows: 1 > rows: 1
...@@ -14,9 +14,3 @@ select floor(null) vn, floor(1) v1, floor(1.1) v2, floor(-1.1) v3, floor(1.9) v4 ...@@ -14,9 +14,3 @@ select floor(null) vn, floor(1) v1, floor(1.1) v2, floor(-1.1) v3, floor(1.9) v4
> ---- --- --- ---- --- ---- > ---- --- --- ---- --- ----
> null 1.0 1.0 -2.0 1.0 -2.0 > null 1.0 1.0 -2.0 1.0 -2.0
> rows: 1 > rows: 1
...@@ -38,8 +38,3 @@ select octet_length(null) en, octet_length('') e0, octet_length('ab') e4 from te ...@@ -38,8 +38,3 @@ select octet_length(null) en, octet_length('') e0, octet_length('ab') e4 from te
> ---- -- -- > ---- -- --
> null 0 4 > null 0 4
> rows: 1 > rows: 1
...@@ -26,9 +26,3 @@ select log(null) vn, log(1) v1, log(1.1) v2, log(-1.1) v3, log(1.9) v4, log(-1.9 ...@@ -26,9 +26,3 @@ select log(null) vn, log(1) v1, log(1.1) v2, log(-1.1) v3, log(1.9) v4, log(-1.9
> ---- --- ------------------- --- ------------------ --- > ---- --- ------------------- --- ------------------ ---
> null 0.0 0.09531017980432493 NaN 0.6418538861723947 NaN > null 0.0 0.09531017980432493 NaN 0.6418538861723947 NaN
> rows: 1 > rows: 1
...@@ -14,7 +14,3 @@ select mod(null, 1) vn, mod(1, null) vn1, mod(null, null) vn2, mod(10, 2) e1 fro ...@@ -14,7 +14,3 @@ select mod(null, 1) vn, mod(1, null) vn1, mod(null, null) vn2, mod(10, 2) e1 fro
> ---- ---- ---- -- > ---- ---- ---- --
> null null null 0 > null null null 0
> rows: 1 > rows: 1
...@@ -14,7 +14,3 @@ select power(null, null) en, power(2, 3) e8, power(16, 0.5) e4 from test; ...@@ -14,7 +14,3 @@ select power(null, null) en, power(2, 3) e8, power(16, 0.5) e4 from test;
> ---- --- --- > ---- --- ---
> null 8.0 4.0 > null 8.0 4.0
> rows: 1 > rows: 1
...@@ -26,6 +26,3 @@ select roundmagic(null) en, roundmagic(cast(3.11 as double) - 3.1) e001, roundma ...@@ -26,6 +26,3 @@ select roundmagic(null) en, roundmagic(cast(3.11 as double) - 3.1) e001, roundma
> ---- ---- ---- ------ > ---- ---- ---- ------
> null 0.01 0.0 2.0E12 > null 0.01 0.0 2.0E12
> rows: 1 > rows: 1
...@@ -14,5 +14,3 @@ select sin(null) vn, sin(-1) r1 from test; ...@@ -14,5 +14,3 @@ select sin(null) vn, sin(-1) r1 from test;
> ---- ------------------- > ---- -------------------
> null -0.8414709848078965 > null -0.8414709848078965
> rows: 1 > rows: 1
...@@ -14,6 +14,3 @@ select sqrt(null) vn, sqrt(0) e0, sqrt(1) e1, sqrt(4) e2, sqrt(100) e10, sqrt(0. ...@@ -14,6 +14,3 @@ select sqrt(null) vn, sqrt(0) e0, sqrt(1) e1, sqrt(4) e2, sqrt(100) e10, sqrt(0.
> ---- --- --- --- ---- --- > ---- --- --- --- ---- ---
> null 0.0 1.0 2.0 10.0 0.5 > null 0.0 1.0 2.0 10.0 0.5
> rows: 1 > rows: 1
...@@ -14,6 +14,3 @@ select tan(null) vn, tan(-1) r1 from test; ...@@ -14,6 +14,3 @@ select tan(null) vn, tan(-1) r1 from test;
> ---- ------------------- > ---- -------------------
> null -1.5574077246549023 > null -1.5574077246549023
> rows: 1 > rows: 1
...@@ -14,7 +14,3 @@ select ascii(null) en, ascii('') en, ascii('Abc') e65 from test; ...@@ -14,7 +14,3 @@ select ascii(null) en, ascii('') en, ascii('Abc') e65 from test;
> ---- ---- --- > ---- ---- ---
> null null 65 > null null 65
> rows: 1 > rows: 1
...@@ -14,4 +14,3 @@ select hextoraw(null) en, rawtohex(null) en1, hextoraw(rawtohex('abc')) abc from ...@@ -14,4 +14,3 @@ select hextoraw(null) en, rawtohex(null) en1, hextoraw(rawtohex('abc')) abc from
> ---- ---- --- > ---- ---- ---
> null null abc > null null abc
> rows: 1 > rows: 1
...@@ -20,4 +20,3 @@ select insert('World', 2, 4, 'e') welt, insert('Hello', 2, 1, 'a') hallo from te ...@@ -20,4 +20,3 @@ select insert('World', 2, 4, 'e') welt, insert('Hello', 2, 1, 'a') hallo from te
> ---- ----- > ---- -----
> We Hallo > We Hallo
> rows: 1 > rows: 1
...@@ -9,7 +9,6 @@ create memory table test(id int primary key, name varchar(255)); ...@@ -9,7 +9,6 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello'); insert into test values(1, 'Hello');
> update count: 1 > update count: 1
select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int) x20 from test; select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int) x20 from test;
> XN X10 X20 > XN X10 X20
> ---- --- --- > ---- --- ---
......
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
...@@ -20,4 +20,3 @@ select isnull(null, '1') x1, isnull(null, null) xn, isnull('a', 'b') xa from tes ...@@ -20,4 +20,3 @@ select isnull(null, '1') x1, isnull(null, null) xn, isnull('a', 'b') xa from tes
> -- ---- -- > -- ---- --
> 1 null a > 1 null a
> rows: 1 > rows: 1
...@@ -15,7 +15,6 @@ select length(curtime())>=8 c1, length(current_time())>=8 c2, substring(curtime( ...@@ -15,7 +15,6 @@ select length(curtime())>=8 c1, length(current_time())>=8 c2, substring(curtime(
> TRUE TRUE : > TRUE TRUE :
> rows: 1 > rows: 1
select length(now())>18 c1, length(current_timestamp())>18 c2, length(now(0))>18 c3, length(now(2))>18 c4 from test; select length(now())>18 c1, length(current_timestamp())>18 c2, length(now(0))>18 c3, length(now(2))>18 c4 from test;
> C1 C2 C3 C4 > C1 C2 C3 C4
> ---- ---- ---- ---- > ---- ---- ---- ----
......
...@@ -372,7 +372,6 @@ SELECT DATE_TRUNC('second', '2015-05-29 00:00:00'); ...@@ -372,7 +372,6 @@ SELECT DATE_TRUNC('second', '2015-05-29 00:00:00');
SELECT DATE_TRUNC('SECOND', '2015-05-29 00:00:00'); SELECT DATE_TRUNC('SECOND', '2015-05-29 00:00:00');
>> 2015-05-29 00:00:00 >> 2015-05-29 00:00:00
-- --
-- Test time unit 'MINUTE' -- Test time unit 'MINUTE'
-- --
...@@ -598,7 +597,6 @@ select DATE_TRUNC('day', '2015-05-29 15:14:13'); ...@@ -598,7 +597,6 @@ select DATE_TRUNC('day', '2015-05-29 15:14:13');
select DATE_TRUNC('DAY', '2015-05-29 15:14:13'); select DATE_TRUNC('DAY', '2015-05-29 15:14:13');
>> 2015-05-29 00:00:00 >> 2015-05-29 00:00:00
-- --
-- Test time unit 'WEEK' -- Test time unit 'WEEK'
-- --
...@@ -818,7 +816,6 @@ SELECT DATE_TRUNC('quarter', '2015-12-29 15:14:13'); ...@@ -818,7 +816,6 @@ SELECT DATE_TRUNC('quarter', '2015-12-29 15:14:13');
SELECT DATE_TRUNC('QUARTER', '2015-12-29 15:14:13'); SELECT DATE_TRUNC('QUARTER', '2015-12-29 15:14:13');
>> 2015-10-01 00:00:00 >> 2015-10-01 00:00:00
-- --
-- Test time unit 'YEAR' -- Test time unit 'YEAR'
-- --
...@@ -1073,4 +1070,3 @@ SELECT DATE_TRUNC('', ''); ...@@ -1073,4 +1070,3 @@ SELECT DATE_TRUNC('', '');
SELECT DATE_TRUNC('YEAR', ''); SELECT DATE_TRUNC('YEAR', '');
> exception INVALID_DATETIME_CONSTANT_2 > exception INVALID_DATETIME_CONSTANT_2
...@@ -87,7 +87,6 @@ SELECT *, ...@@ -87,7 +87,6 @@ SELECT *,
NTH_VALUE(VALUE, 2) OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) F_U_C, NTH_VALUE(VALUE, 2) OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) F_U_C,
NTH_VALUE(VALUE, 2) OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) F_C_U, NTH_VALUE(VALUE, 2) OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) F_C_U,
NTH_VALUE(VALUE, 2) OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) F_U_U, NTH_VALUE(VALUE, 2) OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) F_U_U,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID) L, NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID) L,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) L_U_C, NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) L_U_C,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) L_C_U, NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) L_C_U,
......
...@@ -22,13 +22,11 @@ SELECT *, ...@@ -22,13 +22,11 @@ SELECT *,
ROW_NUMBER() OVER () RN, ROW_NUMBER() OVER () RN,
ROUND(PERCENT_RANK() OVER (), 2) PR, ROUND(PERCENT_RANK() OVER (), 2) PR,
ROUND(CUME_DIST() OVER (), 2) CD, ROUND(CUME_DIST() OVER (), 2) CD,
ROW_NUMBER() OVER (ORDER BY ID) RNO, ROW_NUMBER() OVER (ORDER BY ID) RNO,
RANK() OVER (ORDER BY ID) RKO, RANK() OVER (ORDER BY ID) RKO,
DENSE_RANK() OVER (ORDER BY ID) DRO, DENSE_RANK() OVER (ORDER BY ID) DRO,
ROUND(PERCENT_RANK() OVER (ORDER BY ID), 2) PRO, ROUND(PERCENT_RANK() OVER (ORDER BY ID), 2) PRO,
ROUND(CUME_DIST() OVER (ORDER BY ID), 2) CDO ROUND(CUME_DIST() OVER (ORDER BY ID), 2) CDO
FROM TEST; FROM TEST;
> ID CATEGORY VALUE RN PR CD RNO RKO DRO PRO CDO > ID CATEGORY VALUE RN PR CD RNO RKO DRO PRO CDO
> -- -------- ----- -- --- --- --- --- --- ---- ---- > -- -------- ----- -- --- --- --- --- --- ---- ----
......
...@@ -744,33 +744,46 @@ DROP TABLE C; ...@@ -744,33 +744,46 @@ DROP TABLE C;
CREATE TABLE T1(X1 INT); CREATE TABLE T1(X1 INT);
> ok > ok
CREATE TABLE T2(X2 INT); CREATE TABLE T2(X2 INT);
> ok > ok
CREATE TABLE T3(X3 INT); CREATE TABLE T3(X3 INT);
> ok > ok
CREATE TABLE T4(X4 INT); CREATE TABLE T4(X4 INT);
> ok > ok
CREATE TABLE T5(X5 INT); CREATE TABLE T5(X5 INT);
> ok > ok
INSERT INTO T1 VALUES (1); INSERT INTO T1 VALUES (1);
> update count: 1 > update count: 1
INSERT INTO T1 VALUES (NULL); INSERT INTO T1 VALUES (NULL);
> update count: 1 > update count: 1
INSERT INTO T2 VALUES (1); INSERT INTO T2 VALUES (1);
> update count: 1 > update count: 1
INSERT INTO T2 VALUES (NULL); INSERT INTO T2 VALUES (NULL);
> update count: 1 > update count: 1
INSERT INTO T3 VALUES (1); INSERT INTO T3 VALUES (1);
> update count: 1 > update count: 1
INSERT INTO T3 VALUES (NULL); INSERT INTO T3 VALUES (NULL);
> update count: 1 > update count: 1
INSERT INTO T4 VALUES (1); INSERT INTO T4 VALUES (1);
> update count: 1 > update count: 1
INSERT INTO T4 VALUES (NULL); INSERT INTO T4 VALUES (NULL);
> update count: 1 > update count: 1
INSERT INTO T5 VALUES (1); INSERT INTO T5 VALUES (1);
> update count: 1 > update count: 1
INSERT INTO T5 VALUES (NULL); INSERT INTO T5 VALUES (NULL);
> update count: 1 > update count: 1
......
...@@ -2523,6 +2523,7 @@ insert into address(id, name, name2) values(2, 'test@abc', 'test@acme'); ...@@ -2523,6 +2523,7 @@ insert into address(id, name, name2) values(2, 'test@abc', 'test@acme');
> exception CHECK_CONSTRAINT_VIOLATED_1 > exception CHECK_CONSTRAINT_VIOLATED_1
@reconnect @reconnect
insert into address(id, name, name2) values(3, 'test_abc', 'test@gmail'); insert into address(id, name, name2) values(3, 'test_abc', 'test@gmail');
> exception CHECK_CONSTRAINT_VIOLATED_1 > exception CHECK_CONSTRAINT_VIOLATED_1
...@@ -7954,4 +7955,3 @@ select * from test where year in (select distinct year from test order by year d ...@@ -7954,4 +7955,3 @@ select * from test where year in (select distinct year from test order by year d
drop table test; drop table test;
> ok > ok
...@@ -4,390 +4,558 @@ ...@@ -4,390 +4,558 @@
-- --
select 1000L / 10; select 1000L / 10;
>> 100 >> 100
select * from (select x as y from dual order by y); select * from (select x as y from dual order by y);
>> 1 >> 1
select a.x from dual a, dual b order by x; select a.x from dual a, dual b order by x;
>> 1 >> 1
select 1 from(select 2 from(select 1) a right join dual b) c; select 1 from(select 2 from(select 1) a right join dual b) c;
>> 1 >> 1
select 1.00 / 3 * 0.00; select 1.00 / 3 * 0.00;
>> 0.00000000000000000000000000000 >> 0.00000000000000000000000000000
select 1.00000 / 3 * 0.0000; select 1.00000 / 3 * 0.0000;
>> 0.0000000000000000000000000000000000 >> 0.0000000000000000000000000000000000
select 1.0000000 / 3 * 0.00000; select 1.0000000 / 3 * 0.00000;
>> 0.0000000000000000000000000000000000000 >> 0.0000000000000000000000000000000000000
select 1.0000000 / 3 * 0.000000; select 1.0000000 / 3 * 0.000000;
>> 0E-38 >> 0E-38
create table test(id null); create table test(id null);
> ok > ok
drop table test; drop table test;
> ok > ok
select * from (select group_concat(distinct 1) from system_range(1, 3)); select * from (select group_concat(distinct 1) from system_range(1, 3));
>> 1 >> 1
select sum(mod(x, 2) = 1) from system_range(1, 10); select sum(mod(x, 2) = 1) from system_range(1, 10);
>> 5 >> 5
create table a(x int); create table a(x int);
> ok > ok
create table b(x int); create table b(x int);
> ok > ok
select count(*) from (select b.x from a left join b); select count(*) from (select b.x from a left join b);
>> 0 >> 0
drop table a, b; drop table a, b;
> ok > ok
select count(distinct now()) c from system_range(1, 100), system_range(1, 1000); select count(distinct now()) c from system_range(1, 100), system_range(1, 1000);
>> 1 >> 1
select {fn TIMESTAMPADD(SQL_TSI_DAY, 1, {ts '2011-10-20 20:30:40.001'})}; select {fn TIMESTAMPADD(SQL_TSI_DAY, 1, {ts '2011-10-20 20:30:40.001'})};
>> 2011-10-21 20:30:40.001 >> 2011-10-21 20:30:40.001
select {fn TIMESTAMPADD(SQL_TSI_SECOND, 1, cast('2011-10-20 20:30:40.001' as timestamp))}; select {fn TIMESTAMPADD(SQL_TSI_SECOND, 1, cast('2011-10-20 20:30:40.001' as timestamp))};
>> 2011-10-20 20:30:41.001 >> 2011-10-20 20:30:41.001
select N'test'; select N'test';
>> test >> test
select E'test\\test'; select E'test\\test';
>> test\test >> test\test
create table a(id int) as select null; create table a(id int) as select null;
> ok > ok
create table b(id int references a(id)) as select null; create table b(id int references a(id)) as select null;
> ok > ok
delete from a; delete from a;
> update count: 1 > update count: 1
drop table a, b; drop table a, b;
> ok > ok
create table test(a int, b int) as select 2, 0; create table test(a int, b int) as select 2, 0;
> ok > ok
create index idx on test(b, a); create index idx on test(b, a);
> ok > ok
select count(*) from test where a in(2, 10) and b in(0, null); select count(*) from test where a in(2, 10) and b in(0, null);
>> 1 >> 1
drop table test; drop table test;
> ok > ok
create table test(a int, b int) as select 1, 0; create table test(a int, b int) as select 1, 0;
> ok > ok
create index idx on test(b, a); create index idx on test(b, a);
> ok > ok
select count(*) from test where b in(null, 0) and a in(1, null); select count(*) from test where b in(null, 0) and a in(1, null);
>> 1 >> 1
drop table test; drop table test;
> ok > ok
create cached temp table test(id identity) not persistent; create cached temp table test(id identity) not persistent;
> ok > ok
drop table test; drop table test;
> ok > ok
create table test(a int, b int, unique(a, b)); create table test(a int, b int, unique(a, b));
> ok > ok
insert into test values(1,1), (1,2); insert into test values(1,1), (1,2);
> update count: 2 > update count: 2
select count(*) from test where a in(1,2) and b in(1,2); select count(*) from test where a in(1,2) and b in(1,2);
>> 2 >> 2
drop table test; drop table test;
> ok > ok
create table test(id int); create table test(id int);
> ok > ok
alter table test alter column id set default 'x'; alter table test alter column id set default 'x';
> ok > ok
select column_default from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID'; select column_default from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
>> 'x' >> 'x'
alter table test alter column id set not null; alter table test alter column id set not null;
> ok > ok
select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID'; select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
>> NO >> NO
alter table test alter column id set data type varchar; alter table test alter column id set data type varchar;
> ok > ok
select type_name from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID'; select type_name from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
>> VARCHAR >> VARCHAR
alter table test alter column id type int; alter table test alter column id type int;
> ok > ok
select type_name from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID'; select type_name from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
>> INTEGER >> INTEGER
alter table test alter column id drop default; alter table test alter column id drop default;
> ok > ok
select column_default from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID'; select column_default from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
>> null >> null
alter table test alter column id drop not null; alter table test alter column id drop not null;
> ok > ok
select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID'; select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
>> YES >> YES
drop table test; drop table test;
> ok > ok
select x from (select *, rownum as r from system_range(1, 3)) where r=2; select x from (select *, rownum as r from system_range(1, 3)) where r=2;
>> 2 >> 2
create table test(name varchar(255)) as select 'Hello+World+'; create table test(name varchar(255)) as select 'Hello+World+';
> ok > ok
select count(*) from test where name like 'Hello++World++' escape '+'; select count(*) from test where name like 'Hello++World++' escape '+';
>> 1 >> 1
select count(*) from test where name like '+H+e+l+l+o++World++' escape '+'; select count(*) from test where name like '+H+e+l+l+o++World++' escape '+';
>> 1 >> 1
select count(*) from test where name like 'Hello+World++' escape '+'; select count(*) from test where name like 'Hello+World++' escape '+';
>> 0 >> 0
select count(*) from test where name like 'Hello++World+' escape '+'; select count(*) from test where name like 'Hello++World+' escape '+';
>> 0 >> 0
drop table test; drop table test;
> ok > ok
select count(*) from system_range(1, 1); select count(*) from system_range(1, 1);
>> 1 >> 1
select count(*) from system_range(1, -1); select count(*) from system_range(1, -1);
>> 0 >> 0
select 1 from dual where '\' like '\' escape ''; select 1 from dual where '\' like '\' escape '';
>> 1 >> 1
select left(timestamp '2001-02-03 08:20:31+04', 4); select left(timestamp '2001-02-03 08:20:31+04', 4);
>> 2001 >> 2001
create table t1$2(id int); create table t1$2(id int);
> ok > ok
drop table t1$2; drop table t1$2;
> ok > ok
create table test(id int primary key) as select x from system_range(1, 200); create table test(id int primary key) as select x from system_range(1, 200);
> ok > ok
delete from test; delete from test;
> update count: 200 > update count: 200
insert into test(id) values(1); insert into test(id) values(1);
> update count: 1 > update count: 1
select * from test order by id; select * from test order by id;
>> 1 >> 1
drop table test; drop table test;
> ok > ok
create memory table test(id int) not persistent as select 1 from dual; create memory table test(id int) not persistent as select 1 from dual;
> ok > ok
insert into test values(1); insert into test values(1);
> update count: 1 > update count: 1
select count(1) from test; select count(1) from test;
>> 2 >> 2
@reconnect @reconnect
select count(1) from test; select count(1) from test;
>> 0 >> 0
drop table test; drop table test;
> ok > ok
create table test(t clob) as select 1; create table test(t clob) as select 1;
> ok > ok
select distinct t from test; select distinct t from test;
>> 1 >> 1
drop table test; drop table test;
> ok > ok
create table test(id int unique not null); create table test(id int unique not null);
> ok > ok
drop table test; drop table test;
> ok > ok
create table test(id int not null unique); create table test(id int not null unique);
> ok > ok
drop table test; drop table test;
> ok > ok
select count(*)from((select 1 from dual limit 1)union(select 2 from dual limit 1)); select count(*)from((select 1 from dual limit 1)union(select 2 from dual limit 1));
>> 2 >> 2
select sum(cast(x as int)) from system_range(2147483547, 2147483637); select sum(cast(x as int)) from system_range(2147483547, 2147483637);
>> 195421006872 >> 195421006872
select sum(x) from system_range(9223372036854775707, 9223372036854775797); select sum(x) from system_range(9223372036854775707, 9223372036854775797);
>> 839326855353784593432 >> 839326855353784593432
select sum(cast(100 as tinyint)) from system_range(1, 1000); select sum(cast(100 as tinyint)) from system_range(1, 1000);
>> 100000 >> 100000
select sum(cast(100 as smallint)) from system_range(1, 1000); select sum(cast(100 as smallint)) from system_range(1, 1000);
>> 100000 >> 100000
select avg(cast(x as int)) from system_range(2147483547, 2147483637); select avg(cast(x as int)) from system_range(2147483547, 2147483637);
>> 2147483592 >> 2147483592
select avg(x) from system_range(9223372036854775707, 9223372036854775797); select avg(x) from system_range(9223372036854775707, 9223372036854775797);
>> 9223372036854775752 >> 9223372036854775752
select avg(cast(100 as tinyint)) from system_range(1, 1000); select avg(cast(100 as tinyint)) from system_range(1, 1000);
>> 100 >> 100
select avg(cast(100 as smallint)) from system_range(1, 1000); select avg(cast(100 as smallint)) from system_range(1, 1000);
>> 100 >> 100
select datediff(yyyy, now(), now()); select datediff(yyyy, now(), now());
>> 0 >> 0
create table t(d date) as select '2008-11-01' union select '2008-11-02'; create table t(d date) as select '2008-11-01' union select '2008-11-02';
> ok > ok
select 1 from t group by year(d) order by year(d); select 1 from t group by year(d) order by year(d);
>> 1 >> 1
drop table t; drop table t;
> ok > ok
create table t(d int) as select 2001 union select 2002; create table t(d int) as select 2001 union select 2002;
> ok > ok
select 1 from t group by d/10 order by d/10; select 1 from t group by d/10 order by d/10;
>> 1 >> 1
drop table t; drop table t;
> ok > ok
create schema test; create schema test;
> ok > ok
create sequence test.report_id_seq; create sequence test.report_id_seq;
> ok > ok
select nextval('"test".REPORT_ID_SEQ'); select nextval('"test".REPORT_ID_SEQ');
>> 1 >> 1
select nextval('"test"."report_id_seq"'); select nextval('"test"."report_id_seq"');
>> 2 >> 2
select nextval('test.report_id_seq'); select nextval('test.report_id_seq');
>> 3 >> 3
drop schema test cascade; drop schema test cascade;
> ok > ok
create table master(id int primary key); create table master(id int primary key);
> ok > ok
create table detail(id int primary key, x bigint, foreign key(x) references master(id) on delete cascade); create table detail(id int primary key, x bigint, foreign key(x) references master(id) on delete cascade);
> ok > ok
alter table detail alter column x bigint; alter table detail alter column x bigint;
> ok > ok
insert into master values(0); insert into master values(0);
> update count: 1 > update count: 1
insert into detail values(0,0); insert into detail values(0,0);
> update count: 1 > update count: 1
delete from master; delete from master;
> update count: 1 > update count: 1
drop table master, detail; drop table master, detail;
> ok > ok
drop all objects; drop all objects;
> ok > ok
create table test(id int, parent int references test(id) on delete cascade); create table test(id int, parent int references test(id) on delete cascade);
> ok > ok
insert into test values(0, 0); insert into test values(0, 0);
> update count: 1 > update count: 1
alter table test rename to test2; alter table test rename to test2;
> ok > ok
delete from test2; delete from test2;
> update count: 1 > update count: 1
drop table test2; drop table test2;
> ok > ok
SELECT X FROM dual GROUP BY X HAVING X=AVG(X); SELECT X FROM dual GROUP BY X HAVING X=AVG(X);
>> 1 >> 1
create view test_view(id,) as select * from dual; create view test_view(id,) as select * from dual;
> ok > ok
drop view test_view; drop view test_view;
> ok > ok
create table test(id int,); create table test(id int,);
> ok > ok
insert into test(id,) values(1,); insert into test(id,) values(1,);
> update count: 1 > update count: 1
merge into test(id,) key(id,) values(1,); merge into test(id,) key(id,) values(1,);
> update count: 1 > update count: 1
drop table test; drop table test;
> ok > ok
SET MODE DB2; SET MODE DB2;
> ok > ok
SELECT * FROM SYSTEM_RANGE(1, 100) OFFSET 99 ROWS; SELECT * FROM SYSTEM_RANGE(1, 100) OFFSET 99 ROWS;
>> 100 >> 100
SELECT * FROM SYSTEM_RANGE(1, 100) OFFSET 50 ROWS FETCH FIRST 1 ROW ONLY; SELECT * FROM SYSTEM_RANGE(1, 100) OFFSET 50 ROWS FETCH FIRST 1 ROW ONLY;
>> 51 >> 51
SELECT * FROM SYSTEM_RANGE(1, 100) FETCH FIRST 1 ROWS ONLY; SELECT * FROM SYSTEM_RANGE(1, 100) FETCH FIRST 1 ROWS ONLY;
>> 1 >> 1
SELECT * FROM SYSTEM_RANGE(1, 100) FETCH FIRST ROW ONLY; SELECT * FROM SYSTEM_RANGE(1, 100) FETCH FIRST ROW ONLY;
>> 1 >> 1
SET MODE REGULAR; SET MODE REGULAR;
> ok > ok
create domain email as varchar comment 'e-mail'; create domain email as varchar comment 'e-mail';
> ok > ok
create table test(e email); create table test(e email);
> ok > ok
select remarks from INFORMATION_SCHEMA.COLUMNS where table_name='TEST'; select remarks from INFORMATION_SCHEMA.COLUMNS where table_name='TEST';
>> e-mail >> e-mail
drop table test; drop table test;
> ok > ok
drop domain email; drop domain email;
> ok > ok
create table test$test(id int); create table test$test(id int);
> ok > ok
drop table test$test; drop table test$test;
> ok > ok
create table test$$test(id int); create table test$$test(id int);
> ok > ok
drop table test$$test; drop table test$$test;
> ok > ok
create table test (id varchar(36) as random_uuid() primary key); create table test (id varchar(36) as random_uuid() primary key);
> ok > ok
insert into test() values(); insert into test() values();
> update count: 1 > update count: 1
delete from test where id = select id from test; delete from test where id = select id from test;
> update count: 1 > update count: 1
drop table test; drop table test;
> ok > ok
create table test (id varchar(36) as now() primary key); create table test (id varchar(36) as now() primary key);
> ok > ok
insert into test() values(); insert into test() values();
> update count: 1 > update count: 1
delete from test where id = select id from test; delete from test where id = select id from test;
> update count: 1 > update count: 1
drop table test; drop table test;
> ok > ok
SELECT SOME(X>4) FROM SYSTEM_RANGE(1,6); SELECT SOME(X>4) FROM SYSTEM_RANGE(1,6);
>> TRUE >> TRUE
SELECT EVERY(X>4) FROM SYSTEM_RANGE(1,6); SELECT EVERY(X>4) FROM SYSTEM_RANGE(1,6);
>> FALSE >> FALSE
SELECT BOOL_OR(X>4) FROM SYSTEM_RANGE(1,6); SELECT BOOL_OR(X>4) FROM SYSTEM_RANGE(1,6);
>> TRUE >> TRUE
SELECT BOOL_AND(X>4) FROM SYSTEM_RANGE(1,6); SELECT BOOL_AND(X>4) FROM SYSTEM_RANGE(1,6);
>> FALSE >> FALSE
SELECT BIT_OR(X) FROM SYSTEM_RANGE(1,6); SELECT BIT_OR(X) FROM SYSTEM_RANGE(1,6);
>> 7 >> 7
SELECT BIT_AND(X) FROM SYSTEM_RANGE(1,6); SELECT BIT_AND(X) FROM SYSTEM_RANGE(1,6);
>> 0 >> 0
SELECT BIT_AND(X) FROM SYSTEM_RANGE(1,1); SELECT BIT_AND(X) FROM SYSTEM_RANGE(1,1);
>> 1 >> 1
CREATE TABLE TEST(ID IDENTITY); CREATE TABLE TEST(ID IDENTITY);
> ok > ok
ALTER TABLE TEST ALTER COLUMN ID RESTART WITH ?; ALTER TABLE TEST ALTER COLUMN ID RESTART WITH ?;
{ {
10 10
}; };
> update count: 0 > update count: 0
INSERT INTO TEST VALUES(NULL); INSERT INTO TEST VALUES(NULL);
> update count: 1 > update count: 1
SELECT * FROM TEST; SELECT * FROM TEST;
>> 10 >> 10
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
CREATE SEQUENCE TEST_SEQ; CREATE SEQUENCE TEST_SEQ;
> ok > ok
ALTER SEQUENCE TEST_SEQ RESTART WITH ? INCREMENT BY ?; ALTER SEQUENCE TEST_SEQ RESTART WITH ? INCREMENT BY ?;
{ {
20, 3 20, 3
}; };
> update count: 0 > update count: 0
SELECT NEXT VALUE FOR TEST_SEQ; SELECT NEXT VALUE FOR TEST_SEQ;
>> 20 >> 20
SELECT NEXT VALUE FOR TEST_SEQ; SELECT NEXT VALUE FOR TEST_SEQ;
>> 23 >> 23
DROP SEQUENCE TEST_SEQ; DROP SEQUENCE TEST_SEQ;
> ok > ok
create schema Contact; create schema Contact;
> ok > ok
CREATE TABLE Account (id BIGINT); CREATE TABLE Account (id BIGINT);
> ok > ok
CREATE TABLE Person (id BIGINT, FOREIGN KEY (id) REFERENCES Account(id)); CREATE TABLE Person (id BIGINT, FOREIGN KEY (id) REFERENCES Account(id));
> ok > ok
CREATE TABLE Contact.Contact (id BIGINT, FOREIGN KEY (id) REFERENCES public.Person(id)); CREATE TABLE Contact.Contact (id BIGINT, FOREIGN KEY (id) REFERENCES public.Person(id));
> ok > ok
drop schema contact cascade; drop schema contact cascade;
> ok > ok
drop table account, person; drop table account, person;
> ok > ok
create schema Contact; create schema Contact;
> ok > ok
CREATE TABLE Account (id BIGINT primary key); CREATE TABLE Account (id BIGINT primary key);
> ok > ok
CREATE TABLE Person (id BIGINT primary key, FOREIGN KEY (id) REFERENCES Account); CREATE TABLE Person (id BIGINT primary key, FOREIGN KEY (id) REFERENCES Account);
> ok > ok
CREATE TABLE Contact.Contact (id BIGINT primary key, FOREIGN KEY (id) REFERENCES public.Person); CREATE TABLE Contact.Contact (id BIGINT primary key, FOREIGN KEY (id) REFERENCES public.Person);
> ok > ok
drop schema contact cascade; drop schema contact cascade;
> ok > ok
drop table account, person; drop table account, person;
> ok > ok
CREATE TABLE TEST(A int NOT NULL, B int NOT NULL, C int) ; CREATE TABLE TEST(A int NOT NULL, B int NOT NULL, C int) ;
> ok > ok
ALTER TABLE TEST ADD CONSTRAINT CON UNIQUE(A,B); ALTER TABLE TEST ADD CONSTRAINT CON UNIQUE(A,B);
> ok > ok
ALTER TABLE TEST DROP C; ALTER TABLE TEST DROP C;
> ok > ok
ALTER TABLE TEST DROP CONSTRAINT CON; ALTER TABLE TEST DROP CONSTRAINT CON;
> ok > ok
ALTER TABLE TEST DROP B; ALTER TABLE TEST DROP B;
> ok > ok
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
...@@ -396,16 +564,21 @@ select count(d.*) from dual d group by d.x; ...@@ -396,16 +564,21 @@ select count(d.*) from dual d group by d.x;
create table test(id int); create table test(id int);
> ok > ok
select count(*) from (select * from ((select * from test) union (select * from test)) a) b where id = 0; select count(*) from (select * from ((select * from test) union (select * from test)) a) b where id = 0;
>> 0 >> 0
select count(*) from (select * from ((select * from test) union select * from test) a) b where id = 0; select count(*) from (select * from ((select * from test) union select * from test) a) b where id = 0;
>> 0 >> 0
select count(*) from (select * from (select * from test union select * from test) a) b where id = 0; select count(*) from (select * from (select * from test union select * from test) a) b where id = 0;
>> 0 >> 0
select 1 from ((test d1 inner join test d2 on d1.id = d2.id) inner join test d3 on d1.id = d3.id) inner join test d4 on d4.id = d1.id; select 1 from ((test d1 inner join test d2 on d1.id = d2.id) inner join test d3 on d1.id = d3.id) inner join test d4 on d4.id = d1.id;
> 1 > 1
> - > -
> rows: 0 > rows: 0
drop table test; drop table test;
> ok > ok
...@@ -414,50 +587,67 @@ select replace(lpad('string', 10), ' ', '*'); ...@@ -414,50 +587,67 @@ select replace(lpad('string', 10), ' ', '*');
select count(*) from (select * from dual union select * from dual) where x = 0; select count(*) from (select * from dual union select * from dual) where x = 0;
>> 0 >> 0
select count(*) from (select * from (select * from dual union select * from dual)) where x = 0; select count(*) from (select * from (select * from dual union select * from dual)) where x = 0;
>> 0 >> 0
select instr('abcisj','s', -1) from dual; select instr('abcisj','s', -1) from dual;
>> 5 >> 5
CREATE TABLE TEST(ID INT); CREATE TABLE TEST(ID INT);
> ok > ok
INSERT INTO TEST VALUES(1), (2), (3); INSERT INTO TEST VALUES(1), (2), (3);
> update count: 3 > update count: 3
create index idx_desc on test(id desc); create index idx_desc on test(id desc);
> ok > ok
select * from test where id between 0 and 1; select * from test where id between 0 and 1;
>> 1 >> 1
select * from test where id between 3 and 4; select * from test where id between 3 and 4;
>> 3 >> 3
drop table test; drop table test;
> ok > ok
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255)); CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255));
> ok > ok
INSERT INTO TEST VALUES(1, 'Hello'), (2, 'HelloWorld'), (3, 'HelloWorldWorld'); INSERT INTO TEST VALUES(1, 'Hello'), (2, 'HelloWorld'), (3, 'HelloWorldWorld');
> update count: 3 > update count: 3
SELECT COUNT(*) FROM TEST WHERE NAME REGEXP 'World'; SELECT COUNT(*) FROM TEST WHERE NAME REGEXP 'World';
>> 2 >> 2
SELECT NAME FROM TEST WHERE NAME REGEXP 'WorldW'; SELECT NAME FROM TEST WHERE NAME REGEXP 'WorldW';
>> HelloWorldWorld >> HelloWorldWorld
drop table test; drop table test;
> ok > ok
select * from (select x from (select x from dual)) where 1=x; select * from (select x from (select x from dual)) where 1=x;
>> 1 >> 1
CREATE VIEW TEST_VIEW AS SELECT X FROM (SELECT X FROM DUAL); CREATE VIEW TEST_VIEW AS SELECT X FROM (SELECT X FROM DUAL);
> ok > ok
SELECT * FROM TEST_VIEW; SELECT * FROM TEST_VIEW;
>> 1 >> 1
SELECT * FROM TEST_VIEW; SELECT * FROM TEST_VIEW;
>> 1 >> 1
DROP VIEW TEST_VIEW; DROP VIEW TEST_VIEW;
> ok > ok
SELECT X FROM (SELECT X, X AS "XY" FROM DUAL) WHERE X=1; SELECT X FROM (SELECT X, X AS "XY" FROM DUAL) WHERE X=1;
>> 1 >> 1
SELECT X FROM (SELECT X, X AS "X Y" FROM DUAL) WHERE X=1; SELECT X FROM (SELECT X, X AS "X Y" FROM DUAL) WHERE X=1;
>> 1 >> 1
SELECT X FROM (SELECT X, X AS "X Y" FROM DUAL AS "D Z") WHERE X=1; SELECT X FROM (SELECT X, X AS "X Y" FROM DUAL AS "D Z") WHERE X=1;
>> 1 >> 1
...@@ -465,18 +655,25 @@ select * from (select x from dual union select convert(x, int) from dual) where ...@@ -465,18 +655,25 @@ select * from (select x from dual union select convert(x, int) from dual) where
> X > X
> - > -
> rows: 0 > rows: 0
create table test(id int); create table test(id int);
> ok > ok
insert into script.public.test(id) values(1), (2); insert into script.public.test(id) values(1), (2);
> update count: 2 > update count: 2
update test t set t.id=t.id+1; update test t set t.id=t.id+1;
> update count: 2 > update count: 2
update public.test set public.test.id=1; update public.test set public.test.id=1;
> update count: 2 > update count: 2
select count(script.public.test.id) from script.public.test; select count(script.public.test.id) from script.public.test;
>> 2 >> 2
update script.public.test set script.public.test.id=1; update script.public.test set script.public.test.id=1;
> update count: 2 > update count: 2
drop table script.public.test; drop table script.public.test;
> ok > ok
...@@ -485,39 +682,55 @@ select year(timestamp '2007-07-26T18:44:26.109000+02:00'); ...@@ -485,39 +682,55 @@ select year(timestamp '2007-07-26T18:44:26.109000+02:00');
create table test(id int primary key); create table test(id int primary key);
> ok > ok
begin; begin;
> ok > ok
insert into test values(1); insert into test values(1);
> update count: 1 > update count: 1
rollback; rollback;
> ok > ok
insert into test values(2); insert into test values(2);
> update count: 1 > update count: 1
rollback; rollback;
> ok > ok
begin; begin;
> ok > ok
insert into test values(3); insert into test values(3);
> update count: 1 > update count: 1
commit; commit;
> ok > ok
insert into test values(4); insert into test values(4);
> update count: 1 > update count: 1
rollback; rollback;
> ok > ok
select group_concat(id order by id) from test; select group_concat(id order by id) from test;
>> 2,3,4 >> 2,3,4
drop table test; drop table test;
> ok > ok
create table test(); create table test();
> ok > ok
insert into test values(); insert into test values();
> update count: 1 > update count: 1
ALTER TABLE TEST ADD ID INTEGER; ALTER TABLE TEST ADD ID INTEGER;
> ok > ok
select count(*) from test; select count(*) from test;
>> 1 >> 1
drop table test; drop table test;
> ok > ok
...@@ -526,62 +739,85 @@ select * from dual where 'a_z' like '%=_%' escape '='; ...@@ -526,62 +739,85 @@ select * from dual where 'a_z' like '%=_%' escape '=';
create table test as select 1 from dual union all select 2 from dual; create table test as select 1 from dual union all select 2 from dual;
> ok > ok
drop table test; drop table test;
> ok > ok
create table test_table(column_a integer); create table test_table(column_a integer);
> ok > ok
insert into test_table values(1); insert into test_table values(1);
> update count: 1 > update count: 1
create view test_view AS SELECT * FROM (SELECT DISTINCT * FROM test_table) AS subquery; create view test_view AS SELECT * FROM (SELECT DISTINCT * FROM test_table) AS subquery;
> ok > ok
select * FROM test_view; select * FROM test_view;
>> 1 >> 1
drop view test_view; drop view test_view;
> ok > ok
drop table test_table; drop table test_table;
> ok > ok
CREATE TABLE TEST(ID INT); CREATE TABLE TEST(ID INT);
> ok > ok
INSERT INTO TEST VALUES(1); INSERT INTO TEST VALUES(1);
> update count: 1 > update count: 1
CREATE VIEW TEST_VIEW AS SELECT COUNT(ID) X FROM TEST; CREATE VIEW TEST_VIEW AS SELECT COUNT(ID) X FROM TEST;
> ok > ok
explain SELECT * FROM TEST_VIEW WHERE X>1; explain SELECT * FROM TEST_VIEW WHERE X>1;
>> SELECT TEST_VIEW.X FROM PUBLIC.TEST_VIEW /* SELECT COUNT(ID) AS X FROM PUBLIC.TEST /++ PUBLIC.TEST.tableScan ++/ HAVING COUNT(ID) >= ?1: X > 1 */ WHERE X > 1 >> SELECT TEST_VIEW.X FROM PUBLIC.TEST_VIEW /* SELECT COUNT(ID) AS X FROM PUBLIC.TEST /++ PUBLIC.TEST.tableScan ++/ HAVING COUNT(ID) >= ?1: X > 1 */ WHERE X > 1
DROP VIEW TEST_VIEW; DROP VIEW TEST_VIEW;
> ok > ok
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
create table test1(id int); create table test1(id int);
> ok > ok
insert into test1 values(1), (1), (2), (3); insert into test1 values(1), (1), (2), (3);
> update count: 4 > update count: 4
select sum(C0) from (select count(*) AS C0 from (select distinct * from test1) as temp); select sum(C0) from (select count(*) AS C0 from (select distinct * from test1) as temp);
>> 3 >> 3
drop table test1; drop table test1;
> ok > ok
create table test(id int primary key check id>1); create table test(id int primary key check id>1);
> ok > ok
drop table test; drop table test;
> ok > ok
create table table1(f1 int not null primary key); create table table1(f1 int not null primary key);
> ok > ok
create table table2(f2 int not null references table1(f1) on delete cascade); create table table2(f2 int not null references table1(f1) on delete cascade);
> ok > ok
drop table table2; drop table table2;
> ok > ok
drop table table1; drop table table1;
> ok > ok
create table table1(f1 int not null primary key); create table table1(f1 int not null primary key);
> ok > ok
create table table2(f2 int not null primary key references table1(f1)); create table table2(f2 int not null primary key references table1(f1));
> ok > ok
drop table table1; drop table table1;
> ok > ok
drop table table2; drop table table2;
> ok > ok
...@@ -593,403 +829,588 @@ select case (1) when 1 then 1 else 2 end; ...@@ -593,403 +829,588 @@ select case (1) when 1 then 1 else 2 end;
create table test(id int); create table test(id int);
> ok > ok
insert into test values(1); insert into test values(1);
> update count: 1 > update count: 1
select distinct id from test a order by a.id; select distinct id from test a order by a.id;
>> 1 >> 1
drop table test; drop table test;
> ok > ok
create table FOO (ID int, A number(18, 2)); create table FOO (ID int, A number(18, 2));
> ok > ok
insert into FOO (ID, A) values (1, 10.0), (2, 20.0); insert into FOO (ID, A) values (1, 10.0), (2, 20.0);
> update count: 2 > update count: 2
select SUM (CASE when ID=1 then 0 ELSE A END) col0 from Foo; select SUM (CASE when ID=1 then 0 ELSE A END) col0 from Foo;
>> 20.00 >> 20.00
drop table FOO; drop table FOO;
> ok > ok
select (SELECT true)+1 GROUP BY 1; select (SELECT true)+1 GROUP BY 1;
>> 2 >> 2
create table FOO (ID int, A number(18, 2)); create table FOO (ID int, A number(18, 2));
> ok > ok
insert into FOO (ID, A) values (1, 10.0), (2, 20.0); insert into FOO (ID, A) values (1, 10.0), (2, 20.0);
> update count: 2 > update count: 2
select SUM (CASE when ID=1 then A ELSE 0 END) col0 from Foo; select SUM (CASE when ID=1 then A ELSE 0 END) col0 from Foo;
>> 10.00 >> 10.00
drop table FOO; drop table FOO;
> ok > ok
create table A ( ID integer, a1 varchar(20) ); create table A ( ID integer, a1 varchar(20) );
> ok > ok
create table B ( ID integer, AID integer, b1 varchar(20)); create table B ( ID integer, AID integer, b1 varchar(20));
> ok > ok
create table C ( ID integer, BId integer, c1 varchar(20)); create table C ( ID integer, BId integer, c1 varchar(20));
> ok > ok
insert into A (ID, a1) values (1, 'a1'); insert into A (ID, a1) values (1, 'a1');
> update count: 1 > update count: 1
insert into A (ID, a1) values (2, 'a2'); insert into A (ID, a1) values (2, 'a2');
> update count: 1 > update count: 1
select count(*) from A left outer join (B inner join C on C.BID=B.ID ) on B.AID=A.ID where A.id=1; select count(*) from A left outer join (B inner join C on C.BID=B.ID ) on B.AID=A.ID where A.id=1;
>> 1 >> 1
select count(*) from A left outer join (B left join C on C.BID=B.ID ) on B.AID=A.ID where A.id=1; select count(*) from A left outer join (B left join C on C.BID=B.ID ) on B.AID=A.ID where A.id=1;
>> 1 >> 1
select count(*) from A left outer join B on B.AID=A.ID inner join C on C.BID=B.ID where A.id=1; select count(*) from A left outer join B on B.AID=A.ID inner join C on C.BID=B.ID where A.id=1;
>> 0 >> 0
select count(*) from (A left outer join B on B.AID=A.ID) inner join C on C.BID=B.ID where A.id=1; select count(*) from (A left outer join B on B.AID=A.ID) inner join C on C.BID=B.ID where A.id=1;
>> 0 >> 0
drop table a, b, c; drop table a, b, c;
> ok > ok
create schema a; create schema a;
> ok > ok
create table a.test(id int); create table a.test(id int);
> ok > ok
insert into a.test values(1); insert into a.test values(1);
> update count: 1 > update count: 1
create schema b; create schema b;
> ok > ok
create table b.test(id int); create table b.test(id int);
> ok > ok
insert into b.test values(2); insert into b.test values(2);
> update count: 1 > update count: 1
select a.test.id + b.test.id from a.test, b.test; select a.test.id + b.test.id from a.test, b.test;
>> 3 >> 3
drop schema a cascade; drop schema a cascade;
> ok > ok
drop schema b cascade; drop schema b cascade;
> ok > ok
select date '+0011-01-01'; select date '+0011-01-01';
>> 0011-01-01 >> 0011-01-01
select date'-0010-01-01'; select date'-0010-01-01';
>> -10-01-01 >> -10-01-01
create schema TEST_SCHEMA; create schema TEST_SCHEMA;
> ok > ok
create table TEST_SCHEMA.test(id int); create table TEST_SCHEMA.test(id int);
> ok > ok
create sequence TEST_SCHEMA.TEST_SEQ; create sequence TEST_SCHEMA.TEST_SEQ;
> ok > ok
select TEST_SCHEMA.TEST_SEQ.CURRVAL; select TEST_SCHEMA.TEST_SEQ.CURRVAL;
>> 0 >> 0
select TEST_SCHEMA.TEST_SEQ.nextval; select TEST_SCHEMA.TEST_SEQ.nextval;
>> 1 >> 1
drop schema TEST_SCHEMA cascade; drop schema TEST_SCHEMA cascade;
> ok > ok
create table test(id int); create table test(id int);
> ok > ok
create trigger TEST_TRIGGER before insert on test call "org.h2.test.db.TestTriggersConstraints"; create trigger TEST_TRIGGER before insert on test call "org.h2.test.db.TestTriggersConstraints";
> ok > ok
comment on trigger TEST_TRIGGER is 'just testing'; comment on trigger TEST_TRIGGER is 'just testing';
> ok > ok
select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER'; select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
>> just testing >> just testing
@reconnect @reconnect
select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER'; select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGGER';
>> just testing >> just testing
drop trigger TEST_TRIGGER; drop trigger TEST_TRIGGER;
> ok > ok
@reconnect @reconnect
create alias parse_long for "java.lang.Long.parseLong(java.lang.String)"; create alias parse_long for "java.lang.Long.parseLong(java.lang.String)";
> ok > ok
comment on alias parse_long is 'Parse a long with base'; comment on alias parse_long is 'Parse a long with base';
> ok > ok
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG'; select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
>> Parse a long with base >> Parse a long with base
@reconnect @reconnect
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG'; select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
>> Parse a long with base >> Parse a long with base
drop alias parse_long; drop alias parse_long;
> ok > ok
@reconnect @reconnect
create role hr; create role hr;
> ok > ok
comment on role hr is 'Human Resources'; comment on role hr is 'Human Resources';
> ok > ok
select remarks from information_schema.roles where name = 'HR'; select remarks from information_schema.roles where name = 'HR';
>> Human Resources >> Human Resources
@reconnect @reconnect
select remarks from information_schema.roles where name = 'HR'; select remarks from information_schema.roles where name = 'HR';
>> Human Resources >> Human Resources
create user abc password 'x'; create user abc password 'x';
> ok > ok
grant hr to abc; grant hr to abc;
> ok > ok
drop role hr; drop role hr;
> ok > ok
@reconnect @reconnect
drop user abc; drop user abc;
> ok > ok
create domain email as varchar(100) check instr(value, '@') > 0; create domain email as varchar(100) check instr(value, '@') > 0;
> ok > ok
comment on domain email is 'must contain @'; comment on domain email is 'must contain @';
> ok > ok
select remarks from information_schema.domains where domain_name = 'EMAIL'; select remarks from information_schema.domains where domain_name = 'EMAIL';
>> must contain @ >> must contain @
@reconnect @reconnect
select remarks from information_schema.domains where domain_name = 'EMAIL'; select remarks from information_schema.domains where domain_name = 'EMAIL';
>> must contain @ >> must contain @
drop domain email; drop domain email;
> ok > ok
@reconnect @reconnect
create schema tests; create schema tests;
> ok > ok
set schema tests; set schema tests;
> ok > ok
create sequence walk; create sequence walk;
> ok > ok
comment on schema tests is 'Test Schema'; comment on schema tests is 'Test Schema';
> ok > ok
comment on sequence walk is 'Walker'; comment on sequence walk is 'Walker';
> ok > ok
select remarks from information_schema.schemata where schema_name = 'TESTS'; select remarks from information_schema.schemata where schema_name = 'TESTS';
>> Test Schema >> Test Schema
select remarks from information_schema.sequences where sequence_name = 'WALK'; select remarks from information_schema.sequences where sequence_name = 'WALK';
>> Walker >> Walker
@reconnect @reconnect
select remarks from information_schema.schemata where schema_name = 'TESTS'; select remarks from information_schema.schemata where schema_name = 'TESTS';
>> Test Schema >> Test Schema
select remarks from information_schema.sequences where sequence_name = 'WALK'; select remarks from information_schema.sequences where sequence_name = 'WALK';
>> Walker >> Walker
drop schema tests cascade; drop schema tests cascade;
> ok > ok
@reconnect @reconnect
create constant abc value 1; create constant abc value 1;
> ok > ok
comment on constant abc is 'One'; comment on constant abc is 'One';
> ok > ok
select remarks from information_schema.constants where constant_name = 'ABC'; select remarks from information_schema.constants where constant_name = 'ABC';
>> One >> One
@reconnect @reconnect
select remarks from information_schema.constants where constant_name = 'ABC'; select remarks from information_schema.constants where constant_name = 'ABC';
>> One >> One
drop constant abc; drop constant abc;
> ok > ok
drop table test; drop table test;
> ok > ok
@reconnect @reconnect
create table test(id int); create table test(id int);
> ok > ok
alter table test add constraint const1 unique(id); alter table test add constraint const1 unique(id);
> ok > ok
create index IDX_ID on test(id); create index IDX_ID on test(id);
> ok > ok
comment on constraint const1 is 'unique id'; comment on constraint const1 is 'unique id';
> ok > ok
comment on index IDX_ID is 'id_index'; comment on index IDX_ID is 'id_index';
> ok > ok
select remarks from information_schema.constraints where constraint_name = 'CONST1'; select remarks from information_schema.constraints where constraint_name = 'CONST1';
>> unique id >> unique id
select remarks from information_schema.indexes where index_name = 'IDX_ID'; select remarks from information_schema.indexes where index_name = 'IDX_ID';
>> id_index >> id_index
@reconnect @reconnect
select remarks from information_schema.constraints where constraint_name = 'CONST1'; select remarks from information_schema.constraints where constraint_name = 'CONST1';
>> unique id >> unique id
select remarks from information_schema.indexes where index_name = 'IDX_ID'; select remarks from information_schema.indexes where index_name = 'IDX_ID';
>> id_index >> id_index
drop table test; drop table test;
> ok > ok
@reconnect @reconnect
create user sales password '1'; create user sales password '1';
> ok > ok
comment on user sales is 'mr. money'; comment on user sales is 'mr. money';
> ok > ok
select remarks from information_schema.users where name = 'SALES'; select remarks from information_schema.users where name = 'SALES';
>> mr. money >> mr. money
@reconnect @reconnect
select remarks from information_schema.users where name = 'SALES'; select remarks from information_schema.users where name = 'SALES';
>> mr. money >> mr. money
alter user sales rename to SALES_USER; alter user sales rename to SALES_USER;
> ok > ok
select remarks from information_schema.users where name = 'SALES_USER'; select remarks from information_schema.users where name = 'SALES_USER';
>> mr. money >> mr. money
@reconnect @reconnect
select remarks from information_schema.users where name = 'SALES_USER'; select remarks from information_schema.users where name = 'SALES_USER';
>> mr. money >> mr. money
create table test(id int); create table test(id int);
> ok > ok
create linked table test_link('org.h2.Driver', 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL'); create linked table test_link('org.h2.Driver', 'jdbc:h2:mem:', 'sa', 'sa', 'DUAL');
> ok > ok
comment on table test_link is '123'; comment on table test_link is '123';
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST_LINK'; select remarks from information_schema.tables where table_name = 'TEST_LINK';
>> 123 >> 123
@reconnect @reconnect
select remarks from information_schema.tables where table_name = 'TEST_LINK'; select remarks from information_schema.tables where table_name = 'TEST_LINK';
>> 123 >> 123
comment on table test_link is 'xyz'; comment on table test_link is 'xyz';
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST_LINK'; select remarks from information_schema.tables where table_name = 'TEST_LINK';
>> xyz >> xyz
alter table test_link rename to test_l; alter table test_link rename to test_l;
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST_L'; select remarks from information_schema.tables where table_name = 'TEST_L';
>> xyz >> xyz
@reconnect @reconnect
select remarks from information_schema.tables where table_name = 'TEST_L'; select remarks from information_schema.tables where table_name = 'TEST_L';
>> xyz >> xyz
drop table test; drop table test;
> ok > ok
@reconnect @reconnect
create table test(id int); create table test(id int);
> ok > ok
create view test_v as select * from test; create view test_v as select * from test;
> ok > ok
comment on table test_v is 'abc'; comment on table test_v is 'abc';
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST_V'; select remarks from information_schema.tables where table_name = 'TEST_V';
>> abc >> abc
@reconnect @reconnect
select remarks from information_schema.tables where table_name = 'TEST_V'; select remarks from information_schema.tables where table_name = 'TEST_V';
>> abc >> abc
alter table test_v rename to TEST_VIEW; alter table test_v rename to TEST_VIEW;
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST_VIEW'; select remarks from information_schema.tables where table_name = 'TEST_VIEW';
>> abc >> abc
@reconnect @reconnect
select remarks from information_schema.tables where table_name = 'TEST_VIEW'; select remarks from information_schema.tables where table_name = 'TEST_VIEW';
>> abc >> abc
drop table test cascade; drop table test cascade;
> ok > ok
@reconnect @reconnect
create table test(a int); create table test(a int);
> ok > ok
comment on table test is 'hi'; comment on table test is 'hi';
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST'; select remarks from information_schema.tables where table_name = 'TEST';
>> hi >> hi
alter table test add column b int; alter table test add column b int;
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST'; select remarks from information_schema.tables where table_name = 'TEST';
>> hi >> hi
alter table test rename to test1; alter table test rename to test1;
> ok > ok
select remarks from information_schema.tables where table_name = 'TEST1'; select remarks from information_schema.tables where table_name = 'TEST1';
>> hi >> hi
@reconnect @reconnect
select remarks from information_schema.tables where table_name = 'TEST1'; select remarks from information_schema.tables where table_name = 'TEST1';
>> hi >> hi
comment on table test1 is 'ho'; comment on table test1 is 'ho';
> ok > ok
@reconnect @reconnect
select remarks from information_schema.tables where table_name = 'TEST1'; select remarks from information_schema.tables where table_name = 'TEST1';
>> ho >> ho
drop table test1; drop table test1;
> ok > ok
create table test(a int, b int); create table test(a int, b int);
> ok > ok
comment on column test.b is 'test'; comment on column test.b is 'test';
> ok > ok
select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'B'; select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'B';
>> test >> test
@reconnect @reconnect
select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'B'; select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'B';
>> test >> test
alter table test drop column b; alter table test drop column b;
> ok > ok
@reconnect @reconnect
comment on column test.a is 'ho'; comment on column test.a is 'ho';
> ok > ok
select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'A'; select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'A';
>> ho >> ho
@reconnect @reconnect
select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'A'; select remarks from information_schema.columns where table_name = 'TEST' and column_name = 'A';
>> ho >> ho
drop table test; drop table test;
> ok > ok
@reconnect @reconnect
create table test(a int); create table test(a int);
> ok > ok
comment on column test.a is 'test'; comment on column test.a is 'test';
> ok > ok
alter table test rename to test2; alter table test rename to test2;
> ok > ok
@reconnect @reconnect
select remarks from information_schema.columns where table_name = 'TEST2'; select remarks from information_schema.columns where table_name = 'TEST2';
>> test >> test
@reconnect @reconnect
select remarks from information_schema.columns where table_name = 'TEST2'; select remarks from information_schema.columns where table_name = 'TEST2';
>> test >> test
drop table test2; drop table test2;
> ok > ok
@reconnect @reconnect
create table test1 (a varchar(10)); create table test1 (a varchar(10));
> ok > ok
create hash index x1 on test1(a); create hash index x1 on test1(a);
> ok > ok
insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd'); insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd');
> update count: 4 > update count: 4
insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd'); insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd');
> update count: 4 > update count: 4
insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd'); insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd');
> update count: 4 > update count: 4
insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd'); insert into test1 values ('abcaaaa'),('abcbbbb'),('abccccc'),('abcdddd');
> update count: 4 > update count: 4
select count(*) from test1 where a='abcaaaa'; select count(*) from test1 where a='abcaaaa';
>> 4 >> 4
select count(*) from test1 where a='abcbbbb'; select count(*) from test1 where a='abcbbbb';
>> 4 >> 4
@reconnect @reconnect
select count(*) from test1 where a='abccccc'; select count(*) from test1 where a='abccccc';
>> 4 >> 4
select count(*) from test1 where a='abcdddd'; select count(*) from test1 where a='abcdddd';
>> 4 >> 4
update test1 set a='abccccc' where a='abcdddd'; update test1 set a='abccccc' where a='abcdddd';
> update count: 4 > update count: 4
select count(*) from test1 where a='abccccc'; select count(*) from test1 where a='abccccc';
>> 8 >> 8
select count(*) from test1 where a='abcdddd'; select count(*) from test1 where a='abcdddd';
>> 0 >> 0
delete from test1 where a='abccccc'; delete from test1 where a='abccccc';
> update count: 8 > update count: 8
select count(*) from test1 where a='abccccc'; select count(*) from test1 where a='abccccc';
>> 0 >> 0
truncate table test1; truncate table test1;
> ok > ok
insert into test1 values ('abcaaaa'); insert into test1 values ('abcaaaa');
> update count: 1 > update count: 1
insert into test1 values ('abcaaaa'); insert into test1 values ('abcaaaa');
> update count: 1 > update count: 1
delete from test1; delete from test1;
> update count: 2 > update count: 2
drop table test1; drop table test1;
> ok > ok
@reconnect @reconnect
drop table if exists test; drop table if exists test;
> ok > ok
create table if not exists test(col1 int primary key); create table if not exists test(col1 int primary key);
> ok > ok
insert into test values(1); insert into test values(1);
> update count: 1 > update count: 1
insert into test values(2); insert into test values(2);
> update count: 1 > update count: 1
insert into test values(3); insert into test values(3);
> update count: 1 > update count: 1
select count(*) from test; select count(*) from test;
>> 3 >> 3
select max(col1) from test; select max(col1) from test;
>> 3 >> 3
update test set col1 = col1 + 1 order by col1 asc limit 100; update test set col1 = col1 + 1 order by col1 asc limit 100;
> update count: 3 > update count: 3
select count(*) from test; select count(*) from test;
>> 3 >> 3
select max(col1) from test; select max(col1) from test;
>> 4 >> 4
drop table if exists test; drop table if exists test;
> ok > ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论