提交 88a516d1 authored 作者: Niklas Mehner's avatar Niklas Mehner

Fix "build doc" target (long line / missing copyright / words missing from dictionary)

上级 3049b1ed
......@@ -4031,7 +4031,7 @@ public class Parser {
// Check if any of them are disallowed in the current Mode
if (isIdentity && session.getDatabase().getMode().
disallowedTypes.contains("IDENTITY")) {
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1,
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1,
currentToken);
}
column = new Column(columnName, Value.LONG);
......
......@@ -293,7 +293,7 @@ public class Database implements DataHandler {
e.fillInStackTrace();
}
boolean alreadyOpen = e instanceof DbException
&& ((DbException)e).getErrorCode() == ErrorCode.DATABASE_ALREADY_OPEN_1;
&& ((DbException)e).getErrorCode() == ErrorCode.DATABASE_ALREADY_OPEN_1;
if (alreadyOpen) {
stopServer();
}
......
......@@ -174,7 +174,7 @@ public class Mode {
/**
* An optional Set of hidden/disallowed column types.
* Certain DBMSs don't support all column types provided by H2, such as
* Certain DBMSs don't support all column types provided by H2, such as
* "NUMBER" when using PostgreSQL mode.
*/
public Set<String> disallowedTypes = Collections.emptySet();
......
......@@ -202,7 +202,8 @@ public class Comparison extends Condition {
// to constant type, but vise versa, then let's do this here
// once.
if (constType != resType) {
right = ValueExpression.get(r.convertTo(resType, MathUtils.convertLongToInt(left.getPrecision()), session.getDatabase().getMode()));
right = ValueExpression.get(r.convertTo(resType,
MathUtils.convertLongToInt(left.getPrecision()), session.getDatabase().getMode()));
}
} else if (right instanceof Parameter) {
((Parameter) right).setColumn(
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.table;
import org.h2.command.ddl.CreateSynonymData;
......@@ -7,8 +12,8 @@ import org.h2.message.Trace;
import org.h2.schema.SchemaObjectBase;
/**
* Synonym for an existing table or view. All DML requests are forwarded to the backing table. Adding indices
* to a synonym or altering the table is not supported.
* Synonym for an existing table or view. All DML requests are forwarded to the backing table.
* Adding indices to a synonym or altering the table is not supported.
*/
public class TableSynonym extends SchemaObjectBase {
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.value;
import java.nio.charset.Charset;
......
......@@ -37,8 +37,8 @@ public class CompareMode {
public static final String ICU4J = "ICU4J_";
/**
* This constant means the charset specified should be used. This will fail if the specified charset does
* not exist.
* This constant means the charset specified should be used.
* This will fail if the specified charset does not exist.
*/
public static final String CHARSET = "CHARSET_";
......
......@@ -542,7 +542,7 @@ public abstract class Value {
* @return the converted value
*/
public Value convertTo(int targetType) {
// Use -1 to indicate "default behaviour" where value conversion should not
// Use -1 to indicate "default behaviour" where value conversion should not
// depend on any datatype precision.
return convertTo(targetType, -1, null);
}
......
......@@ -23,8 +23,8 @@ public class ValueStringFixed extends ValueString {
public static final int PRECISION_DO_NOT_TRIM = Integer.MIN_VALUE;
/**
* Special value for the precision in {@link #get(String, int, Mode)} to indicate that the default
* behaviour should of trimming the value should apply.
* Special value for the precision in {@link #get(String, int, Mode)} to indicate
* that the default behaviour should of trimming the value should apply.
*/
public static final int PRECISION_TRIM = -1;
......@@ -79,14 +79,16 @@ public class ValueStringFixed extends ValueString {
/**
* Get or create a fixed length string value for the given string.
* <p>
* This method will use a {@link Mode}-specific conversion when <code>mode</code> is not <code>null</code>.
* Otherwise it will use the default H2 behaviour of trimming the given string if <code>precision</code>
* is not {@link #PRECISION_DO_NOT_TRIM}.
* This method will use a {@link Mode}-specific conversion when <code>mode</code> is not
* <code>null</code>.
* Otherwise it will use the default H2 behaviour of trimming the given string if
* <code>precision</code> is not {@link #PRECISION_DO_NOT_TRIM}.
*
* @param s the string
* @param precision if the {@link Mode#padFixedLengthStrings} indicates that strings should be padded, this
* defines the overall length of the (potentially padded) string.
* If the special constant {@link #PRECISION_DO_NOT_TRIM} is used the value will not be trimmed.
* @param precision if the {@link Mode#padFixedLengthStrings} indicates that strings should
* be padded, this defines the overall length of the (potentially padded) string.
* If the special constant {@link #PRECISION_DO_NOT_TRIM} is used the value will
* not be trimmed.
* @return the value
*/
public static ValueStringFixed get(String s, int precision, Mode mode) {
......
......@@ -139,7 +139,8 @@ public class ValueTimestamp extends Value {
}
/**
* See: https://stackoverflow.com/questions/3976616/how-to-find-nth-occurrence-of-character-in-a-string#answer-3976656
* See:
* https://stackoverflow.com/questions/3976616/how-to-find-nth-occurrence-of-character-in-a-string#answer-3976656
*/
private static int findNthIndexOf(String str, char chr, int n) {
int pos = str.indexOf(chr);
......
......@@ -517,9 +517,12 @@ public class TestCompatibility extends TestBase {
stat.execute("drop table test if exists");
stat.execute("create table test(date TIMESTAMP)");
stat.executeUpdate("insert into test (date) values ('2014-04-05-09.48.28.020005')");
assertResult("2014-04-05 09:48:28.020005", stat, "select date from test"); // <- result is always H2 format timestamp!
assertResult("2014-04-05 09:48:28.020005", stat, "select date from test where date = '2014-04-05-09.48.28.020005'");
assertResult("2014-04-05 09:48:28.020005", stat, "select date from test where date = '2014-04-05 09:48:28.020005'");
assertResult("2014-04-05 09:48:28.020005", stat,
"select date from test"); // <- result is always H2 format timestamp!
assertResult("2014-04-05 09:48:28.020005", stat,
"select date from test where date = '2014-04-05-09.48.28.020005'");
assertResult("2014-04-05 09:48:28.020005", stat,
"select date from test where date = '2014-04-05 09:48:28.020005'");
}
private void testDerby() throws SQLException {
......
......@@ -72,7 +72,8 @@ public class TestQueryCache extends TestBase {
assertEquals(0, c);
time = System.nanoTime() - time;
if (i == 1000) {
// take from cache and do not close, so that next iteration will have a cache miss
// take from cache and do not close,
// so that next iteration will have a cache miss
prep = conn.prepareStatement(query);
} else if (i == 1001) {
first = time;
......
......@@ -156,7 +156,7 @@ public class TestRecursiveQueries extends TestBase {
conn.close();
deleteDb("recursiveQueries");
}
private void testSimpleUnion() throws Exception {
deleteDb("recursiveQueries");
Connection conn = getConnection("recursiveQueries");
......@@ -174,9 +174,9 @@ public class TestRecursiveQueries extends TestBase {
assertTrue(rs.next());
assertEquals(3, rs.getInt(1));
assertFalse(rs.next());
conn.close();
deleteDb("recursiveQueries");
}
}
}
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
......@@ -13,10 +18,9 @@ import org.h2.jdbc.JdbcSQLException;
import org.h2.test.TestBase;
public class TestSetCollation extends TestBase {
private static final String[] TEST_STRINGS = new String[]{"A", "Ä", "AA", "B", "$", "1A", null};
public static final String DB_NAME = "collator";
private static final String[] TEST_STRINGS = new String[]{"A", "\u00c4", "AA", "B", "$", "1A", null};
private static final String DB_NAME = "collator";
/**
* Run just this test.
......@@ -41,25 +45,26 @@ public class TestSetCollation extends TestBase {
private void testDefaultCollator() throws Exception {
assertEquals(Arrays.asList(null, "$", "1A", "A", "AA", "B", "Ä"), orderedWithCollator(null));
assertEquals(Arrays.asList(null, "$", "1A", "A", "AA", "B", "\u00c4"), orderedWithCollator(null));
}
private void testDeCollator() throws Exception {
assertEquals(Arrays.asList(null, "$", "1A", "A", "Ä", "AA", "B"), orderedWithCollator("DE"));
assertEquals(Arrays.asList(null, "$", "1A", "A", "Ä", "AA", "B"), orderedWithCollator("DEFAULT_DE"));
assertEquals(Arrays.asList(null, "$", "1A", "A", "\u00c4", "AA", "B"), orderedWithCollator("DE"));
assertEquals(Arrays.asList(null, "$", "1A", "A", "\u00c4", "AA", "B"), orderedWithCollator("DEFAULT_DE"));
}
private void testCp500Collator() throws Exception {
// IBM z/OS codepage
assertEquals(Arrays.asList(null, "A", "AA", "B", "1A", "$", "Ä"),
assertEquals(Arrays.asList(null, "A", "AA", "B", "1A", "$", "\u00c4"),
orderedWithCollator("CHARSET_CP500"));
}
private void testUrlParameter() throws Exception {
// Specifying the collator in the JDBC Url should have the same effect as setting it with a set statement
// Specifying the collator in the JDBC Url should have the same effect
// as setting it with a set statement
config.collation = "CHARSET_CP500";
try {
assertEquals(Arrays.asList(null, "A", "AA", "B", "1A", "$", "Ä"), orderedWithCollator(null));
assertEquals(Arrays.asList(null, "A", "AA", "B", "1A", "$", "\u00c4"), orderedWithCollator(null));
} finally {
config.collation = null;
}
......@@ -69,9 +74,10 @@ public class TestSetCollation extends TestBase {
orderedWithCollator("DE");
try (Connection con = getConnection(DB_NAME)) {
insertValues(con, new String[]{"A", "Ä"}, 100);
insertValues(con, new String[]{"A", "\u00c4"}, 100);
assertEquals(Arrays.asList(null, "$", "1A", "A", "A", "Ä", "Ä", "AA", "B"), loadTableValues(con));
assertEquals(Arrays.asList(null, "$", "1A", "A", "A", "\u00c4", "\u00c4", "AA", "B"),
loadTableValues(con));
}
}
......@@ -83,11 +89,13 @@ public class TestSetCollation extends TestBase {
config.collation = null;
}
// reopen the database without specifying a collation in the url. This should keep the initial collation.
// reopen the database without specifying a collation in the url.
// This should keep the initial collation.
try (Connection con = getConnection(DB_NAME)) {
insertValues(con, new String[]{"A", "Ä"}, 100);
insertValues(con, new String[]{"A", "\u00c4"}, 100);
assertEquals(Arrays.asList(null, "$", "1A", "A", "A", "Ä", "Ä", "AA", "B"), loadTableValues(con));
assertEquals(Arrays.asList(null, "$", "1A", "A", "A", "\u00c4", "\u00c4", "AA", "B"),
loadTableValues(con));
}
}
......@@ -121,9 +129,10 @@ public class TestSetCollation extends TestBase {
config.collation = "DE";
try (Connection con = getConnection(DB_NAME)) {
insertValues(con, new String[]{"A", "Ä"}, 100);
insertValues(con, new String[]{"A", "\u00c4"}, 100);
assertEquals(Arrays.asList(null, "$", "1A", "A", "A", "Ä", "Ä", "AA", "B"), loadTableValues(con));
assertEquals(Arrays.asList(null, "$", "1A", "A", "A", "\u00c4", "\u00c4", "AA", "B"),
loadTableValues(con));
} finally {
config.collation = null;
}
......
......@@ -1146,7 +1146,7 @@ public class TestSpatial extends TestBase {
try (Connection conn = getConnection(URL)) {
Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS BUILDINGS;" +
"CREATE TABLE BUILDINGS (PK serial, THE_GEOM geometry);" +
"CREATE TABLE BUILDINGS (PK serial, THE_GEOM geometry);" +
"insert into buildings(the_geom) SELECT 'POINT(1 1)" +
"'::geometry from SYSTEM_RANGE(1,10000);\n" +
"CREATE SPATIAL INDEX ON PUBLIC.BUILDINGS(THE_GEOM);\n");
......
......@@ -85,7 +85,8 @@ public class TestSynonymForTable extends TestBase {
assertThrows(JdbcSQLException.class, stat).execute("SELECT id FROM testsynonym");
// Synonym should be dropped as well
ResultSet synonyms = conn.createStatement().executeQuery("SELECT * FROM INFORMATION_SCHEMA.SYNONYMS WHERE SYNONYM_NAME='TESTSYNONYM'");
ResultSet synonyms = conn.createStatement().executeQuery(
"SELECT * FROM INFORMATION_SCHEMA.SYNONYMS WHERE SYNONYM_NAME='TESTSYNONYM'");
assertFalse(synonyms.next());
conn.close();
......
......@@ -397,23 +397,24 @@ public class TestStatement extends TestBase {
stat.execute("DROP TABLE TEST");
stat.execute("DROP TABLE TEST2");
}
private void testPreparedStatement() throws SQLException{
Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar(255))");
stat.execute("insert into test values(1, 'Hello')");
stat.execute("insert into test values(2, 'World')");
PreparedStatement ps = conn.prepareStatement("select name from test where id in (select id from test where name REGEXP ?)");
PreparedStatement ps = conn.prepareStatement(
"select name from test where id in (select id from test where name REGEXP ?)");
ps.setString(1, "Hello");
ResultSet rs = ps.executeQuery();
assertTrue(rs.next());
assertEquals("Hello", rs.getString("name"));
assertFalse(rs.next());
assertFalse(rs.next());
ps.setString(1, "World");
rs = ps.executeQuery();
assertTrue(rs.next());
assertEquals("World", rs.getString("name"));
assertFalse(rs.next());
assertFalse(rs.next());
//Changes the table structure
stat.execute("create index t_id on test(name)");
//Test the prepared statement again to check if the internal cache attributes were reset
......@@ -421,13 +422,13 @@ public class TestStatement extends TestBase {
rs = ps.executeQuery();
assertTrue(rs.next());
assertEquals("Hello", rs.getString("name"));
assertFalse(rs.next());
assertFalse(rs.next());
ps.setString(1, "World");
rs = ps.executeQuery();
assertTrue(rs.next());
assertEquals("World", rs.getString("name"));
assertFalse(rs.next());
stat.execute("drop table test");
assertFalse(rs.next());
stat.execute("drop table test");
}
}
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.unit;
import java.nio.charset.Charset;
......
......@@ -737,3 +737,7 @@ choosing optimise arte preparator katzyn bla jenkins tot artes pgserver npe
suffers closeablem mni significance vise identiy vitalus aka ilike uppercasing reentrant
aff ignite warm upstream producing sfu jit smtm affinity stashed tbl
stumc numbered
reopening cloudera hive clustername whomooz unittest anymore snowflakecomputing unpadded endpoint redshift backingtable
trimming hadoop azure resolves snowflake testsynonym plays charsettable synonyms nonexisting impala codepage recognize
dbm forwarded amazon stmnt excessive testvalue
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论