Unverified 提交 e2742465 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #820 from katzyn/warnings

Fix some compiler warnings
...@@ -4006,8 +4006,10 @@ public class Parser { ...@@ -4006,8 +4006,10 @@ public class Parser {
case '#': case '#':
if (database.getMode().supportPoundSymbolForColumnNames) { if (database.getMode().supportPoundSymbolForColumnNames) {
type = CHAR_NAME; type = CHAR_NAME;
break; } else {
type = CHAR_SPECIAL_1;
} }
break;
default: default:
if (c >= 'a' && c <= 'z') { if (c >= 'a' && c <= 'z') {
if (identifiersToUpper) { if (identifiersToUpper) {
......
...@@ -1483,7 +1483,7 @@ public class Select extends Query { ...@@ -1483,7 +1483,7 @@ public class Select extends Query {
Value[] row = new Value[columnCount]; Value[] row = new Value[columnCount];
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
Expression expr = expressions.get(i); Expression expr = expressions.get(i);
row[i] = expr.getValue(session); row[i] = expr.getValue(getSession());
} }
return row; return row;
} }
...@@ -1521,7 +1521,7 @@ public class Select extends Query { ...@@ -1521,7 +1521,7 @@ public class Select extends Query {
for (int i = 0; i < groupIndex.length; i++) { for (int i = 0; i < groupIndex.length; i++) {
int idx = groupIndex[i]; int idx = groupIndex[i];
Expression expr = expressions.get(idx); Expression expr = expressions.get(idx);
keyValues[i] = expr.getValue(session); keyValues[i] = expr.getValue(getSession());
} }
Value[] row = null; Value[] row = null;
...@@ -1538,7 +1538,7 @@ public class Select extends Query { ...@@ -1538,7 +1538,7 @@ public class Select extends Query {
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
if (groupByExpression == null || !groupByExpression[i]) { if (groupByExpression == null || !groupByExpression[i]) {
Expression expr = expressions.get(i); Expression expr = expressions.get(i);
expr.updateAggregate(session); expr.updateAggregate(getSession());
} }
} }
if (row != null) { if (row != null) {
......
...@@ -919,39 +919,41 @@ public class PgServerThread implements Runnable { ...@@ -919,39 +919,41 @@ public class PgServerThread implements Runnable {
private void initDb() throws SQLException { private void initDb() throws SQLException {
Statement stat = null; Statement stat = null;
ResultSet rs = null;
try { try {
synchronized (server) { synchronized (server) {
// better would be: set the database to exclusive mode // better would be: set the database to exclusive mode
rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null); boolean tableFound;
boolean tableFound = rs.next(); try (ResultSet rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null)) {
tableFound = rs.next();
}
stat = conn.createStatement(); stat = conn.createStatement();
if (!tableFound) { if (!tableFound) {
installPgCatalog(stat); installPgCatalog(stat);
} }
rs = stat.executeQuery("select * from pg_catalog.pg_version"); try (ResultSet rs = stat.executeQuery("select * from pg_catalog.pg_version")) {
if (!rs.next() || rs.getInt(1) < 2) { if (!rs.next() || rs.getInt(1) < 2) {
// installation incomplete, or old version // installation incomplete, or old version
installPgCatalog(stat); installPgCatalog(stat);
} else { } else {
// version 2 or newer: check the read version // version 2 or newer: check the read version
int versionRead = rs.getInt(2); int versionRead = rs.getInt(2);
if (versionRead > 2) { if (versionRead > 2) {
throw DbException.throwInternalError("Incompatible PG_VERSION"); throw DbException.throwInternalError("Incompatible PG_VERSION");
}
} }
} }
} }
stat.execute("set search_path = PUBLIC, pg_catalog"); stat.execute("set search_path = PUBLIC, pg_catalog");
HashSet<Integer> typeSet = server.getTypeSet(); HashSet<Integer> typeSet = server.getTypeSet();
if (typeSet.size() == 0) { if (typeSet.size() == 0) {
rs = stat.executeQuery("select oid from pg_catalog.pg_type"); try (ResultSet rs = stat.executeQuery("select oid from pg_catalog.pg_type")) {
while (rs.next()) { while (rs.next()) {
typeSet.add(rs.getInt(1)); typeSet.add(rs.getInt(1));
}
} }
} }
} finally { } finally {
JdbcUtils.closeSilently(stat); JdbcUtils.closeSilently(stat);
JdbcUtils.closeSilently(rs);
} }
} }
......
...@@ -956,7 +956,7 @@ public abstract class TestBase { ...@@ -956,7 +956,7 @@ public abstract class TestBase {
* @param condition the condition * @param condition the condition
* @throws AssertionError if the condition is false * @throws AssertionError if the condition is false
*/ */
protected void assertTrue(String message, boolean condition) { public void assertTrue(String message, boolean condition) {
if (!condition) { if (!condition) {
fail(message); fail(message);
} }
...@@ -1058,7 +1058,7 @@ public abstract class TestBase { ...@@ -1058,7 +1058,7 @@ public abstract class TestBase {
* *
* @param stat the statement * @param stat the statement
*/ */
protected void execute(PreparedStatement stat) throws SQLException { public void execute(PreparedStatement stat) throws SQLException {
execute(stat, null); execute(stat, null);
} }
...@@ -1651,7 +1651,10 @@ public abstract class TestBase { ...@@ -1651,7 +1651,10 @@ public abstract class TestBase {
throw (E) e; throw (E) e;
} }
protected String getTestName() { /**
* @return the name of the test class
*/
public String getTestName() {
return getClass().getSimpleName(); return getClass().getSimpleName();
} }
......
...@@ -389,7 +389,7 @@ public class TestPgServer extends TestBase { ...@@ -389,7 +389,7 @@ public class TestPgServer extends TestBase {
} }
} }
private void testBinaryTypes() throws SQLException, InterruptedException { private void testBinaryTypes() throws SQLException {
if (!getPgJdbcDriver()) { if (!getPgJdbcDriver()) {
return; return;
} }
...@@ -464,7 +464,7 @@ public class TestPgServer extends TestBase { ...@@ -464,7 +464,7 @@ public class TestPgServer extends TestBase {
} }
} }
private void testDateTime() throws SQLException, InterruptedException { private void testDateTime() throws SQLException {
if (!getPgJdbcDriver()) { if (!getPgJdbcDriver()) {
return; return;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论