提交 f4a652d2 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix many issuses with ./build.sh docs with sources

* Trailing whitespace
* Wrong identation
* Long lines
* Line endings
上级 ca7e0c55
...@@ -1136,7 +1136,8 @@ public class Parser { ...@@ -1136,7 +1136,8 @@ public class Parser {
command.setQueryAlias(readFromAlias(null, Arrays.asList("ON"))); command.setQueryAlias(readFromAlias(null, Arrays.asList("ON")));
String[] querySQLOutput = new String[]{null}; String[] querySQLOutput = new String[]{null};
List<Column> columnTemplateList = TableView.createQueryColumnTemplateList(null, command.getQuery(), querySQLOutput); List<Column> columnTemplateList = TableView.createQueryColumnTemplateList(null, command.getQuery(),
querySQLOutput);
TableView temporarySourceTableView = createCTEView( TableView temporarySourceTableView = createCTEView(
command.getQueryAlias(), querySQLOutput[0], command.getQueryAlias(), querySQLOutput[0],
columnTemplateList, false/* no recursion */, columnTemplateList, false/* no recursion */,
...@@ -5154,8 +5155,8 @@ public class Parser { ...@@ -5154,8 +5155,8 @@ public class Parser {
List<TableView> viewsCreated = new ArrayList<>(); List<TableView> viewsCreated = new ArrayList<>();
readIf("RECURSIVE"); readIf("RECURSIVE");
// this WITH statement might not be a temporary view - allow optional keyword to tell us that // this WITH statement might not be a temporary view - allow optional keyword to
// this keyword. This feature will not be documented - H2 internal use only. // tell us that this keyword. This feature will not be documented - H2 internal use only.
boolean isPersistent = readIf("PERSISTENT"); boolean isPersistent = readIf("PERSISTENT");
// this WITH statement is not a temporary view - it is part of a persistent view // this WITH statement is not a temporary view - it is part of a persistent view
...@@ -5307,7 +5308,8 @@ public class Parser { ...@@ -5307,7 +5308,8 @@ public class Parser {
synchronized (targetSession) { synchronized (targetSession) {
view = new TableView(schema, id, cteViewName, querySQL, view = new TableView(schema, id, cteViewName, querySQL,
parameters, columnTemplateArray, targetSession, parameters, columnTemplateArray, targetSession,
allowRecursiveQueryDetection, false /* literalsChecked */, true /* isTableExpression */, isPersistent); allowRecursiveQueryDetection, false /* literalsChecked */, true /* isTableExpression */,
isPersistent);
if (!view.isRecursiveQueryDetected() && allowRecursiveQueryDetection) { if (!view.isRecursiveQueryDetected() && allowRecursiveQueryDetection) {
if (isPersistent) { if (isPersistent) {
db.addSchemaObject(targetSession, view); db.addSchemaObject(targetSession, view);
...@@ -5318,7 +5320,8 @@ public class Parser { ...@@ -5318,7 +5320,8 @@ public class Parser {
} }
view = new TableView(schema, id, cteViewName, querySQL, parameters, view = new TableView(schema, id, cteViewName, querySQL, parameters,
columnTemplateArray, targetSession, columnTemplateArray, targetSession,
false/* assume recursive */, false /* literalsChecked */, true /* isTableExpression */, isPersistent); false/* assume recursive */, false /* literalsChecked */, true /* isTableExpression */,
isPersistent);
} }
// both removeSchemaObject and removeLocalTempTable hold meta locks // both removeSchemaObject and removeLocalTempTable hold meta locks
targetSession.getDatabase().unlockMeta(targetSession); targetSession.getDatabase().unlockMeta(targetSession);
......
...@@ -117,9 +117,12 @@ public class CreateView extends SchemaCommand { ...@@ -117,9 +117,12 @@ public class CreateView extends SchemaCommand {
} }
if (view == null) { if (view == null) {
if (isTableExpression) { if (isTableExpression) {
view = TableView.createTableViewMaybeRecursive(getSchema(), id, viewName, querySQL, null, columnTemplatesAsStrings, 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, columnTemplatesAsUnknowns, 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...
......
...@@ -1064,8 +1064,9 @@ public class Select extends Query { ...@@ -1064,8 +1064,9 @@ public class Select extends Query {
if (tableView != null && tableView.isRecursive() && tableView.isTableExpression()) { if (tableView != null && tableView.isRecursive() && tableView.isTableExpression()) {
if (tableView.isPersistent()) { if (tableView.isPersistent()) {
// skip the generation of plan SQL for this already recursive persistent ctes, since using a with // skip the generation of plan SQL for this already recursive persistent CTEs,
// statement will re-create the common table expression views. // since using a with statement will re-create the common table expression
// views.
continue; continue;
} else { } else {
buff.append("WITH RECURSIVE ").append(t.getName()).append('('); buff.append("WITH RECURSIVE ").append(t.getName()).append('(');
......
...@@ -67,7 +67,8 @@ public class TableView extends Table { ...@@ -67,7 +67,8 @@ public class TableView extends Table {
ArrayList<Parameter> params, Column[] columnTemplates, Session session, ArrayList<Parameter> params, Column[] columnTemplates, Session session,
boolean allowRecursive, boolean literalsChecked, boolean isTableExpression, boolean isPersistent) { boolean allowRecursive, boolean literalsChecked, boolean isTableExpression, boolean isPersistent) {
super(schema, id, name, false, true); super(schema, id, name, false, true);
init(querySQL, params, columnTemplates, session, allowRecursive, literalsChecked, isTableExpression, isPersistent); init(querySQL, params, columnTemplates, session, allowRecursive, literalsChecked, isTableExpression,
isPersistent);
} }
/** /**
...@@ -746,15 +747,17 @@ public class TableView extends Table { ...@@ -746,15 +747,17 @@ public class TableView extends Table {
parameters, columnTemplateList.toArray(columnTemplates), session, parameters, columnTemplateList.toArray(columnTemplates), session,
true/* try recursive */, literalsChecked, isTableExpression, isPersistent); true/* try recursive */, literalsChecked, isTableExpression, isPersistent);
// is recursion really detected ? if not - recreate it without recursion flag and no recursive index // is recursion really detected ? if not - recreate it without recursion flag
// and no recursive index
if (!view.isRecursiveQueryDetected()) { if (!view.isRecursiveQueryDetected()) {
if (isPersistent) { if (isPersistent) {
db.addSchemaObject(session, view); db.addSchemaObject(session, view);
view.lock(session, true, true); view.lock(session, true, true);
session.getDatabase().removeSchemaObject(session, view); session.getDatabase().removeSchemaObject(session, view);
// during database startup - this method does not normally get called - and it needs to be // during database startup - this method does not normally get called - and it
// to correctly un-register the table which the table expression uses... // needs to be to correctly un-register the table which the table expression
// uses...
view.removeChildrenAndResources(session); view.removeChildrenAndResources(session);
} else { } else {
session.removeLocalTempTable(view); session.removeLocalTempTable(view);
......
...@@ -11,27 +11,29 @@ import java.sql.ResultSet; ...@@ -11,27 +11,29 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
* Base class for common table expression tests * Base class for common table expression tests
*/ */
public abstract class AbstractBaseForCommonTableExpressions extends TestBase { public abstract class AbstractBaseForCommonTableExpressions extends TestBase {
protected void testRepeatedQueryWithSetup(int maxRetries, String[] expectedRowData, String[] expectedColumnNames, int expectedNumbeOfRows, String setupSQL, protected void testRepeatedQueryWithSetup(int maxRetries, String[] expectedRowData, String[] expectedColumnNames,
String withQuery, int closeAndReopenDatabaseConnectionOnIteration, String[] expectedColumnTypes) throws SQLException { int expectedNumbeOfRows, String setupSQL, String withQuery,
int closeAndReopenDatabaseConnectionOnIteration, String[] expectedColumnTypes) throws SQLException {
deleteDb("commonTableExpressionQueries"); deleteDb("commonTableExpressionQueries");
Connection conn = getConnection("commonTableExpressionQueries"); Connection conn = getConnection("commonTableExpressionQueries");
PreparedStatement prep; PreparedStatement prep;
ResultSet rs; ResultSet rs;
for (int queryRunTries = 1; queryRunTries <= maxRetries; queryRunTries++) { for (int queryRunTries = 1; queryRunTries <= maxRetries; queryRunTries++) {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute(setupSQL); stat.execute(setupSQL);
stat.close(); stat.close();
// 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) {
conn.close(); conn.close();
...@@ -44,7 +46,9 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase { ...@@ -44,7 +46,9 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase {
assertTrue(rs.getMetaData().getColumnLabel(columnIndex) != null); assertTrue(rs.getMetaData().getColumnLabel(columnIndex) != null);
assertEquals(expectedColumnNames[columnIndex - 1], rs.getMetaData().getColumnLabel(columnIndex)); assertEquals(expectedColumnNames[columnIndex - 1], rs.getMetaData().getColumnLabel(columnIndex));
assertEquals("wrongly type column "+rs.getMetaData().getColumnLabel(columnIndex)+" on iteration#"+queryRunTries, assertEquals(
"wrongly type column " + rs.getMetaData().getColumnLabel(columnIndex) + " on iteration#"
+ queryRunTries,
expectedColumnTypes[columnIndex - 1], rs.getMetaData().getColumnTypeName(columnIndex)); expectedColumnTypes[columnIndex - 1], rs.getMetaData().getColumnTypeName(columnIndex));
} }
...@@ -52,7 +56,7 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase { ...@@ -52,7 +56,7 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase {
while (rs.next()) { while (rs.next()) {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
for (int columnIndex = 1; columnIndex <= rs.getMetaData().getColumnCount(); columnIndex++) { for (int columnIndex = 1; columnIndex <= rs.getMetaData().getColumnCount(); columnIndex++) {
buf.append("|"+rs.getString(columnIndex)); buf.append("|" + rs.getString(columnIndex));
} }
assertEquals(expectedRowData[rowNdx], buf.toString()); assertEquals(expectedRowData[rowNdx], buf.toString());
rowNdx++; rowNdx++;
......
...@@ -302,7 +302,8 @@ public class TestCases extends TestBase { ...@@ -302,7 +302,8 @@ public class TestCases extends TestBase {
throws SQLException { throws SQLException {
assertThrows(expectedDropSuccess ? 0 : ErrorCode.CANNOT_DROP_2, stat) assertThrows(expectedDropSuccess ? 0 : ErrorCode.CANNOT_DROP_2, stat)
.execute("drop table test " + (restrict ? "restrict" : "cascade")); .execute("drop table test " + (restrict ? "restrict" : "cascade"));
assertThrows(expectedDropSuccess ? ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1 : 0, stat).execute("select * from test"); assertThrows(expectedDropSuccess ? ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1 : 0, stat)
.execute("select * from test");
} }
private void testDropTableNoReference(final boolean stdDropTableRestrict, final boolean restrict) private void testDropTableNoReference(final boolean stdDropTableRestrict, final boolean restrict)
......
...@@ -2061,7 +2061,8 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -2061,7 +2061,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertThrows(ErrorCode.INVALID_VALUE_2, stat).execute("select signal('00145', 'success class is invalid')"); assertThrows(ErrorCode.INVALID_VALUE_2, stat).execute("select signal('00145', 'success class is invalid')");
assertThrows(ErrorCode.INVALID_VALUE_2, stat).execute("select signal('foo', 'SQLSTATE has 5 chars')"); assertThrows(ErrorCode.INVALID_VALUE_2, stat).execute("select signal('foo', 'SQLSTATE has 5 chars')");
assertThrows(ErrorCode.INVALID_VALUE_2, stat).execute("select signal('Ab123', 'SQLSTATE has only digits or upper-case letters')"); assertThrows(ErrorCode.INVALID_VALUE_2, stat)
.execute("select signal('Ab123', 'SQLSTATE has only digits or upper-case letters')");
try { try {
stat.execute("select signal('AB123', 'some custom error')"); stat.execute("select signal('AB123', 'some custom error')");
fail("Should have thrown"); fail("Should have thrown");
......
...@@ -526,8 +526,10 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp ...@@ -526,8 +526,10 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
config = new TestAll(); config = new TestAll();
try { try {
//Test with settings: lazy mvStore memory mvcc multiThreaded // Test with settings: lazy mvStore memory mvcc multiThreaded
// connection url is =mem:script;MV_STORE=true;LOG=1;LOCK_TIMEOUT=50;MVCC=TRUE;MULTI_THREADED=TRUE;LAZY_QUERY_EXECUTION=1 // connection url is
// mem:script;MV_STORE=true;LOG=1;LOCK_TIMEOUT=50;MVCC=TRUE;
// MULTI_THREADED=TRUE;LAZY_QUERY_EXECUTION=1
config.lazy = true; config.lazy = true;
config.mvStore = true; config.mvStore = true;
config.memory = true; config.memory = true;
...@@ -545,8 +547,8 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp ...@@ -545,8 +547,8 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
int maxRetries = 10; int maxRetries = 10;
int expectedNumberOfRows = expectedRowData.length; int expectedNumberOfRows = expectedRowData.length;
testRepeatedQueryWithSetup(maxRetries, expectedRowData, expectedColumnNames, expectedNumberOfRows, setupSQL, testRepeatedQueryWithSetup(maxRetries, expectedRowData, expectedColumnNames, expectedNumberOfRows,
withQuery, maxRetries - 1, expectedColumnTypes); setupSQL, withQuery, maxRetries - 1, expectedColumnTypes);
} finally { } finally {
config = backupConfig; config = backupConfig;
} }
......
...@@ -93,10 +93,11 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -93,10 +93,11 @@ public class TestMvccMultiThreaded2 extends TestBase {
} }
if (DISPLAY_STATS) { if (DISPLAY_STATS) {
System.out.println(String.format("+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, "+ System.out.println(String.format(
"totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n", "+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, "
TEST_THREAD_COUNT, minProcessed, maxProcessed, totalProcessed, totalProcessed/TEST_THREAD_COUNT, + "totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n",
totalProcessed/(TEST_THREAD_COUNT * TEST_TIME_SECONDS))); TEST_THREAD_COUNT, minProcessed, maxProcessed, totalProcessed, totalProcessed / TEST_THREAD_COUNT,
totalProcessed / (TEST_THREAD_COUNT * TEST_TIME_SECONDS)));
} }
IOUtils.closeSilently(conn); IOUtils.closeSilently(conn);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论