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 {
queryAlias, querySQLOutput[0],
columnTemplateList, false/* no recursion */,
false/* do not add to session */,
true /* isTemporary */,
session);
true /* isTemporary */
);
TableFilter sourceTableFilter = new TableFilter(session,
temporarySourceTableView, queryAlias,
rightsChecked, (Select) command.getQuery(), 0, null);
......@@ -6254,7 +6254,6 @@ public class Parser {
} else {
session.removeLocalTempTable(oldViewFound);
}
oldViewFound = null;
}
/*
* This table is created as a workaround because recursive table
......@@ -6284,13 +6283,13 @@ public class Parser {
querySQLOutput[0], columnTemplateList,
true/* allowRecursiveQueryDetection */,
true/* add to session */,
isTemporary, session);
isTemporary);
}
private TableView createCTEView(String cteViewName, String querySQL,
List<Column> columnTemplateList, boolean allowRecursiveQueryDetection,
boolean addViewToSession, boolean isTemporary, Session targetSession) {
Database db = targetSession.getDatabase();
private TableView createCTEView(String cteViewName, String querySQL,
List<Column> columnTemplateList, boolean allowRecursiveQueryDetection,
boolean addViewToSession, boolean isTemporary) {
Database db = session.getDatabase();
Schema schema = getSchemaWithDefault();
int id = db.allocateObjectId();
Column[] columnTemplateArray = columnTemplateList.toArray(new Column[0]);
......@@ -6299,26 +6298,26 @@ public class Parser {
// it twice - once without the flag set, and if we didn't see a recursive term,
// then we just compile it again.
TableView view;
synchronized (targetSession) {
synchronized (session) {
view = new TableView(schema, id, cteViewName, querySQL,
parameters, columnTemplateArray, targetSession,
parameters, columnTemplateArray, session,
allowRecursiveQueryDetection, false /* literalsChecked */, true /* isTableExpression */,
isTemporary);
if (!view.isRecursiveQueryDetected() && allowRecursiveQueryDetection) {
if (!isTemporary) {
db.addSchemaObject(targetSession, view);
view.lock(targetSession, true, true);
db.removeSchemaObject(targetSession, view);
db.addSchemaObject(session, view);
view.lock(session, true, true);
db.removeSchemaObject(session, view);
} else {
session.removeLocalTempTable(view);
}
view = new TableView(schema, id, cteViewName, querySQL, parameters,
columnTemplateArray, targetSession,
columnTemplateArray, session,
false/* assume recursive */, false /* literalsChecked */, true /* isTableExpression */,
isTemporary);
}
// both removeSchemaObject and removeLocalTempTable hold meta locks
db.unlockMeta(targetSession);
db.unlockMeta(session);
}
view.setTableExpression(true);
view.setTemporary(isTemporary);
......@@ -6326,11 +6325,11 @@ public class Parser {
view.setOnCommitDrop(false);
if (addViewToSession) {
if (!isTemporary) {
db.addSchemaObject(targetSession, view);
view.unlock(targetSession);
db.unlockMeta(targetSession);
db.addSchemaObject(session, view);
view.unlock(session);
db.unlockMeta(session);
} else {
targetSession.addLocalTempTable(view);
session.addLocalTempTable(view);
}
}
return view;
......
......@@ -162,7 +162,7 @@ public class IndexCursor implements Cursor {
if (intersects != null && index instanceof SpatialIndex) {
cursor = ((SpatialIndex) index).findByGeometry(tableFilter,
start, end, intersects);
} else {
} else if (index != null) {
cursor = index.find(tableFilter, start, end);
}
}
......
......@@ -322,9 +322,9 @@ public class Sequence extends SchemaObjectBase {
database.updateMeta(session, this);
} finally {
writeWithMargin = false;
}
if (!metaWasLocked) {
database.unlockMeta(session);
if (!metaWasLocked) {
database.unlockMeta(session);
}
}
}
......
......@@ -21,8 +21,8 @@ import java.util.Random;
public class BenchB implements Bench, Runnable {
private static final int SCALE = 4;
private static final int BRANCHES = 1;
private static final int TELLERS = 10;
private static final int BRANCHES = 10;
private static final int TELLERS = 100;
private static final int ACCOUNTS = 100000;
private int threadCount = 10;
......
......@@ -108,3 +108,20 @@ SET BUILTIN_ALIAS_OVERRIDE=0;
DROP SCHEMA TEST_SCHEMA RESTRICT;
> 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论