提交 56466880 authored 作者: Thomas Mueller's avatar Thomas Mueller

New experimental system property "h2.modifyOnWrite".

上级 7936f195
...@@ -95,22 +95,43 @@ public class LobStorage { ...@@ -95,22 +95,43 @@ public class LobStorage {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
// stat.execute("SET UNDO_LOG 0"); // stat.execute("SET UNDO_LOG 0");
// stat.execute("SET REDO_LOG_BINARY 0"); // stat.execute("SET REDO_LOG_BINARY 0");
stat.execute("CREATE TABLE IF NOT EXISTS " + LOBS + boolean create = true;
"(ID BIGINT PRIMARY KEY, BYTE_COUNT BIGINT, TABLE INT) HIDDEN"); PreparedStatement prep = conn.prepareStatement(
stat.execute("CREATE INDEX IF NOT EXISTS " + "SELECT ZERO() FROM INFORMATION_SCHEMA.COLUMNS WHERE " +
"INFORMATION_SCHEMA.INDEX_LOB_TABLE ON " + LOBS + "(TABLE)"); "TABLE_SCHEMA=? AND TABLE_NAME=? AND COLUMN_NAME=?");
stat.execute("CREATE TABLE IF NOT EXISTS " + LOB_MAP + prep.setString(1, "INFORMATION_SCHEMA");
"(LOB BIGINT, SEQ INT, POS BIGINT, HASH INT, BLOCK BIGINT, PRIMARY KEY(LOB, SEQ)) HIDDEN"); prep.setString(2, "LOB_MAP");
// TODO the column name OFFSET was used in version 1.3.156, prep.setString(3, "POS");
// so this can be remove in a later version
stat.execute("ALTER TABLE " + LOB_MAP + " RENAME TO " + LOB_MAP + " HIDDEN");
stat.execute("ALTER TABLE " + LOB_MAP + " ADD IF NOT EXISTS POS BIGINT BEFORE HASH");
stat.execute("ALTER TABLE " + LOB_MAP + " DROP COLUMN IF EXISTS \"OFFSET\"");
stat.execute("CREATE INDEX IF NOT EXISTS " +
"INFORMATION_SCHEMA.INDEX_LOB_MAP_DATA_LOB ON " + LOB_MAP + "(BLOCK, LOB)");
stat.execute("CREATE TABLE IF NOT EXISTS " + LOB_DATA +
"(BLOCK BIGINT PRIMARY KEY, COMPRESSED INT, DATA BINARY) HIDDEN");
ResultSet rs; ResultSet rs;
rs = prep.executeQuery();
if (rs.next()) {
prep = conn.prepareStatement(
"SELECT ZERO() FROM INFORMATION_SCHEMA.TABLES WHERE " +
"TABLE_SCHEMA=? AND TABLE_NAME=?");
prep.setString(1, "INFORMATION_SCHEMA");
prep.setString(2, "LOB_DATA");
rs = prep.executeQuery();
if (rs.next()) {
create = false;
}
}
if (create) {
stat.execute("CREATE CACHED TABLE IF NOT EXISTS " + LOBS +
"(ID BIGINT PRIMARY KEY, BYTE_COUNT BIGINT, TABLE INT) HIDDEN");
stat.execute("CREATE INDEX IF NOT EXISTS " +
"INFORMATION_SCHEMA.INDEX_LOB_TABLE ON " + LOBS + "(TABLE)");
stat.execute("CREATE CACHED TABLE IF NOT EXISTS " + LOB_MAP +
"(LOB BIGINT, SEQ INT, POS BIGINT, HASH INT, BLOCK BIGINT, PRIMARY KEY(LOB, SEQ)) HIDDEN");
// TODO the column name OFFSET was used in version 1.3.156,
// so this can be remove in a later version
stat.execute("ALTER TABLE " + LOB_MAP + " RENAME TO " + LOB_MAP + " HIDDEN");
stat.execute("ALTER TABLE " + LOB_MAP + " ADD IF NOT EXISTS POS BIGINT BEFORE HASH");
stat.execute("ALTER TABLE " + LOB_MAP + " DROP COLUMN IF EXISTS \"OFFSET\"");
stat.execute("CREATE INDEX IF NOT EXISTS " +
"INFORMATION_SCHEMA.INDEX_LOB_MAP_DATA_LOB ON " + LOB_MAP + "(BLOCK, LOB)");
stat.execute("CREATE CACHED TABLE IF NOT EXISTS " + LOB_DATA +
"(BLOCK BIGINT PRIMARY KEY, COMPRESSED INT, DATA BINARY) HIDDEN");
}
rs = stat.executeQuery("SELECT MAX(BLOCK) FROM " + LOB_DATA); rs = stat.executeQuery("SELECT MAX(BLOCK) FROM " + LOB_DATA);
rs.next(); rs.next();
nextBlock = rs.getLong(1) + 1; nextBlock = rs.getLong(1) + 1;
......
...@@ -601,6 +601,10 @@ public class MetaTable extends Table { ...@@ -601,6 +601,10 @@ public class MetaTable extends Table {
return s == null ? "" : s; return s == null ? "" : s;
} }
private boolean hideTable(Table table, Session session) {
return table.isHidden() && session != database.getSystemSession();
}
/** /**
* Generate the data for the given metadata table using the given first and * Generate the data for the given metadata table using the given first and
* last row filters. * last row filters.
...@@ -632,7 +636,7 @@ public class MetaTable extends Table { ...@@ -632,7 +636,7 @@ public class MetaTable extends Table {
if (!checkIndex(session, tableName, indexFrom, indexTo)) { if (!checkIndex(session, tableName, indexFrom, indexTo)) {
continue; continue;
} }
if (table.isHidden()) { if (hideTable(table, session)) {
continue; continue;
} }
String storageType; String storageType;
...@@ -678,7 +682,7 @@ public class MetaTable extends Table { ...@@ -678,7 +682,7 @@ public class MetaTable extends Table {
if (!checkIndex(session, tableName, indexFrom, indexTo)) { if (!checkIndex(session, tableName, indexFrom, indexTo)) {
continue; continue;
} }
if (table.isHidden()) { if (hideTable(table, session)) {
continue; continue;
} }
Column[] cols = table.getColumns(); Column[] cols = table.getColumns();
...@@ -744,7 +748,7 @@ public class MetaTable extends Table { ...@@ -744,7 +748,7 @@ public class MetaTable extends Table {
if (!checkIndex(session, tableName, indexFrom, indexTo)) { if (!checkIndex(session, tableName, indexFrom, indexTo)) {
continue; continue;
} }
if (table.isHidden()) { if (hideTable(table, session)) {
continue; continue;
} }
ArrayList<Index> indexes = table.getIndexes(); ArrayList<Index> indexes = table.getIndexes();
...@@ -1209,7 +1213,7 @@ public class MetaTable extends Table { ...@@ -1209,7 +1213,7 @@ public class MetaTable extends Table {
case TABLE_PRIVILEGES: { case TABLE_PRIVILEGES: {
for (Right r : database.getAllRights()) { for (Right r : database.getAllRights()) {
Table table = r.getGrantedTable(); Table table = r.getGrantedTable();
if (table == null || table.isHidden()) { if (table == null || hideTable(table, session)) {
continue; continue;
} }
String tableName = identifier(table.getName()); String tableName = identifier(table.getName());
...@@ -1223,7 +1227,7 @@ public class MetaTable extends Table { ...@@ -1223,7 +1227,7 @@ public class MetaTable extends Table {
case COLUMN_PRIVILEGES: { case COLUMN_PRIVILEGES: {
for (Right r : database.getAllRights()) { for (Right r : database.getAllRights()) {
Table table = r.getGrantedTable(); Table table = r.getGrantedTable();
if (table == null || table.isHidden()) { if (table == null || hideTable(table, session)) {
continue; continue;
} }
String tableName = identifier(table.getName()); String tableName = identifier(table.getName());
...@@ -1355,7 +1359,7 @@ public class MetaTable extends Table { ...@@ -1355,7 +1359,7 @@ public class MetaTable extends Table {
String checkExpression = null; String checkExpression = null;
IndexColumn[] indexColumns = null; IndexColumn[] indexColumns = null;
Table table = constraint.getTable(); Table table = constraint.getTable();
if (table.isHidden()) { if (hideTable(table, session)) {
continue; continue;
} }
Index index = constraint.getUniqueIndex(); Index index = constraint.getUniqueIndex();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论