[groonga-dev,01041] mroongaストーレージモードでのunique indexについて

Back to archive index

jd fonc oreno****@gmail*****
2012年 9月 29日 (土) 14:23:18 JST


環境
uname -a
==============
Darwin ******.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23
16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

mysql --version
==============
mysql  Ver 14.14 Distrib 5.5.27, for osx10.7 (i386) using readline 5.1

groonga --version
==============
groonga 2.0.6 [darwin11.4.0,x86_64,utf8,match-escalation-threshold=0,nfkc,mecab,msgpack,zlib,lzo,kqueue]

configure options: < '--prefix=/usr/local/Cellar/groonga/2.0.6'
'--with-zlib' 'CC=cc' 'CXX=c++'
'PKG_CONFIG_PATH=/usr/local/lib/pkgconfig'>

brew info mroonga
==============
mroonga: stable 2.06


最近mroongaを使い始めて気になる事があるので連絡します。
ENGINE=mroonga を使用してストーレージモードでmysqlを使う場合についてですが、下のようなSQL文を実行すると

ERROR 1062 (23000): Duplicate entry 'test-2000-01-01' for key
'index_unique_has_problem_table_on_columns'

のようなエラーが出てしまいます。

---------------------
CREATE TABLE `unique_has_problem_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tried_on` date NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_unique_has_problem_table_on_columns` (`name`,`tried_on`)
) ENGINE=mroonga DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
delete from unique_has_problem_table where id = 1;
insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
---------------------

delete from unique_has_problem_table where id = 1;
をしているので、1回目に入れたデータは消されていると思うのですが、その後同じ内容でインサートするとuniqueインデックスのエラーが出ます。

engineのコメントを外して同じように実行すると、やはりuniqueインデックスのエラーは出ません。
---------------------
CREATE TABLE `unique_has_problem_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tried_on` date NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_unique_has_problem_table_on_columns` (`name`,`tried_on`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
delete from unique_has_problem_table where id = 1;
insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
---------------------


もしくは、ENGINE=mroonga の場合であっても date を varchar に変えると出ないようです。
---------------------
CREATE TABLE `unique_has_problem_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tried_on` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_unique_has_problem_table_on_columns` (`name`,`tried_on`)
) ENGINE=mroonga DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
delete from unique_has_problem_table where id = 1;
insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
---------------------

または、ENGINE=mroonga の場合であっても、dateの場合であってもインデックスが単一カラムであればエラーは出ないようです。
---------------------
drop table unique_has_problem_table;

CREATE TABLE `unique_has_problem_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tried_on` date NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_unique_has_problem_table_on_column` (`tried_on`)
) ENGINE=mroonga DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
delete from unique_has_problem_table where id = 1;
insert into unique_has_problem_table (id, name, tried_on) values (1,
"test", "2000/1/1");
---------------------

使い方に原因あるのかご一報頂ければうれしいです。




groonga-dev メーリングリストの案内
Back to archive index