提交 236daa35 authored 作者: Noel Grandin's avatar Noel Grandin

Improve the script-based unit testing to check the error code of the exception thrown.

上级 7db8f19e
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Improve the script-based unit testing to check the error code of the exception thrown.
</li>
<li>Issue #1003: Decrypting database with incorrect password renders the database corrupt
</li>
<li>Issue #873: No error when `=` in equal condition when column is not of array type
......
......@@ -11,6 +11,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -18,7 +20,10 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.h2.api.ErrorCode;
import org.h2.engine.SysProperties;
import org.h2.test.TestAll;
import org.h2.test.TestBase;
......@@ -454,16 +459,30 @@ public class TestScript extends TestBase {
return buff.toString();
}
private void writeException(String sql, SQLException e) throws Exception {
writeResult(sql, "exception", e);
/** Convert the error code to a symbolic name from ErrorCode. */
private static final Map<Integer, String> ERROR_CODE_TO_NAME = new HashMap<>();
static {
try {
for (Field field : ErrorCode.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())) {
ERROR_CODE_TO_NAME.put(field.getInt(null), field.getName());
}
}
} catch (IllegalAccessException ex) {
throw new RuntimeException(ex);
}
}
private void writeException(String sql, SQLException ex) throws Exception {
writeResult(sql, "exception " + ERROR_CODE_TO_NAME.get(ex.getErrorCode()), ex);
}
private void writeResult(String sql, String s, SQLException e) throws Exception {
writeResult(sql, s, e, "> ");
private void writeResult(String sql, String s, SQLException ex) throws Exception {
writeResult(sql, s, ex, "> ");
}
private void writeResult(String sql, String s, SQLException e, String prefix) throws Exception {
assertKnownException(sql, e);
private void writeResult(String sql, String s, SQLException ex, String prefix) throws Exception {
assertKnownException(sql, ex);
s = (prefix + s).trim();
String compare = readLine();
if (compare != null && compare.startsWith(">")) {
......@@ -472,11 +491,11 @@ public class TestScript extends TestBase {
return;
}
errors.append(fileName).append('\n');
errors.append("line: ").append(outputLineNo).append('\n');
errors.append("line: ").append(in.getLineNumber()).append('\n');
errors.append("exp: ").append(compare).append('\n');
errors.append("got: ").append(s).append('\n');
if (e != null) {
TestBase.logError("script", e);
if (ex != null) {
TestBase.logError("script", ex);
}
TestBase.logErrorMessage(errors.toString());
if (failFast) {
......
......@@ -7,7 +7,7 @@ CREATE MEMORY TABLE TEST(D1 DOUBLE, D2 DOUBLE PRECISION, D3 FLOAT, D4 FLOAT(25),
> ok
ALTER TABLE TEST ADD COLUMN D6 FLOAT(54);
> exception
> exception INVALID_VALUE_SCALE_PRECISION
SELECT COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TEST' ORDER BY ORDINAL_POSITION;
......
......@@ -73,13 +73,13 @@ select * from card where rank = 5;
--- ENUM edge cases
insert into card (rank, suit) values(6, ' ');
> exception
> exception ENUM_VALUE_NOT_PERMITTED
alter table card alter column suit enum('hearts', 'clubs', 'spades', 'diamonds', 'clubs');
> exception
> exception ENUM_DUPLICATE
alter table card alter column suit enum('hearts', 'clubs', 'spades', 'diamonds', '');
> exception
> exception ENUM_EMPTY
drop table card;
> ok
......@@ -118,7 +118,7 @@ insert into card (rank, suit) values (0, 'clubs'), (3, 'hearts'), (1, 'clubs');
> update count: 3
insert into card (rank, suit) values (0, 'clubs');
> exception
> exception DUPLICATE_KEY_1
select rank from card where suit = 'clubs';
> RANK
......
......@@ -7,7 +7,7 @@ CREATE MEMORY TABLE TEST(D1 REAL, D2 FLOAT4, D3 FLOAT(0), D4 FLOAT(24));
> ok
ALTER TABLE TEST ADD COLUMN D5 FLOAT(-1);
> exception
> exception INVALID_VALUE_2
SELECT COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TEST' ORDER BY ORDINAL_POSITION;
......
......@@ -37,7 +37,7 @@ SELECT COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_TYPE, NUMERIC_SCALE FROM INFORM
> rows (ordered): 4
ALTER TABLE TEST ADD T5 TIME(10);
> exception
> exception INVALID_VALUE_SCALE_PRECISION
DROP TABLE TEST;
> ok
......
......@@ -49,7 +49,7 @@ SELECT COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_TYPE, NUMERIC_SCALE FROM INFORM
> rows (ordered): 3
ALTER TABLE TEST ADD T4 TIMESTAMP (10) WITH TIME ZONE;
> exception
> exception INVALID_VALUE_SCALE_PRECISION
DROP TABLE TEST;
> ok
......
......@@ -34,13 +34,13 @@ SELECT COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_TYPE, NUMERIC_SCALE FROM INFORM
> rows (ordered): 8
ALTER TABLE TEST ADD T5 TIMESTAMP(10);
> exception
> exception INVALID_VALUE_SCALE_PRECISION
ALTER TABLE TEST ADD DT4 DATETIME(10);
> exception
> exception INVALID_VALUE_SCALE_PRECISION
ALTER TABLE TEST ADD STD2 SMALLDATETIME(1);
> exception
> exception SYNTAX_ERROR_1
DROP TABLE TEST;
> ok
......
......@@ -52,7 +52,7 @@ CREATE TABLE TEST(A INT NOT NULL, B INT);
-- column B may be null
ALTER TABLE TEST ADD (CONSTRAINT PK_B PRIMARY KEY (B));
> exception
> exception COLUMN_MUST_NOT_BE_NULLABLE_1
ALTER TABLE TEST ADD (CONSTRAINT PK_A PRIMARY KEY (A));
> ok
......@@ -70,16 +70,16 @@ SELECT * FROM TEST;
> rows: 1
INSERT INTO TEST VALUES (11, 20, 30, 40);
> exception
> exception DUPLICATE_KEY_1
INSERT INTO TEST VALUES (10, 12, 30, 40);
> exception
> exception DUPLICATE_KEY_1
INSERT INTO TEST VALUES (10, 20, 1, 40);
> exception
> exception DUPLICATE_KEY_1
INSERT INTO TEST VALUES (10, 20, 30, 14);
> exception
> exception DUPLICATE_KEY_1
INSERT INTO TEST VALUES (10, 20, 30, 40);
> update count: 1
......
......@@ -16,7 +16,7 @@ ALTER TABLE IF EXISTS TEST DROP COLUMN A;
> ok
ALTER TABLE TEST DROP COLUMN A;
> exception
> exception TABLE_OR_VIEW_NOT_FOUND_1
CREATE TABLE TEST(A INT, B INT, C INT, D INT, E INT, F INT, G INT, H INT, I INT, J INT);
> ok
......@@ -25,7 +25,7 @@ ALTER TABLE TEST DROP COLUMN IF EXISTS J;
> ok
ALTER TABLE TEST DROP COLUMN J;
> exception
> exception COLUMN_NOT_FOUND_1
ALTER TABLE TEST DROP COLUMN B;
> ok
......@@ -39,7 +39,7 @@ SELECT * FROM TEST;
> rows: 0
ALTER TABLE TEST DROP COLUMN B, D;
> exception
> exception COLUMN_NOT_FOUND_1
ALTER TABLE TEST DROP COLUMN IF EXISTS B, D;
> ok
......@@ -58,7 +58,7 @@ SELECT * FROM TEST;
> rows: 0
ALTER TABLE TEST DROP COLUMN (B, H);
> exception
> exception COLUMN_NOT_FOUND_1
ALTER TABLE TEST DROP COLUMN IF EXISTS (B, H);
> ok
......
......@@ -4,13 +4,13 @@
--
create alias "SYSDATE" for "java.lang.Integer.parseInt(java.lang.String)";
> exception
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
create alias "MIN" for "java.lang.Integer.parseInt(java.lang.String)";
> exception
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
create alias "CAST" for "java.lang.Integer.parseInt(java.lang.String)";
> exception
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
--- function alias ---------------------------------------------------------------------------------------------
CREATE ALIAS MY_SQRT FOR "java.lang.Math.sqrt";
......@@ -54,13 +54,13 @@ CREATE SCHEMA TEST_SCHEMA;
> ok
CREATE ALIAS TRUNC FOR "java.lang.Math.floor(double)";
> exception
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
CREATE ALIAS PUBLIC.TRUNC FOR "java.lang.Math.floor(double)";
> exception
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
CREATE ALIAS TEST_SCHEMA.TRUNC FOR "java.lang.Math.round(double)";
> exception
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
SET BUILTIN_ALIAS_OVERRIDE=1;
> ok
......
......@@ -16,7 +16,7 @@ CREATE TABLE TEST_SCHEMA.TEST();
> ok
DROP SCHEMA TEST_SCHEMA RESTRICT;
> exception
> exception CANNOT_DROP_2
DROP SCHEMA TEST_SCHEMA CASCADE;
> ok
......@@ -28,7 +28,7 @@ CREATE VIEW TEST_SCHEMA.TEST AS SELECT 1;
> ok
DROP SCHEMA TEST_SCHEMA RESTRICT;
> exception
> exception CANNOT_DROP_2
DROP SCHEMA TEST_SCHEMA CASCADE;
> ok
......@@ -43,7 +43,7 @@ CREATE SYNONYM TEST_SCHEMA.TEST FOR PUBLIC.SRC;
> ok
DROP SCHEMA TEST_SCHEMA RESTRICT;
> exception
> exception CANNOT_DROP_2
DROP SCHEMA TEST_SCHEMA CASCADE;
> ok
......@@ -58,7 +58,7 @@ CREATE SEQUENCE TEST_SCHEMA.TEST;
> ok
DROP SCHEMA TEST_SCHEMA RESTRICT;
> exception
> exception CANNOT_DROP_2
DROP SCHEMA TEST_SCHEMA CASCADE;
> ok
......@@ -70,7 +70,7 @@ CREATE CONSTANT TEST_SCHEMA.TEST VALUE 1;
> ok
DROP SCHEMA TEST_SCHEMA RESTRICT;
> exception
> exception CANNOT_DROP_2
DROP SCHEMA TEST_SCHEMA CASCADE;
> ok
......@@ -82,7 +82,7 @@ CREATE ALIAS TEST_SCHEMA.TEST FOR "java.lang.System.currentTimeMillis";
> ok
DROP SCHEMA TEST_SCHEMA RESTRICT;
> exception
> exception CANNOT_DROP_2
DROP SCHEMA TEST_SCHEMA CASCADE;
> ok
......@@ -34,16 +34,16 @@ SELECT A AS A1, B AS B1 FROM (VALUES(1, 2)) AS T(A, B) WHERE A <> B;
> rows: 1
SELECT A AS A1, B AS B1 FROM (VALUES(1, 2)) AS T(A, B) WHERE A1 <> B1;
> exception
> exception COLUMN_NOT_FOUND_1
SELECT * FROM (VALUES(1, 2)) AS T(A);
> exception
> exception COLUMN_COUNT_DOES_NOT_MATCH
SELECT * FROM (VALUES(1, 2)) AS T(A, a);
> exception
> exception DUPLICATE_COLUMN_NAME_1
SELECT * FROM (VALUES(1, 2)) AS T(A, B, C);
> exception
> exception COLUMN_COUNT_DOES_NOT_MATCH
SELECT V AS V1, A AS A1, B AS B1 FROM (VALUES (1)) T1(V) INNER JOIN (VALUES(1, 2)) T2(A, B) ON V = A;
> V1 A1 B1
......
......@@ -7,7 +7,7 @@ CREATE TABLE test (id INT NOT NULL, name VARCHAR);
> ok
select * from test where id = (1, 2);
> exception
> exception COMPARING_ARRAY_TO_SCALAR
drop table test;
> ok
\ No newline at end of file
......@@ -13,7 +13,7 @@ INSERT INTO TEST VALUES (1, 10), (2, 20), (3, 30), (4, 40);
> update count: 4
INSERT INTO TEST VALUES (3, 31), (5, 51);
> exception
> exception DUPLICATE_KEY_1
SELECT * FROM TEST ORDER BY ID;
> ID VALUE
......
......@@ -4,7 +4,7 @@
--
call hash('SHA256', 'Hello', 0);
> exception
> exception INVALID_VALUE_2
call hash('SHA256', 'Hello');
>> 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
......@@ -22,4 +22,4 @@ CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000);
>> c644a176ce920bde361ac336089b06cc2f1514dfa95ba5aabfe33f9a22d577f0
call hash('unknown', 'Hello', 1);
> exception
> exception INVALID_VALUE_2
......@@ -16,7 +16,7 @@ SELECT ORA_HASH(1);
>> 3509391659
SELECT ORA_HASH(1, -1);
> exception
> exception INVALID_VALUE_2
SELECT ORA_HASH(1, 0);
>> 0
......@@ -28,7 +28,7 @@ SELECT ORA_HASH(1, 4294967296)
> exception
SELECT ORA_HASH(1, 4294967295, -1);
> exception
> exception SYNTAX_ERROR_1
SELECT ORA_HASH(1, 4294967295, 0);
>> 3509391659
......@@ -40,7 +40,7 @@ SELECT ORA_HASH(1, 4294967295, 4294967295);
>> 3501171530
SELECT ORA_HASH(1, 4294967295, 4294967296);
> exception
> exception INVALID_VALUE_2
CREATE TABLE TEST(I BINARY, B BLOB, S VARCHAR, C CLOB);
> ok
......
......@@ -4,7 +4,7 @@
--
call regexp_replace('x', 'x', '\');
> exception
> exception LIKE_ESCAPE_ERROR_1
CALL REGEXP_REPLACE('abckaboooom', 'o+', 'o');
>> abckabom
......
......@@ -4,7 +4,7 @@
--
call select 1 from dual where regexp_like('x', 'x', '\');
> exception
> exception INVALID_VALUE_2
select x from dual where REGEXP_LIKE('A', '[a-z]', 'i');
>> 1
......
......@@ -89,7 +89,7 @@ select cast(cast('01020304-0506-0708-090a-0b0c0d0e0f00' as uuid) as binary);
>> 0102030405060708090a0b0c0d0e0f00
call cast('null' as uuid);
> exception
> exception DATA_CONVERSION_ERROR_1
select cast('12345678123456781234567812345678' as uuid);
>> 12345678-1234-5678-1234-567812345678
......
......@@ -1063,14 +1063,14 @@ SELECT DATE_TRUNC('MILLENNIUM', '2000-05-29 15:14:13');
-- Test unhandled time unit and bad date
--
SELECT DATE_TRUNC('---', '2015-05-29 15:14:13');
> exception
> exception INVALID_VALUE_2
SELECT DATE_TRUNC('', '2015-05-29 15:14:13');
> exception
> exception INVALID_VALUE_2
SELECT DATE_TRUNC('', '');
> exception
> exception INVALID_VALUE_2
SELECT DATE_TRUNC('YEAR', '');
> exception
> exception INVALID_DATETIME_CONSTANT_2
......@@ -88,7 +88,7 @@ SELECT DATEADD('MINUTE', 30, TIME '12:30:55');
>> 13:00:55
SELECT DATEADD('DAY', 1, TIME '12:30:55');
> exception
> exception INVALID_VALUE_2
SELECT DATEADD('QUARTER', 1, DATE '2010-11-16');
>> 2011-02-16
......
......@@ -84,7 +84,7 @@ INSERT INTO PARENT VALUES(1);
> update count: 1
SELECT * FROM PARENT P LEFT OUTER JOIN CHILD C ON C.PARENTID=P.ID;
> exception
> exception COLUMN_NOT_FOUND_1
DROP TABLE PARENT, CHILD;
> ok
......@@ -380,7 +380,7 @@ select * from left_hand left join right_hand on left_hand.id=right_hand.id where
-- h2: 0 (2 cols); postgresql: 0 (1 col), mysql: exception; derby, hsqldb: no natural join
select * from left_hand natural join right_hand where left_hand.id=1 having right_hand.id=2;
> exception
> exception MUST_GROUP_BY_COLUMN_1
-- h2, mysql, hsqldb: 0 rows; postgresql, derby: exception
select * from left_hand left outer join right_hand on left_hand.id=right_hand.id where left_hand.id=1 group by left_hand.id having right_hand.id=2;
......
......@@ -182,16 +182,16 @@ SELECT COUNT(*) FROM SYSTEM_RANGE(2, 1, 2);
>> 0
SELECT * FROM SYSTEM_RANGE(1, 2, 0);
> exception
> exception STEP_SIZE_MUST_NOT_BE_ZERO
SELECT COUNT(*) FROM SYSTEM_RANGE(1, 2, 0);
> exception
> exception STEP_SIZE_MUST_NOT_BE_ZERO
SELECT * FROM SYSTEM_RANGE(2, 1, 0);
> exception
> exception STEP_SIZE_MUST_NOT_BE_ZERO
SELECT COUNT(*) FROM SYSTEM_RANGE(2, 1, 0);
> exception
> exception STEP_SIZE_MUST_NOT_BE_ZERO
SELECT * FROM SYSTEM_RANGE(1, 8, 2);
> X
......
......@@ -213,7 +213,7 @@ insert into test values (2, null);
> update count: 1
update test set pid = 1 where id = 2;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
drop table test;
> ok
......@@ -222,7 +222,7 @@ create table test(name varchar(255));
> ok
select * from test union select * from test order by test.name;
> exception
> exception ORDER_BY_NOT_IN_RESULT
insert into test values('a'), ('b'), ('c');
> update count: 3
......@@ -305,7 +305,7 @@ drop table test;
> ok
select x from dual order by y.x;
> exception
> exception COLUMN_NOT_FOUND_1
create table test(id int primary key, name varchar(255), row_number int);
> ok
......@@ -361,7 +361,7 @@ drop table test;
> ok
select 2^2;
> exception
> exception SYNTAX_ERROR_1
select * from dual where x in (select x from dual group by x order by max(x));
> X
......@@ -370,7 +370,7 @@ select * from dual where x in (select x from dual group by x order by max(x));
> rows (ordered): 1
create table test(d decimal(1, 2));
> exception
> exception INVALID_VALUE_SCALE_PRECISION
call truncate_value('Test 123', 4, false);
> 'Test'
......@@ -379,7 +379,7 @@ call truncate_value('Test 123', 4, false);
> rows: 1
call truncate_value(1234567890.123456789, 4, false);
> exception
> exception NUMERIC_VALUE_OUT_OF_RANGE_1
call truncate_value(1234567890.123456789, 4, true);
> 1234567890.1234567
......@@ -501,7 +501,7 @@ create table test(id x);
> ok
insert into test values(null);
> exception
> exception NULL_NOT_ALLOWED
drop table test;
> ok
......@@ -587,7 +587,7 @@ create view x as select * from test;
> ok
drop table test restrict;
> exception
> exception CANNOT_DROP_2
drop table test cascade;
> ok
......@@ -631,7 +631,7 @@ delete from a where x = 0 and y is null;
> update count: 1
delete from a where x = 0 and y = 0;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1
drop table b;
> ok
......@@ -648,7 +648,7 @@ create table test(a int primary key, b int references(a));
> ok
merge into test values(1, 2);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
drop table test;
> ok
......@@ -825,13 +825,13 @@ create table test(id identity);
> ok
set password test;
> exception
> exception COLUMN_NOT_FOUND_1
alter user sa set password test;
> exception
> exception COLUMN_NOT_FOUND_1
comment on table test is test;
> exception
> exception COLUMN_NOT_FOUND_1
select 1 from test a where 1 in(select 1 from test b where b.id in(select 1 from test c where c.id=a.id));
> 1
......@@ -851,7 +851,7 @@ select @n := case when x = 1 then 1 else @n * x end f from system_range(1, 4);
> rows: 4
select * from (select "x" from dual);
> exception
> exception COLUMN_NOT_FOUND_1
select * from(select 1 from system_range(1, 2) group by sin(x) order by sin(x));
> 1
......@@ -867,13 +867,13 @@ create table child(id int references parent(id)) as select 1;
> ok
delete from parent;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1
drop table parent, child;
> ok
create domain integer as varchar;
> exception
> exception USER_DATA_TYPE_ALREADY_EXISTS_1
create domain int as varchar;
> ok
......@@ -903,13 +903,13 @@ insert into test values(0, 0), (1, NULL), (2, 1), (3, 3), (4, 3);
> update count: 5
delete from test where id = 3;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1
delete from test where id = 0;
> update count: 1
delete from test where id = 1;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1
drop table test;
> ok
......@@ -986,13 +986,13 @@ select 1 as id, id as b, count(*) from test group by id;
> rows: 2
select id+1 as x, count(*) from test group by -x;
> exception
> exception COLUMN_NOT_FOUND_1
select id+1 as x, count(*) from test group by x having x>2;
> exception
> exception MUST_GROUP_BY_COLUMN_1
select id+1 as x, count(*) from test group by 1;
> exception
> exception MUST_GROUP_BY_COLUMN_1
drop table test;
> ok
......@@ -1141,7 +1141,7 @@ CREATE ROLE TEST_A;
> ok
GRANT TEST_A TO TEST_A;
> exception
> exception ROLE_ALREADY_GRANTED_1
CREATE ROLE TEST_B;
> ok
......@@ -1150,7 +1150,7 @@ GRANT TEST_A TO TEST_B;
> ok
GRANT TEST_B TO TEST_A;
> exception
> exception ROLE_ALREADY_GRANTED_1
DROP ROLE TEST_A;
> ok
......@@ -1194,7 +1194,7 @@ drop table test;
> ok
alter table information_schema.help rename to information_schema.help2;
> exception
> exception FEATURE_NOT_SUPPORTED_1
help abc;
> ID SECTION TOPIC SYNTAX TEXT
......@@ -1359,7 +1359,7 @@ CREATE ROLE X;
> ok
GRANT X TO X;
> exception
> exception ROLE_ALREADY_GRANTED_1
CREATE ROLE Y;
> ok
......@@ -1374,7 +1374,7 @@ DROP ROLE X;
> ok
select top sum(1) 0 from dual;
> exception
> exception SYNTAX_ERROR_1
create table test(id int primary key, name varchar) as select 1, 'Hello World';
> ok
......@@ -1389,7 +1389,7 @@ drop table test;
> ok
select rtrim() from dual;
> exception
> exception INVALID_PARAMETER_COUNT_2
CREATE TABLE COUNT(X INT);
> ok
......@@ -1398,7 +1398,7 @@ CREATE FORCE TRIGGER T_COUNT BEFORE INSERT ON COUNT CALL "com.Unknown";
> ok
INSERT INTO COUNT VALUES(NULL);
> exception
> exception ERROR_CREATING_TRIGGER_OBJECT_3
DROP TRIGGER T_COUNT;
> ok
......@@ -1410,7 +1410,7 @@ insert into items values(DEFAULT);
> update count: 1
DROP TABLE COUNT;
> exception
> exception CANNOT_DROP_2
insert into items values(DEFAULT);
> update count: 1
......@@ -1435,13 +1435,13 @@ DROP TABLE TEST;
> ok
call 'a' regexp 'Ho.*\';
> exception
> exception LIKE_ESCAPE_ERROR_1
set @t = 0;
> ok
call set(1, 2);
> exception
> exception CAN_ONLY_ASSIGN_TO_VARIABLE_1
select x, set(@t, ifnull(@t, 0) + x) from system_range(1, 3);
> X SET(@T, (IFNULL(@T, 0) + X))
......@@ -1543,7 +1543,7 @@ CREATE TABLE TEST(ID INTEGER NOT NULL, ID2 INTEGER DEFAULT 0);
> ok
ALTER TABLE test ALTER COLUMN ID2 RENAME TO ID;
> exception
> exception DUPLICATE_COLUMN_NAME_1
drop table test;
> ok
......@@ -1630,7 +1630,7 @@ select * from dual where x = 1000000000000000000000;
> rows: 0
select * from dual where x = 'Hello';
> exception
> exception DATA_CONVERSION_ERROR_1
create table test(id smallint primary key);
> ok
......@@ -1792,7 +1792,7 @@ ALTER TABLE A SET REFERENTIAL_INTEGRITY FALSE;
> ok
ALTER TABLE A SET REFERENTIAL_INTEGRITY TRUE CHECK;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
DROP TABLE A;
> ok
......@@ -1813,7 +1813,7 @@ INSERT INTO CHILD VALUES(2);
> update count: 1
ALTER TABLE CHILD ADD CONSTRAINT CP FOREIGN KEY(PID) REFERENCES PARENT(ID);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
UPDATE CHILD SET PID=1;
> update count: 1
......@@ -1831,7 +1831,7 @@ INSERT INTO A VALUES(1, 2);
> update count: 1
ALTER TABLE A ADD CONSTRAINT AC FOREIGN KEY(SK) REFERENCES A(ID);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
DROP TABLE A;
> ok
......@@ -1843,7 +1843,7 @@ INSERT INTO TEST VALUES(0), (1), (100);
> update count: 3
ALTER TABLE TEST ADD CONSTRAINT T CHECK ID<100;
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
UPDATE TEST SET ID=20 WHERE ID=100;
> update count: 1
......@@ -1909,7 +1909,7 @@ insert into test values(1, 1);
> update count: 1
insert into test values(2, 3);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
set autocommit false;
> ok
......@@ -1927,7 +1927,7 @@ set referential_integrity true;
> ok
insert into test values(7, 7), (8, 9);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
set autocommit true;
> ok
......@@ -2080,7 +2080,7 @@ create table d(d double, r real);
> ok
insert into d(d, d, r) values(1.1234567890123456789, 1.1234567890123456789, 3);
> exception
> exception DUPLICATE_COLUMN_NAME_1
insert into d values(1.1234567890123456789, 1.1234567890123456789);
> update count: 1
......@@ -2266,7 +2266,7 @@ drop all objects;
> ok
call abc;
> exception
> exception COLUMN_NOT_FOUND_1
create table FOO(id integer primary key);
> ok
......@@ -2281,7 +2281,7 @@ truncate table bar;
> ok
truncate table foo;
> exception
> exception CANNOT_TRUNCATE_1
drop table bar, foo;
> ok
......@@ -2555,7 +2555,7 @@ insert into content values(0, 0), (0, 0);
> update count: 2
insert into content values(0, 1);
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
insert into content values(1, 1), (2, 2);
> update count: 2
......@@ -2564,7 +2564,7 @@ insert into content values(2, 1);
> update count: 1
insert into content values(2, 3);
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
drop table content;
> ok
......@@ -2640,7 +2640,7 @@ select id/(10*100) from test group by id/(10*100);
> rows: 1
select id/1000 from test group by id/100;
> exception
> exception MUST_GROUP_BY_COLUMN_1
drop table test;
> ok
......@@ -2724,7 +2724,7 @@ insert into test values(null);
> update count: 1
insert into test values('aa');
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
insert into test values('AA');
> update count: 1
......@@ -2753,13 +2753,13 @@ insert into address(id, name, name2) values(1, 'test@abc', 'test@gmail.com');
> update count: 1
insert into address(id, name, name2) values(2, 'test@abc', 'test@acme');
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
insert into address(id, name, name2) values(3, 'test_abc', 'test@gmail');
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
insert into address2(name) values('test@abc');
> exception
> exception TABLE_OR_VIEW_NOT_FOUND_1
CREATE DOMAIN STRING AS VARCHAR(255) DEFAULT '' NOT NULL;
> ok
......@@ -2852,7 +2852,7 @@ create force view address_view as select * from address;
> ok
create table address(id identity, name varchar check instr(value, '@') > 1);
> exception
> exception COLUMN_NOT_FOUND_1
create table address(id identity, name varchar check instr(name, '@') > 1);
> ok
......@@ -2882,7 +2882,7 @@ create table c();
> ok
drop table information_schema.columns;
> exception
> exception CANNOT_DROP_TABLE_1
create table columns as select * from information_schema.columns;
> ok
......@@ -3106,7 +3106,7 @@ INSERT INTO TEST2 VALUES(2, 'World');
> update count: 1
INSERT INTO TEST2 VALUES(3, 'WoRlD');
> exception
> exception DUPLICATE_KEY_1
drop index idx_test2_name;
> ok
......@@ -3352,7 +3352,7 @@ create force view t1 as select * from t1;
> ok
select * from t1;
> exception
> exception VIEW_IS_INVALID_2
drop table t1;
> ok
......@@ -3533,10 +3533,10 @@ select count(*) from test where id in ((select id from test));
> rows: 1
select count(*) from test where id = ((select id from test));
> exception
> exception SCALAR_SUBQUERY_CONTAINS_MORE_THAN_ONE_ROW
select count(*) from test where id = ((select id from test), 1);
> exception
> exception COMPARING_ARRAY_TO_SCALAR
select (select id from test where 1=0) from test;
> SELECT ID FROM PUBLIC.TEST /* PUBLIC.TEST.tableScan: FALSE */ WHERE FALSE
......@@ -3588,7 +3588,7 @@ insert into test values(6, 'F');
> update count: 1
select max(id) from test where id = max(id) group by id;
> exception
> exception INVALID_USE_OF_AGGREGATE_FUNCTION_1
select * from test where a=TRUE=a;
> ID A
......@@ -3663,13 +3663,13 @@ create table test (id identity, value int not null);
> ok
create primary key on test(id);
> exception
> exception SECOND_PRIMARY_KEY
alter table test drop primary key;
> ok
alter table test drop primary key;
> exception
> exception INDEX_NOT_FOUND_1
create primary key on test(id, id, id);
> ok
......@@ -3826,7 +3826,7 @@ select test."ID" from test;
> rows: 0
select test."id" from test;
> exception
> exception COLUMN_NOT_FOUND_1
select "TEST"."ID" from test;
> ID
......@@ -3834,7 +3834,7 @@ select "TEST"."ID" from test;
> rows: 0
select "test"."ID" from test;
> exception
> exception COLUMN_NOT_FOUND_1
select public."TEST".id from test;
> ID
......@@ -3852,7 +3852,7 @@ select public."TEST"."ID" from test;
> rows: 0
select public."test"."ID" from test;
> exception
> exception COLUMN_NOT_FOUND_1
select "PUBLIC"."TEST".id from test;
> ID
......@@ -3870,7 +3870,7 @@ select public."TEST"."ID" from test;
> rows: 0
select "public"."TEST"."ID" from test;
> exception
> exception COLUMN_NOT_FOUND_1
drop table test;
> ok
......@@ -4053,7 +4053,7 @@ create table test(ID INT default next value for seq1);
> ok
drop sequence seq1;
> exception
> exception CANNOT_DROP_2
alter table test add column name varchar;
> ok
......@@ -4154,7 +4154,7 @@ INSERT INTO CHILD VALUES(1, '1');
> update count: 1
INSERT INTO CHILD VALUES(2, 'Hello');
> exception
> exception DATA_CONVERSION_ERROR_1
DROP TABLE IF EXISTS CHILD;
> ok
......@@ -4322,13 +4322,13 @@ INSERT INTO label VALUES ( 0, 0, 0, 'TEST');
> update count: 1
INSERT INTO label VALUES ( 1, 0, 0, 'TEST');
> exception
> exception DUPLICATE_KEY_1
INSERT INTO label VALUES ( 1, 0, 0, 'TEST1');
> update count: 1
INSERT INTO label VALUES ( 2, 2, 1, 'TEST');
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
drop table label;
> ok
......@@ -4457,7 +4457,7 @@ TRUNCATE TABLE CHILD;
> ok
TRUNCATE TABLE PARENT;
> exception
> exception CANNOT_TRUNCATE_1
DROP TABLE CHILD;
> ok
......@@ -4549,19 +4549,19 @@ EXPLAIN MERGE INTO TEST(ID, NAME) KEY(ID) VALUES(3, 'How do you do');
> rows: 1
MERGE INTO TEST(ID, NAME) KEY(NAME) VALUES(3, 'Fine');
> exception
> exception LOCK_TIMEOUT_1
MERGE INTO TEST(ID, NAME) KEY(NAME) VALUES(4, 'Fine!');
> update count: 1
MERGE INTO TEST(ID, NAME) KEY(NAME) VALUES(4, 'Fine! And you');
> exception
> exception LOCK_TIMEOUT_1
MERGE INTO TEST(ID, NAME) KEY(NAME, ID) VALUES(5, 'I''m ok');
> update count: 1
MERGE INTO TEST(ID, NAME) KEY(NAME, ID) VALUES(5, 'Oh, fine');
> exception
> exception DUPLICATE_KEY_1
MERGE INTO TEST(ID, NAME) VALUES(6, 'Oh, fine.');
> update count: 1
......@@ -4980,7 +4980,7 @@ select * from test;
> rows: 4
UPDATE test SET name='Hi';
> exception
> exception DUPLICATE_KEY_1
select * from test;
> ID NAME B
......@@ -5281,7 +5281,7 @@ CREATE UNIQUE INDEX IDX_NAME_ID ON TEST(ID, NAME);
> ok
ALTER TABLE TEST DROP COLUMN NAME;
> exception
> exception COLUMN_IS_REFERENCED_1
DROP INDEX IDX_NAME_ID;
> ok
......@@ -6009,7 +6009,7 @@ DROP VIEW CHILDREN_CLASSES;
> ok
DROP VIEW CHILDREN_CLASS12;
> exception
> exception VIEW_NOT_FOUND_1
CREATE VIEW V_UNION AS SELECT * FROM CHILDREN UNION ALL SELECT * FROM CHILDREN;
> ok
......@@ -6170,7 +6170,7 @@ DROP TABLE TEST_B cascade;
> ok
DROP VIEW TEST_ALL;
> exception
> exception VIEW_NOT_FOUND_1
DROP VIEW IF EXISTS TEST_ALL;
> ok
......@@ -6203,7 +6203,7 @@ INSERT INTO TEST VALUES(2, 'World');
> update count: 1
ROLLBACK TO SAVEPOINT NOT_EXISTING;
> exception
> exception SAVEPOINT_IS_INVALID_1
ROLLBACK TO SAVEPOINT TEST;
> ok
......@@ -6283,16 +6283,16 @@ DROP TABLE TEST;
--- syntax errors ----------------------------------------------------------------------------------------------
CREATE SOMETHING STRANGE;
> exception
> exception SYNTAX_ERROR_2
SELECT T1.* T2;
> exception
> exception SYNTAX_ERROR_1
select replace('abchihihi', 'i', 'o') abcehohoho, replace('this is tom', 'i') 1e_th_st_om from test;
> exception
> exception SYNTAX_ERROR_1
select monthname(date )'005-0E9-12') d_set fm test;
> exception
> exception SYNTAX_ERROR_1
call substring('bob', 2, -1);
> ''
......@@ -6463,10 +6463,10 @@ SELECT * FROM TEST;
> rows: 1
DROP_ TABLE_ TEST_T;
> exception
> exception SYNTAX_ERROR_2
DROP TABLE TEST /*;
> exception
> exception SYNTAX_ERROR_1
DROP TABLE TEST;
> ok
......@@ -6568,13 +6568,13 @@ select 1 from test, test where 1 in (select 1 from test where id=1);
> rows: 9
select * from test, test where id=id;
> exception
> exception AMBIGUOUS_COLUMN_NAME_1
select 1 from test, test where id=id;
> exception
> exception AMBIGUOUS_COLUMN_NAME_1
select 1 from test where id in (select id from test, test);
> exception
> exception AMBIGUOUS_COLUMN_NAME_1
DROP TABLE TEST;
> ok
......@@ -6683,13 +6683,13 @@ INSERT INTO TEST VALUES(0, '0:0:0','1-2-3','2-3-4 0:0:0');
> update count: 1
INSERT INTO TEST VALUES(1, '01:02:03','2001-02-03','2001-02-29 0:0:0');
> exception
> exception INVALID_DATETIME_CONSTANT_2
INSERT INTO TEST VALUES(1, '24:62:03','2001-02-03','2001-02-01 0:0:0');
> exception
> exception INVALID_DATETIME_CONSTANT_2
INSERT INTO TEST VALUES(1, '23:02:03','2001-04-31','2001-02-01 0:0:0');
> exception
> exception INVALID_DATETIME_CONSTANT_2
INSERT INTO TEST VALUES(1,'1:2:3','4-5-6','7-8-9 0:1:2');
> update count: 1
......@@ -6964,25 +6964,25 @@ SELECT 2/3 FROM TEST WHERE ID=1;
> rows: 1
SELECT ID/ID FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT XT/XT FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT X_SM/X_SM FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT XB/XB FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT XD/XD FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT XD2/XD2 FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT XR/XR FROM TEST;
> exception
> exception DIVISION_BY_ZERO_1
SELECT ID++0, -X1, -XT, -X_SM, -XB, -XD, -XD2, -XR FROM TEST;
> ID + 0 - X1 - XT - X_SM - XB - XD - XD2 - XR
......@@ -7650,7 +7650,7 @@ CREATE TABLE TEST(ID INT, CONSTRAINT PK PRIMARY KEY(ID), NAME VARCHAR, PARENT IN
> ok
ALTER TABLE TEST DROP PRIMARY KEY;
> exception
> exception INDEX_BELONGS_TO_CONSTRAINT_2
ALTER TABLE TEST DROP CONSTRAINT PK;
> ok
......@@ -7665,7 +7665,7 @@ INSERT INTO TEST VALUES(3, 'Karin', 2);
> update count: 1
INSERT INTO TEST VALUES(4, 'Joe', 5);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
INSERT INTO TEST VALUES(4, 'Joe', 3);
> update count: 1
......@@ -7683,7 +7683,7 @@ ALTER TABLE TEST DROP PRIMARY KEY;
> ok
ALTER TABLE TEST DROP PRIMARY KEY;
> exception
> exception INDEX_NOT_FOUND_1
ALTER TABLE TEST DROP CONSTRAINT A_UNIQUE;
> ok
......@@ -7704,7 +7704,7 @@ ALTER TABLE TEST DROP CONSTRAINT C1;
> ok
ALTER TABLE TEST DROP CONSTRAINT C1;
> exception
> exception CONSTRAINT_NOT_FOUND_1
DROP TABLE TEST;
> ok
......@@ -7725,16 +7725,16 @@ ALTER TABLE A_TEST ADD CONSTRAINT DATE_UNIQUE_2 UNIQUE(A_DATE);
> ok
INSERT INTO A_TEST VALUES(NULL, NULL, NULL, NULL);
> exception
> exception NULL_NOT_ALLOWED
INSERT INTO A_TEST VALUES(1, 'A', NULL, NULL);
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
INSERT INTO A_TEST VALUES(1, 'AB', NULL, NULL);
> update count: 1
INSERT INTO A_TEST VALUES(1, 'AB', NULL, NULL);
> exception
> exception DUPLICATE_KEY_1
INSERT INTO A_TEST VALUES(2, 'AB', NULL, NULL);
> update count: 1
......@@ -7743,7 +7743,7 @@ INSERT INTO A_TEST VALUES(3, 'AB', '2004-01-01', NULL);
> update count: 1
INSERT INTO A_TEST VALUES(4, 'AB', '2004-01-01', NULL);
> exception
> exception DUPLICATE_KEY_1
INSERT INTO A_TEST VALUES(5, 'ABC', '2004-01-02', NULL);
> update count: 1
......@@ -7761,10 +7761,10 @@ ALTER TABLE B_TEST ADD PRIMARY KEY(B_INT);
> ok
INSERT INTO B_TEST VALUES(10, 'X');
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
INSERT INTO B_TEST VALUES(1, 'X');
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
INSERT INTO B_TEST VALUES(1, 'XX');
> update count: 1
......@@ -7791,7 +7791,7 @@ ALTER TABLE B_TEST ADD CONSTRAINT C2 FOREIGN KEY(B_INT) REFERENCES A_TEST(A_INT)
> ok
UPDATE A_TEST SET A_INT = A_INT*10;
> exception
> exception NULL_NOT_ALLOWED
SELECT * FROM B_TEST;
> B_INT B_VARCHAR
......@@ -7889,7 +7889,7 @@ INSERT INTO FAMILY VALUES(1, 'Capone');
> update count: 1
INSERT INTO CHILD VALUES(100, 1, 1, 'early');
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
INSERT INTO PARENT VALUES(1, 1, 'Sue');
> update count: 1
......@@ -7922,7 +7922,7 @@ SELECT * FROM CHILD;
> rows: 4
UPDATE CHILD SET PARENTID=-1 WHERE PARENTID IS NOT NULL;
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
DELETE FROM PARENT WHERE ID=2;
> update count: 1
......@@ -8022,7 +8022,7 @@ INSERT INTO INVOICE_LINE VALUES(1, 100, 10, 'Apples', 20.35), (1, 100, 20, 'Pape
> update count: 4
INSERT INTO INVOICE_LINE VALUES(1, 102, 20, 'Nothing', 30.00);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
DELETE FROM INVOICE WHERE ID = 100;
> update count: 1
......@@ -8304,13 +8304,13 @@ drop table test;
> ok
select 0 from ((
select 0 as f from dual u1 where null in (?, ?, ?, ?, ?)
select 0 as f from dual u1 where null in (?, ?, ?, ?, ?)
) union all (
select u2.f from (
select 0 as f from (
select 0 from dual u2f1f1 where now() = ?
) u2f1
) u2
select u2.f from (
select 0 as f from (
select 0 from dual u2f1f1 where now() = ?
) u2f1
) u2
)) where f = 12345;
{
11, 22, 33, 44, 55, null
......@@ -8330,7 +8330,7 @@ alter table if exists x add column a varchar;
> ok
alter table if exists x add column a varchar;
> exception
> exception DUPLICATE_COLUMN_NAME_1
alter table if exists y alter column a rename to b;
> ok
......@@ -8339,7 +8339,7 @@ alter table if exists x alter column a rename to b;
> ok
alter table if exists x alter column a rename to b;
> exception
> exception COLUMN_NOT_FOUND_1
alter table if exists y alter column b set default 'a';
> ok
......@@ -8372,7 +8372,7 @@ alter table if exists x alter column b set not null;
> ok
insert into x(id) values(1);
> exception
> exception NULL_NOT_ALLOWED
alter table if exists y alter column b drop not null;
> ok
......@@ -8399,13 +8399,13 @@ alter table if exists x add constraint x_pk primary key (id);
> ok
alter table if exists x add constraint x_pk primary key (id);
> exception
> exception CONSTRAINT_ALREADY_EXISTS_1
insert into x(id) values(1);
> update count: 1
insert into x(id) values(1);
> exception
> exception DUPLICATE_KEY_1
delete from x;
> update count: 1
......@@ -8417,10 +8417,10 @@ alter table if exists x add constraint x_check check (b = 'a');
> ok
alter table if exists x add constraint x_check check (b = 'a');
> exception
> exception CONSTRAINT_ALREADY_EXISTS_1
insert into x(id, b) values(1, 'b');
> exception
> exception CHECK_CONSTRAINT_VIOLATED_1
alter table if exists y rename constraint x_check to x_check1;
> ok
......@@ -8429,7 +8429,7 @@ alter table if exists x rename constraint x_check to x_check1;
> ok
alter table if exists x rename constraint x_check to x_check1;
> exception
> exception CONSTRAINT_NOT_FOUND_1
alter table if exists y drop constraint x_check1;
> ok
......@@ -8459,13 +8459,13 @@ alter table if exists z add constraint z_uk unique (b);
> ok
alter table if exists z add constraint z_uk unique (b);
> exception
> exception CONSTRAINT_ALREADY_EXISTS_1
insert into z(id, b) values(1, 'b');
> update count: 1
insert into z(id, b) values(1, 'b');
> exception
> exception DUPLICATE_KEY_1
delete from z;
> update count: 1
......@@ -8477,7 +8477,7 @@ alter table if exists z drop column b;
> ok
alter table if exists z drop column b;
> exception
> exception COLUMN_NOT_FOUND_1
alter table if exists y drop primary key;
> ok
......@@ -8486,7 +8486,7 @@ alter table if exists z drop primary key;
> ok
alter table if exists z drop primary key;
> exception
> exception INDEX_NOT_FOUND_1
create table x (id int not null primary key);
> ok
......@@ -8498,10 +8498,10 @@ alter table if exists z add constraint z_fk foreign key (id) references x (id);
> ok
alter table if exists z add constraint z_fk foreign key (id) references x (id);
> exception
> exception CONSTRAINT_ALREADY_EXISTS_1
insert into z (id) values (1);
> exception
> exception REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
alter table if exists y drop foreign key z_fk;
> ok
......@@ -8510,7 +8510,7 @@ alter table if exists z drop foreign key z_fk;
> ok
alter table if exists z drop foreign key z_fk;
> exception
> exception CONSTRAINT_NOT_FOUND_1
insert into z (id) values (1);
> update count: 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论