Unverified 提交 5dab1f7f authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1658 from h2database/assorti

Assorted small changes
...@@ -1519,8 +1519,8 @@ public class Parser { ...@@ -1519,8 +1519,8 @@ public class Parser {
queryAlias, querySQLOutput[0], queryAlias, querySQLOutput[0],
columnTemplateList, false/* no recursion */, columnTemplateList, false/* no recursion */,
false/* do not add to session */, false/* do not add to session */,
true /* isTemporary */, true /* isTemporary */
session); );
TableFilter sourceTableFilter = new TableFilter(session, TableFilter sourceTableFilter = new TableFilter(session,
temporarySourceTableView, queryAlias, temporarySourceTableView, queryAlias,
rightsChecked, (Select) command.getQuery(), 0, null); rightsChecked, (Select) command.getQuery(), 0, null);
...@@ -6254,7 +6254,6 @@ public class Parser { ...@@ -6254,7 +6254,6 @@ public class Parser {
} else { } else {
session.removeLocalTempTable(oldViewFound); session.removeLocalTempTable(oldViewFound);
} }
oldViewFound = null;
} }
/* /*
* This table is created as a workaround because recursive table * This table is created as a workaround because recursive table
...@@ -6284,13 +6283,13 @@ public class Parser { ...@@ -6284,13 +6283,13 @@ public class Parser {
querySQLOutput[0], columnTemplateList, querySQLOutput[0], columnTemplateList,
true/* allowRecursiveQueryDetection */, true/* allowRecursiveQueryDetection */,
true/* add to session */, true/* add to session */,
isTemporary, session); isTemporary);
} }
private TableView createCTEView(String cteViewName, String querySQL, private TableView createCTEView(String cteViewName, String querySQL,
List<Column> columnTemplateList, boolean allowRecursiveQueryDetection, List<Column> columnTemplateList, boolean allowRecursiveQueryDetection,
boolean addViewToSession, boolean isTemporary, Session targetSession) { boolean addViewToSession, boolean isTemporary) {
Database db = targetSession.getDatabase(); Database db = session.getDatabase();
Schema schema = getSchemaWithDefault(); Schema schema = getSchemaWithDefault();
int id = db.allocateObjectId(); int id = db.allocateObjectId();
Column[] columnTemplateArray = columnTemplateList.toArray(new Column[0]); Column[] columnTemplateArray = columnTemplateList.toArray(new Column[0]);
...@@ -6299,26 +6298,26 @@ public class Parser { ...@@ -6299,26 +6298,26 @@ public class Parser {
// it twice - once without the flag set, and if we didn't see a recursive term, // it twice - once without the flag set, and if we didn't see a recursive term,
// then we just compile it again. // then we just compile it again.
TableView view; TableView view;
synchronized (targetSession) { synchronized (session) {
view = new TableView(schema, id, cteViewName, querySQL, view = new TableView(schema, id, cteViewName, querySQL,
parameters, columnTemplateArray, targetSession, parameters, columnTemplateArray, session,
allowRecursiveQueryDetection, false /* literalsChecked */, true /* isTableExpression */, allowRecursiveQueryDetection, false /* literalsChecked */, true /* isTableExpression */,
isTemporary); isTemporary);
if (!view.isRecursiveQueryDetected() && allowRecursiveQueryDetection) { if (!view.isRecursiveQueryDetected() && allowRecursiveQueryDetection) {
if (!isTemporary) { if (!isTemporary) {
db.addSchemaObject(targetSession, view); db.addSchemaObject(session, view);
view.lock(targetSession, true, true); view.lock(session, true, true);
db.removeSchemaObject(targetSession, view); db.removeSchemaObject(session, view);
} else { } else {
session.removeLocalTempTable(view); session.removeLocalTempTable(view);
} }
view = new TableView(schema, id, cteViewName, querySQL, parameters, view = new TableView(schema, id, cteViewName, querySQL, parameters,
columnTemplateArray, targetSession, columnTemplateArray, session,
false/* assume recursive */, false /* literalsChecked */, true /* isTableExpression */, false/* assume recursive */, false /* literalsChecked */, true /* isTableExpression */,
isTemporary); isTemporary);
} }
// both removeSchemaObject and removeLocalTempTable hold meta locks // both removeSchemaObject and removeLocalTempTable hold meta locks
db.unlockMeta(targetSession); db.unlockMeta(session);
} }
view.setTableExpression(true); view.setTableExpression(true);
view.setTemporary(isTemporary); view.setTemporary(isTemporary);
...@@ -6326,11 +6325,11 @@ public class Parser { ...@@ -6326,11 +6325,11 @@ public class Parser {
view.setOnCommitDrop(false); view.setOnCommitDrop(false);
if (addViewToSession) { if (addViewToSession) {
if (!isTemporary) { if (!isTemporary) {
db.addSchemaObject(targetSession, view); db.addSchemaObject(session, view);
view.unlock(targetSession); view.unlock(session);
db.unlockMeta(targetSession); db.unlockMeta(session);
} else { } else {
targetSession.addLocalTempTable(view); session.addLocalTempTable(view);
} }
} }
return view; return view;
......
...@@ -162,7 +162,7 @@ public class IndexCursor implements Cursor { ...@@ -162,7 +162,7 @@ public class IndexCursor implements Cursor {
if (intersects != null && index instanceof SpatialIndex) { if (intersects != null && index instanceof SpatialIndex) {
cursor = ((SpatialIndex) index).findByGeometry(tableFilter, cursor = ((SpatialIndex) index).findByGeometry(tableFilter,
start, end, intersects); start, end, intersects);
} else { } else if (index != null) {
cursor = index.find(tableFilter, start, end); cursor = index.find(tableFilter, start, end);
} }
} }
......
...@@ -322,9 +322,9 @@ public class Sequence extends SchemaObjectBase { ...@@ -322,9 +322,9 @@ public class Sequence extends SchemaObjectBase {
database.updateMeta(session, this); database.updateMeta(session, this);
} finally { } finally {
writeWithMargin = false; writeWithMargin = false;
} if (!metaWasLocked) {
if (!metaWasLocked) { database.unlockMeta(session);
database.unlockMeta(session); }
} }
} }
......
...@@ -21,8 +21,8 @@ import java.util.Random; ...@@ -21,8 +21,8 @@ import java.util.Random;
public class BenchB implements Bench, Runnable { public class BenchB implements Bench, Runnable {
private static final int SCALE = 4; private static final int SCALE = 4;
private static final int BRANCHES = 1; private static final int BRANCHES = 10;
private static final int TELLERS = 10; private static final int TELLERS = 100;
private static final int ACCOUNTS = 100000; private static final int ACCOUNTS = 100000;
private int threadCount = 10; private int threadCount = 10;
......
...@@ -108,3 +108,20 @@ SET BUILTIN_ALIAS_OVERRIDE=0; ...@@ -108,3 +108,20 @@ SET BUILTIN_ALIAS_OVERRIDE=0;
DROP SCHEMA TEST_SCHEMA RESTRICT; DROP SCHEMA TEST_SCHEMA RESTRICT;
> ok > ok
-- test for issue #1531
CREATE TABLE TEST (ID BIGINT, VAL VARCHAR2(10)) AS SELECT x,'val'||x FROM SYSTEM_RANGE(1,2);
> ok
CREATE ALIAS FTBL AS $$ ResultSet t(Connection c) throws SQLException {return c.prepareStatement("SELECT ID, VAL FROM TEST").executeQuery();} $$;
> ok
CREATE OR REPLACE VIEW V_TEST (ID, VAL) AS (SELECT * FROM FTBL());
> ok
SELECT * FROM V_TEST;
> ID VAL
> -- ----
> 1 val1
> 2 val2
> rows: 2
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论