null+****@clear*****
null+****@clear*****
2012年 6月 7日 (木) 00:20:07 JST
Kentoku 2012-06-07 00:20:07 +0900 (Thu, 07 Jun 2012)
New Revision: b31f3666f554983e27491d9c1763d49b754abecf
Log:
fix case of using query cache with transaction. refs #1384
Added files:
test/sql/suite/mroonga_wrapper/r/query_cache_with_transaction.result
test/sql/suite/mroonga_wrapper/t/query_cache_with_transaction.test
Modified files:
ha_mroonga.cpp
ha_mroonga.hpp
test/sql/suite/mroonga_wrapper/r/files.am
test/sql/suite/mroonga_wrapper/t/files.am
Modified: ha_mroonga.cpp (+63 -0)
===================================================================
--- ha_mroonga.cpp 2012-06-04 00:12:15 +0900 (3fc9b66)
+++ ha_mroonga.cpp 2012-06-07 00:20:07 +0900 (ba38abf)
@@ -12415,6 +12415,69 @@ void ha_mroonga::rebind_psi()
}
#endif
+my_bool ha_mroonga::wrapper_register_query_cache_table(THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback
+ *engine_callback,
+ ulonglong *engine_data)
+{
+ MRN_DBUG_ENTER_METHOD();
+ my_bool res;
+ MRN_SET_WRAP_SHARE_KEY(share, table->s);
+ MRN_SET_WRAP_TABLE_KEY(this, table);
+ res = wrap_handler->register_query_cache_table(thd,
+ table_key,
+ key_length,
+ engine_callback,
+ engine_data);
+ MRN_SET_BASE_SHARE_KEY(share, table->s);
+ MRN_SET_BASE_TABLE_KEY(this, table);
+ DBUG_RETURN(res);
+}
+
+my_bool ha_mroonga::storage_register_query_cache_table(THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback
+ *engine_callback,
+ ulonglong *engine_data)
+{
+ MRN_DBUG_ENTER_METHOD();
+ my_bool res = handler::register_query_cache_table(thd,
+ table_key,
+ key_length,
+ engine_callback,
+ engine_data);
+ DBUG_RETURN(res);
+}
+
+my_bool ha_mroonga::register_query_cache_table(THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback
+ *engine_callback,
+ ulonglong *engine_data)
+{
+ MRN_DBUG_ENTER_METHOD();
+ my_bool res;
+ if (share->wrapper_mode)
+ {
+ res = wrapper_register_query_cache_table(thd,
+ table_key,
+ key_length,
+ engine_callback,
+ engine_data);
+ } else {
+ res = storage_register_query_cache_table(thd,
+ table_key,
+ key_length,
+ engine_callback,
+ engine_data);
+ }
+ DBUG_RETURN(res);
+}
+
#ifdef __cplusplus
}
#endif
Modified: ha_mroonga.hpp (+17 -0)
===================================================================
--- ha_mroonga.hpp 2012-06-04 00:12:15 +0900 (b843ede)
+++ ha_mroonga.hpp 2012-06-07 00:20:07 +0900 (53c8f61)
@@ -455,6 +455,11 @@ protected:
void unbind_psi();
void rebind_psi();
#endif
+ my_bool register_query_cache_table(THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback *engine_callback,
+ ulonglong *engine_data);
private:
void push_warning_unsupported_spatial_index_search(enum ha_rkey_function flag);
@@ -964,6 +969,18 @@ private:
void wrapper_rebind_psi();
void storage_rebind_psi();
#endif
+ my_bool wrapper_register_query_cache_table(THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback
+ *engine_callback,
+ ulonglong *engine_data);
+ my_bool storage_register_query_cache_table(THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback
+ *engine_callback,
+ ulonglong *engine_data);
};
#ifdef __cplusplus
Modified: test/sql/suite/mroonga_wrapper/r/files.am (+1 -0)
===================================================================
--- test/sql/suite/mroonga_wrapper/r/files.am 2012-06-04 00:12:15 +0900 (0017275)
+++ test/sql/suite/mroonga_wrapper/r/files.am 2012-06-07 00:20:07 +0900 (a6dcbc7)
@@ -42,6 +42,7 @@ result_files = \
match_escalation_threshold_global.result \
match_escalation_threshold_session.result \
optimization_order_limit_todo_split_me.result \
+ query_cache_with_transaction.result \
repair_table.result \
temporary_table.result \
transaction_rollback_delete_delete.result \
Added: test/sql/suite/mroonga_wrapper/r/query_cache_with_transaction.result (+28 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/mroonga_wrapper/r/query_cache_with_transaction.result 2012-06-07 00:20:07 +0900 (35263c2)
@@ -0,0 +1,28 @@
+SET @tmp_query_cache_size = @@query_cache_size;
+SET GLOBAL query_cache_size = 1048576;
+DROP TABLE IF EXISTS simple_table;
+CREATE TABLE simple_table (
+id INT PRIMARY KEY
+) COMMENT = 'ENGINE "InnoDB"' DEFAULT CHARSET=UTF8;
+SHOW CREATE TABLE simple_table;
+Table Create Table
+simple_table CREATE TABLE `simple_table` (
+ `id` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=mroonga DEFAULT CHARSET=utf8 COMMENT='ENGINE "InnoDB"'
+INSERT INTO simple_table (id) VALUES (1),(2);
+USE test;
+START TRANSACTION;
+INSERT INTO simple_table (id) VALUES (3);
+SELECT * FROM simple_table;
+id
+1
+2
+COMMIT;
+SELECT * FROM simple_table;
+id
+1
+2
+3
+DROP TABLE simple_table;
+SET GLOBAL query_cache_size = @tmp_query_cache_size;
Modified: test/sql/suite/mroonga_wrapper/t/files.am (+1 -0)
===================================================================
--- test/sql/suite/mroonga_wrapper/t/files.am 2012-06-04 00:12:15 +0900 (f743d96)
+++ test/sql/suite/mroonga_wrapper/t/files.am 2012-06-07 00:20:07 +0900 (600230f)
@@ -42,6 +42,7 @@ test_files = \
match_escalation_threshold_global.test \
match_escalation_threshold_session.test \
optimization_order_limit_todo_split_me.test \
+ query_cache_with_transaction.test \
repair_table.test \
temporary_table.test \
transaction_rollback_delete_delete.test \
Added: test/sql/suite/mroonga_wrapper/t/query_cache_with_transaction.test (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/mroonga_wrapper/t/query_cache_with_transaction.test 2012-06-07 00:20:07 +0900 (848a60a)
@@ -0,0 +1,53 @@
+# Copyright(C) 2012 Kentoku SHIBA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+--source include/have_innodb.inc
+--source include/have_mroonga.inc
+
+SET @tmp_query_cache_size = @@query_cache_size;
+SET GLOBAL query_cache_size = 1048576;
+
+--disable_warnings
+DROP TABLE IF EXISTS simple_table;
+--enable_warnings
+
+CREATE TABLE simple_table (
+ id INT PRIMARY KEY
+) COMMENT = 'ENGINE "InnoDB"' DEFAULT CHARSET=UTF8;
+SHOW CREATE TABLE simple_table;
+
+INSERT INTO simple_table (id) VALUES (1),(2);
+
+CONNECT(second_connection, localhost, root);
+USE test;
+START TRANSACTION;
+INSERT INTO simple_table (id) VALUES (3);
+
+CONNECTION default;
+SELECT * FROM simple_table;
+
+CONNECTION second_connection;
+COMMIT;
+
+CONNECTION default;
+SELECT * FROM simple_table;
+
+DROP TABLE simple_table;
+DISCONNECT second_connection;
+
+SET GLOBAL query_cache_size = @tmp_query_cache_size;
+
+--source include/have_mroonga_deinit.inc