提交 6092aecf authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remember Mode instead of its name in JdbcConnection

上级 7a4d6f35
...@@ -93,7 +93,7 @@ public class JdbcConnection extends TraceObject ...@@ -93,7 +93,7 @@ public class JdbcConnection extends TraceObject
private int queryTimeoutCache = -1; private int queryTimeoutCache = -1;
private Map<String, String> clientInfo; private Map<String, String> clientInfo;
private String mode; private volatile Mode mode;
private final boolean scopeGeneratedKeys; private final boolean scopeGeneratedKeys;
/** /**
...@@ -1783,8 +1783,7 @@ public class JdbcConnection extends TraceObject ...@@ -1783,8 +1783,7 @@ public class JdbcConnection extends TraceObject
Collections.<String, ClientInfoStatus> emptyMap()); Collections.<String, ClientInfoStatus> emptyMap());
} }
Pattern clientInfoNameRegEx = Mode Pattern clientInfoNameRegEx = getMode().supportedClientInfoPropertiesRegEx;
.getInstance(getMode()).supportedClientInfoPropertiesRegEx;
if (clientInfoNameRegEx != null if (clientInfoNameRegEx != null
&& clientInfoNameRegEx.matcher(name).matches()) { && clientInfoNameRegEx.matcher(name).matches()) {
...@@ -2102,15 +2101,22 @@ public class JdbcConnection extends TraceObject ...@@ -2102,15 +2101,22 @@ public class JdbcConnection extends TraceObject
trace.setLevel(level); trace.setLevel(level);
} }
String getMode() throws SQLException { Mode getMode() throws SQLException {
Mode mode = this.mode;
if (mode == null) { if (mode == null) {
PreparedStatement prep = prepareStatement( String name;
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?"); try (PreparedStatement prep = prepareStatement(
prep.setString(1, "MODE"); "SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?")) {
ResultSet rs = prep.executeQuery(); prep.setString(1, "MODE");
rs.next(); ResultSet rs = prep.executeQuery();
mode = rs.getString(1); rs.next();
prep.close(); name = rs.getString(1);
}
mode = Mode.getInstance(name);
if (mode == null) {
mode = Mode.getRegular();
}
this.mode = mode;
} }
return mode; return mode;
} }
......
...@@ -16,6 +16,7 @@ import java.util.Arrays; ...@@ -16,6 +16,7 @@ import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Mode.ModeEnum;
import org.h2.engine.SessionInterface; import org.h2.engine.SessionInterface;
import org.h2.engine.SessionRemote; import org.h2.engine.SessionRemote;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
...@@ -2562,8 +2563,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2562,8 +2563,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override @Override
public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
debugCodeCall("supportsMixedCaseQuotedIdentifiers"); debugCodeCall("supportsMixedCaseQuotedIdentifiers");
String m = conn.getMode(); return conn.getMode().getEnum() != ModeEnum.MySQL;
return !m.equals("MySQL");
} }
/** /**
...@@ -2575,8 +2575,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2575,8 +2575,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override @Override
public boolean storesUpperCaseIdentifiers() throws SQLException { public boolean storesUpperCaseIdentifiers() throws SQLException {
debugCodeCall("storesUpperCaseIdentifiers"); debugCodeCall("storesUpperCaseIdentifiers");
String m = conn.getMode(); return conn.getMode().getEnum() != ModeEnum.MySQL;
return !m.equals("MySQL");
} }
/** /**
...@@ -2588,8 +2587,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2588,8 +2587,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override @Override
public boolean storesLowerCaseIdentifiers() throws SQLException { public boolean storesLowerCaseIdentifiers() throws SQLException {
debugCodeCall("storesLowerCaseIdentifiers"); debugCodeCall("storesLowerCaseIdentifiers");
String m = conn.getMode(); return conn.getMode().getEnum() == ModeEnum.MySQL;
return m.equals("MySQL");
} }
/** /**
...@@ -2613,8 +2611,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2613,8 +2611,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override @Override
public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
debugCodeCall("storesUpperCaseQuotedIdentifiers"); debugCodeCall("storesUpperCaseQuotedIdentifiers");
String m = conn.getMode(); return conn.getMode().getEnum() == ModeEnum.MySQL;
return m.equals("MySQL");
} }
/** /**
...@@ -2626,8 +2623,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2626,8 +2623,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override @Override
public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
debugCodeCall("storesLowerCaseQuotedIdentifiers"); debugCodeCall("storesLowerCaseQuotedIdentifiers");
String m = conn.getMode(); return conn.getMode().getEnum() == ModeEnum.MySQL;
return m.equals("MySQL");
} }
/** /**
...@@ -2639,8 +2635,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2639,8 +2635,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override @Override
public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
debugCodeCall("storesMixedCaseQuotedIdentifiers"); debugCodeCall("storesMixedCaseQuotedIdentifiers");
String m = conn.getMode(); return conn.getMode().getEnum() != ModeEnum.MySQL;
return !m.equals("MySQL");
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论