null+****@clear*****
null+****@clear*****
2012年 2月 15日 (水) 18:33:09 JST
Kouhei Sutou 2012-02-15 18:33:09 +0900 (Wed, 15 Feb 2012)
New Revision: 1869e432d4f5d26786ac89bf62b20d370bf7792b
Log:
suppress a needless warning on "INSERT ... ON DUPLICATE KEY UPDATE".
Added files:
test/sql/suite/mroonga_storage/r/insert_on_duplicate_key_update.result
test/sql/suite/mroonga_storage/t/insert_on_duplicate_key_update.test
Modified files:
ha_mroonga.cc
ha_mroonga.h
Modified: ha_mroonga.cc (+8 -1)
===================================================================
--- ha_mroonga.cc 2012-02-15 17:52:26 +0900 (1f2f634)
+++ ha_mroonga.cc 2012-02-15 18:33:09 +0900 (bb5c61c)
@@ -1813,6 +1813,7 @@ static _ft_vft mrn_no_such_key_ft_vft = {
ha_mroonga::ha_mroonga(handlerton *hton, TABLE_SHARE *share_arg)
:handler(hton, share_arg),
ignoring_duplicated_key(false),
+ inserting_with_update(false),
ignoring_no_key_columns(false)
{
MRN_DBUG_ENTER_METHOD();
@@ -3926,6 +3927,9 @@ int ha_mroonga::generic_extra(enum ha_extra_function operation)
case HA_EXTRA_NO_IGNORE_DUP_KEY:
ignoring_duplicated_key = false;
break;
+ case HA_EXTRA_INSERT_WITH_UPDATE:
+ inserting_with_update = true;
+ break;
case HA_EXTRA_KEYREAD:
ignoring_no_key_columns = true;
break;
@@ -4643,7 +4647,9 @@ int ha_mroonga::storage_update_row(const uchar *old_data, uchar *new_data)
if (error)
DBUG_RETURN(error);
- if (pkey_info) {
+ bool on_duplicate_key_update =
+ (inserting_with_update && ignoring_duplicated_key);
+ if (!on_duplicate_key_update && pkey_info) {
bool have_pkey = false;
for (uint j = 0; j < pkey_info->key_parts; j++) {
Field *pkey_field = pkey_info->key_part[j].field;
@@ -8284,6 +8290,7 @@ int ha_mroonga::reset()
else
error = storage_reset();
ignoring_no_key_columns = false;
+ inserting_with_update = false;
ignoring_duplicated_key = false;
fulltext_searching = false;
mrn_lock_type = F_UNLCK;
Modified: ha_mroonga.h (+1 -0)
===================================================================
--- ha_mroonga.h 2012-02-15 17:52:26 +0900 (0d4825e)
+++ ha_mroonga.h 2012-02-15 18:33:09 +0900 (48266e3)
@@ -203,6 +203,7 @@ private:
bool fast_order_limit_with_index;
bool ignoring_duplicated_key;
+ bool inserting_with_update;
bool fulltext_searching;
#ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
Added: test/sql/suite/mroonga_storage/r/insert_on_duplicate_key_update.result (+26 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/mroonga_storage/r/insert_on_duplicate_key_update.result 2012-02-15 18:33:09 +0900 (c5b5b03)
@@ -0,0 +1,26 @@
+DROP TABLE IF EXISTS diaries;
+CREATE TABLE diaries (
+day DATE PRIMARY KEY,
+title TEXT
+) DEFAULT CHARSET=UTF8;
+SHOW CREATE TABLE diaries;
+Table Create Table
+diaries CREATE TABLE `diaries` (
+ `day` date NOT NULL,
+ `title` text,
+ PRIMARY KEY (`day`)
+) ENGINE=mroonga DEFAULT CHARSET=utf8
+INSERT INTO diaries (day, title)
+VALUES ("2012-02-14", "clear day")
+ON DUPLICATE KEY UPDATE title = "clear day (duplicated)";
+INSERT INTO diaries (day, title)
+VALUES ("2012-02-14", "rainy day")
+ON DUPLICATE KEY UPDATE title = "rainy day (duplicated)";
+INSERT INTO diaries (day, title)
+VALUES ("2012-02-15", "cloudy day")
+ON DUPLICATE KEY UPDATE title = "cloudy day (duplicated)";
+SELECT * FROM diaries;
+day title
+2012-02-14 rainy day (duplicated)
+2012-02-15 cloudy day
+DROP TABLE diaries;
Added: test/sql/suite/mroonga_storage/t/insert_on_duplicate_key_update.test (+43 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/suite/mroonga_storage/t/insert_on_duplicate_key_update.test 2012-02-15 18:33:09 +0900 (126179c)
@@ -0,0 +1,43 @@
+# Copyright(C) 2012 Kouhei Sutou <kou****@clear*****>
+#
+# 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_mroonga.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS diaries;
+--enable_warnings
+
+CREATE TABLE diaries (
+ day DATE PRIMARY KEY,
+ title TEXT
+) DEFAULT CHARSET=UTF8;
+SHOW CREATE TABLE diaries;
+
+INSERT INTO diaries (day, title)
+ VALUES ("2012-02-14", "clear day")
+ ON DUPLICATE KEY UPDATE title = "clear day (duplicated)";
+INSERT INTO diaries (day, title)
+ VALUES ("2012-02-14", "rainy day")
+ ON DUPLICATE KEY UPDATE title = "rainy day (duplicated)";
+INSERT INTO diaries (day, title)
+ VALUES ("2012-02-15", "cloudy day")
+ ON DUPLICATE KEY UPDATE title = "cloudy day (duplicated)";
+
+SELECT * FROM diaries;
+
+DROP TABLE diaries;
+
+--source include/have_mroonga_deinit.inc