提交 dc35938e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix newlines in test scripts

上级 58a8b8bf
...@@ -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
...@@ -28,4 +28,4 @@ select len(null) en, len('MSSQLServer uses the len keyword') e_32 from test; ...@@ -28,4 +28,4 @@ select len(null) en, len('MSSQLServer uses the len keyword') e_32 from test;
> rows: 1 > rows: 1
SET MODE Regular; SET MODE Regular;
> ok > ok
\ No newline at end of file
...@@ -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
> ---- ---- ---- ---- > ---- ---- ---- ----
......
...@@ -25,4 +25,4 @@ SELECT CURRENT_DATE = GETDATE(); ...@@ -25,4 +25,4 @@ SELECT CURRENT_DATE = GETDATE();
>> TRUE >> TRUE
SET MODE Regular; SET MODE Regular;
> ok > ok
\ No newline at end of file
...@@ -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
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论