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

Merge pull request #1114 from katzyn/misc

Minor cleanup and formatting fixes
...@@ -37,7 +37,7 @@ Change Log ...@@ -37,7 +37,7 @@ Change Log
</li> </li>
<li>Issue #1089: Parser does not quote words INTERSECTS, DUAL, TOP <li>Issue #1089: Parser does not quote words INTERSECTS, DUAL, TOP
</li> </li>
<li>Issue #230: Renaming a column does not update foreign key constraint <li>Issue #230: Renaming a column does not update foreign key constraint
</li> </li>
<li>Issue #1091 Get rid if the New class <li>Issue #1091 Get rid if the New class
</li> </li>
...@@ -45,15 +45,15 @@ Change Log ...@@ -45,15 +45,15 @@ Change Log
</li> </li>
<li>Issue #394: Recover tool places COLLATION and BINARY_COLLATION after temporary tables <li>Issue #394: Recover tool places COLLATION and BINARY_COLLATION after temporary tables
</li> </li>
<li>Improve the script-based unit testing to check the error code of the exception thrown. <li>Improve the script-based unit testing to check the error code of the exception thrown.
</li> </li>
<li>Issue #1041: Support OR syntax while creating trigger <li>Issue #1041: Support OR syntax while creating trigger
</li> </li>
<li>Issue #1023: MVCC and existing page store file <li>Issue #1023: MVCC and existing page store file
</li> </li>
<li>Issue #1003: Decrypting database with incorrect password renders the database corrupt <li>Issue #1003: Decrypting database with incorrect password renders the database corrupt
</li> </li>
<li>Issue #873: No error when `=` in equal condition when column is not of array type <li>Issue #873: No error when `=` in equal condition when column is not of array type
</li> </li>
<li>Issue #1069: Failed to add DATETIME(3) column since 1.4.197 <li>Issue #1069: Failed to add DATETIME(3) column since 1.4.197
</li> </li>
......
...@@ -4469,7 +4469,8 @@ public class Parser { ...@@ -4469,7 +4469,8 @@ public class Parser {
if (readIf("(")) { if (readIf("(")) {
originalScale = readPositiveInt(); originalScale = readPositiveInt();
if (originalScale > ValueTime.MAXIMUM_SCALE) { 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(")"); read(")");
scale = originalScale; scale = originalScale;
......
...@@ -200,14 +200,14 @@ public class Mode { ...@@ -200,14 +200,14 @@ public class Mode {
private final String name; private final String name;
private ModeEnum modeEnum; private final ModeEnum modeEnum;
static { static {
Mode mode = new Mode(ModeEnum.REGULAR.name()); Mode mode = new Mode(ModeEnum.REGULAR);
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.DB2.name()); mode = new Mode(ModeEnum.DB2);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.sysDummy1 = true; mode.sysDummy1 = true;
mode.isolationLevelInSelectOrInsertStatement = true; mode.isolationLevelInSelectOrInsertStatement = true;
...@@ -221,7 +221,7 @@ public class Mode { ...@@ -221,7 +221,7 @@ public class Mode {
mode.allowDB2TimestampFormat = true; mode.allowDB2TimestampFormat = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.Derby.name()); mode = new Mode(ModeEnum.Derby);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES; mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES;
mode.sysDummy1 = true; mode.sysDummy1 = true;
...@@ -230,7 +230,7 @@ public class Mode { ...@@ -230,7 +230,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
add(mode); add(mode);
mode = new Mode(ModeEnum.HSQLDB.name()); mode = new Mode(ModeEnum.HSQLDB);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true; mode.convertOnlyToSmallerScale = true;
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
...@@ -243,7 +243,7 @@ public class Mode { ...@@ -243,7 +243,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
add(mode); add(mode);
mode = new Mode(ModeEnum.MSSQLServer.name()); mode = new Mode(ModeEnum.MSSQLServer);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.squareBracketQuotedNames = true; mode.squareBracketQuotedNames = true;
mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES; mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.FORBID_ANY_DUPLICATES;
...@@ -255,7 +255,7 @@ public class Mode { ...@@ -255,7 +255,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
add(mode); add(mode);
mode = new Mode(ModeEnum.MySQL.name()); mode = new Mode(ModeEnum.MySQL);
mode.convertInsertNullToZero = true; mode.convertInsertNullToZero = true;
mode.indexDefinitionInCreateTable = true; mode.indexDefinitionInCreateTable = true;
mode.lowerCaseIdentifiers = true; mode.lowerCaseIdentifiers = true;
...@@ -271,7 +271,7 @@ public class Mode { ...@@ -271,7 +271,7 @@ public class Mode {
mode.prohibitEmptyInPredicate = true; mode.prohibitEmptyInPredicate = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.Oracle.name()); mode = new Mode(ModeEnum.Oracle);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true; mode.convertOnlyToSmallerScale = true;
mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.ALLOW_DUPLICATES_WITH_ALL_NULLS; mode.uniqueIndexNullsHandling = UniqueIndexNullsHandling.ALLOW_DUPLICATES_WITH_ALL_NULLS;
...@@ -286,7 +286,7 @@ public class Mode { ...@@ -286,7 +286,7 @@ public class Mode {
mode.typeByNameMap.put("DATE", DataType.getDataType(Value.TIMESTAMP)); mode.typeByNameMap.put("DATE", DataType.getDataType(Value.TIMESTAMP));
add(mode); add(mode);
mode = new Mode(ModeEnum.PostgreSQL.name()); mode = new Mode(ModeEnum.PostgreSQL);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
mode.systemColumns = true; mode.systemColumns = true;
...@@ -309,16 +309,16 @@ public class Mode { ...@@ -309,16 +309,16 @@ public class Mode {
mode.disallowedTypes = disallowedTypes; mode.disallowedTypes = disallowedTypes;
add(mode); add(mode);
mode = new Mode(ModeEnum.Ignite.name()); mode = new Mode(ModeEnum.Ignite);
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
mode.allowAffinityKey = true; mode.allowAffinityKey = true;
mode.indexDefinitionInCreateTable = true; mode.indexDefinitionInCreateTable = true;
add(mode); add(mode);
} }
private Mode(String name) { private Mode(ModeEnum modeEnum) {
this.name = name; this.name = modeEnum.name();
this.modeEnum = ModeEnum.valueOf(name); this.modeEnum = modeEnum;
} }
private static void add(Mode mode) { private static void add(Mode mode) {
......
...@@ -88,7 +88,7 @@ public abstract class Page implements Cloneable ...@@ -88,7 +88,7 @@ public abstract class Page implements Cloneable
MEMORY_POINTER + // children MEMORY_POINTER + // children
MEMORY_ARRAY + // Object[] children MEMORY_ARRAY + // Object[] children
8; // totalCount 8; // totalCount
/** /**
* The estimated number of bytes used per empty leaf page. * The estimated number of bytes used per empty leaf page.
*/ */
......
...@@ -1247,21 +1247,13 @@ public class ObjectDataType implements DataType { ...@@ -1247,21 +1247,13 @@ public class ObjectDataType implements DataType {
Class<?> type = obj.getClass().getComponentType(); Class<?> type = obj.getClass().getComponentType();
if (type.isPrimitive()) { if (type.isPrimitive()) {
int len = Array.getLength(obj); int len = Array.getLength(obj);
if (type == boolean.class) { if (type == boolean.class || type == byte.class) {
size += len; size += len;
} else if (type == byte.class) { } else if (type == char.class || type == short.class) {
size += len;
} else if (type == char.class) {
size += len * 2;
} else if (type == short.class) {
size += len * 2; size += len * 2;
} else if (type == int.class) { } else if (type == int.class || type == float.class) {
size += len * 4; size += len * 4;
} else if (type == float.class) { } else if (type == double.class || type == long.class) {
size += len * 4;
} else if (type == double.class) {
size += len * 8;
} else if (type == long.class) {
size += len * 8; size += len * 8;
} }
} else { } else {
......
...@@ -649,8 +649,8 @@ public class Recover extends Tool implements DataHandler { ...@@ -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, // Have to do these before the tables because settings like COLLATION may affect
// and we can't change settings after we have created user tables // some of them, and we can't change settings after we have created user tables
writeSchemaSET(writer); writeSchemaSET(writer);
writer.println("---- Table Data ----"); writer.println("---- Table Data ----");
for (String mapName : mv.getMapNames()) { for (String mapName : mv.getMapNames()) {
......
...@@ -201,37 +201,25 @@ CREATE VIEW V AS SELECT * FROM TEST; ...@@ -201,37 +201,25 @@ CREATE VIEW V AS SELECT * FROM TEST;
> ok > ok
SELECT * FROM V; SELECT * FROM V;
> E >> B
> -
> B
> rows: 1
CREATE VIEW V1 AS SELECT E + 2 AS E FROM TEST; CREATE VIEW V1 AS SELECT E + 2 AS E FROM TEST;
> ok > ok
SELECT * FROM V1; SELECT * FROM V1;
> E >> 3
> -
> 3
> rows: 1
CREATE VIEW V2 AS SELECT E + E AS E FROM TEST; CREATE VIEW V2 AS SELECT E + E AS E FROM TEST;
> ok > ok
SELECT * FROM V2; SELECT * FROM V2;
> E >> 2
> -
> 2
> rows: 1
CREATE VIEW V3 AS SELECT -E AS E FROM TEST; CREATE VIEW V3 AS SELECT -E AS E FROM TEST;
> ok > ok
SELECT * FROM V3; SELECT * FROM V3;
> E >> -1
> --
> -1
> rows: 1
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_NAME; 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 > 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'); ...@@ -50,10 +50,7 @@ INSERT INTO TEST VALUES (TIME '08:00:00');
> update count: 1 > update count: 1
SELECT TIME FROM TEST; SELECT TIME FROM TEST;
> TIME >> 08:00:00
> --------
> 08:00:00
> rows: 1
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
......
...@@ -6,10 +6,7 @@ explain with recursive r(n) as ( ...@@ -6,10 +6,7 @@ explain 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)
) )
select n from r; 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 */
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
select sum(n) from ( select sum(n) from (
with recursive r(n) as ( with recursive r(n) as (
...@@ -17,10 +14,7 @@ select sum(n) from ( ...@@ -17,10 +14,7 @@ select sum(n) from (
) )
select n from r select n from r
); );
> SUM(N) >> 6
> ------
> 6
> rows: 1
select sum(n) from (select 0) join ( select sum(n) from (select 0) join (
with recursive r(n) as ( with recursive r(n) as (
...@@ -28,10 +22,7 @@ select sum(n) from (select 0) join ( ...@@ -28,10 +22,7 @@ select sum(n) from (select 0) join (
) )
select n from r select n from r
) on 1=1; ) on 1=1;
> SUM(N) >> 6
> ------
> 6
> rows: 1
select 0 from ( select 0 from (
select 0 where 0 in ( select 0 where 0 in (
......
...@@ -32,10 +32,7 @@ drop table test; ...@@ -32,10 +32,7 @@ drop table test;
> ok > ok
explain select * from table(id int = (1, 2), name varchar=('Hello', 'World')); 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 */
> -----------------------------------------------------------------------------------------------------
> SELECT TABLE.ID, TABLE.NAME FROM TABLE(ID INT=(1, 2), NAME VARCHAR=('Hello', 'World')) /* function */
> rows: 1
select * from table(id int=(1, 2), name varchar=('Hello', 'World')) x order by id; select * from table(id int=(1, 2), name varchar=('Hello', 'World')) x order by id;
> ID NAME > ID NAME
......
...@@ -40,16 +40,10 @@ create table test(a int, b int) as select x, x from system_range(1, 100); ...@@ -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 -- the table t1 should be processed first
explain select * from test t2, test t1 where t1.a=1 and t1.b = t2.b; 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)
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
explain select * from test t1, test t2 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)
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
drop table test; drop table test;
> ok > ok
...@@ -128,10 +122,7 @@ CREATE TABLE TESTB(ID IDENTITY); ...@@ -128,10 +122,7 @@ CREATE TABLE TESTB(ID IDENTITY);
> ok > ok
explain SELECT TESTA.ID A, TESTB.ID B FROM TESTA, TESTB ORDER BY TESTA.ID, TESTB.ID; 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
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
DROP TABLE IF EXISTS TESTA, TESTB; DROP TABLE IF EXISTS TESTA, TESTB;
> ok > ok
...@@ -213,10 +204,7 @@ is null or three.val>=DATE'2006-07-01'; ...@@ -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 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 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'; 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'))
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
-- Query #4: same as #3, but the joins have been manually re-ordered -- Query #4: same as #3, but the joins have been manually re-ordered
-- Correct result set, same as expected for #3. -- Correct result set, same as expected for #3.
...@@ -580,10 +568,7 @@ select * from t1 natural join t2; ...@@ -580,10 +568,7 @@ select * from t1 natural join t2;
> rows: 0 > rows: 0
explain select * from t1 natural join t2; 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)
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
drop table t1; drop table t1;
> ok > ok
...@@ -617,10 +602,7 @@ select c.*, i.*, l.* from customer c natural join invoice i natural join INVOICE ...@@ -617,10 +602,7 @@ select c.*, i.*, l.* from customer c natural join invoice i natural join INVOICE
> rows: 2 > rows: 2
explain select c.*, i.*, l.* from customer c natural join invoice i natural join INVOICE_LINE l; 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))
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
drop table customer; drop table customer;
> ok > ok
......
...@@ -16,7 +16,4 @@ insert into person select convert(x,varchar) as firstname, (convert(x,varchar) | ...@@ -16,7 +16,4 @@ insert into person select convert(x,varchar) as firstname, (convert(x,varchar) |
-- can directly use the index. -- can directly use the index.
-- --
explain analyze SELECT * FROM person WHERE firstname IN ('FirstName1', 'FirstName2') AND lastname='LastName1'; 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')
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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
...@@ -4,22 +4,13 @@ ...@@ -4,22 +4,13 @@
-- --
explain select * from system_range(1, 2) where x=x+1 and x=1; 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))
> ---------------------------------------------------------------------------------------------------------------------------------
> 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
explain select * from system_range(1, 2) where not (x = 1 and x*2 = 2); 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)
> -------------------------------------------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX */ WHERE (X <> 1) OR ((X * 2) <> 2)
> rows: 1
explain select * from system_range(1, 10) where (NOT x >= 5); 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
> ------------------------------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 10) /* PUBLIC.RANGE_INDEX: X < 5 */ WHERE X < 5
> rows: 1
select (select t1.x from system_range(1,1) t2) from system_range(1,1) t1; 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 */ > 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; ...@@ -28,23 +19,14 @@ select (select t1.x from system_range(1,1) t2) from system_range(1,1) t1;
> rows: 1 > rows: 1
EXPLAIN PLAN FOR SELECT * FROM SYSTEM_RANGE(1, 20); EXPLAIN PLAN FOR SELECT * FROM SYSTEM_RANGE(1, 20);
> PLAN >> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 20) /* PUBLIC.RANGE_INDEX */
> -----------------------------------------------------------------------
> SELECT SYSTEM_RANGE.X FROM SYSTEM_RANGE(1, 20) /* PUBLIC.RANGE_INDEX */
> rows: 1
select sum(x) from system_range(2, 1000) r where 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); not exists(select * from system_range(2, 32) r2 where r.x>r2.x and mod(r.x, r2.x)=0);
> SUM(X) >> 76127
> ------
> 76127
> rows: 1
SELECT COUNT(*) FROM SYSTEM_RANGE(0, 2111222333); SELECT COUNT(*) FROM SYSTEM_RANGE(0, 2111222333);
> COUNT(*) >> 2111222334
> ----------
> 2111222334
> rows: 1
select * from system_range(2, 100) r where 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); 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); ...@@ -148,19 +130,13 @@ SELECT COUNT(*) FROM SYSTEM_RANGE(10, 2, -2);
>> 5 >> 5
SELECT * FROM SYSTEM_RANGE(1, 1); SELECT * FROM SYSTEM_RANGE(1, 1);
> X >> 1
> -
> 1
> rows: 1
SELECT COUNT(*) FROM SYSTEM_RANGE(1, 1); SELECT COUNT(*) FROM SYSTEM_RANGE(1, 1);
>> 1 >> 1
SELECT * FROM SYSTEM_RANGE(1, 1, -1); SELECT * FROM SYSTEM_RANGE(1, 1, -1);
> X >> 1
> -
> 1
> rows: 1
SELECT COUNT(*) FROM SYSTEM_RANGE(1, 1, -1); SELECT COUNT(*) FROM SYSTEM_RANGE(1, 1, -1);
>> 1 >> 1
......
...@@ -773,3 +773,5 @@ opti excessively ...@@ -773,3 +773,5 @@ opti excessively
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
geometries sourceschema destschema generatedcolumn alphanumerically usages geometries sourceschema destschema generatedcolumn alphanumerically usages
sizable instantiates renders sdt txcommit unhelpful optimiser treats rejects referring untrusted computes vacate inverted
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论