提交 5f78b1cb authored 作者: Owner's avatar Owner

Reverted to UNKNOWN column types for create view

上级 e3e6fa9f
...@@ -103,24 +103,29 @@ public class CreateView extends SchemaCommand { ...@@ -103,24 +103,29 @@ public class CreateView extends SchemaCommand {
} }
querySQL = select.getPlanSQL(); querySQL = select.getPlanSQL();
} }
Column[] columnTemplates = null; Column[] columnTemplatesAsUnknowns = null;
Column[] columnTemplatesAsStrings = null;
if (columnNames != null) { if (columnNames != null) {
columnTemplates = new Column[columnNames.length]; columnTemplatesAsUnknowns = new Column[columnNames.length];
columnTemplatesAsStrings = new Column[columnNames.length];
for (int i = 0; i < columnNames.length; ++i) { for (int i = 0; i < columnNames.length; ++i) {
columnTemplates[i] = new Column(columnNames[i], Value.STRING); // non table expressions are fine to use unknown column type
columnTemplatesAsUnknowns[i] = new Column(columnNames[i], Value.UNKNOWN);
// table expressions can't have unknown types - so we use string instead
columnTemplatesAsStrings[i] = new Column(columnNames[i], Value.STRING);
} }
} }
if (view == null) { if (view == null) {
if(isTableExpression){ if(isTableExpression){
view = TableView.createTableViewMaybeRecursive(getSchema(), id, viewName, querySQL, null, columnTemplates, session, false /* literalsChecked */, isTableExpression, true /*isPersistent*/ , db); view = TableView.createTableViewMaybeRecursive(getSchema(), id, viewName, querySQL, null, columnTemplatesAsStrings, session, false /* literalsChecked */, isTableExpression, true /*isPersistent*/ , db);
} }
else else
{ {
view = new TableView(getSchema(), id, viewName, querySQL, null, columnTemplates, session, false/* allow recursive */, false/* literalsChecked */, isTableExpression, true); view = new TableView(getSchema(), id, viewName, querySQL, null, columnTemplatesAsUnknowns, session, false/* allow recursive */, false/* literalsChecked */, isTableExpression, true);
} }
} else { } else {
// TODO support isTableExpression in replace function... // TODO support isTableExpression in replace function...
view.replace(querySQL, columnTemplates, session, false, force, false); view.replace(querySQL, columnTemplatesAsUnknowns, session, false, force, false);
view.setModified(); view.setModified();
} }
if (comment != null) { if (comment != null) {
......
...@@ -402,20 +402,20 @@ public class MVTable extends TableBase { ...@@ -402,20 +402,20 @@ public class MVTable extends TableBase {
exclusive ? "exclusive write lock" : "shared read lock", statusText, exclusive ? "exclusive write lock" : "shared read lock", statusText,
getName()); getName());
// create a stack trace when the lock is granted so we can debug where that was... // // create a stack trace when the lock is granted so we can debug where that was...
if(statusText.equals(TRACE_LOCK_ADDED_FOR) || statusText.equals(TRACE_LOCK_ADD_UPGRADED_FOR)){ // if(statusText.equals(TRACE_LOCK_ADDED_FOR) || statusText.equals(TRACE_LOCK_ADD_UPGRADED_FOR)){
lockExclusiveSessionStackTrace = new Throwable("trace lock - lock granted stack trace"); // lockExclusiveSessionStackTrace = new Throwable("trace lock - lock granted stack trace");
} // }
//
// clear the stack trace of the granted lock, on unlock // // clear the stack trace of the granted lock, on unlock
if(statusText.equals(TRACE_LOCK_UNLOCK)){ // if(statusText.equals(TRACE_LOCK_UNLOCK)){
lockExclusiveSessionStackTrace = null; // lockExclusiveSessionStackTrace = null;
} // }
//
// show the stack trace where the lock was granted, if a timeout happens... // // show the stack trace where the lock was granted, if a timeout happens...
if(statusText.contains(TRACE_LOCK_TIMEOUT_AFTER) && lockExclusiveSessionStackTrace!=null){ // if(statusText.contains(TRACE_LOCK_TIMEOUT_AFTER) && lockExclusiveSessionStackTrace!=null){
lockExclusiveSessionStackTrace.printStackTrace(); // lockExclusiveSessionStackTrace.printStackTrace();
} // }
} }
} }
......
...@@ -598,7 +598,7 @@ public class TestGeneralCommonTableQueries extends TestBase { ...@@ -598,7 +598,7 @@ public class TestGeneralCommonTableQueries extends TestBase {
; ;
String WITH_QUERY = "SELECT * FROM v_my_nr_tree"; String WITH_QUERY = "SELECT * FROM v_my_nr_tree";
int maxRetries = 4; int maxRetries = 6;
String[] expectedRowData =new String[]{ String[] expectedRowData =new String[]{
"|1|0|null|1", "|1|0|null|1",
"|11|0|1|11", "|11|0|1|11",
...@@ -622,7 +622,7 @@ public class TestGeneralCommonTableQueries extends TestBase { ...@@ -622,7 +622,7 @@ public class TestGeneralCommonTableQueries extends TestBase {
for(int queryRunTries=1;queryRunTries<=maxRetries;queryRunTries++){ for(int queryRunTries=1;queryRunTries<=maxRetries;queryRunTries++){
//System.out.println("==================================== Iteration #"+queryRunTries); System.out.println("==================================== Iteration #"+queryRunTries);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute(SETUP_SQL); stat.execute(SETUP_SQL);
...@@ -630,12 +630,12 @@ public class TestGeneralCommonTableQueries extends TestBase { ...@@ -630,12 +630,12 @@ public class TestGeneralCommonTableQueries extends TestBase {
// close and re-open connection for one iteration to make sure the query work between connections // close and re-open connection for one iteration to make sure the query work between connections
if(queryRunTries==closeAndReopenDatabaseConnectionOnIteration){ if(queryRunTries==closeAndReopenDatabaseConnectionOnIteration){
//System.out.println("Reconnecting to database on iteration#"+queryRunTries+" of "+maxRetries); System.out.println("Reconnecting to database on iteration#"+queryRunTries+" of "+maxRetries);
conn.close(); conn.close();
conn = getConnection("commonTableExpressionQueries"); conn = getConnection("commonTableExpressionQueries");
} }
//System.out.println("=========== test with query"); System.out.println("=========== test with query");
prep = conn.prepareStatement(WITH_QUERY); prep = conn.prepareStatement(WITH_QUERY);
rs = prep.executeQuery(); rs = prep.executeQuery();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论