Unverified 提交 0b9b6cf0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1068 from katzyn/synonym

1.4.196 doesn't have actual support for synonyms
...@@ -69,7 +69,7 @@ Change Log ...@@ -69,7 +69,7 @@ Change Log
</li> </li>
<li>PR #1021: Update JdbcDatabaseMetaData to JDBC 4.1 (Java 7) <li>PR #1021: Update JdbcDatabaseMetaData to JDBC 4.1 (Java 7)
</li> </li>
<li>Issue #992: 1.4.196+ client cannot use DatabaseMetaData with 1.4.195- server <li>Issue #992: 1.4.197 client cannot use DatabaseMetaData with 1.4.196 and older server
</li> </li>
<li>Issue #1016: ResultSet.getObject() should return enum value, not ordinal <li>Issue #1016: ResultSet.getObject() should return enum value, not ordinal
</li> </li>
......
...@@ -15,7 +15,6 @@ import java.sql.Types; ...@@ -15,7 +15,6 @@ import java.sql.Types;
import java.util.Arrays; import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
import org.h2.command.CommandInterface;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.SessionInterface; import org.h2.engine.SessionInterface;
import org.h2.engine.SessionRemote; import org.h2.engine.SessionRemote;
...@@ -23,7 +22,6 @@ import org.h2.engine.SysProperties; ...@@ -23,7 +22,6 @@ import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.message.TraceObject; import org.h2.message.TraceObject;
import org.h2.result.ResultInterface;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -36,11 +34,6 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -36,11 +34,6 @@ public class JdbcDatabaseMetaData extends TraceObject implements
private final JdbcConnection conn; private final JdbcConnection conn;
/**
* Whether database has support for synonyms ({@code null} if not yet known).
*/
private Boolean hasSynonyms;
JdbcDatabaseMetaData(JdbcConnection conn, Trace trace, int id) { JdbcDatabaseMetaData(JdbcConnection conn, Trace trace, int id) {
setTrace(trace, TraceObject.DATABASE_META_DATA, id); setTrace(trace, TraceObject.DATABASE_META_DATA, id);
this.conn = conn; this.conn = conn;
...@@ -116,30 +109,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -116,30 +109,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements
} }
private boolean hasSynonyms() { private boolean hasSynonyms() {
Boolean hasSynonyms = this.hasSynonyms; SessionInterface si = conn.getSession();
if (hasSynonyms == null) { return !(si instanceof SessionRemote)
SessionInterface si = conn.getSession(); || ((SessionRemote) si).getClientVersion() >= Constants.TCP_PROTOCOL_VERSION_17;
if (si instanceof SessionRemote) {
SessionRemote sr = (SessionRemote) si;
int clientVersion = sr.getClientVersion();
if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_17) {
hasSynonyms = true;
} else if (clientVersion <= Constants.TCP_PROTOCOL_VERSION_15) {
hasSynonyms = false;
} else { // 1.4.194-1.4.196
CommandInterface c = sr.prepareCommand("CALL H2VERSION()", Integer.MAX_VALUE);
ResultInterface result = c.executeQuery(0, false);
result.next();
String s = result.currentRow()[0].getString();
result.close();
hasSynonyms = "1.4.196".equals(s);
}
} else {
hasSynonyms = true;
}
this.hasSynonyms = hasSynonyms;
}
return hasSynonyms;
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论