null+****@clear*****
null+****@clear*****
2011年 10月 3日 (月) 20:19:21 JST
Kouhei Sutou 2011-10-03 11:19:21 +0000 (Mon, 03 Oct 2011)
New Revision: 7da9beebd67e06fcff1f468fbf49892013affbfe
Log:
[wrapper] support geo index update.
Added files:
test/sql/groonga_wrapper/r/geometry_update.result
test/sql/groonga_wrapper/t/geometry_update.test
Modified files:
ha_mroonga.cc
Modified: ha_mroonga.cc (+2 -1)
===================================================================
--- ha_mroonga.cc 2011-10-03 11:04:33 +0000 (7f5f7db)
+++ ha_mroonga.cc 2011-10-03 11:19:21 +0000 (f9ba0af)
@@ -3530,7 +3530,8 @@ int ha_mroonga::wrapper_update_row_index(const uchar *old_data, uchar *new_data)
for (i = 0; i < n_keys; i++) {
KEY key_info = table->key_info[i];
- if (key_info.algorithm != HA_KEY_ALG_FULLTEXT) {
+ if (!(key_info.algorithm == HA_KEY_ALG_FULLTEXT ||
+ mrn_is_geo_key(&key_info))) {
continue;
}
Added: test/sql/groonga_wrapper/r/geometry_update.result (+36 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/r/geometry_update.result 2011-10-03 11:19:21 +0000 (d985f4b)
@@ -0,0 +1,36 @@
+drop table if exists diaries;
+create table shops (
+id int primary key auto_increment,
+name text,
+location geometry NOT NULL,
+spatial key location_index (location)
+) comment = 'engine "innodb"';
+show create table shops;
+Table Create Table
+shops CREATE TABLE `shops` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` text,
+ `location` geometry NOT NULL,
+ PRIMARY KEY (`id`),
+ SPATIAL KEY `location_index` (`location`)
+) ENGINE=groonga DEFAULT CHARSET=latin1 COMMENT='engine "innodb"'
+insert into shops (name, location)
+values ('sazare',
+GeomFromText('POINT(139.685043 35.714653)'));
+select id, name, AsText(location) as location_text from shops
+where MBRContains(GeomFromText('LineString(139.68466 35.71592, 139.68804 35.71411)'), location);
+id name location_text
+1 sazare POINT(139.685043 35.714653)
+select id, name, AsText(location) as location_text from shops
+where MBRContains(GeomFromText('LineString(139.65659 35.57903, 139.66489 35.57262)'), location);
+id name location_text
+update shops set location = GeomFromText('POINT(139.66116 35.57566)')
+where name = 'sazare';
+select id, name, AsText(location) as location_text from shops
+where MBRContains(GeomFromText('LineString(139.68466 35.71592, 139.68804 35.71411)'), location);
+id name location_text
+select id, name, AsText(location) as location_text from shops
+where MBRContains(GeomFromText('LineString(139.65659 35.57903, 139.66489 35.57262)'), location);
+id name location_text
+1 sazare POINT(139.66116 35.57566)
+drop table shops;
Added: test/sql/groonga_wrapper/t/geometry_update.test (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/sql/groonga_wrapper/t/geometry_update.test 2011-10-03 11:19:21 +0000 (3e79891)
@@ -0,0 +1,48 @@
+# Copyright(C) 2011 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 suite/groonga_include/groonga_init.inc
+
+--disable_warnings
+drop table if exists diaries;
+--enable_warnings
+
+create table shops (
+ id int primary key auto_increment,
+ name text,
+ location geometry NOT NULL,
+ spatial key location_index (location)
+) comment = 'engine "innodb"';
+show create table shops;
+
+insert into shops (name, location)
+ values ('sazare',
+ GeomFromText('POINT(139.685043 35.714653)'));
+select id, name, AsText(location) as location_text from shops
+ where MBRContains(GeomFromText('LineString(139.68466 35.71592, 139.68804 35.71411)'), location);
+select id, name, AsText(location) as location_text from shops
+ where MBRContains(GeomFromText('LineString(139.65659 35.57903, 139.66489 35.57262)'), location);
+
+update shops set location = GeomFromText('POINT(139.66116 35.57566)')
+ where name = 'sazare';
+select id, name, AsText(location) as location_text from shops
+ where MBRContains(GeomFromText('LineString(139.68466 35.71592, 139.68804 35.71411)'), location);
+select id, name, AsText(location) as location_text from shops
+ where MBRContains(GeomFromText('LineString(139.65659 35.57903, 139.66489 35.57262)'), location);
+
+drop table shops;
+
+--source suite/groonga_include/groonga_deinit.inc