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