提交 85e74dd1 authored 作者: noelgrandin's avatar noelgrandin

Bug: Changes to the database structure did not result in the Session query cache being invalidated.

上级 101d72e0
......@@ -24,6 +24,8 @@ Change Log
</li><li>Fix bug in unique and non-unique hash indexes which manifested as incorrect results
when the search key was a different cardinal type from the table index key.
e.g. where the one was INT and the other was LONG
</li><li>Bug: Changes to the database structure did not result
in the Session query cache being invalidated.
</li></ul>
<h2>Version 1.3.173 (2013-07-28)</h2>
......
......@@ -110,6 +110,7 @@ public class Session extends SessionWithState {
private int objectId;
private final int queryCacheSize;
private SmallLRUCache<String, Command> queryCache;
private long modificationMetaID = -1;
private Transaction transaction;
private long startStatement = -1;
......@@ -416,7 +417,13 @@ public class Session extends SessionWithState {
if (queryCacheSize > 0) {
if (queryCache == null) {
queryCache = SmallLRUCache.newInstance(queryCacheSize);
modificationMetaID = database.getModificationMetaId();
} else {
long newModificationMetaID = database.getModificationMetaId();
if (newModificationMetaID != modificationMetaID) {
queryCache.clear();
modificationMetaID = newModificationMetaID;
}
command = queryCache.get(sql);
if (command != null && command.canReuse()) {
command.reuse();
......
......@@ -68,9 +68,12 @@ public class TestQueryCache extends TestBase {
private void testClearingCacheWithTableStructureChanges() throws Exception {
Connection conn = getConnection("queryCache;QUERY_CACHE_SIZE=10");
conn.createStatement().executeUpdate("CREATE TABLE TEST(col1 bigint, col2 varchar(255))");
conn.prepareStatement("SELECT * FROM TEST");
conn.createStatement().executeUpdate("DROP TABLE TEST");
assertThrows(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, conn).prepareStatement("SELECT * FROM TEST");
Statement stat = conn.createStatement();
stat.executeUpdate("CREATE TABLE TEST(col1 bigint, col2 varchar(255))");
PreparedStatement prep = conn.prepareStatement("SELECT * FROM TEST");
prep.close();
stat.executeUpdate("DROP TABLE TEST");
assertThrows(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, conn).prepareStatement("SELECT * FROM TEST");
conn.close();
}
......
......@@ -57,7 +57,7 @@ public class TestSQLInjection extends TestBase {
stat.execute("CALL 123");
assertThrows(ErrorCode.LITERALS_ARE_NOT_ALLOWED, stat).
execute("CALL 'Hello'");
assertThrows(ErrorCode.SYNTAX_ERROR_1, stat).
assertThrows(ErrorCode.LITERALS_ARE_NOT_ALLOWED, stat).
execute("CALL $$Hello World$$");
stat.execute("SET ALLOW_LITERALS NONE");
try {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论