Unverified 提交 3ab43d18 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1114 from katzyn/misc

Minor cleanup and formatting fixes
......@@ -4469,7 +4469,8 @@ public class Parser {
if (readIf("(")) {
originalScale = readPositiveInt();
if (originalScale > ValueTime.MAXIMUM_SCALE) {
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(originalScale));
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION,
Integer.toString(originalScale));
}
read(")");
scale = originalScale;
......
......@@ -200,14 +200,14 @@ public class Mode {
private final String name;
private ModeEnum modeEnum;
private final ModeEnum modeEnum;
static {
Mode mode = new Mode(ModeEnum.REGULAR.name());
Mode mode = new Mode(ModeEnum.REGULAR);
mode.nullConcatIsNull = true;
add(mode);
mode = new Mode(ModeEnum.DB2.name());
mode = new Mode(ModeEnum.DB2);
mode.aliasColumnName = true;
mode.sysDummy1 = true;
mode.isolationLevelInSelectOrInsertStatement = true;
......@@ -221,7 +221,7 @@ public class Mode {
mode.allowDB2TimestampFormat = true;
add(mode);
mode = new Mode(ModeEnum.Derby.name());
mode = new Mode(ModeEnum.Derby);
mode.aliasColumnName = true;
mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES;
mode.sysDummy1 = true;
......@@ -230,7 +230,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null;
add(mode);
mode = new Mode(ModeEnum.HSQLDB.name());
mode = new Mode(ModeEnum.HSQLDB);
mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true;
mode.nullConcatIsNull = true;
......@@ -243,7 +243,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null;
add(mode);
mode = new Mode(ModeEnum.MSSQLServer.name());
mode = new Mode(ModeEnum.MSSQLServer);
mode.aliasColumnName = true;
mode.squareBracketQuotedNames = true;
mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES;
......@@ -255,7 +255,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null;
add(mode);
mode = new Mode(ModeEnum.MySQL.name());
mode = new Mode(ModeEnum.MySQL);
mode.convertInsertNullToZero = true;
mode.indexDefinitionInCreateTable = true;
mode.lowerCaseIdentifiers = true;
......@@ -271,7 +271,7 @@ public class Mode {
mode.prohibitEmptyInPredicate = true;
add(mode);
mode = new Mode(ModeEnum.Oracle.name());
mode = new Mode(ModeEnum.Oracle);
mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true;
mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.ALLOW_DUPLICATES_WITH_ALL_NULLS;
......@@ -286,7 +286,7 @@ public class Mode {
mode.typeByNameMap.put("DATE", DataType.getDataType(Value.TIMESTAMP));
add(mode);
mode = new Mode(ModeEnum.PostgreSQL.name());
mode = new Mode(ModeEnum.PostgreSQL);
mode.aliasColumnName = true;
mode.nullConcatIsNull = true;
mode.systemColumns = true;
......@@ -309,16 +309,16 @@ public class Mode {
mode.disallowedTypes = disallowedTypes;
add(mode);
mode = new Mode(ModeEnum.Ignite.name());
mode = new Mode(ModeEnum.Ignite);
mode.nullConcatIsNull = true;
mode.allowAffinityKey = true;
mode.indexDefinitionInCreateTable = true;
add(mode);
}
private Mode(String name) {
this.name = name;
this.modeEnum = ModeEnum.valueOf(name);
private Mode(ModeEnum modeEnum) {
this.name = modeEnum.name();
this.modeEnum = modeEnum;
}
private static void add(Mode mode) {
......
......@@ -1247,21 +1247,13 @@ public class ObjectDataType implements DataType {
Class<?> type = obj.getClass().getComponentType();
if (type.isPrimitive()) {
int len = Array.getLength(obj);
if (type == boolean.class) {
size += len;
} else if (type == byte.class) {
if (type == boolean.class || type == byte.class) {
size += len;
} else if (type == char.class) {
size += len * 2;
} else if (type == short.class) {
} else if (type == char.class || type == short.class) {
size += len * 2;
} else if (type == int.class) {
size += len * 4;
} else if (type == float.class) {
} else if (type == int.class || type == float.class) {
size += len * 4;
} else if (type == double.class) {
size += len * 8;
} else if (type == long.class) {
} else if (type == double.class || type == long.class) {
size += len * 8;
}
} else {
......
......@@ -649,8 +649,8 @@ public class Recover extends Tool implements DataHandler {
}
}
}
// Have to do these before the tables because settings like COLLATION may affect some of them,
// and we can't change settings after we have created user tables
// Have to do these before the tables because settings like COLLATION may affect
// some of them, and we can't change settings after we have created user tables
writeSchemaSET(writer);
writer.println("---- Table Data ----");
for (String mapName : mv.getMapNames()) {
......
......@@ -201,37 +201,25 @@ CREATE VIEW V AS SELECT * FROM TEST;
> ok
SELECT * FROM V;
> E
> -
> B
> rows: 1
>> B
CREATE VIEW V1 AS SELECT E + 2 AS E FROM TEST;
> ok
SELECT * FROM V1;
> E
> -
> 3
> rows: 1
>> 3
CREATE VIEW V2 AS SELECT E + E AS E FROM TEST;
> ok
SELECT * FROM V2;
> E
> -
> 2
> rows: 1
>> 2
CREATE VIEW V3 AS SELECT -E AS E FROM TEST;
> ok
SELECT * FROM V3;
> E
> --
> -1
> rows: 1
>> -1
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_NAME;
> TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE
......
......@@ -50,10 +50,7 @@ INSERT INTO TEST VALUES (TIME '08:00:00');
> update count: 1
SELECT TIME FROM TEST;
> TIME
> --------
> 08:00:00
> rows: 1
>> 08:00:00
DROP TABLE TEST;
> ok
......
......@@ -6,10 +6,7 @@ explain with recursive r(n) as (
(select 1) union all (select n+1 from r where n < 3)
)
select n from r;
> PLAN
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> WITH RECURSIVE 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 R R /* null */
> rows: 1
>> WITH RECURSIVE 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 R R /* null */
select sum(n) from (
with recursive r(n) as (
......@@ -17,10 +14,7 @@ select sum(n) from (
)
select n from r
);
> SUM(N)
> ------
> 6
> rows: 1
>> 6
select sum(n) from (select 0) join (
with recursive r(n) as (
......@@ -28,10 +22,7 @@ select sum(n) from (select 0) join (
)
select n from r
) on 1=1;
> SUM(N)
> ------
> 6
> rows: 1
>> 6
select 0 from (
select 0 where 0 in (
......
......@@ -32,10 +32,7 @@ drop table test;
> ok
explain select * from table(id int = (1, 2), name varchar=('Hello', 'World'));
> PLAN
> -----------------------------------------------------------------------------------------------------
> SELECT TABLE.ID, TABLE.NAME FROM TABLE(ID INT=(1, 2), NAME VARCHAR=('Hello', 'World')) /* function */
> rows: 1
>> SELECT TABLE.ID, TABLE.NAME FROM TABLE(ID INT=(1, 2), NAME VARCHAR=('Hello', 'World')) /* function */
select * from table(id int=(1, 2), name varchar=('Hello', 'World')) x order by id;
> ID NAME
......
......@@ -40,16 +40,10 @@ create table test(a int, b int) as select x, x from system_range(1, 100);
-- the table t1 should be processed first
explain select * from test t2, test t1 where t1.a=1 and t1.b = t2.b;
> PLAN
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T2.A, T2.B, T1.A, T1.B FROM PUBLIC.TEST T1 /* PUBLIC.TEST.tableScan */ /* WHERE T1.A = 1 */ INNER JOIN PUBLIC.TEST T2 /* PUBLIC.TEST.tableScan */ ON 1=1 WHERE (T1.A = 1) AND (T1.B = T2.B)
> rows: 1
>> SELECT T2.A, T2.B, T1.A, T1.B FROM PUBLIC.TEST T1 /* PUBLIC.TEST.tableScan */ /* WHERE T1.A = 1 */ INNER JOIN PUBLIC.TEST T2 /* PUBLIC.TEST.tableScan */ ON 1=1 WHERE (T1.A = 1) AND (T1.B = T2.B)
explain select * from test t1, test t2 where t1.a=1 and t1.b = t2.b;
> PLAN
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.A, T1.B, T2.A, T2.B FROM PUBLIC.TEST T1 /* PUBLIC.TEST.tableScan */ /* WHERE T1.A = 1 */ INNER JOIN PUBLIC.TEST T2 /* PUBLIC.TEST.tableScan */ ON 1=1 WHERE (T1.A = 1) AND (T1.B = T2.B)
> rows: 1
>> SELECT T1.A, T1.B, T2.A, T2.B FROM PUBLIC.TEST T1 /* PUBLIC.TEST.tableScan */ /* WHERE T1.A = 1 */ INNER JOIN PUBLIC.TEST T2 /* PUBLIC.TEST.tableScan */ ON 1=1 WHERE (T1.A = 1) AND (T1.B = T2.B)
drop table test;
> ok
......@@ -128,10 +122,7 @@ CREATE TABLE TESTB(ID IDENTITY);
> ok
explain SELECT TESTA.ID A, TESTB.ID B FROM TESTA, TESTB ORDER BY TESTA.ID, TESTB.ID;
> PLAN
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT TESTA.ID AS A, TESTB.ID AS B FROM PUBLIC.TESTA /* PUBLIC.TESTA.tableScan */ INNER JOIN PUBLIC.TESTB /* PUBLIC.TESTB.tableScan */ ON 1=1 ORDER BY 1, 2
> rows (ordered): 1
>> SELECT TESTA.ID AS A, TESTB.ID AS B FROM PUBLIC.TESTA /* PUBLIC.TESTA.tableScan */ INNER JOIN PUBLIC.TESTB /* PUBLIC.TESTB.tableScan */ ON 1=1 ORDER BY 1, 2
DROP TABLE IF EXISTS TESTA, TESTB;
> ok
......@@ -213,10 +204,7 @@ is null or three.val>=DATE'2006-07-01';
explain select * from one natural join two left join two three on
one.id=three.id left join one four on two.id=four.id where three.val
is null or three.val>=DATE'2006-07-01';
> PLAN
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT ONE.ID, TWO.VAL, THREE.ID, THREE.VAL, FOUR.ID FROM PUBLIC.ONE /* PUBLIC.ONE.tableScan */ INNER JOIN PUBLIC.TWO /* PUBLIC.PRIMARY_KEY_14: ID = PUBLIC.ONE.ID AND ID = PUBLIC.ONE.ID */ ON 1=1 /* WHERE PUBLIC.ONE.ID = PUBLIC.TWO.ID */ LEFT OUTER JOIN PUBLIC.TWO THREE /* PUBLIC.PRIMARY_KEY_14: ID = ONE.ID */ ON ONE.ID = THREE.ID LEFT OUTER JOIN PUBLIC.ONE FOUR /* PUBLIC.PRIMARY_KEY_1: ID = TWO.ID */ ON TWO.ID = FOUR.ID WHERE (PUBLIC.ONE.ID = PUBLIC.TWO.ID) AND ((THREE.VAL IS NULL) OR (THREE.VAL >= DATE '2006-07-01'))
> rows: 1
>> SELECT ONE.ID, TWO.VAL, THREE.ID, THREE.VAL, FOUR.ID FROM PUBLIC.ONE /* PUBLIC.ONE.tableScan */ INNER JOIN PUBLIC.TWO /* PUBLIC.PRIMARY_KEY_14: ID = PUBLIC.ONE.ID AND ID = PUBLIC.ONE.ID */ ON 1=1 /* WHERE PUBLIC.ONE.ID = PUBLIC.TWO.ID */ LEFT OUTER JOIN PUBLIC.TWO THREE /* PUBLIC.PRIMARY_KEY_14: ID = ONE.ID */ ON ONE.ID = THREE.ID LEFT OUTER JOIN PUBLIC.ONE FOUR /* PUBLIC.PRIMARY_KEY_1: ID = TWO.ID */ ON TWO.ID = FOUR.ID WHERE (PUBLIC.ONE.ID = PUBLIC.TWO.ID) AND ((THREE.VAL IS NULL) OR (THREE.VAL >= DATE '2006-07-01'))
-- Query #4: same as #3, but the joins have been manually re-ordered
-- Correct result set, same as expected for #3.
......@@ -580,10 +568,7 @@ select * from t1 natural join t2;
> rows: 0
explain select * from t1 natural join t2;
> PLAN
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM PUBLIC.T2 /* PUBLIC.T2.tableScan */ INNER JOIN PUBLIC.T1 /* PUBLIC.T1.tableScan */ ON 1=1 WHERE (PUBLIC.T1.ID = PUBLIC.T2.ID) AND (PUBLIC.T1.NAME = PUBLIC.T2.NAME)
> rows: 1
>> SELECT T1.ID, T1.NAME FROM PUBLIC.T2 /* PUBLIC.T2.tableScan */ INNER JOIN PUBLIC.T1 /* PUBLIC.T1.tableScan */ ON 1=1 WHERE (PUBLIC.T1.ID = PUBLIC.T2.ID) AND (PUBLIC.T1.NAME = PUBLIC.T2.NAME)
drop table t1;
> ok
......@@ -617,10 +602,7 @@ select c.*, i.*, l.* from customer c natural join invoice i natural join INVOICE
> rows: 2
explain select c.*, i.*, l.* from customer c natural join invoice i natural join INVOICE_LINE l;
> PLAN
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT C.CUSTOMERID, C.CUSTOMER_NAME, I.INVOICEID, I.INVOICE_TEXT, L.LINE_ID, L.LINE_TEXT FROM PUBLIC.INVOICE I /* PUBLIC.INVOICE.tableScan */ INNER JOIN PUBLIC.INVOICE_LINE L /* PUBLIC.INVOICE_LINE.tableScan */ ON 1=1 /* WHERE (PUBLIC.I.CUSTOMERID = PUBLIC.L.CUSTOMERID) AND (PUBLIC.I.INVOICEID = PUBLIC.L.INVOICEID) */ INNER JOIN PUBLIC.CUSTOMER C /* PUBLIC.CUSTOMER.tableScan */ ON 1=1 WHERE (PUBLIC.C.CUSTOMERID = PUBLIC.I.CUSTOMERID) AND ((PUBLIC.I.CUSTOMERID = PUBLIC.L.CUSTOMERID) AND (PUBLIC.I.INVOICEID = PUBLIC.L.INVOICEID))
> rows: 1
>> SELECT C.CUSTOMERID, C.CUSTOMER_NAME, I.INVOICEID, I.INVOICE_TEXT, L.LINE_ID, L.LINE_TEXT FROM PUBLIC.INVOICE I /* PUBLIC.INVOICE.tableScan */ INNER JOIN PUBLIC.INVOICE_LINE L /* PUBLIC.INVOICE_LINE.tableScan */ ON 1=1 /* WHERE (PUBLIC.I.CUSTOMERID = PUBLIC.L.CUSTOMERID) AND (PUBLIC.I.INVOICEID = PUBLIC.L.INVOICEID) */ INNER JOIN PUBLIC.CUSTOMER C /* PUBLIC.CUSTOMER.tableScan */ ON 1=1 WHERE (PUBLIC.C.CUSTOMERID = PUBLIC.I.CUSTOMERID) AND ((PUBLIC.I.CUSTOMERID = PUBLIC.L.CUSTOMERID) AND (PUBLIC.I.INVOICEID = PUBLIC.L.INVOICEID))
drop table customer;
> ok
......
......@@ -16,7 +16,4 @@ insert into person select convert(x,varchar) as firstname, (convert(x,varchar) |
-- can directly use the index.
--
explain analyze SELECT * FROM person WHERE firstname IN ('FirstName1', 'FirstName2') AND lastname='LastName1';
> PLAN
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SELECT PERSON.FIRSTNAME, PERSON.LASTNAME FROM PUBLIC.PERSON /* PUBLIC.PERSON_1: FIRSTNAME IN('FirstName1', 'FirstName2') AND LASTNAME = 'LastName1' */ /* scanCount: 1 */ WHERE (FIRSTNAME IN('FirstName1', 'FirstName2')) AND (LASTNAME = 'LastName1')
> rows: 1
>> SELECT PERSON.FIRSTNAME, PERSON.LASTNAME FROM PUBLIC.PERSON /* PUBLIC.PERSON_1: FIRSTNAME IN('FirstName1', 'FirstName2') AND LASTNAME = 'LastName1' */ /* scanCount: 1 */ WHERE (FIRSTNAME IN('FirstName1', 'FirstName2')) AND (LASTNAME = 'LastName1')
......@@ -4,22 +4,13 @@
--
explain select * from system_range(1, 2) where x=x+1 and x=1;
> PLAN
> ---------------------------------------------------------------------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX: X = 1 */ WHERE ((X = 1) AND (X = (X + 1))) AND (1 = (X + 1))
> rows: 1
>> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX: X = 1 */ WHERE ((X = 1) AND (X = (X + 1))) AND (1 = (X + 1))
explain select * from system_range(1, 2) where not (x = 1 and x*2 = 2);
> PLAN
> -------------------------------------------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX */ WHERE (X <> 1) OR ((X * 2) <> 2)
> rows: 1
>> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX */ WHERE (X <> 1) OR ((X * 2) <> 2)
explain select * from system_range(1, 10) where (NOT x >= 5);
> PLAN
> ------------------------------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 10) /* PUBLIC.RANGE_INDEX: X < 5 */ WHERE X < 5
> rows: 1
>> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 10) /* PUBLIC.RANGE_INDEX: X < 5 */ WHERE X < 5
select (select t1.x from system_range(1,1) t2) from system_range(1,1) t1;
> SELECT T1.X FROM SYSTEM_RANGE(1, 1) T2 /* PUBLIC.RANGE_INDEX */ /* scanCount: 2 */
......@@ -28,23 +19,14 @@ select (select t1.x from system_range(1,1) t2) from system_range(1,1) t1;
> rows: 1
EXPLAIN PLAN FOR SELECT * FROM SYSTEM_RANGE(1, 20);
> PLAN
> -----------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 20) /* PUBLIC.RANGE_INDEX */
> rows: 1
>> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 20) /* PUBLIC.RANGE_INDEX */
select sum(x) from system_range(2, 1000) r where
not exists(select * from system_range(2, 32) r2 where r.x>r2.x and mod(r.x, r2.x)=0);
> SUM(X)
> ------
> 76127
> rows: 1
>> 76127
SELECT COUNT(*) FROM SYSTEM_RANGE(0, 2111222333);
> COUNT(*)
> ----------
> 2111222334
> rows: 1
>> 2111222334
select * from system_range(2, 100) r where
not exists(select * from system_range(2, 11) r2 where r.x>r2.x and mod(r.x, r2.x)=0);
......@@ -148,19 +130,13 @@ SELECT COUNT(*) FROM SYSTEM_RANGE(10, 2, -2);
>> 5
SELECT * FROM SYSTEM_RANGE(1, 1);
> X
> -
> 1
> rows: 1
>> 1
SELECT COUNT(*) FROM SYSTEM_RANGE(1, 1);
>> 1
SELECT * FROM SYSTEM_RANGE(1, 1, -1);
> X
> -
> 1
> rows: 1
>> 1
SELECT COUNT(*) FROM SYSTEM_RANGE(1, 1, -1);
>> 1
......
......@@ -773,3 +773,5 @@ opti excessively
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
geometries sourceschema destschema generatedcolumn alphanumerically usages
sizable instantiates renders sdt txcommit unhelpful optimiser treats rejects referring untrusted computes vacate inverted
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论