1#!/usr/bin/perl 2 3# Copyright (c) 2003, 2021, Oracle and/or its affiliates. 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, version 2.0, 8# as published by the Free Software Foundation. 9# 10# This program is also distributed with certain software (including 11# but not limited to OpenSSL) that is licensed under separate terms, 12# as designated in a particular file or component or in included license 13# documentation. The authors of MySQL hereby grant you an additional 14# permission to link the program and your derivative works with the 15# separately licensed software that they have included with MySQL. 16# 17# This program is distributed in the hope that it will be useful, 18# but WITHOUT ANY WARRANTY; without even the implied warranty of 19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20# GNU General Public License, version 2.0, for more details. 21# 22# You should have received a copy of the GNU General Public License 23# along with this program; if not, write to the Free Software 24# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 25 26$test=shift || die "Usage $0 testname [option]"; 27$option=shift; 28 29open(D, "<data/$test.d") || die "Cannot open(<data/$test.d): $!"; 30open(Q, "<data/$test.q") || die "Cannot open(<data/$test.q): $!"; 31 32$N=0; 33 34print <<__HEADER__; 35DROP TABLE IF EXISTS $test; 36CREATE TABLE $test ( 37 id int(10) unsigned NOT NULL, 38 text text NOT NULL, 39 FULLTEXT KEY text (text) 40) TYPE=MyISAM CHARSET=latin1; 41 42ALTER TABLE $test DISABLE KEYS; 43__HEADER__ 44 45while (<D>) { chomp; 46 s/'/\\'/g; ++$N; 47 print "INSERT $test VALUES ($N, '$_');\n"; 48} 49 50print <<__PREP__; 51ALTER TABLE $test ENABLE KEYS; 52SELECT $N; 53__PREP__ 54 55$N=0; 56 57while (<Q>) { chomp; 58 s/'/\\'/g; ++$N; 59 $_="MATCH text AGAINST ('$_' $option)"; 60 print "SELECT $N, id, $_ FROM $test WHERE $_;\n"; 61} 62 63print <<__FOOTER__; 64DROP TABLE $test; 65__FOOTER__ 66 67 68