| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
# Copyright (c) 2003, 2005 MySQL AB |
| 4 |
# Use is subject to license terms |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; version 2 of the License. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; if not, write to the Free Software |
| 17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 18 |
|
| 19 |
$test=shift || die "Usage $0 testname [option]"; |
| 20 |
$option=shift; |
| 21 |
|
| 22 |
open(D, "<data/$test.d") || die "Cannot open(<data/$test.d): $!"; |
| 23 |
open(Q, "<data/$test.q") || die "Cannot open(<data/$test.q): $!"; |
| 24 |
|
| 25 |
$N=0; |
| 26 |
|
| 27 |
print <<__HEADER__; |
| 28 |
DROP TABLE IF EXISTS $test; |
| 29 |
CREATE TABLE $test ( |
| 30 |
id int(10) unsigned NOT NULL, |
| 31 |
text text NOT NULL, |
| 32 |
FULLTEXT KEY text (text) |
| 33 |
) TYPE=MyISAM CHARSET=latin1; |
| 34 |
|
| 35 |
ALTER TABLE $test DISABLE KEYS; |
| 36 |
__HEADER__ |
| 37 |
|
| 38 |
while (<D>) { chomp; |
| 39 |
s/'/\\'/g; ++$N; |
| 40 |
print "INSERT $test VALUES ($N, '$_');\n"; |
| 41 |
} |
| 42 |
|
| 43 |
print <<__PREP__; |
| 44 |
ALTER TABLE $test ENABLE KEYS; |
| 45 |
SELECT $N; |
| 46 |
__PREP__ |
| 47 |
|
| 48 |
$N=0; |
| 49 |
|
| 50 |
while (<Q>) { chomp; |
| 51 |
s/'/\\'/g; ++$N; |
| 52 |
$_="MATCH text AGAINST ('$_' $option)"; |
| 53 |
print "SELECT $N, id, $_ FROM $test WHERE $_;\n"; |
| 54 |
} |
| 55 |
|
| 56 |
print <<__FOOTER__; |
| 57 |
DROP TABLE $test; |
| 58 |
__FOOTER__ |
| 59 |
|
| 60 |
|