提交 9a3f0ccd authored 作者: Andrei Tokar's avatar Andrei Tokar

eliminate useless session parameter

上级 596a4bdb
...@@ -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;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论