Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #15 from naoa/test-between-over-case
Browse files Browse the repository at this point in the history
test: add test case for optimized between specify outside of key range

Patch by Naoya Murakami. Thanks!!!
  • Loading branch information
kou committed Aug 5, 2014
2 parents 899f1d1 + 36298ce commit 46aebd9
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 0 deletions.
@@ -0,0 +1,35 @@
DROP TABLE IF EXISTS diaries;
FLUSH STATUS;
SET NAMES UTF8;
CREATE TABLE diaries (
id INT UNSIGNED NOT NULL,
date DATETIME,
content TEXT,
FULLTEXT INDEX(content),
KEY(date)
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE diaries;
Table Create Table
diaries CREATE TABLE `diaries` (
`id` int(10) unsigned NOT NULL,
`date` datetime DEFAULT NULL,
`content` text,
KEY `date` (`date`),
FULLTEXT KEY `content` (`content`)
) ENGINE=mroonga DEFAULT CHARSET=utf8
INSERT INTO diaries VALUES(1, "2011-11-11 12:23:30", "Today is fine.");
INSERT INTO diaries VALUES(2, "2011-11-11 12:23:31", "Today's lucky item is flower!");
INSERT INTO diaries VALUES(3, "2011-11-11 12:23:32", "I will do something today!");
INSERT INTO diaries VALUES(4, "2011-11-11 12:23:33", "I don't want to anything today...");
INSERT INTO diaries VALUES(5, "2011-11-11 12:23:34", "I'm sleepy today.");
SELECT * FROM diaries
WHERE MATCH(content) AGAINST("today" IN BOOLEAN MODE) AND
date BETWEEN "2011-11-11 12:23:31" AND "2011-11-11 12:23:43"
ORDER BY id LIMIT 1,2;
id date content
3 2011-11-11 12:23:32 I will do something today!
4 2011-11-11 12:23:33 I don't want to anything today...
SHOW STATUS LIKE 'mroonga_fast_order_limit';
Variable_name Value
Mroonga_fast_order_limit 1
DROP TABLE diaries;
@@ -0,0 +1,50 @@
# Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com>
#
# 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/mroonga/have_mroonga.inc

--disable_warnings
DROP TABLE IF EXISTS diaries;
--enable_warnings

FLUSH STATUS;

SET NAMES UTF8;
CREATE TABLE diaries (
id INT UNSIGNED NOT NULL,
date DATETIME,
content TEXT,
FULLTEXT INDEX(content),
KEY(date)
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE diaries;

INSERT INTO diaries VALUES(1, "2011-11-11 12:23:30", "Today is fine.");
INSERT INTO diaries VALUES(2, "2011-11-11 12:23:31", "Today's lucky item is flower!");
INSERT INTO diaries VALUES(3, "2011-11-11 12:23:32", "I will do something today!");
INSERT INTO diaries VALUES(4, "2011-11-11 12:23:33", "I don't want to anything today...");
INSERT INTO diaries VALUES(5, "2011-11-11 12:23:34", "I'm sleepy today.");

SELECT * FROM diaries
WHERE MATCH(content) AGAINST("today" IN BOOLEAN MODE) AND
date BETWEEN "2011-11-11 12:23:31" AND "2011-11-11 12:23:43"
ORDER BY id LIMIT 1,2;

SHOW STATUS LIKE 'mroonga_fast_order_limit';

DROP TABLE diaries;

--source ../../../../../../include/mroonga/have_mroonga_deinit.inc
@@ -0,0 +1,25 @@
DROP TABLE IF EXISTS memos;
FLUSH STATUS;
SET NAMES UTF8;
CREATE TABLE memos (
id INT UNSIGNED,
content TEXT,
FULLTEXT INDEX(content),
KEY(id)
) DEFAULT CHARSET UTF8;
INSERT INTO memos VALUES(1, "Today is fine.");
INSERT INTO memos VALUES(2, "Today's lucky item is flower!");
INSERT INTO memos VALUES(3, "I will do something today!");
INSERT INTO memos VALUES(4, "I don't want to anything today...");
INSERT INTO memos VALUES(5, "I'm sleepy today.");
SELECT * FROM memos
WHERE MATCH(content) AGAINST("today" IN BOOLEAN MODE) AND
id BETWEEN 2 AND 6
ORDER BY id LIMIT 1,2;
id content
3 I will do something today!
4 I don't want to anything today...
SHOW STATUS LIKE 'mroonga_fast_order_limit';
Variable_name Value
Mroonga_fast_order_limit 1
DROP TABLE memos;
@@ -0,0 +1,48 @@
# Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com>
#
# 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/mroonga/have_mroonga.inc

--disable_warnings
DROP TABLE IF EXISTS memos;
--enable_warnings

FLUSH STATUS;

SET NAMES UTF8;
CREATE TABLE memos (
id INT UNSIGNED,
content TEXT,
FULLTEXT INDEX(content),
KEY(id)
) DEFAULT CHARSET UTF8;

INSERT INTO memos VALUES(1, "Today is fine.");
INSERT INTO memos VALUES(2, "Today's lucky item is flower!");
INSERT INTO memos VALUES(3, "I will do something today!");
INSERT INTO memos VALUES(4, "I don't want to anything today...");
INSERT INTO memos VALUES(5, "I'm sleepy today.");

SELECT * FROM memos
WHERE MATCH(content) AGAINST("today" IN BOOLEAN MODE) AND
id BETWEEN 2 AND 6
ORDER BY id LIMIT 1,2;

SHOW STATUS LIKE 'mroonga_fast_order_limit';

DROP TABLE memos;

--source ../../../../../../include/mroonga/have_mroonga_deinit.inc
@@ -0,0 +1,35 @@
DROP TABLE IF EXISTS memos;
FLUSH STATUS;
SET NAMES UTF8;
CREATE TABLE memos (
id INT UNSIGNED NOT NULL,
writing_time TIME,
content TEXT,
FULLTEXT INDEX(content),
KEY(writing_time)
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE memos;
Table Create Table
memos CREATE TABLE `memos` (
`id` int(10) unsigned NOT NULL,
`writing_time` time DEFAULT NULL,
`content` text,
KEY `writing_time` (`writing_time`),
FULLTEXT KEY `content` (`content`)
) ENGINE=mroonga DEFAULT CHARSET=utf8
INSERT INTO memos VALUES(1, "1:23:30", "Today is fine.");
INSERT INTO memos VALUES(2, "1:23:31", "Today's lucky item is flower!");
INSERT INTO memos VALUES(3, "1:23:32", "I will do something today!");
INSERT INTO memos VALUES(4, "1:23:33", "I don't want to anything today...");
INSERT INTO memos VALUES(5, "1:23:34", "I'm sleepy today.");
SELECT * FROM memos
WHERE MATCH(content) AGAINST("today" IN BOOLEAN MODE) AND
writing_time BETWEEN "1:23:31" AND "1:23:43"
ORDER BY id LIMIT 1,2;
id writing_time content
3 01:23:32 I will do something today!
4 01:23:33 I don't want to anything today...
SHOW STATUS LIKE 'mroonga_fast_order_limit';
Variable_name Value
Mroonga_fast_order_limit 1
DROP TABLE memos;
@@ -0,0 +1,50 @@
# Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com>
#
# 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/mroonga/have_mroonga.inc

--disable_warnings
DROP TABLE IF EXISTS memos;
--enable_warnings

FLUSH STATUS;

SET NAMES UTF8;
CREATE TABLE memos (
id INT UNSIGNED NOT NULL,
writing_time TIME,
content TEXT,
FULLTEXT INDEX(content),
KEY(writing_time)
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE memos;

INSERT INTO memos VALUES(1, "1:23:30", "Today is fine.");
INSERT INTO memos VALUES(2, "1:23:31", "Today's lucky item is flower!");
INSERT INTO memos VALUES(3, "1:23:32", "I will do something today!");
INSERT INTO memos VALUES(4, "1:23:33", "I don't want to anything today...");
INSERT INTO memos VALUES(5, "1:23:34", "I'm sleepy today.");

SELECT * FROM memos
WHERE MATCH(content) AGAINST("today" IN BOOLEAN MODE) AND
writing_time BETWEEN "1:23:31" AND "1:23:43"
ORDER BY id LIMIT 1,2;

SHOW STATUS LIKE 'mroonga_fast_order_limit';

DROP TABLE memos;

--source ../../../../../../include/mroonga/have_mroonga_deinit.inc
@@ -0,0 +1,30 @@
DROP TABLE IF EXISTS mroonga_releases;
FLUSH STATUS;
CREATE TABLE mroonga_releases (
id INT PRIMARY KEY AUTO_INCREMENT,
release_title TEXT,
release_year YEAR,
KEY (release_year),
FULLTEXT KEY (release_title)
) DEFAULT CHARSET UTF8;
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Groonga storage engine 0.1 has been released", "10");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Rename Groonga storage engine to Mroonga", "2011");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Mroonga 2.0 has been released", "2012");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Mroonga 3.0 has been released", "13");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Mroonga 4.0 will be released", "2014");
SELECT * FROM mroonga_releases
WHERE release_year BETWEEN "11" AND "2015" AND
MATCH(release_title) AGAINST("Mroonga" IN BOOLEAN MODE)
ORDER BY id DESC LIMIT 1,2;
id release_title release_year
4 Mroonga 3.0 has been released 2013
3 Mroonga 2.0 has been released 2012
SHOW STATUS LIKE 'mroonga_fast_order_limit';
Variable_name Value
Mroonga_fast_order_limit 1
DROP TABLE mroonga_releases;
@@ -0,0 +1,53 @@
# Copyright(C) 2013 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/mroonga/have_mroonga.inc

--disable_warnings
DROP TABLE IF EXISTS mroonga_releases;
--enable_warnings

FLUSH STATUS;

CREATE TABLE mroonga_releases (
id INT PRIMARY KEY AUTO_INCREMENT,
release_title TEXT,
release_year YEAR,
KEY (release_year),
FULLTEXT KEY (release_title)
) DEFAULT CHARSET UTF8;

INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Groonga storage engine 0.1 has been released", "10");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Rename Groonga storage engine to Mroonga", "2011");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Mroonga 2.0 has been released", "2012");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Mroonga 3.0 has been released", "13");
INSERT INTO mroonga_releases (release_title, release_year)
VALUES ("Mroonga 4.0 will be released", "2014");

SELECT * FROM mroonga_releases
WHERE release_year BETWEEN "11" AND "2015" AND
MATCH(release_title) AGAINST("Mroonga" IN BOOLEAN MODE)
ORDER BY id DESC LIMIT 1,2;

SHOW STATUS LIKE 'mroonga_fast_order_limit';

DROP TABLE mroonga_releases;

--source ../../../../../../include/mroonga/have_mroonga_deinit.inc

0 comments on commit 46aebd9

Please sign in to comment.