Merge 5.3 -> 5.3-subqueries-mwl90

This commit is contained in:
Sergey Petrunya 2011-03-01 13:21:48 +03:00
commit cb147b3965
359 changed files with 27404 additions and 2224 deletions

View file

@ -1943,3 +1943,4 @@ storage/pbxt/bin/xtstat
libmysqld/sql_expression_cache.cc
mysql-test/mtr_command
scripts/convert-debug-for-diff
plugin/handler_socket/client/hsclient

View file

@ -28,7 +28,7 @@ fi
# Default to gcc for CC and CXX
if test -z "$CXX" ; then
export CXX
CXX=gcc
CXX=g++
# Set some required compile options
if test -z "$CXXFLAGS" ; then
export CXXFLAGS

View file

@ -4,7 +4,10 @@ path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$pentium64_cflags $fast_cflags"
extra_configs="$pentium_configs $static_link"
# On CentOS/Fedora Core 10 amd64, there is system libz.so but not
# libz.a, so need to use bundled zlib when building static
# binary. Hence we use --with-zlib-dir=bundled
extra_configs="$pentium_configs $static_link --with-zlib-dir=bundled"
CC="$CC --pipe"
strip=yes

31
README
View file

@ -1291,3 +1291,34 @@ Use of any of this software is governed by the terms of the license below:
*/
***************************************************************************
%%The following software may be included in this product:
HandlerSocket plugin for MySQL
Copyright (c) 2010 DeNA Co.,Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of DeNA Co.,Ltd. nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY DeNA Co.,Ltd. "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DeNA Co.,Ltd. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************

View file

@ -47,6 +47,7 @@ char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
char *pos;
ulong out_length;
DBUG_ASSERT(truncated != NULL);
LINT_INIT(out_length);
if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
return 0;

View file

@ -1012,8 +1012,13 @@ vi_histedit(EditLine *el, int c __attribute__((__unused__)))
if (fd < 0)
return CC_ERROR;
cp = el->el_line.buffer;
write(fd, cp, el->el_line.lastchar - cp +0u);
write(fd, "\n", 1);
if (write(fd, cp, el->el_line.lastchar - cp +0u) == -1 ||
write(fd, "\n", 1) == -1)
{
close(fd);
unlink(tempfile);
return CC_ERROR;
}
pid = fork();
switch (pid) {
case -1:

View file

@ -1481,7 +1481,7 @@ next:
subdir=0;
while (ctlp < end && *ctlp != ',')
ctlp++;
len=ctlp-start;
len= (int) (ctlp-start);
if (start[len-1] == '/')
{
len--;
@ -1544,7 +1544,7 @@ static struct link *ListCopy(struct link *orig)
{
struct link *new_malloc;
struct link *head;
int len;
size_t len;
head= NULL;
while (orig != NULL)
@ -1999,7 +1999,7 @@ static void DBUGOpenFile(CODE_STATE *cs,
{
if (end)
{
int len=end-name;
int len= (int) (end-name);
memcpy(cs->stack->name, name, len);
cs->stack->name[len]=0;
}

View file

@ -136,6 +136,8 @@ typedef struct st_heap_share
ulong min_records,max_records; /* Params to open */
ulonglong data_length,index_length,max_table_size;
uint key_stat_version; /* version to indicate insert/delete */
uint key_version; /* Updated on key change */
uint file_version; /* Update on clear */
uint records; /* records */
uint blength; /* records rounded up to 2^n */
uint deleted; /* Deleted records in database */
@ -173,6 +175,8 @@ typedef struct st_heap_info
enum ha_rkey_function last_find_flag;
TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
TREE_ELEMENT **last_pos;
uint key_version; /* Version at last read */
uint file_version; /* Version at scan */
uint lastkey_len;
my_bool implicit_emptied;
#ifdef THREAD

View file

@ -445,7 +445,8 @@ enum ha_base_keytype {
#define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */
#define HA_ERR_ROW_NOT_VISIBLE 177
#define HA_ERR_TOO_MANY_CONCURRENT_TRXS 178 /*Too many active concurrent transactions */
#define HA_ERR_LAST 178 /* Copy of last error nr */
#define HA_ERR_ABORTED_BY_USER 179
#define HA_ERR_LAST 179 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)

View file

@ -135,6 +135,9 @@ extern void my_handler_error_unregister(void);
if we're scanning "t.key BETWEEN 10 AND 20" and got a
"t.key=21" tuple (the engine should stop scanning and return
HA_ERR_END_OF_FILE right away).
-1= ICP_ERROR - Reserved for internal errors in engines. Should not be
returned by index_cond_func_xxx
*/
typedef enum icp_result {

View file

@ -88,6 +88,7 @@ typedef struct st_alarm {
extern uint thr_client_alarm;
extern pthread_t alarm_thread;
extern my_bool my_disable_thr_alarm;
#define thr_alarm_init(A) (*(A))=0
#define thr_alarm_in_use(A) (*(A)!= 0)

View file

@ -123,8 +123,10 @@ typedef struct st_thr_lock_data {
struct st_thr_lock *lock;
pthread_cond_t *cond;
void *status_param; /* Param to status functions */
void *debug_print_param;
enum thr_lock_type type;
enum thr_lock_type org_type; /* Cache for MariaDB */
void *debug_print_param; /* For error messages */
uint priority;
} THR_LOCK_DATA;

View file

@ -109,6 +109,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \
suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \
suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \
suite/innodb_plugin/include \
suite/handler \
suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \
suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \
suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \

View file

@ -4,13 +4,14 @@ this directory. It will fire up the newly built mysqld and test it.
Note that you do not have to have to do "make install", and you could
actually have a co-existing MySQL installation. The tests will not
conflict with it.
conflict with it. To run the test suite in a source directory, you
must do make first.
All tests must pass. If one or more of them fail on your system, please
read the following manual section for instructions on how to report the
problem:
http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html
http://kb.askmonty.org/v/reporting-bugs
If you want to use an already running MySQL server for specific tests,
use the --extern option to mysql-test-run. Please note that in this mode,
@ -27,7 +28,6 @@ With no test cases named on the command line, mysql-test-run falls back
to the normal "non-extern" behavior. The reason for this is that some
tests cannot run with an external server.
You can create your own test cases. To create a test case, create a new
file in the t subdirectory using a text editor. The file should have a .test
extension. For example:
@ -67,7 +67,12 @@ extension. For example:
edit the test result to the correct results so that we can verify
that the bug is corrected in future releases.
To submit your test case, put your .test file and .result file(s) into
a tar.gz archive, add a README that explains the problem, ftp the
archive to ftp://support.mysql.com/pub/mysql/secret/ and send a mail
to bugs@lists.mysql.com
If you want to submit your test case you can send it
to maria-developers@lists.launchpad.com or attach it to a bug report on
https://bugs.launchpad.net/maria/.
If the test case is really big or if it contains 'not public' data,
then put your .test file and .result file(s) into a tar.gz archive,
add a README that explains the problem, ftp the archive to
ftp://ftp.askmonty.org/private and send a mail to
https://bugs.launchpad.net/maria/ about it.

View file

@ -42,6 +42,7 @@ send STOP SLAVE SQL_THREAD;
connection slave1;
--echo # To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
--echo

View file

@ -43,7 +43,7 @@ connection default;
# of our statement.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "insert into $table (i) values (0)";
where state = "Table lock" and info = "insert into $table (i) values (0)";
--source include/wait_condition.inc
--disable_result_log

View file

@ -3,7 +3,7 @@
# i.e it will support dlopen
#
--source include/have_dynamic_loading.inc
--source include/not_windows_embedded.inc
#
# Check if the variable HA_EXAMPLE_SO is set
#

View file

@ -1,4 +1,5 @@
disable_query_log;
--require r/true.require
SELECT (plugin_description LIKE '%xtradb%') AS `TRUE` FROM information_schema.plugins WHERE LOWER(plugin_name) = 'innodb' AND LOWER(plugin_status) = 'active';
enable_query_log;
if (!`SELECT count(*) FROM information_schema.plugins WHERE
plugin_name = 'innodb' AND plugin_status = 'active' AND
plugin_description LIKE '%xtradb%'`){
skip Need XtraDB engine;
}

View file

@ -0,0 +1,2 @@
--loose-innodb
--plugin-load=$HA_XTRADB_SO

View file

@ -0,0 +1,4 @@
# We use this --source include to mark a test as taking long to run.
# We can use this to schedule such test early (to not be left with
# only one or two long tests running, and rests of works idle), or to
# run a quick test skipping long-running test cases.

View file

@ -89,6 +89,20 @@ sub init_pattern {
}
sub testcase_sort_order {
my ($a, $b, $sort_criteria)= @_;
my $a_sort_criteria= $sort_criteria->{$a->fullname()};
my $b_sort_criteria= $sort_criteria->{$b->fullname()};
my $res= $a_sort_criteria cmp $b_sort_criteria;
return $res if $res;
# Run slow tests first, trying to avoid getting stuck at the end
# with a slow test in one worker and the other workers idle.
return -1 if $a->{'long_test'} && !$b->{'long_test'};
return 1 if !$a->{'long_test'} && $b->{'long_test'};
return $a->fullname() cmp $b->fullname();
}
##############################################################################
#
# Collect information about test cases to be run
@ -177,9 +191,7 @@ sub collect_test_cases ($$$) {
$sort_criteria{$tinfo->fullname()} = join(" ", @criteria);
}
@$cases = sort {
$sort_criteria{$a->fullname()} . $a->fullname() cmp
$sort_criteria{$b->fullname()} . $b->fullname() } @$cases;
@$cases = sort { testcase_sort_order($a, $b, \%sort_criteria) } @$cases;
# For debugging the sort-order
# foreach my $tinfo (@$cases)
@ -1065,6 +1077,7 @@ my @tags=
["include/have_example_plugin.inc", "example_plugin_test", 1],
["include/have_oqgraph_engine.inc", "oqgraph_test", 1],
["include/have_ssl.inc", "need_ssl", 1],
["include/long_test.inc", "long_test", 1],
);

View file

@ -142,7 +142,7 @@ my $path_config_file; # The generated config file, var/my.cnf
# executables will be used by the test suite.
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
my $DEFAULT_SUITES="main,binlog,federated,rpl,maria,parts,innodb," .
my $DEFAULT_SUITES="main,binlog,federated,rpl,maria,handler,parts,innodb," .
"innodb_plugin,percona,ndb,vcol,oqgraph,sphinx," .
"optimizer_unfixed_bugs";
my $opt_suites;
@ -320,9 +320,10 @@ sub main {
gcov_prepare($basedir . "/" . $opt_gcov_src_dir);
}
if (!$opt_suites) {
$opt_suites= $DEFAULT_SUITES;
# Check for any extra suites to enable based on the path name
my %extra_suites=
(
@ -731,9 +732,11 @@ sub run_test_server ($$$) {
last;
}
# Second best choice is the first that does not fulfill
# any of the above conditions
if (!defined $second_best){
# From secondary choices, we prefer to pick a 'long-running' test if
# possible; this helps avoid getting stuck with a few of those at the
# end of high --parallel runs, with most workers being idle.
if (!defined $second_best ||
($t->{'long_test'} && !($tests->[$second_best]{'long_test'}))){
#mtr_report("Setting second_best to $i");
$second_best= $i;
}
@ -2376,7 +2379,7 @@ sub setup_vardir() {
$plugindir="$opt_vardir/plugins";
unshift (@opt_extra_mysqld_opt, "--plugin-dir=$plugindir");
mkpath($plugindir);
if (IS_WINDOWS)
if (IS_WINDOWS && !$opt_embedded_server)
{
for (<../storage/*$opt_vs_config/*.dll>,
<../plugin/*$opt_vs_config/*.dll>,

View file

@ -64,22 +64,22 @@ EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL 9 Using sort_intersect(Name,Population); Using where
1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'M%' AND Population > 1500000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 5 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 300000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range Population,Name Name 35 NULL 164 Using index condition; Using where; Using MRR
1 SIMPLE City range Population,Name Name 35 NULL # Using index condition; Using where; Using MRR
EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range Population,Name Population 4 NULL 15 Using index condition; Using where; Using MRR
1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where; Using MRR
SELECT * FROM City USE INDEX ()
WHERE Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
@ -361,17 +361,17 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Name,Population 35,4 NULL 9 Using sort_intersect(Name,Population); Using where
1 SIMPLE City index_merge Population,Country,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL 19 Using sort_intersect(Population,Country); Using where
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range Population,Country,Name Name 35 NULL 283 Using index condition; Using where; Using MRR
1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where; Using MRR
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
ID Name Country Population
@ -462,29 +462,29 @@ EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL 359 Using index condition; Using where; Using MRR
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where; Using MRR
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country Country,Population 3,4 NULL 6 Using sort_intersect(Country,Population); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country Country,Population 3,4 NULL # Using sort_intersect(Country,Population); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range PRIMARY,Population,Country Country 3 NULL 21 Using index condition; Using where; Using MRR
1 SIMPLE City range PRIMARY,Population,Country Country 3 NULL # Using index condition; Using where; Using MRR
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000
AND Country BETWEEN 'S' AND 'Z';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY 4,4 NULL 17 Using sort_intersect(Population,PRIMARY); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY 4,4 NULL # Using sort_intersect(Population,PRIMARY); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
AND Country BETWEEN 'S' AND 'Z' ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL 429 Using index condition; Using where; Using MRR
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where; Using MRR
SELECT * FROM City USE INDEX ()
WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
ID Name Country Population
@ -718,33 +718,33 @@ EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL 9 Using sort_intersect(Name,Population); Using where
1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'M%' AND Population > 1500000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 5 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL 19 Using sort_intersect(Population,Country); Using where
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range Population,Country,Name Name 35 NULL 225 Using index condition; Using where; Using MRR
1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where; Using MRR
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country Country,Population 3,4 NULL 6 Using sort_intersect(Country,Population); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country Country,Population 3,4 NULL # Using sort_intersect(Country,Population); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
AND Country BETWEEN 'S' AND 'Z';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL 429 Using index condition; Using where; Using MRR
1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where; Using MRR
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
@ -885,17 +885,17 @@ EXPLAIN
SELECT * FROM City
WHERE Country LIKE 'M%' AND Population > 1000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL 15 Using sort_intersect(Population,CountryID); Using where
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
EXPLAIN
SELECT * FROM City
WHERE Country='CHN' AND Population > 1500000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL 11 Using sort_intersect(Population,CountryID); Using where
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
EXPLAIN
SELECT * FROM City
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name,CountryID,CountryName CountryName,Population 38,4 NULL 1 Using sort_intersect(CountryName,Population); Using where
1 SIMPLE City index_merge Population,Name,CountryID,CountryName CountryName,Population 38,4 NULL # Using sort_intersect(CountryName,Population); Using where
SELECT * FROM City USE INDEX ()
WHERE Country LIKE 'M%' AND Population > 1000000;
ID Name Country Population
@ -1028,7 +1028,7 @@ EXPLAIN
SELECT * FROM t1
WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,f4 f4 35 NULL 5 Using index condition; Using where; Using MRR
1 SIMPLE t1 range PRIMARY,f4 f4 35 NULL # Using index condition; Using where; Using MRR
SELECT * FROM t1
WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
f1 f4 f5

View file

@ -65,22 +65,22 @@ EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 16 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'M%' AND Population > 1500000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 9 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 300000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL 79 Using sort_intersect(Name,Population); Using where
1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 1 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
SELECT * FROM City USE INDEX ()
WHERE Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
@ -362,17 +362,17 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL 2 Using sort_intersect(Population,Name,Country); Using where
1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL 2 Using sort_intersect(Population,Country,Name); Using where
1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL 26 Using sort_intersect(Population,Name,Country); Using where
1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
ID Name Country Population
@ -463,29 +463,29 @@ EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,3,4 NULL 11 Using sort_intersect(PRIMARY,Country,Population); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,3,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,3 NULL 1 Using sort_intersect(PRIMARY,Population,Country); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,3 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country 4,3 NULL 7 Using sort_intersect(PRIMARY,Country); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country 4,3 NULL # Using sort_intersect(PRIMARY,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000
AND Country BETWEEN 'S' AND 'Z';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,3,4 NULL 2 Using sort_intersect(PRIMARY,Country,Population); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,3,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
AND Country BETWEEN 'S' AND 'Z' ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,3 NULL 30 Using sort_intersect(PRIMARY,Population,Country); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,3 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
SELECT * FROM City USE INDEX ()
WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
ID Name Country Population
@ -719,33 +719,33 @@ EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 16 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'M%' AND Population > 1500000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL 9 Using sort_intersect(Population,Name); Using where
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL 2 Using sort_intersect(Population,Country,Name); Using where
1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Name,Population,Country 35,4,3 NULL 7 Using sort_intersect(Name,Population,Country); Using where
1 SIMPLE City index_merge Population,Country,Name Name,Population,Country 35,4,3 NULL # Using sort_intersect(Name,Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,3 NULL 1 Using sort_intersect(PRIMARY,Population,Country); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,3 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
AND Country BETWEEN 'S' AND 'Z';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,3,4 NULL 30 Using sort_intersect(PRIMARY,Country,Population); Using where
1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Country,Population 4,3,4 NULL # Using sort_intersect(PRIMARY,Country,Population); Using where
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
@ -886,17 +886,17 @@ EXPLAIN
SELECT * FROM City
WHERE Country LIKE 'M%' AND Population > 1000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL 16 Using sort_intersect(Population,CountryID); Using where
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
EXPLAIN
SELECT * FROM City
WHERE Country='CHN' AND Population > 1500000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL 11 Using sort_intersect(Population,CountryID); Using where
1 SIMPLE City index_merge Population,CountryID,CountryName Population,CountryID 4,3 NULL # Using sort_intersect(Population,CountryID); Using where
EXPLAIN
SELECT * FROM City
WHERE Country='CHN' AND Population > 1500000 AND Name LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name,CountryID,CountryName CountryName,Population 38,4 NULL 1 Using sort_intersect(CountryName,Population); Using where
1 SIMPLE City index_merge Population,Name,CountryID,CountryName CountryName,Population 38,4 NULL # Using sort_intersect(CountryName,Population); Using where
SELECT * FROM City USE INDEX ()
WHERE Country LIKE 'M%' AND Population > 1000000;
ID Name Country Population
@ -1026,7 +1026,7 @@ EXPLAIN
SELECT * FROM t1
WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,f4 PRIMARY,f4 4,35 NULL 1 Using sort_intersect(PRIMARY,f4); Using where
1 SIMPLE t1 index_merge PRIMARY,f4 PRIMARY,f4 4,35 NULL # Using sort_intersect(PRIMARY,f4); Using where
SELECT * FROM t1
WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
f1 f4 f5

View file

@ -1251,3 +1251,37 @@ Handler_read_rnd 0
Handler_read_rnd_next 1
DROP TABLE t1, t2;
End of 5.1 tests
#
# BUG#724275: Crash in JOIN::optimize in maria-5.3
#
create table t1 (a int);
insert into t1 values (1),(2);
insert into t1 select * from t1;
create table t2 (a int, b int, key(a,b));
insert into t2 values (1,1),(1,2),(1,3),(1,4),(2,5),(2,6),(2,7),(2,8),(2,9);
insert into t2 select * from t2;
insert into t2 select * from t2;
insert into t2 select * from t2;
create table t3 (a int, b int, key(a));
insert into t3 values (1,1),(2,2);
select * from
t3 straight_join t1 straight_join t2 force index(a)
where t2.a=1 and t2.b=t1.a and t1.a=t3.b and t3.a=1;
a b a a b
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
drop table t1,t2,t3;

View file

@ -201,7 +201,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -231,8 +231,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE CountryLanguage hash NULL hj_key 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -279,7 +279,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -309,8 +309,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash NULL hj_key 3 world.Country.Code 984 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (incremental, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -347,6 +347,110 @@ Long Beach United States English
Lexington-Fayette United States English
Louisville United States English
Little Rock United States English
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND City.Population > 5000000
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
Name Population Name Population
China 1277558000 Shanghai 9696300
China 1277558000 Peking 7472000
China 1277558000 Chongqing 6351600
China 1277558000 Tianjin 5286800
Colombia 42321000 Santafé de Bogotá 6260862
Congo, The Democratic Republic of the 51654000 Kinshasa 5064000
Chile 15211000 NULL NULL
Cambodia 11168000 NULL NULL
Cameroon 15085000 NULL NULL
Canada 31147000 NULL NULL
Cuba 11201000 NULL NULL
Côte d?Ivoire 14786000 NULL NULL
Czech Republic 10278100 NULL NULL
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND
(City.Population > 5000000 OR City.Name LIKE 'Za%')
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
Name Population Name Population
China 1277558000 Shanghai 9696300
China 1277558000 Peking 7472000
China 1277558000 Chongqing 6351600
China 1277558000 Tianjin 5286800
China 1277558000 Zaozhuang 380846
China 1277558000 Zaoyang 162198
China 1277558000 Zalantun 130031
Colombia 42321000 Santafé de Bogotá 6260862
Congo, The Democratic Republic of the 51654000 Kinshasa 5064000
Chile 15211000 NULL NULL
Cambodia 11168000 NULL NULL
Cameroon 15085000 NULL NULL
Canada 31147000 NULL NULL
Cuba 11201000 NULL NULL
Côte d?Ivoire 14786000 NULL NULL
Czech Republic 10278100 NULL NULL
CREATE INDEX City_Population ON City(Population);
CREATE INDEX City_Name ON City(Name);
ANALYZE TABLE City;
Table Op Msg_type Msg_text
world.City analyze status Table is already up to date
EXPLAIN
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND City.Population > 5000000
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash_range City_Population #hash#$hj:City_Population 3:4 world.Country.Code 25 Using where; Using MRR; Using join buffer (flat, BNLH join)
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND City.Population > 5000000
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
Name Population Name Population
China 1277558000 Shanghai 9696300
China 1277558000 Peking 7472000
China 1277558000 Chongqing 6351600
China 1277558000 Tianjin 5286800
Colombia 42321000 Santafé de Bogotá 6260862
Congo, The Democratic Republic of the 51654000 Kinshasa 5064000
Chile 15211000 NULL NULL
Cambodia 11168000 NULL NULL
Cameroon 15085000 NULL NULL
Canada 31147000 NULL NULL
Cuba 11201000 NULL NULL
Côte d?Ivoire 14786000 NULL NULL
Czech Republic 10278100 NULL NULL
EXPLAIN
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND
(City.Population > 5000000 OR City.Name LIKE 'Za%')
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash_index_merge City_Population,City_Name #hash#$hj:City_Population,City_Name 3:4,35 world.Country.Code 96 Using sort_union(City_Population,City_Name); Using where; Using join buffer (flat, BNLH join)
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND
(City.Population > 5000000 OR City.Name LIKE 'Za%')
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
Name Population Name Population
China 1277558000 Shanghai 9696300
China 1277558000 Peking 7472000
China 1277558000 Chongqing 6351600
China 1277558000 Tianjin 5286800
China 1277558000 Zaozhuang 380846
China 1277558000 Zaoyang 162198
China 1277558000 Zalantun 130031
Colombia 42321000 Santafé de Bogotá 6260862
Congo, The Democratic Republic of the 51654000 Kinshasa 5064000
Chile 15211000 NULL NULL
Cambodia 11168000 NULL NULL
Cameroon 15085000 NULL NULL
Canada 31147000 NULL NULL
Cuba 11201000 NULL NULL
Côte d?Ivoire 14786000 NULL NULL
Czech Republic 10278100 NULL NULL
DROP INDEX City_Population ON City;
DROP INDEX City_Name ON City;
set join_cache_level=default;
set join_buffer_size=256;
show variables like 'join_buffer_size';
@ -517,7 +621,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -547,8 +651,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash NULL hj_key 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -595,7 +699,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -625,8 +729,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE City hash NULL hj_key 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash NULL hj_key 3 world.Country.Code 984 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE City hash_ALL NULL #hash#$hj 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash_ALL NULL #hash#$hj 3 world.Country.Code 984 Using where; Using join buffer (incremental, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -712,7 +816,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 SIMPLE City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -742,8 +846,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE CountryLanguage ALL PRIMARY,Percentage NULL NULL NULL 984 Using where
1 SIMPLE Country hash PRIMARY PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash Country Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Country #hash#Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -786,7 +890,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 PRIMARY City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT Name FROM City
WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
City.Population > 100000;
@ -814,7 +918,7 @@ WHERE
Country.Population > 10000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE CountryLanguage hash PRIMARY PRIMARY 33 world.Country.Code,const 984 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash_ALL PRIMARY #hash#PRIMARY 33 world.Country.Code,const 984 Using where; Using join buffer (flat, BNLH join)
SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage)
FROM Country LEFT JOIN CountryLanguage ON
(CountryLanguage.Country=Country.Code AND Language='English')
@ -912,7 +1016,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 SIMPLE City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -942,8 +1046,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE CountryLanguage ALL PRIMARY,Percentage NULL NULL NULL 984 Using where
1 SIMPLE Country hash PRIMARY PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash Country Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Country #hash#Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (incremental, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -986,7 +1090,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 PRIMARY City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT Name FROM City
WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
City.Population > 100000;
@ -1014,7 +1118,7 @@ WHERE
Country.Population > 10000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 Using where
1 SIMPLE CountryLanguage hash PRIMARY PRIMARY 33 world.Country.Code,const 984 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE CountryLanguage hash_ALL PRIMARY #hash#PRIMARY 33 world.Country.Code,const 984 Using where; Using join buffer (flat, BNLH join)
SELECT Country.Name, IF(ISNULL(CountryLanguage.Country), NULL, CountryLanguage.Percentage)
FROM Country LEFT JOIN CountryLanguage ON
(CountryLanguage.Country=Country.Code AND Language='English')
@ -1099,6 +1203,65 @@ Belarus NULL
Venezuela NULL
Russian Federation NULL
Vietnam NULL
EXPLAIN
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND City.Population > 5000000
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country range Name Name 52 NULL # Using index condition; Using where; Using MRR
1 SIMPLE City hash_range Population,Country #hash#Country:Population 3:4 world.Country.Code # Using where; Using MRR; Using join buffer (flat, BNLH join)
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND City.Population > 5000000
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
Name Population Name Population
China 1277558000 Shanghai 9696300
China 1277558000 Peking 7472000
China 1277558000 Chongqing 6351600
China 1277558000 Tianjin 5286800
Colombia 42321000 Santafé de Bogotá 6260862
Congo, The Democratic Republic of the 51654000 Kinshasa 5064000
Chile 15211000 NULL NULL
Cambodia 11168000 NULL NULL
Cameroon 15085000 NULL NULL
Canada 31147000 NULL NULL
Cuba 11201000 NULL NULL
Côte d?Ivoire 14786000 NULL NULL
Czech Republic 10278100 NULL NULL
CREATE INDEX City_Name ON City(Name);
EXPLAIN
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND
(City.Population > 5000000 OR City.Name LIKE 'Za%')
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country range Name Name 52 NULL 17 Using index condition; Using where; Using MRR
1 SIMPLE City hash_index_merge Population,Country,City_Name #hash#Country:Population,City_Name 3:4,35 world.Country.Code 96 Using sort_union(Population,City_Name); Using where; Using join buffer (flat, BNLH join)
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND
(City.Population > 5000000 OR City.Name LIKE 'Za%')
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
Name Population Name Population
China 1277558000 Shanghai 9696300
China 1277558000 Peking 7472000
China 1277558000 Chongqing 6351600
China 1277558000 Tianjin 5286800
China 1277558000 Zaozhuang 380846
China 1277558000 Zaoyang 162198
China 1277558000 Zalantun 130031
Colombia 42321000 Santafé de Bogotá 6260862
Congo, The Democratic Republic of the 51654000 Kinshasa 5064000
Chile 15211000 NULL NULL
Cambodia 11168000 NULL NULL
Cameroon 15085000 NULL NULL
Canada 31147000 NULL NULL
Cuba 11201000 NULL NULL
Côte d?Ivoire 14786000 NULL NULL
Czech Republic 10278100 NULL NULL
DROP INDEX City_Name ON City;
show variables like 'join_buffer_size';
Variable_name Value
join_buffer_size 131072
@ -1904,7 +2067,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 SIMPLE City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -1934,8 +2097,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE CountryLanguage ALL PRIMARY,Percentage NULL NULL NULL 984 Using where
1 SIMPLE Country hash PRIMARY PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash Country Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Country #hash#Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -1978,7 +2141,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 PRIMARY City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT Name FROM City
WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
City.Population > 100000;
@ -2008,7 +2171,7 @@ WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 SIMPLE City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT City.Name, Country.Name FROM City,Country
WHERE City.Country=Country.Code AND
Country.Name LIKE 'L%' AND City.Population > 100000;
@ -2038,8 +2201,8 @@ CountryLanguage.Percentage > 50 AND
LENGTH(Language) < LENGTH(City.Name) - 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE CountryLanguage ALL PRIMARY,Percentage NULL NULL NULL 984 Using where
1 SIMPLE Country hash PRIMARY PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash Country Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE Country hash_ALL PRIMARY #hash#PRIMARY 3 world.CountryLanguage.Country 239 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE City hash_ALL Country #hash#Country 3 world.CountryLanguage.Country 4079 Using where; Using join buffer (incremental, BNLH join)
SELECT City.Name, Country.Name, CountryLanguage.Language
FROM City,Country,CountryLanguage
WHERE City.Country=Country.Code AND
@ -2082,7 +2245,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
City.Population > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY Country range PRIMARY,Name Name 52 NULL 10 Using index condition; Using MRR
1 PRIMARY City hash Population,Country Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY City hash_ALL Population,Country #hash#Country 3 world.Country.Code 4079 Using where; Using join buffer (flat, BNLH join)
SELECT Name FROM City
WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
City.Population > 100000;
@ -3105,7 +3268,7 @@ a b a c
explain select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 hash NULL hj_key 5 test.t1.a 3 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 Using where; Using join buffer (flat, BNLH join)
select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null;
a b a c
3 30 3 102
@ -3959,7 +4122,7 @@ WHERE t3.u <='a' AND t2.j < 5 AND t3.v = t2.u;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 16
1 SIMPLE t2 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 hash idx idx 3 test.t2.u 20 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 hash_ALL idx #hash#idx 3 test.t2.u 20 Using where; Using join buffer (flat, BNLH join)
SELECT t1.i, t1.d, t1.v, t2.i, t2.d, t2.t, t2.v FROM t1,t2,t3
WHERE t3.u <='a' AND t2.j < 5 AND t3.v = t2.u;
i d v i d t v
@ -4082,8 +4245,8 @@ SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v
GROUP BY t2.v ORDER BY t1.pk,t2.v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort
1 SIMPLE t3 hash PRIMARY,idx2 PRIMARY 4 test.t2.i 20 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash idx2 idx2 3 test.t3.v 15 Using join buffer (incremental, BNLH join)
1 SIMPLE t3 hash_ALL PRIMARY,idx2 #hash#PRIMARY 4 test.t2.i 20 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 15 Using join buffer (incremental, BNLH join)
SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v
GROUP BY t2.v ORDER BY t1.pk,t2.v;
v
@ -4134,7 +4297,7 @@ EXPLAIN
SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6
1 SIMPLE t1 hash cu cu 33 func 10 Using where; Using index; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_index cu #hash#cu:cu 33:33 func 10 Using where; Using join buffer (flat, BNLH join)
SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ;
i
6
@ -4161,7 +4324,7 @@ EXPLAIN
SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 36 Using where
1 SIMPLE t2 hash idx idx 10 test.t1.a,const 15 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 10 test.t1.a,const 15 Using join buffer (flat, BNLH join)
SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99;
a c
SET SESSION join_cache_level = DEFAULT;
@ -4211,7 +4374,7 @@ EXPLAIN
SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t2 hash idx idx 13 test.t1.v 18 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 13 test.t1.v 18 Using join buffer (flat, BNLH join)
SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v;
v i
f 4
@ -4220,7 +4383,7 @@ EXPLAIN
SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7
1 SIMPLE t2 hash idx idx 13 func 18 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 13 func 18 Using where; Using join buffer (flat, BNLH join)
SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v);
v i
f 5
@ -4273,8 +4436,8 @@ SELECT t3.i FROM t1,t2,t3
WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index idx idx 13 NULL 7 Using where; Using index
1 SIMPLE t2 hash idx idx 1003 test.t1.v 18 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 hash idx idx 1002 func 32 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 1003 test.t1.v 18 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 hash_ALL idx #hash#idx 1002 func 32 Using where; Using join buffer (incremental, BNLH join)
SELECT t3.i FROM t1,t2,t3
WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0;
i
@ -4311,7 +4474,7 @@ EXPLAIN
SELECT * FROM t1,t2 WHERE t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL idx NULL NULL NULL 3 Using where
1 SIMPLE t2 hash idx idx 515 test.t1.a 12 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 515 test.t1.a 12 Using join buffer (flat, BNLH join)
SELECT * FROM t1,t2 WHERE t2.a=t1.a;
pk a pk a
2 aa 30 aa
@ -4494,8 +4657,8 @@ t1 LEFT JOIN
WHERE t3.a3 IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t3 hash PRIMARY hj_key 5 test.t1.c1 1 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash NULL hj_key 5 test.t3.b3 1 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t3 hash_ALL PRIMARY #hash#$hj 5 test.t1.c1 1 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t3.b3 1 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)
SELECT * FROM
t1 LEFT JOIN
@ -4548,7 +4711,7 @@ SELECT * FROM t1 LEFT JOIN t2 JOIN t3 ON t3.a3 = t2.a2 ON t3.b3 <> 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 hash PRIMARY PRIMARY 4 test.t2.a2 1 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t3 hash_ALL PRIMARY #hash#PRIMARY 4 test.t2.a2 1 Using where; Using join buffer (incremental, BNLH join)
SELECT * FROM t1 LEFT JOIN t2 JOIN t3 ON t3.a3 = t2.a2 ON t3.b3 <> 0;
a1 a2 b2 a3 b3
0 2 1 2 1
@ -4624,7 +4787,7 @@ EXPLAIN
SELECT * FROM t1,t2 WHERE t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t2 hash idx idx 35 test.t1.a 15 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 35 test.t1.a 15 Using join buffer (flat, BNLH join)
SELECT * FROM t1,t2 WHERE t1.a=t2.a;
pk a pk a
20 BBBB 1 Bbbb
@ -4739,7 +4902,7 @@ EXPLAIN
SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
1 SIMPLE t2 hash idx idx 5 const 23 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_range idx #hash#idx:idx 5:5 const 4 Using index condition; Using MRR; Using join buffer (flat, BNLH join)
SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL;
a a b
1 NULL 10
@ -4767,7 +4930,7 @@ EXPLAIN
SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL f1 NULL NULL NULL 2 Using where
1 SIMPLE t2 hash f1 f1 13 test.t1.f1 12 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL f1 #hash#f1 13 test.t1.f1 12 Using join buffer (flat, BNLH join)
SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1;
f1 f2 f1 f2
SET SESSION join_cache_level = DEFAULT;
@ -4787,7 +4950,7 @@ EXPLAIN
SELECT a FROM t1,t2 WHERE t2.v = t1.v ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t2 hash idx idx 4 test.t1.v 8 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL idx #hash#idx 4 test.t1.v 8 Using join buffer (flat, BNLH join)
SELECT a FROM t1,t2 WHERE t2.v = t1.v ;
a
11

View file

@ -81,7 +81,7 @@ WHERE t3.a=1 OR t3.c IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where ((`test`.`t3`.`a` = 1) or isnull(`test`.`t3`.`c`))
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
@ -157,7 +157,7 @@ WHERE t3.a>1 OR t3.c IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where ((`test`.`t3`.`a` > 1) or isnull(`test`.`t3`.`c`))
@ -187,7 +187,7 @@ WHERE (t3.a>1 OR t3.c IS NULL) AND
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where (((`test`.`t3`.`a` > 1) or isnull(`test`.`t3`.`c`)) and ((`test`.`t5`.`a` < 3) or isnull(`test`.`t5`.`c`)))
@ -237,7 +237,7 @@ ON t7.b=t8.b AND t6.b < 10;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
1 SIMPLE t8 hash NULL hj_key 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and (`test`.`t8`.`b` = `test`.`t7`.`b`)) and (`test`.`t7`.`b` is not null))) where 1
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
@ -551,14 +551,14 @@ t0.b=t1.b AND
(t2.a >= 4 OR t2.c IS NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 hash NULL hj_key 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
1 SIMPLE t7 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
@ -646,14 +646,14 @@ t0.b=t1.b AND
(t9.a=1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 hash NULL hj_key 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t7 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
@ -845,7 +845,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2)
CREATE INDEX idx_b ON t2(b);
@ -913,14 +913,14 @@ t0.b=t1.b AND
(t9.a=1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 hash NULL hj_key 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 hash NULL hj_key 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t7 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
@ -963,14 +963,14 @@ t0.b=t1.b AND
(t9.a=1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 hash NULL hj_key 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t7 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
@ -1012,12 +1012,12 @@ t0.b=t1.b AND
(t9.a=1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 hash NULL hj_key 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t7 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
@ -1067,7 +1067,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t7 hash NULL hj_key 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 ref idx_b idx_b 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BKA join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
@ -1324,7 +1324,7 @@ c11 c21 c31
EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 hash NULL hj_key 5 test.t1.c11 0 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.c11 0 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (incremental, BNL join)
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL);

View file

@ -319,11 +319,11 @@ Lilliana Angelovska NULL NULL
explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 hash NULL hj_key 2 test.t1.id 3 Using where; Not exists; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 2 test.t1.id 3 Using where; Not exists; Using join buffer (flat, BNLH join)
explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 hash NULL hj_key 2 test.t1.id 3 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 2 test.t1.id 3 Using where; Using join buffer (flat, BNLH join)
select count(*) from t1 left join t2 on (t1.id = t2.owner);
count(*)
4
@ -339,11 +339,11 @@ Lilliana Angelovska NULL NULL
explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 hash NULL hj_key 2 test.t1.id 3 Using where; Not exists; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 2 test.t1.id 3 Using where; Not exists; Using join buffer (flat, BNLH join)
explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 hash NULL hj_key 2 test.t1.id 3 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 2 test.t1.id 3 Using where; Using join buffer (flat, BNLH join)
select count(*) from t2 right join t1 on (t1.id = t2.owner);
count(*)
4
@ -695,8 +695,8 @@ a1 a2 b1 b2 c1 c2
explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 hash NULL hj_key 4 test.t1.a1 2 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 hash NULL hj_key 5 test.t1.a1 2 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 4 test.t1.a1 2 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a1 2 Using where; Using join buffer (incremental, BNLH join)
drop table t1, t2, t3;
create table t1 (
a int(11),

View file

@ -162,13 +162,6 @@ ERROR 70100: Query execution was interrupted
unlock tables;
drop table t1;
drop table if exists t1;
create table t1 (a int) ENGINE=MEMORY;
--> client 2
handler t1 open;
ERROR HY000: Table storage engine for 't1' doesn't have this option
--> client 1
drop table t1;
drop table if exists t1;
create table t1 (i int);
connection: default
lock tables t1 write;

View file

@ -248,13 +248,13 @@ set global slow_query_log='OFF';
set @save_storage_engine= @@session.storage_engine;
set storage_engine= MEMORY;
alter table mysql.slow_log engine=ndb;
ERROR HY000: This storage engine cannot be used for log tables"
ERROR HY000: This storage engine cannot be used for log tables
alter table mysql.slow_log engine=innodb;
ERROR HY000: This storage engine cannot be used for log tables"
ERROR HY000: This storage engine cannot be used for log tables
alter table mysql.slow_log engine=archive;
ERROR HY000: This storage engine cannot be used for log tables"
ERROR HY000: This storage engine cannot be used for log tables
alter table mysql.slow_log engine=blackhole;
ERROR HY000: This storage engine cannot be used for log tables"
ERROR HY000: This storage engine cannot be used for log tables
set storage_engine= @save_storage_engine;
drop table mysql.slow_log;
drop table mysql.general_log;

View file

@ -198,3 +198,4 @@ COUNT(*)
12
DROP PROCEDURE insert_data;
DROP TABLE t1, t2, t3;
drop table if exists t0, t1, t1i, t1m;

View file

@ -75,9 +75,9 @@ SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
#illegal value fixed
CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
Warnings:
Warning 1652 Incorrect value '10000000000000000000' for option 'ULL'
Warning 1652 Incorrect value 'ttt' for option 'one_or_two'
Warning 1652 Incorrect value 'SSS' for option 'YESNO'
Warning 1653 Incorrect value '10000000000000000000' for option 'ULL'
Warning 1653 Incorrect value 'ttt' for option 'one_or_two'
Warning 1653 Incorrect value 'SSS' for option 'YESNO'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (

View file

@ -0,0 +1,18 @@
#
# Bug #725050: print keyuse info when hash join is used
#
create table t1 (a int, b int);
insert into t1 values (2,2), (1,1);
create table t2 (a int);
insert into t2 values (2), (3);
set session join_cache_level=3;
set @@debug = 'd:t:O,/tmp/trace.out';
explain select t1.b from t1,t2 where t1.b=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.b 2 Using where; Using join buffer (flat, BNLH join)
select t1.b from t1,t2 where t1.b=t2.a;
b
2
set session join_cache_level=default;
drop table t1,t2;

View file

@ -1370,7 +1370,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1200 Using where; Not exists; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1200 Using where; Not exists; Using join buffer (flat, BNLH join)
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
companynr companyname
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
@ -1398,39 +1398,39 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1 SIMPLE t2 hash NULL hj_key 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 test.t4.companynr 1199 Using where; Using join buffer (flat, BNLH join)
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr
37 36
@ -1438,7 +1438,7 @@ companynr companynr
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 hash NULL hj_key 1 func 1199 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 func 1199 Using where; Using join buffer (flat, BNLH join)
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
fld1 companynr fld3 period
038008 37 reporters 1008
@ -2337,7 +2337,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 system NULL NULL NULL NULL 0 const row not found
1 SIMPLE t4 const id4 NULL NULL NULL 1
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 hash NULL hj_key 4 test.t1.id1 1 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 4 test.t1.id1 1 Using where; Using join buffer (flat, BNLH join)
select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
id1 id2 id3 id4 id44
@ -2917,11 +2917,11 @@ a
EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t2 hash NULL hj_key 5 test.t1.a 3 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 Using where; Using join buffer (flat, BNLH join)
EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 hash NULL hj_key 5 test.t2.a 5 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t2.a 5 Using where; Using join buffer (flat, BNLH join)
DROP TABLE t1,t2;
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0

View file

@ -35,7 +35,7 @@ call bug9486();
show processlist;
Id User Host db Command Time State Info
# root localhost test Sleep # NULL
# root localhost test Query # Locked update t1, t2 set val= 1 where id1=id2
# root localhost test Query # Table lock update t1, t2 set val= 1 where id1=id2
# root localhost test Query # NULL show processlist
# root localhost test Sleep # NULL
unlock tables;

View file

@ -4957,6 +4957,17 @@ sum(a) sub
1 3
deallocate prepare stmt1;
drop table t1,t2;
#
# Bug LP#693935/#58727: Assertion failure with
# a single row subquery returning more than one row
#
create table t1 (a char(1) charset utf8);
insert into t1 values ('a'), ('b');
create table t2 (a binary(1));
insert into t2 values ('x'), ('y');
select * from t2 where a=(select a from t1) and a='x';
ERROR 21000: Subquery returns more than 1 row
drop table t1,t2;
End of 5.1 tests
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test

View file

@ -1031,10 +1031,10 @@ explain select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 Using temporary; Using filesort
1 PRIMARY t21 hash NULL hj_key 4 test.t11.a 26 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY t22 hash NULL hj_key 4 test.t11.a 26 Using where; Using join buffer (incremental, BNLH join)
1 PRIMARY t21 hash_ALL NULL #hash#$hj 4 test.t11.a 26 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY t22 hash_ALL NULL #hash#$hj 4 test.t11.a 26 Using where; Using join buffer (incremental, BNLH join)
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
2 SUBQUERY t12 hash NULL hj_key 4 test.t11.a 8 Using where; Using join buffer (flat, BNLH join)
2 SUBQUERY t12 hash_ALL NULL #hash#$hj 4 test.t11.a 8 Using where; Using join buffer (flat, BNLH join)
select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
a b c
@ -1155,7 +1155,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (incremental, BNL join)
1 PRIMARY C ALL NULL NULL NULL NULL 10 Using join buffer (incremental, BNL join)
1 PRIMARY D hash NULL hj_key 5 test.E.a 10 Using where; End temporary; Using join buffer (incremental, BNLH join)
1 PRIMARY D hash_ALL NULL #hash#$hj 5 test.E.a 10 Using where; End temporary; Using join buffer (incremental, BNLH join)
flush status;
select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E);
count(*)
@ -1193,11 +1193,11 @@ insert into t3 values (1),(2);
explain select * from t2 where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
1 PRIMARY t1 hash NULL hj_key 4 test.t2.a 4 Using where; End temporary; Using join buffer (flat, BNLH join)
1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.a 4 Using where; End temporary; Using join buffer (flat, BNLH join)
explain select * from t2 where a in (select a from t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
1 PRIMARY t2 hash NULL hj_key 5 test.t2.a 2 Using where; End temporary; Using join buffer (flat, BNLH join)
1 PRIMARY t2 hash_ALL NULL #hash#$hj 5 test.t2.a 2 Using where; End temporary; Using join buffer (flat, BNLH join)
explain select * from t2 where a in (select a from t3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Start temporary
@ -1212,7 +1212,7 @@ insert into t1 values (1),(2);
explain select * from t1 where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Start temporary
1 PRIMARY t1 hash NULL hj_key 6 test.t1.a 2 Using where; End temporary; Using join buffer (flat, BNLH join)
1 PRIMARY t1 hash_ALL NULL #hash#$hj 6 test.t1.a 2 Using where; End temporary; Using join buffer (flat, BNLH join)
drop table t1;
set @@optimizer_switch=@save_optimizer_switch;
create table t1 (a int);

View file

@ -689,3 +689,21 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY X ALL NULL NULL NULL NULL 10
2 DEPENDENT SUBQUERY B ALL a,b NULL NULL NULL 1000 Range checked for each record (index map: 0x3)
drop table t1, t2;
#
# BUG#723822: Crash in get_constant_key_infix with EXISTS ( SELECT .. DISTINCT )
#
CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ;
INSERT INTO t1 VALUES ('8','c'),('5','f');
ALTER TABLE t1 ADD KEY (f3,f1);
CREATE TABLE t2 ( f4 varchar(1)) ;
INSERT INTO t2 VALUES ('f'),('d');
SELECT * FROM t2
WHERE EXISTS (
SELECT DISTINCT f3
FROM t1
WHERE f3 <= t2.f4
);
f4
f
d
drop table t1,t2;

View file

@ -4956,6 +4956,17 @@ sum(a) sub
1 3
deallocate prepare stmt1;
drop table t1,t2;
#
# Bug LP#693935/#58727: Assertion failure with
# a single row subquery returning more than one row
#
create table t1 (a char(1) charset utf8);
insert into t1 values ('a'), ('b');
create table t2 (a binary(1));
insert into t2 values ('x'), ('y');
select * from t2 where a=(select a from t1) and a='x';
ERROR 21000: Subquery returns more than 1 row
drop table t1,t2;
End of 5.1 tests
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test

View file

@ -4953,6 +4953,17 @@ sum(a) sub
1 3
deallocate prepare stmt1;
drop table t1,t2;
#
# Bug LP#693935/#58727: Assertion failure with
# a single row subquery returning more than one row
#
create table t1 (a char(1) charset utf8);
insert into t1 values ('a'), ('b');
create table t2 (a binary(1));
insert into t2 values ('x'), ('y');
select * from t2 where a=(select a from t1) and a='x';
ERROR 21000: Subquery returns more than 1 row
drop table t1,t2;
End of 5.1 tests
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test

View file

@ -4953,6 +4953,17 @@ sum(a) sub
1 3
deallocate prepare stmt1;
drop table t1,t2;
#
# Bug LP#693935/#58727: Assertion failure with
# a single row subquery returning more than one row
#
create table t1 (a char(1) charset utf8);
insert into t1 values ('a'), ('b');
create table t2 (a binary(1));
insert into t2 values ('x'), ('y');
select * from t2 where a=(select a from t1) and a='x';
ERROR 21000: Subquery returns more than 1 row
drop table t1,t2;
End of 5.1 tests
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test

View file

@ -138,7 +138,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
1 PRIMARY ot hash NULL hj_key 5 test.it.a 32 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 32 Using where; Using join buffer (flat, BNLH join)
2 SUBQUERY it ALL NULL NULL NULL NULL 22 Using where
select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
@ -206,7 +206,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
1 PRIMARY ot hash NULL hj_key 5 test.it.a 52 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 52 Using where; Using join buffer (flat, BNLH join)
2 SUBQUERY it ALL NULL NULL NULL NULL 22 Using where
select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
@ -592,7 +592,7 @@ explain
select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
1 PRIMARY t2 hash NULL hj_key 5 test.t1.a 3 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 Using where; Using join buffer (flat, BNLH join)
2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
drop table t0, t1, t2, t3;
create table t1 (a int);

View file

@ -535,3 +535,34 @@ HAVING
field4 != 6;
field1 field2 field3 field4 field5 field6
drop table t0,t1,t2,t3,t4,t5,t6;
#
# BUG#675118: Elimination of a table results in an invalid execution plan
#
CREATE TABLE t1 (f1 int(11), PRIMARY KEY (f1)) ;
CREATE TABLE t2 (f4 varchar(1024), KEY (f4)) ;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
INSERT IGNORE INTO t2 VALUES ('xcddwntkbxyorzdv'),
('cnxxcddwntkbxyor'),('r'),('r'), ('did'),('I'),('when'),
('hczkfqjeggivdvac'),('e'),('okay'),('up');
CREATE TABLE t3 (f4 varchar(1024), f1 int(11), f2 int(11)) ;
INSERT IGNORE INTO t3 VALUES ('f','4','0'),('n','5','-996540416');
CREATE TABLE t4 (f1 int(11), f3 varchar(10)) ;
INSERT IGNORE INTO t4 VALUES ('8','n'),('9','nwzcerzsgx'),('10','c');
CREATE TABLE t5 (f5 int(11), KEY (f5)) ;
EXPLAIN
SELECT t3.f2
FROM t2
LEFT JOIN t3
LEFT JOIN t4
LEFT JOIN t1 ON t4.f1 = t1.f1
JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4
WHERE t3.f2 ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t5 ref f5 f5 5 test.t3.f1 2 Using where; Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ALL f4 NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join)
# ^^ The above must not produce a QEP of t3,t5,t2,t4
# as that violates the "no interleaving of outer join nests" rule.
DROP TABLE t1,t2,t3,t4,t5;

View file

@ -3,9 +3,9 @@ SET @OLD_SQL_MODE=@@SQL_MODE;
SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1';
Warnings:
Warning 1651 Unknown option 'fkey'
Warning 1651 Unknown option 'dff'
Warning 1651 Unknown option 'tkey1'
Warning 1652 Unknown option 'fkey'
Warning 1652 Unknown option 'dff'
Warning 1652 Unknown option 'tkey1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -16,10 +16,10 @@ drop table t1;
#reassiginig options in the same line
create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1;
Warnings:
Warning 1651 Unknown option 'fkey'
Warning 1651 Unknown option 'dff'
Warning 1651 Unknown option 'tkey1'
Warning 1651 Unknown option 'tkey2'
Warning 1652 Unknown option 'fkey'
Warning 1652 Unknown option 'dff'
Warning 1652 Unknown option 'tkey1'
Warning 1652 Unknown option 'tkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -29,7 +29,7 @@ t1 CREATE TABLE `t1` (
#add option
alter table t1 tkey4=4v1;
Warnings:
Warning 1651 Unknown option 'tkey4'
Warning 1652 Unknown option 'tkey4'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -39,8 +39,8 @@ t1 CREATE TABLE `t1` (
#remove options
alter table t1 tkey3=DEFAULT tkey4=DEFAULT;
Warnings:
Warning 1651 Unknown option 'tkey3'
Warning 1651 Unknown option 'tkey4'
Warning 1652 Unknown option 'tkey3'
Warning 1652 Unknown option 'tkey4'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -50,11 +50,11 @@ t1 CREATE TABLE `t1` (
drop table t1;
create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1;
Warnings:
Warning 1651 Unknown option 'fkey1'
Warning 1651 Unknown option 'kkey1'
Warning 1651 Unknown option 'TKEY1'
Warning 1651 Unknown option 'tkey2'
Warning 1651 Unknown option 'tkey3'
Warning 1652 Unknown option 'fkey1'
Warning 1652 Unknown option 'kkey1'
Warning 1652 Unknown option 'TKEY1'
Warning 1652 Unknown option 'tkey2'
Warning 1652 Unknown option 'tkey3'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -64,7 +64,7 @@ t1 CREATE TABLE `t1` (
#change field with option with the same value
alter table t1 change a a int `FKEY1`='v1';
Warnings:
Warning 1651 Unknown option 'FKEY1'
Warning 1652 Unknown option 'FKEY1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -74,7 +74,7 @@ t1 CREATE TABLE `t1` (
#change field with option with a different value
alter table t1 change a a int fkey1=v2;
Warnings:
Warning 1651 Unknown option 'fkey1'
Warning 1652 Unknown option 'fkey1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -93,7 +93,7 @@ t1 CREATE TABLE `t1` (
#new key with options
alter table t1 add key bkey (b) kkey2=v1;
Warnings:
Warning 1651 Unknown option 'kkey2'
Warning 1652 Unknown option 'kkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -105,8 +105,8 @@ t1 CREATE TABLE `t1` (
#new column with options
alter table t1 add column c int fkey1=v1 fkey2=v2;
Warnings:
Warning 1651 Unknown option 'fkey1'
Warning 1651 Unknown option 'fkey2'
Warning 1652 Unknown option 'fkey1'
Warning 1652 Unknown option 'fkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -141,7 +141,7 @@ t1 CREATE TABLE `t1` (
#add column with options after delete
alter table t1 add column b int fkey2=v1;
Warnings:
Warning 1651 Unknown option 'fkey2'
Warning 1652 Unknown option 'fkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -154,7 +154,7 @@ t1 CREATE TABLE `t1` (
#add key
alter table t1 add key bkey (b) kkey2=v2;
Warnings:
Warning 1651 Unknown option 'kkey2'
Warning 1652 Unknown option 'kkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -168,7 +168,7 @@ t1 CREATE TABLE `t1` (
drop table t1;
create table t1 (a int) tkey1=100;
Warnings:
Warning 1651 Unknown option 'tkey1'
Warning 1652 Unknown option 'tkey1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (

View file

@ -60,7 +60,7 @@ let $wait_condition=
--echo # con1
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
state = "Locked" and info = "INSERT INTO t2 VALUES (3)";
state = "Table Lock" and info = "INSERT INTO t2 VALUES (3)";
--source include/wait_condition.inc
SELECT RELEASE_LOCK('Bug#34306');
--connection con2

View file

@ -1,4 +1,5 @@
--source include/have_debug.inc
--source include/long_test.inc
--source federated.inc
--echo #

View file

@ -368,13 +368,13 @@ echo
;
connection default;
echo
# Poll till INFO is no more NULL and State = 'Locked'.
# Poll till INFO is no more NULL and State = "Table Lock".
;
let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO IS NOT NULL AND STATE = 'Locked';
WHERE INFO IS NOT NULL AND STATE = "Table Lock";
--source include/wait_condition.inc
#
# Expect to see the state 'Locked' for the third connection because the SELECT
# Expect to see the state "Table Lock" for the third connection because the SELECT
# collides with the WRITE TABLE LOCK.
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
@ -423,10 +423,10 @@ echo
;
connection default;
echo
# Poll till INFO is no more NULL and State = 'Locked'.
# Poll till INFO is no more NULL and State = "Table Lock".
;
let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO IS NOT NULL AND STATE = 'Locked';
WHERE INFO IS NOT NULL AND STATE = "Table Lock";
--source include/wait_condition.inc
echo
# Expect result:

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,842 @@
SET SESSION STORAGE_ENGINE = Aria;
drop table if exists t1,t3,t4,t5;
create table t1 (a int, b char(10), key a (a), key b (a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");
handler t1 open as t2;
handler t2 read b first;
a b
14 aaa
handler t2 read b next;
a b
16 ccc
handler t2 read b next;
a b
16 xxx
handler t2 read b prev;
a b
16 ccc
handler t2 read b last;
a b
25 xxx
handler t2 read b prev;
a b
24 xxx
handler t2 read b prev;
a b
23 xxx
handler t2 read b first;
a b
14 aaa
handler t2 read b prev;
a b
handler t2 read b last;
a b
25 xxx
handler t2 read b prev;
a b
24 xxx
handler t2 read b next;
a b
25 xxx
handler t2 read b next;
a b
handler t2 read a=(15);
a b
handler t2 read a=(21);
a b
21 hhh
handler t2 read a=(19,"fff");
ERROR 42000: Too many key parts specified; max 1 parts allowed
handler t2 read b=(19,"fff");
a b
19 fff
handler t2 read b=(19,"yyy");
a b
19 yyy
handler t2 read b=(19);
a b
19 fff
handler t1 read a last;
ERROR 42S02: Unknown table 't1' in HANDLER
handler t2 read a=(11);
a b
handler t2 read a>=(11);
a b
14 aaa
handler t2 read b=(18);
a b
18 eee
handler t2 read b>=(18);
a b
18 eee
handler t2 read b>(18);
a b
19 fff
handler t2 read b<=(18);
a b
18 eee
handler t2 read b<(18);
a b
17 ddd
handler t2 read a=(15);
a b
handler t2 read a>=(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a>(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a<=(15);
a b
14 aaa
handler t2 read a<(15);
a b
14 aaa
handler t2 read a=(54);
a b
handler t2 read a>=(54);
a b
handler t2 read a>(54);
a b
handler t2 read a<=(54);
a b
25 xxx
handler t2 read a<(54);
a b
25 xxx
handler t2 read a=(1);
a b
handler t2 read a>=(1);
a b
14 aaa
handler t2 read a>(1);
a b
14 aaa
handler t2 read a<=(1);
a b
handler t2 read a<(1);
a b
handler t2 read b first limit 5;
a b
14 aaa
16 ccc
16 xxx
17 ddd
18 eee
handler t2 read b next limit 3;
a b
19 fff
19 yyy
20 ggg
handler t2 read b prev limit 10;
a b
19 yyy
19 fff
18 eee
17 ddd
16 xxx
16 ccc
14 aaa
handler t2 read b>=(16) limit 4;
a b
16 ccc
16 xxx
17 ddd
18 eee
handler t2 read b>=(16) limit 2,2;
a b
17 ddd
18 eee
select * from t1 where a>=16 order by a,b limit 2,2;
a b
17 ddd
18 eee
handler t2 read a last limit 3;
a b
25 xxx
24 xxx
23 xxx
handler t2 read b=(16) limit 1,3;
a b
16 xxx
handler t2 read b=(19);
a b
19 fff
handler t2 read b=(19) where b="yyy";
a b
19 yyy
handler t2 read first;
a b
17 ddd
handler t2 read next;
a b
18 eee
handler t2 read next;
a b
19 fff
handler t2 close;
handler t1 open;
handler t1 read b next;
a b
14 aaa
handler t1 read b next;
a b
16 ccc
handler t1 close;
handler t1 open;
handler t1 read a prev;
a b
25 xxx
handler t1 read a prev;
a b
24 xxx
handler t1 close;
handler t1 open as t2;
handler t2 read first;
a b
17 ddd
alter table t1 engine = Aria;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open;
handler t1 read a=(20) limit 1,3;
a b
flush tables;
handler t1 read a=(20) limit 1,3;
a b
handler t1 close;
handler t1 open;
handler t1 read a=(25);
a b
25 xxx
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(14);
a b
14 aaa
handler t1 read a prev;
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a next;
a b
14 aaa
handler t1 close;
handler t1 open;
prepare stmt from 'handler t1 read a=(?) limit ?,?';
set @a=20,@b=1,@c=100;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=2,@c=1;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=0,@c=2;
execute stmt using @a,@b,@c;
a b
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a next limit ?';
handler t1 read a>=(21);
a b
21 hhh
set @a=3;
execute stmt using @a;
a b
22 iii
23 xxx
24 xxx
execute stmt using @a;
a b
25 xxx
execute stmt using @a;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b prev limit ?';
execute stmt using @a;
a b
25 xxx
24 xxx
23 xxx
execute stmt using @a;
a b
22 iii
21 hhh
20 ggg
execute stmt using @a;
a b
19 yyy
19 fff
18 eee
execute stmt using @a;
a b
17 ddd
16 xxx
16 ccc
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(?,?)';
set @a=14, @b='aaa';
execute stmt using @a,@b;
a b
14 aaa
set @a=14, @b='not found';
execute stmt using @a,@b;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(1+?) limit 10';
set @a=15;
execute stmt using @a;
a b
16 ccc
16 xxx
execute stmt using @a;
a b
16 ccc
16 xxx
deallocate prepare stmt;
prepare stmt from 'handler t1 read b>=(?) where a < ? limit 5';
set @a=17, @b=24;
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a=(?)';
set @a=17;
execute stmt using @a;
a b
17 ddd
alter table t1 add c int;
execute stmt using @a;
ERROR 42S02: Unknown table 't1' in HANDLER
deallocate prepare stmt;
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
handler t1 open;
prepare stmt from 'handler t1 read a=(?)';
flush tables;
set @a=17;
execute stmt using @a;
ERROR HY000: Prepared statement needs to be re-prepared
deallocate prepare stmt;
handler t1 close;
handler t1 open as t2;
drop table t1;
create table t1 (a int not null);
insert into t1 values (17);
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open as t2;
alter table t1 engine=CSV;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
handler t1 open;
handler t1 read first;
a
3
handler t1 read first limit 1,1;
a
4
handler t1 read first limit 2,2;
a
5
6
delete from t1 limit 3;
handler t1 read first;
a
6
drop table t1;
create table t1(a int, index (a));
insert into t1 values (1), (2), (3);
handler t1 open;
handler t1 read a=(W);
ERROR 42S22: Unknown column 'W' in 'field list'
handler t1 read a=(a);
ERROR HY000: Incorrect arguments to HANDLER ... READ
drop table t1;
create table t1 (a char(5));
insert into t1 values ("Ok");
handler t1 open as t;
handler t read first;
a
Ok
use mysql;
handler t read first;
a
Ok
handler t close;
handler test.t1 open as t;
handler t read first;
a
Ok
handler t close;
use test;
drop table t1;
create table t1 ( a int, b int, INDEX a (a) );
insert into t1 values (1,2), (2,1);
handler t1 open;
handler t1 read a=(1) where b=2;
a b
1 2
handler t1 read a=(1) where b=3;
a b
handler t1 read a=(1) where b=1;
a b
handler t1 close;
drop table t1;
create table t1 (c1 char(20));
insert into t1 values ("t1");
handler t1 open as h1;
handler h1 read first limit 9;
c1
t1
create table t2 (c1 char(20));
insert into t2 values ("t2");
handler t2 open as h2;
handler h2 read first limit 9;
c1
t2
create table t3 (c1 char(20));
insert into t3 values ("t3");
handler t3 open as h3;
handler h3 read first limit 9;
c1
t3
create table t4 (c1 char(20));
insert into t4 values ("t4");
handler t4 open as h4;
handler h4 read first limit 9;
c1
t4
create table t5 (c1 char(20));
insert into t5 values ("t5");
handler t5 open as h5;
handler h5 read first limit 9;
c1
t5
alter table t1 engine=MyISAM;
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
c1
t2
handler h3 read first limit 9;
c1
t3
handler h4 read first limit 9;
c1
t4
handler h5 read first limit 9;
c1
t5
alter table t5 engine=MyISAM;
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
c1
t2
handler h3 read first limit 9;
c1
t3
handler h4 read first limit 9;
c1
t4
handler h5 read first limit 9;
ERROR 42S02: Unknown table 'h5' in HANDLER
alter table t3 engine=MyISAM;
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
c1
t2
handler h3 read first limit 9;
ERROR 42S02: Unknown table 'h3' in HANDLER
handler h4 read first limit 9;
c1
t4
handler h5 read first limit 9;
ERROR 42S02: Unknown table 'h5' in HANDLER
handler h2 close;
handler h4 close;
handler t1 open as h1_1;
handler t1 open as h1_2;
handler t1 open as h1_3;
handler h1_1 read first limit 9;
c1
t1
handler h1_2 read first limit 9;
c1
t1
handler h1_3 read first limit 9;
c1
t1
alter table t1 engine=Aria;
handler h1_1 read first limit 9;
ERROR 42S02: Unknown table 'h1_1' in HANDLER
handler h1_2 read first limit 9;
ERROR 42S02: Unknown table 'h1_2' in HANDLER
handler h1_3 read first limit 9;
ERROR 42S02: Unknown table 'h1_3' in HANDLER
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
create table t1 (c1 int);
insert into t1 values (1);
handler t1 open;
handler t1 read first;
c1
1
send the below to another connection, do not wait for the result
optimize table t1;
proceed with the normal connection
handler t1 read next;
c1
1
handler t1 close;
read the result from the other connection
Table Op Msg_type Msg_text
test.t1 optimize status OK
proceed with the normal connection
drop table t1;
CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2));
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
HANDLER t1 OPEN;
HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` PREV;
no1 no2
1 275
HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` NEXT;
no1 no2
2 6
DROP TABLE t1;
create table t1 (c1 int);
insert into t1 values (14397);
flush tables with read lock;
drop table t1;
ERROR HY000: Can't execute the query because you have a conflicting read lock
send the below to another connection, do not wait for the result
drop table t1;
proceed with the normal connection
select * from t1;
c1
14397
unlock tables;
read the result from the other connection
proceed with the normal connection
select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1 (a int not null) ENGINE=CSV;
--> client 2
handler t1 open;
ERROR HY000: Table storage engine for 't1' doesn't have this option
--> client 1
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read a next;
ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
handler t1_alias READ a next where inexistent > 0;
ERROR 42S22: Unknown column 'inexistent' in 'field list'
handler t1_alias read a next;
ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
handler t1_alias READ a next where inexistent > 0;
ERROR 42S22: Unknown column 'inexistent' in 'field list'
handler t1_alias close;
drop table t1;
create temporary table t1 (a int, b char(1), key a (a), key b (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
select a,b from t1;
a b
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
8 i
9 j
9 k
handler t1 open as a1;
handler a1 read a=(1);
a b
1 b
handler a1 read a next;
a b
2 c
handler a1 read a next;
a b
3 d
select a,b from t1;
ERROR HY000: Can't reopen table: 'a1'
handler a1 read a prev;
a b
2 c
handler a1 read a prev;
a b
1 b
handler a1 read a=(6) where b="g";
a b
6 g
handler a1 close;
select a,b from t1;
a b
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
8 i
9 j
9 k
handler t1 open as a2;
handler a2 read b=(9);
a b
9 j
handler a2 read b next;
a b
9 k
handler a2 read b prev limit 2;
a b
9 j
8 i
handler a2 read b last;
a b
9 k
handler a2 read b prev;
a b
9 j
handler a2 close;
drop table t1;
create table t1 (a int);
create temporary table t2 (a int, key (a));
handler t1 open as a1;
handler t2 open as a2;
handler a2 read a first;
a
drop table t1, t2;
handler a2 read a next;
ERROR 42S02: Unknown table 'a2' in HANDLER
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
create table t1 (a int, key (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
handler a1 read a first;
a
handler a2 read a first;
a
alter table t1 add b int;
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
create table t1 (a int, key (a));
handler t1 open as a1;
handler a1 read a first;
a
rename table t1 to t2;
handler a1 read a first;
ERROR 42S02: Unknown table 'a1' in HANDLER
drop table t2;
create table t1 (a int, key (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
handler a1 read a first;
a
handler a2 read a first;
a
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
#
# BUG#51877 - HANDLER interface causes invalid memory read
#
CREATE TABLE t1(a INT, KEY (a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
a
INSERT INTO t1 VALUES(1);
HANDLER t1 READ a NEXT;
a
1
HANDLER t1 CLOSE;
DROP TABLE t1;
#
# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
#
CREATE TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
HANDLER t1 READ FIRST;
ERROR 42S02: Unknown table 't1' in HANDLER
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
HANDLER t1 READ FIRST;
ERROR 42S02: Unknown table 't1' in HANDLER
DROP TABLE t1;
#
# Bug #54007: assert in ha_myisam::index_next , HANDLER
#
CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
a b
HANDLER t1 READ `PRIMARY` NEXT;
a b
HANDLER t1 READ ab NEXT;
a b
HANDLER t1 READ b NEXT;
a b
HANDLER t1 READ NEXT;
a b
HANDLER t1 CLOSE;
INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30);
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
a b
2 20
HANDLER t1 READ NEXT;
a b
1 10
HANDLER t1 READ `PRIMARY` NEXT;
a b
1 10
HANDLER t1 READ `PRIMARY` NEXT;
a b
2 20
HANDLER t1 READ ab NEXT;
a b
1 10
HANDLER t1 READ ab NEXT;
a b
2 20
HANDLER t1 READ b NEXT;
a b
1 10
HANDLER t1 READ b NEXT;
a b
2 20
HANDLER t1 READ b NEXT;
a b
3 30
HANDLER t1 READ b NEXT;
a b
4 40
HANDLER t1 READ b NEXT;
a b
HANDLER t1 READ NEXT;
a b
2 20
HANDLER t1 READ NEXT;
a b
1 10
HANDLER t1 READ NEXT;
a b
4 40
HANDLER t1 CLOSE;
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
a b
2 20
HANDLER t1 READ `PRIMARY` PREV;
a b
4 40
HANDLER t1 READ `PRIMARY` PREV;
a b
3 30
HANDLER t1 READ b PREV;
a b
4 40
HANDLER t1 READ b PREV;
a b
3 30
HANDLER t1 CLOSE;
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
a b
2 20
HANDLER t1 READ `PRIMARY` PREV LIMIT 3;
a b
4 40
3 30
2 20
HANDLER t1 READ b NEXT LIMIT 5;
a b
1 10
2 20
3 30
4 40
HANDLER t1 CLOSE;
DROP TABLE t1;
End of 5.1 tests

View file

@ -0,0 +1,82 @@
# t/handler_innodb.test
#
# test of HANDLER ...
#
# Last update:
# 2006-07-31 ML test refactored (MySQL 5.1)
# code of t/handler.test and t/innodb_handler.test united
# main testing code put into handler.inc
# rename t/innodb_handler.test to t/handler_innodb.test
#
--source include/have_maria.inc
let $engine_type= Aria;
--source init.inc
--source handler.inc
--echo #
--echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
--echo #
CREATE TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
--error ER_UNKNOWN_TABLE
HANDLER t1 READ FIRST;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
--error ER_UNKNOWN_TABLE
HANDLER t1 READ FIRST;
DROP TABLE t1;
--echo #
--echo # Bug #54007: assert in ha_myisam::index_next , HANDLER
--echo #
CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
HANDLER t1 READ `PRIMARY` NEXT;
HANDLER t1 READ ab NEXT;
HANDLER t1 READ b NEXT;
HANDLER t1 READ NEXT;
HANDLER t1 CLOSE;
INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30);
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
HANDLER t1 READ NEXT;
HANDLER t1 READ `PRIMARY` NEXT;
HANDLER t1 READ `PRIMARY` NEXT;
HANDLER t1 READ ab NEXT;
HANDLER t1 READ ab NEXT;
HANDLER t1 READ b NEXT;
HANDLER t1 READ b NEXT;
HANDLER t1 READ b NEXT;
HANDLER t1 READ b NEXT;
HANDLER t1 READ b NEXT;
HANDLER t1 READ NEXT;
HANDLER t1 READ NEXT;
HANDLER t1 READ NEXT;
HANDLER t1 CLOSE;
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
HANDLER t1 READ `PRIMARY` PREV;
HANDLER t1 READ `PRIMARY` PREV;
HANDLER t1 READ b PREV;
HANDLER t1 READ b PREV;
HANDLER t1 CLOSE;
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;
HANDLER t1 READ `PRIMARY` PREV LIMIT 3;
HANDLER t1 READ b NEXT LIMIT 5;
HANDLER t1 CLOSE;
DROP TABLE t1;
--echo End of 5.1 tests

View file

@ -1,5 +1,7 @@
# include/handler.inc
# handler.inc
#
# See init.inc for setup of variables for this script
#
# The variables
# $engine_type -- storage engine to be tested
# $other_engine_type -- storage engine <> $engine_type
@ -8,49 +10,37 @@
# 2. $other_handler_engine_type must point to an all
# time available storage engine
# 2006-08 MySQL 5.1 MyISAM and MEMORY only
# have to be set before sourcing this script.
-- source include/not_embedded.inc
#
# test of HANDLER ...
#
# Last update:
# 2006-07-31 ML test refactored (MySQL 5.1)
# code of t/handler.test and t/innodb_handler.test united
# main testing code put into include/handler.inc
# main testing code put into handler.inc
#
eval SET SESSION STORAGE_ENGINE = $engine_type;
--disable_warnings
drop table if exists t1,t3,t4,t5;
--enable_warnings
create table t1 (a int, b char(10), key a(a), key b(a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii");
#
# Start testing the table created in init.inc
#
handler t1 open as t2;
-- error 1064
handler t2 read a=(SELECT 1);
handler t2 read a first;
handler t2 read a next;
handler t2 read a next;
handler t2 read a prev;
handler t2 read a last;
handler t2 read a prev;
handler t2 read a prev;
handler t2 read b first;
handler t2 read b next;
handler t2 read b next;
handler t2 read b prev;
handler t2 read b last;
handler t2 read b prev;
handler t2 read b prev;
handler t2 read a first;
handler t2 read a prev;
handler t2 read b first;
handler t2 read b prev;
handler t2 read a last;
handler t2 read a prev;
handler t2 read a next;
handler t2 read a next;
handler t2 read b last;
handler t2 read b prev;
handler t2 read b next;
handler t2 read b next;
handler t2 read a=(15);
handler t2 read a=(16);
handler t2 read a=(21);
--error 1070
handler t2 read a=(19,"fff");
@ -65,33 +55,57 @@ handler t1 read a last;
handler t2 read a=(11);
handler t2 read a>=(11);
handler t2 read a=(18);
handler t2 read a>=(18);
handler t2 read a>(18);
handler t2 read a<=(18);
handler t2 read a<(18);
# Search on something we can find
handler t2 read b=(18);
handler t2 read b>=(18);
handler t2 read b>(18);
handler t2 read b<=(18);
handler t2 read b<(18);
handler t2 read a first limit 5;
handler t2 read a next limit 3;
handler t2 read a prev limit 10;
# Search on something we can't find
--sorted_result
handler t2 read a=(15);
--sorted_result
handler t2 read a>=(15) limit 2;
--sorted_result
handler t2 read a>(15) limit 2;
handler t2 read a<=(15);
handler t2 read a<(15);
handler t2 read a>=(16) limit 4;
handler t2 read a>=(16) limit 2,2;
# Search from upper end
handler t2 read a=(54);
handler t2 read a>=(54);
handler t2 read a>(54);
handler t2 read a<=(54);
handler t2 read a<(54);
# Search from lower end
handler t2 read a=(1);
handler t2 read a>=(1);
handler t2 read a>(1);
handler t2 read a<=(1);
handler t2 read a<(1);
handler t2 read b first limit 5;
handler t2 read b next limit 3;
handler t2 read b prev limit 10;
handler t2 read b>=(16) limit 4;
handler t2 read b>=(16) limit 2,2;
select * from t1 where a>=16 order by a,b limit 2,2;
handler t2 read a last limit 3;
handler t2 read a=(19);
handler t2 read a=(19) where b="yyy";
handler t2 read b=(16) limit 1,3;
handler t2 read b=(19);
handler t2 read b=(19) where b="yyy";
handler t2 read first;
handler t2 read next;
handler t2 read next;
--error 1064
handler t2 read last;
handler t2 close;
handler t1 open;
handler t1 read a next; # this used to crash as a bug#5373
handler t1 read a next;
handler t1 read b next; # this used to crash as a bug#5373
handler t1 read b next;
handler t1 close;
handler t1 open;
@ -105,12 +119,113 @@ eval alter table t1 engine = $engine_type;
--error 1109
handler t2 read first;
handler t1 open;
handler t1 read a=(20) limit 1,3;
flush tables;
handler t1 read a=(20) limit 1,3;
handler t1 close;
#
# Search after end and before start of index
#
handler t1 open;
handler t1 read a=(25);
handler t1 read a next;
handler t1 read a next;
handler t1 read a next;
handler t1 read a prev;
handler t1 read a=(1000);
handler t1 read a next;
handler t1 read a prev;
handler t1 read a=(1000);
handler t1 read a prev;
handler t1 read a=(14);
handler t1 read a prev;
handler t1 read a prev;
handler t1 read a next;
handler t1 read a=(1);
handler t1 read a prev;
handler t1 read a next;
handler t1 read a=(1);
handler t1 read a next;
handler t1 close;
#
# Test with prepared statements
#
handler t1 open;
prepare stmt from 'handler t1 read a=(?) limit ?,?';
set @a=20,@b=1,@c=100;
execute stmt using @a,@b,@c;
set @a=20,@b=2,@c=1;
execute stmt using @a,@b,@c;
set @a=20,@b=0,@c=2;
execute stmt using @a,@b,@c;
deallocate prepare stmt;
prepare stmt from 'handler t1 read a next limit ?';
handler t1 read a>=(21);
set @a=3;
execute stmt using @a;
execute stmt using @a;
execute stmt using @a;
deallocate prepare stmt;
prepare stmt from 'handler t1 read b prev limit ?';
execute stmt using @a;
execute stmt using @a;
execute stmt using @a;
execute stmt using @a;
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(?,?)';
set @a=14, @b='aaa';
execute stmt using @a,@b;
set @a=14, @b='not found';
execute stmt using @a,@b;
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(1+?) limit 10';
set @a=15;
execute stmt using @a;
execute stmt using @a;
deallocate prepare stmt;
prepare stmt from 'handler t1 read b>=(?) where a < ? limit 5';
set @a=17, @b=24;
execute stmt using @a,@b;
execute stmt using @a,@b;
deallocate prepare stmt;
prepare stmt from 'handler t1 read a=(?)';
set @a=17;
execute stmt using @a;
alter table t1 add c int;
--error 1109
execute stmt using @a;
deallocate prepare stmt;
--error 1109
handler t1 close;
handler t1 open;
prepare stmt from 'handler t1 read a=(?)';
flush tables;
set @a=17;
--error ER_NEED_REPREPARE
execute stmt using @a;
deallocate prepare stmt;
handler t1 close;
#
# DROP TABLE / ALTER TABLE
#
handler t1 open as t2;
drop table t1;
create table t1 (a int);
create table t1 (a int not null);
insert into t1 values (17);
--error 1109
handler t2 read first;
@ -137,7 +252,7 @@ drop table t1;
#
# Test for #751
#
create table t1(a int, index(a));
eval create table t1(a int, index $key_type (a));
insert into t1 values (1), (2), (3);
handler t1 open;
--error 1054
@ -164,7 +279,7 @@ drop table t1;
#
# BUG#3649
#
create table t1 ( a int, b int, INDEX a (a) );
eval create table t1 ( a int, b int, INDEX a $key_type (a) );
insert into t1 values (1,2), (2,1);
handler t1 open;
handler t1 read a=(1) where b=2;
@ -173,143 +288,6 @@ handler t1 read a=(1) where b=1;
handler t1 close;
drop table t1;
#
# Check if two database names beginning the same are seen as different.
#
# This database begins like the usual 'test' database.
#
--disable_warnings
drop database if exists test_test;
--enable_warnings
create database test_test;
use test_test;
create table t1(table_id char(20) primary key);
insert into t1 values ('test_test.t1');
insert into t1 values ('');
handler t1 open;
handler t1 read first limit 9;
create table t2(table_id char(20) primary key);
insert into t2 values ('test_test.t2');
insert into t2 values ('');
handler t2 open;
handler t2 read first limit 9;
#
# This is the usual 'test' database.
#
use test;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(table_id char(20) primary key);
insert into t1 values ('test.t1');
insert into t1 values ('');
--error 1066
handler t1 open;
#
# Check accesibility of all the tables.
#
use test;
--error 1064
handler test.t1 read first limit 9;
--error 1064
handler test_test.t1 read first limit 9;
handler t1 read first limit 9;
--error 1064
handler test_test.t2 read first limit 9;
handler t2 read first limit 9;
#
# Cleanup.
#
--error 1064
handler test_test.t1 close;
handler t1 close;
drop table test_test.t1;
--error 1064
handler test_test.t2 close;
handler t2 close;
drop table test_test.t2;
drop database test_test;
#
use test;
--error 1064
handler test.t1 close;
--error 1109
handler t1 close;
drop table test.t1;
#
# BUG#4335
#
--disable_warnings
drop database if exists test_test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
--enable_warnings
create database test_test;
use test_test;
create table t1 (c1 char(20));
insert into t1 values ('test_test.t1');
create table t3 (c1 char(20));
insert into t3 values ('test_test.t3');
handler t1 open;
handler t1 read first limit 9;
handler t1 open h1;
handler h1 read first limit 9;
use test;
create table t1 (c1 char(20));
create table t2 (c1 char(20));
create table t3 (c1 char(20));
insert into t1 values ('t1');
insert into t2 values ('t2');
insert into t3 values ('t3');
--error 1066
handler t1 open;
--error 1066
handler t2 open t1;
--error 1066
handler t3 open t1;
handler t1 read first limit 9;
--error 1064
handler test.t1 close;
--error 1066
handler test.t1 open h1;
--error 1066
handler test_test.t1 open h1;
handler test_test.t3 open h3;
handler test.t1 open h2;
handler t1 read first limit 9;
handler h1 read first limit 9;
handler h2 read first limit 9;
handler h3 read first limit 9;
handler h2 read first limit 9;
--error 1064
handler test.h1 close;
handler t1 close;
handler h1 close;
handler h2 close;
--error 1109
handler t1 read first limit 9;
--error 1109
handler h1 read first limit 9;
--error 1109
handler h2 read first limit 9;
handler h3 read first limit 9;
handler h3 read first limit 9;
use test_test;
handler h3 read first limit 9;
--error 1064
handler test.h3 read first limit 9;
handler h3 close;
use test;
drop table t3;
drop table t2;
drop table t1;
drop database test_test;
#
# Test if fix for BUG#4286 correctly closes handler tables.
#
@ -410,11 +388,13 @@ reap;
connection default;
drop table t1;
CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2));
eval CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY $key_type (no1,no2));
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
HANDLER t1 OPEN;
HANDLER t1 READ `primary` = (1, 1000);
HANDLER t1 READ `primary` PREV;
HANDLER t1 READ `primary` = (1, 1000);
HANDLER t1 READ `primary` NEXT;
DROP TABLE t1;
# End of 4.1 tests
@ -468,10 +448,7 @@ drop table if exists t1;
#
# Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one
#
--disable_warnings
drop table if exists t1;
--enable_warnings
eval create table t1 (a int) ENGINE=$other_engine_type;
eval create table t1 (a int not null) ENGINE=$other_engine_type;
--echo --> client 2
connection con2;
--error 1031
@ -484,9 +461,6 @@ disconnect con2;
#
# Bug#30632 HANDLER read failure causes hang
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int);
handler t1 open as t1_alias;
--error 1176
@ -500,74 +474,6 @@ handler t1_alias READ a next where inexistent > 0;
handler t1_alias close;
drop table t1;
#
# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements
#
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (c1 int);
create table t2 (c1 int);
insert into t1 values (1);
insert into t2 values (2);
--echo connection: default
handler t1 open;
handler t1 read first;
connect (flush,localhost,root,,);
connection flush;
--echo connection: flush
--send flush tables;
connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Flushing tables";
--source include/wait_condition.inc
handler t2 open;
handler t2 read first;
handler t1 read next;
handler t1 close;
handler t2 close;
connection flush;
reap;
connection default;
drop table t1,t2;
disconnect flush;
#
# Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements
#
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (c1 int);
--echo connection: default
handler t1 open;
handler t1 read first;
connect (flush,localhost,root,,);
connection flush;
--echo connection: flush
--send rename table t1 to t2;
connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "rename table t1 to t2";
--source include/wait_condition.inc
handler t2 open;
handler t2 read first;
--error ER_NO_SUCH_TABLE
handler t1 read next;
handler t1 close;
handler t2 close;
connection flush;
reap;
connection default;
drop table t2;
disconnect flush;
#
# Bug#30882 Dropping a temporary table inside a stored function may cause a server crash
#
@ -575,15 +481,12 @@ disconnect flush;
# is open by a HANDLER, no other statement can access it.
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create temporary table t1 (a int, b char(1), key a(a), key b(a,b));
eval create temporary table t1 (a int, b char(1), key a $key_type (a), key b $key_type (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
select a,b from t1;
handler t1 open as a1;
handler a1 read a first;
handler a1 read a=(1);
handler a1 read a next;
handler a1 read a next;
--error ER_CANT_REOPEN_TABLE
@ -594,41 +497,19 @@ handler a1 read a=(6) where b="g";
handler a1 close;
select a,b from t1;
handler t1 open as a2;
handler a2 read a first;
handler a2 read a last;
handler a2 read a prev;
handler a2 read b=(9);
handler a2 read b next;
handler a2 read b prev limit 2;
--error 0,1031
handler a2 read b last;
handler a2 read b prev;
handler a2 close;
drop table t1;
#
# Bug#31397 Inconsistent drop table behavior of handler tables.
#
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (a int);
handler t1 open as t1_alias;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
flush tables;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias close;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read first;
drop table t1;
--error ER_UNKNOWN_TABLE
handler t1_alias read next;
# Test that temporary tables associated with handlers are properly dropped.
create table t1 (a int);
create temporary table t2 (a int, key(a));
eval create temporary table t2 (a int, key $key_type (a));
handler t1 open as a1;
handler t2 open as a2;
handler a2 read a first;
@ -640,7 +521,7 @@ handler a1 close;
# Alter table drop handlers
create table t1 (a int, key(a));
eval create table t1 (a int, key $key_type (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
@ -654,7 +535,7 @@ drop table t1, t2;
# Rename table drop handlers
create table t1 (a int, key(a));
eval create table t1 (a int, key $key_type (a));
handler t1 open as a1;
handler a1 read a first;
rename table t1 to t2;
@ -664,7 +545,7 @@ drop table t2;
# Optimize table drop handlers
create table t1 (a int, key(a));
eval create table t1 (a int, key $key_type (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
@ -676,56 +557,14 @@ handler a1 close;
handler a2 close;
drop table t1, t2;
# Flush tables causes handlers reopen
create table t1 (a int, b char(1), key a(a), key b(a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
handler t1 open;
handler t1 read a first;
handler t1 read a next;
flush tables;
handler t1 read a next;
handler t1 read a next;
flush tables with read lock;
handler t1 read a next;
unlock tables;
drop table t1;
--error ER_UNKNOWN_TABLE
handler t1 read a next;
#
# Bug#41110: crash with handler command when used concurrently with alter table
# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int);
insert into t1 values (1);
handler t1 open;
connect(con1,localhost,root,,);
send alter table t1 engine=memory;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "rename result table" and info = "alter table t1 engine=memory";
--source include/wait_condition.inc
--error ER_ILLEGAL_HA
handler t1 read a next;
handler t1 close;
connection con1;
--reap
drop table t1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
#
# Bug#44151 using handler commands on information_schema tables crashes server
#
USE information_schema;
--error ER_WRONG_USAGE
HANDLER COLUMNS OPEN;
USE test;
--echo #
--echo # BUG#51877 - HANDLER interface causes invalid memory read
--echo #
eval CREATE TABLE t1(a INT, KEY $key_type (a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
INSERT INTO t1 VALUES(1);
--error 0,ER_CHECKREAD
HANDLER t1 READ a NEXT;
HANDLER t1 CLOSE;
DROP TABLE t1;

View file

@ -0,0 +1,827 @@
SET SESSION STORAGE_ENGINE = MEMORY;
drop table if exists t1,t3,t4,t5;
create table t1 (a int, b char(10), key a using btree (a), key b using btree (a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");
handler t1 open as t2;
handler t2 read b first;
a b
14 aaa
handler t2 read b next;
a b
16 ccc
handler t2 read b next;
a b
16 xxx
handler t2 read b prev;
a b
16 ccc
handler t2 read b last;
a b
25 xxx
handler t2 read b prev;
a b
24 xxx
handler t2 read b prev;
a b
23 xxx
handler t2 read b first;
a b
14 aaa
handler t2 read b prev;
a b
handler t2 read b last;
a b
25 xxx
handler t2 read b prev;
a b
24 xxx
handler t2 read b next;
a b
25 xxx
handler t2 read b next;
a b
handler t2 read a=(15);
a b
handler t2 read a=(21);
a b
21 hhh
handler t2 read a=(19,"fff");
ERROR 42000: Too many key parts specified; max 1 parts allowed
handler t2 read b=(19,"fff");
a b
19 fff
handler t2 read b=(19,"yyy");
a b
19 yyy
handler t2 read b=(19);
a b
19 fff
handler t1 read a last;
ERROR 42S02: Unknown table 't1' in HANDLER
handler t2 read a=(11);
a b
handler t2 read a>=(11);
a b
14 aaa
handler t2 read b=(18);
a b
18 eee
handler t2 read b>=(18);
a b
18 eee
handler t2 read b>(18);
a b
19 fff
handler t2 read b<=(18);
a b
18 eee
handler t2 read b<(18);
a b
17 ddd
handler t2 read a=(15);
a b
handler t2 read a>=(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a>(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a<=(15);
a b
14 aaa
handler t2 read a<(15);
a b
14 aaa
handler t2 read a=(54);
a b
handler t2 read a>=(54);
a b
handler t2 read a>(54);
a b
handler t2 read a<=(54);
a b
25 xxx
handler t2 read a<(54);
a b
25 xxx
handler t2 read a=(1);
a b
handler t2 read a>=(1);
a b
14 aaa
handler t2 read a>(1);
a b
14 aaa
handler t2 read a<=(1);
a b
handler t2 read a<(1);
a b
handler t2 read b first limit 5;
a b
14 aaa
16 ccc
16 xxx
17 ddd
18 eee
handler t2 read b next limit 3;
a b
19 fff
19 yyy
20 ggg
handler t2 read b prev limit 10;
a b
19 yyy
19 fff
18 eee
17 ddd
16 xxx
16 ccc
14 aaa
handler t2 read b>=(16) limit 4;
a b
16 ccc
16 xxx
17 ddd
18 eee
handler t2 read b>=(16) limit 2,2;
a b
17 ddd
18 eee
select * from t1 where a>=16 order by a,b limit 2,2;
a b
17 ddd
18 eee
handler t2 read a last limit 3;
a b
25 xxx
24 xxx
23 xxx
handler t2 read b=(16) limit 1,3;
a b
16 xxx
handler t2 read b=(19);
a b
19 fff
handler t2 read b=(19) where b="yyy";
a b
19 yyy
handler t2 read first;
a b
17 ddd
handler t2 read next;
a b
18 eee
handler t2 read next;
a b
19 fff
handler t2 close;
handler t1 open;
handler t1 read b next;
a b
14 aaa
handler t1 read b next;
a b
16 ccc
handler t1 close;
handler t1 open;
handler t1 read a prev;
a b
25 xxx
handler t1 read a prev;
a b
24 xxx
handler t1 close;
handler t1 open as t2;
handler t2 read first;
a b
17 ddd
alter table t1 engine = MEMORY;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open;
handler t1 read a=(20) limit 1,3;
a b
flush tables;
handler t1 read a=(20) limit 1,3;
a b
handler t1 close;
handler t1 open;
handler t1 read a=(25);
a b
25 xxx
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(14);
a b
14 aaa
handler t1 read a prev;
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a next;
a b
14 aaa
handler t1 close;
handler t1 open;
prepare stmt from 'handler t1 read a=(?) limit ?,?';
set @a=20,@b=1,@c=100;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=2,@c=1;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=0,@c=2;
execute stmt using @a,@b,@c;
a b
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a next limit ?';
handler t1 read a>=(21);
a b
21 hhh
set @a=3;
execute stmt using @a;
a b
22 iii
23 xxx
24 xxx
execute stmt using @a;
a b
25 xxx
execute stmt using @a;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b prev limit ?';
execute stmt using @a;
a b
25 xxx
24 xxx
23 xxx
execute stmt using @a;
a b
22 iii
21 hhh
20 ggg
execute stmt using @a;
a b
19 yyy
19 fff
18 eee
execute stmt using @a;
a b
17 ddd
16 xxx
16 ccc
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(?,?)';
set @a=14, @b='aaa';
execute stmt using @a,@b;
a b
14 aaa
set @a=14, @b='not found';
execute stmt using @a,@b;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(1+?) limit 10';
set @a=15;
execute stmt using @a;
a b
16 ccc
16 xxx
execute stmt using @a;
a b
16 ccc
16 xxx
deallocate prepare stmt;
prepare stmt from 'handler t1 read b>=(?) where a < ? limit 5';
set @a=17, @b=24;
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a=(?)';
set @a=17;
execute stmt using @a;
a b
17 ddd
alter table t1 add c int;
execute stmt using @a;
ERROR 42S02: Unknown table 't1' in HANDLER
deallocate prepare stmt;
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
handler t1 open;
prepare stmt from 'handler t1 read a=(?)';
flush tables;
set @a=17;
execute stmt using @a;
ERROR HY000: Prepared statement needs to be re-prepared
deallocate prepare stmt;
handler t1 close;
handler t1 open as t2;
drop table t1;
create table t1 (a int not null);
insert into t1 values (17);
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open as t2;
alter table t1 engine=CSV;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
handler t1 open;
handler t1 read first;
a
3
handler t1 read first limit 1,1;
a
4
handler t1 read first limit 2,2;
a
5
6
delete from t1 limit 3;
handler t1 read first;
a
6
drop table t1;
create table t1(a int, index using btree (a));
insert into t1 values (1), (2), (3);
handler t1 open;
handler t1 read a=(W);
ERROR 42S22: Unknown column 'W' in 'field list'
handler t1 read a=(a);
ERROR HY000: Incorrect arguments to HANDLER ... READ
drop table t1;
create table t1 (a char(5));
insert into t1 values ("Ok");
handler t1 open as t;
handler t read first;
a
Ok
use mysql;
handler t read first;
a
Ok
handler t close;
handler test.t1 open as t;
handler t read first;
a
Ok
handler t close;
use test;
drop table t1;
create table t1 ( a int, b int, INDEX a using btree (a) );
insert into t1 values (1,2), (2,1);
handler t1 open;
handler t1 read a=(1) where b=2;
a b
1 2
handler t1 read a=(1) where b=3;
a b
handler t1 read a=(1) where b=1;
a b
handler t1 close;
drop table t1;
create table t1 (c1 char(20));
insert into t1 values ("t1");
handler t1 open as h1;
handler h1 read first limit 9;
c1
t1
create table t2 (c1 char(20));
insert into t2 values ("t2");
handler t2 open as h2;
handler h2 read first limit 9;
c1
t2
create table t3 (c1 char(20));
insert into t3 values ("t3");
handler t3 open as h3;
handler h3 read first limit 9;
c1
t3
create table t4 (c1 char(20));
insert into t4 values ("t4");
handler t4 open as h4;
handler h4 read first limit 9;
c1
t4
create table t5 (c1 char(20));
insert into t5 values ("t5");
handler t5 open as h5;
handler h5 read first limit 9;
c1
t5
alter table t1 engine=MyISAM;
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
c1
t2
handler h3 read first limit 9;
c1
t3
handler h4 read first limit 9;
c1
t4
handler h5 read first limit 9;
c1
t5
alter table t5 engine=MyISAM;
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
c1
t2
handler h3 read first limit 9;
c1
t3
handler h4 read first limit 9;
c1
t4
handler h5 read first limit 9;
ERROR 42S02: Unknown table 'h5' in HANDLER
alter table t3 engine=MyISAM;
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
c1
t2
handler h3 read first limit 9;
ERROR 42S02: Unknown table 'h3' in HANDLER
handler h4 read first limit 9;
c1
t4
handler h5 read first limit 9;
ERROR 42S02: Unknown table 'h5' in HANDLER
handler h2 close;
handler h4 close;
handler t1 open as h1_1;
handler t1 open as h1_2;
handler t1 open as h1_3;
handler h1_1 read first limit 9;
c1
t1
handler h1_2 read first limit 9;
c1
t1
handler h1_3 read first limit 9;
c1
t1
alter table t1 engine=MEMORY;
handler h1_1 read first limit 9;
ERROR 42S02: Unknown table 'h1_1' in HANDLER
handler h1_2 read first limit 9;
ERROR 42S02: Unknown table 'h1_2' in HANDLER
handler h1_3 read first limit 9;
ERROR 42S02: Unknown table 'h1_3' in HANDLER
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
create table t1 (c1 int);
insert into t1 values (1);
handler t1 open;
handler t1 read first;
c1
1
send the below to another connection, do not wait for the result
optimize table t1;
proceed with the normal connection
handler t1 read next;
c1
1
handler t1 close;
read the result from the other connection
Table Op Msg_type Msg_text
test.t1 optimize note The storage engine for the table doesn't support optimize
proceed with the normal connection
drop table t1;
CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY using btree (no1,no2));
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
HANDLER t1 OPEN;
HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` PREV;
no1 no2
1 275
HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` NEXT;
no1 no2
2 6
DROP TABLE t1;
create table t1 (c1 int);
insert into t1 values (14397);
flush tables with read lock;
drop table t1;
ERROR HY000: Can't execute the query because you have a conflicting read lock
send the below to another connection, do not wait for the result
drop table t1;
proceed with the normal connection
select * from t1;
c1
14397
unlock tables;
read the result from the other connection
proceed with the normal connection
select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1 (a int not null) ENGINE=CSV;
--> client 2
handler t1 open;
ERROR HY000: Table storage engine for 't1' doesn't have this option
--> client 1
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read a next;
ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
handler t1_alias READ a next where inexistent > 0;
ERROR 42S22: Unknown column 'inexistent' in 'field list'
handler t1_alias read a next;
ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
handler t1_alias READ a next where inexistent > 0;
ERROR 42S22: Unknown column 'inexistent' in 'field list'
handler t1_alias close;
drop table t1;
create temporary table t1 (a int, b char(1), key a using btree (a), key b using btree (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
select a,b from t1;
a b
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
8 i
9 j
9 k
handler t1 open as a1;
handler a1 read a=(1);
a b
1 b
handler a1 read a next;
a b
2 c
handler a1 read a next;
a b
3 d
select a,b from t1;
ERROR HY000: Can't reopen table: 'a1'
handler a1 read a prev;
a b
2 c
handler a1 read a prev;
a b
1 b
handler a1 read a=(6) where b="g";
a b
6 g
handler a1 close;
select a,b from t1;
a b
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
8 i
9 j
9 k
handler t1 open as a2;
handler a2 read b=(9);
a b
9 j
handler a2 read b next;
a b
9 k
handler a2 read b prev limit 2;
a b
9 j
8 i
handler a2 read b last;
a b
9 k
handler a2 read b prev;
a b
9 j
handler a2 close;
drop table t1;
create table t1 (a int);
create temporary table t2 (a int, key using btree (a));
handler t1 open as a1;
handler t2 open as a2;
handler a2 read a first;
a
drop table t1, t2;
handler a2 read a next;
ERROR 42S02: Unknown table 'a2' in HANDLER
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
create table t1 (a int, key using btree (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
handler a1 read a first;
a
handler a2 read a first;
a
alter table t1 add b int;
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
create table t1 (a int, key using btree (a));
handler t1 open as a1;
handler a1 read a first;
a
rename table t1 to t2;
handler a1 read a first;
ERROR 42S02: Unknown table 'a1' in HANDLER
drop table t2;
create table t1 (a int, key using btree (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
handler a1 read a first;
a
handler a2 read a first;
a
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize note The storage engine for the table doesn't support optimize
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
#
# BUG#51877 - HANDLER interface causes invalid memory read
#
CREATE TABLE t1(a INT, KEY using btree (a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
a
INSERT INTO t1 VALUES(1);
HANDLER t1 READ a NEXT;
HANDLER t1 CLOSE;
DROP TABLE t1;
CREATE TABLE t1(a INT, b INT, KEY(a), KEY b using btree (b), KEY ab using btree(a, b)) engine=memory;
INSERT INTO t1 VALUES (2, 20), (2,20), (1, 10), (4, 40), (3, 30), (5,50), (6,50);
HANDLER t1 OPEN;
HANDLER t1 READ a>=(2) limit 3;
a b
2 20
2 20
HANDLER t1 READ a PREV;
a b
2 20
HANDLER t1 READ a PREV;
a b
2 20
HANDLER t1 READ a PREV;
a b
HANDLER t1 READ b>=(20) limit 3;
a b
2 20
2 20
3 30
HANDLER t1 READ b PREV;
a b
2 20
HANDLER t1 READ b PREV LIMIT 2;
a b
2 20
1 10
HANDLER t1 READ ab=(3,30) limit 3;
a b
3 30
HANDLER t1 READ ab>=(3,30) limit 3;
a b
3 30
4 40
5 50
HANDLER t1 READ a FIRST;
ERROR HY000: Table storage engine for 't1' doesn't have this option
HANDLER t1 READ a LAST;
ERROR HY000: Table storage engine for 't1' doesn't have this option
HANDLER t1 READ b FIRST LIMIT 2;
a b
1 10
2 20
HANDLER t1 READ ab LAST LIMIT 2;
a b
6 50
5 50
HANDLER t1 READ FIRST LIMIT 10;
a b
2 20
2 20
1 10
4 40
3 30
5 50
6 50
HANDLER t1 READ b FIRST;
a b
1 10
insert into t1 values (7,50);
HANDLER t1 READ b NEXT;
ERROR HY000: Record has changed since last read in table 't1'
HANDLER t1 READ b FIRST;
a b
1 10
insert into t1 values (7,50);
HANDLER t1 READ b NEXT;
ERROR HY000: Record has changed since last read in table 't1'
HANDLER t1 READ FIRST;
a b
2 20
insert into t1 values (8,50);
HANDLER t1 READ NEXT;
a b
2 20
delete from t1 where a=3;
HANDLER t1 READ NEXT LIMIT 2;
a b
1 10
4 40
delete from t1;
HANDLER t1 READ NEXT LIMIT 2;
ERROR HY000: Record has changed since last read in table 't1'
HANDLER t1 CLOSE;
DROP TABLE t1;
create table t1 (f1 integer not null, key (f1)) engine=Memory;
insert into t1 values (1);
HANDLER t1 OPEN;
HANDLER t1 READ f1 NEXT;
ERROR HY000: Table storage engine for 't1' doesn't have this option
HANDLER t1 READ f1 NEXT;
ERROR HY000: Table storage engine for 't1' doesn't have this option
HANDLER t1 READ f1 NEXT;
ERROR HY000: Table storage engine for 't1' doesn't have this option
HANDLER t1 CLOSE;
DROP TABLE t1;
End of 5.3 tests

View file

@ -0,0 +1,88 @@
# test of HANDLER with HEAP tables
#
let $engine_type= MEMORY;
let $key_type=using btree;
--source init.inc
--source handler.inc
#
# Test what happens if table is changed (Unique test for HEAP)
#
connect (con1,localhost,root,,);
connection default;
CREATE TABLE t1(a INT, b INT, KEY(a), KEY b using btree (b), KEY ab using btree(a, b)) engine=memory;
INSERT INTO t1 VALUES (2, 20), (2,20), (1, 10), (4, 40), (3, 30), (5,50), (6,50);
HANDLER t1 OPEN;
HANDLER t1 READ a>=(2) limit 3;
HANDLER t1 READ a PREV;
HANDLER t1 READ a PREV;
HANDLER t1 READ a PREV;
HANDLER t1 READ b>=(20) limit 3;
HANDLER t1 READ b PREV;
HANDLER t1 READ b PREV LIMIT 2;
HANDLER t1 READ ab=(3,30) limit 3;
HANDLER t1 READ ab>=(3,30) limit 3;
# Test FIRST/LAST on hash and btree keys
--error ER_ILLEGAL_HA
HANDLER t1 READ a FIRST;
--error ER_ILLEGAL_HA
HANDLER t1 READ a LAST;
HANDLER t1 READ b FIRST LIMIT 2;
HANDLER t1 READ ab LAST LIMIT 2;
# Table scan
HANDLER t1 READ FIRST LIMIT 10;
# Index scan
HANDLER t1 READ b FIRST;
insert into t1 values (7,50);
--error ER_CHECKREAD
HANDLER t1 READ b NEXT;
HANDLER t1 READ b FIRST;
connection con1;
insert into t1 values (7,50);
connection default;
--error ER_CHECKREAD
HANDLER t1 READ b NEXT;
HANDLER t1 READ FIRST;
connection con1;
insert into t1 values (8,50);
connection default;
HANDLER t1 READ NEXT;
connection con1;
delete from t1 where a=3;
connection default;
HANDLER t1 READ NEXT LIMIT 2;
connection con1;
delete from t1;
connection default;
--error ER_CHECKREAD
HANDLER t1 READ NEXT LIMIT 2;
HANDLER t1 CLOSE;
DROP TABLE t1;
disconnect con1;
#
# LP#702786 Two handler read f1 next gives different errors
#
create table t1 (f1 integer not null, key (f1)) engine=Memory;
insert into t1 values (1);
HANDLER t1 OPEN;
--error 1031
HANDLER t1 READ f1 NEXT;
--error 1031
HANDLER t1 READ f1 NEXT;
--error 1031
HANDLER t1 READ f1 NEXT;
HANDLER t1 CLOSE;
DROP TABLE t1;
--echo End of 5.3 tests

View file

@ -0,0 +1,33 @@
# Setup things for handler.inc
#
# Input variables
# $engine_type -- storage engine to be tested
# $key_type -- set if you want a non standard key type
#
# This scripts sets up default values for:
# $other_engine_type -- storage engine <> $engine_type
# $other_handler_engine_type -- storage engine <> $engine_type, if possible
# 1. $other_handler_engine_type must support handler
# 2. $other_handler_engine_type must point to an all
# time available storage engine
# have to be set before sourcing this script.
#
# Handler tests don't work with embedded server
#
-- source include/not_embedded.inc
eval SET SESSION STORAGE_ENGINE = $engine_type;
let $other_engine_type= CSV;
let $other_handler_engine_type= MyISAM;
--disable_warnings
drop table if exists t1,t3,t4,t5;
--enable_warnings
# Create default test table
eval create table t1 (a int, b char(10), key a $key_type (a), key b $key_type (a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");

View file

@ -1,56 +1,53 @@
SET SESSION STORAGE_ENGINE = InnoDB;
drop table if exists t1,t3,t4,t5;
create table t1 (a int, b char(10), key a(a), key b(a,b));
create table t1 (a int, b char(10), key a (a), key b (a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii");
(14,"aaa"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");
handler t1 open as t2;
handler t2 read a=(SELECT 1);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
handler t2 read a first;
handler t2 read b first;
a b
14 aaa
handler t2 read a next;
a b
15 bbb
handler t2 read a next;
handler t2 read b next;
a b
16 ccc
handler t2 read a prev;
handler t2 read b next;
a b
15 bbb
handler t2 read a last;
16 xxx
handler t2 read b prev;
a b
22 iii
handler t2 read a prev;
16 ccc
handler t2 read b last;
a b
21 hhh
handler t2 read a prev;
25 xxx
handler t2 read b prev;
a b
20 ggg
handler t2 read a first;
24 xxx
handler t2 read b prev;
a b
23 xxx
handler t2 read b first;
a b
14 aaa
handler t2 read a prev;
handler t2 read b prev;
a b
handler t2 read a last;
handler t2 read b last;
a b
22 iii
handler t2 read a prev;
25 xxx
handler t2 read b prev;
a b
21 hhh
handler t2 read a next;
24 xxx
handler t2 read b next;
a b
22 iii
handler t2 read a next;
25 xxx
handler t2 read b next;
a b
handler t2 read a=(15);
a b
15 bbb
handler t2 read a=(16);
handler t2 read a=(21);
a b
16 ccc
21 hhh
handler t2 read a=(19,"fff");
ERROR 42000: Too many key parts specified; max 1 parts allowed
handler t2 read b=(19,"fff");
@ -69,61 +66,108 @@ a b
handler t2 read a>=(11);
a b
14 aaa
handler t2 read a=(18);
handler t2 read b=(18);
a b
18 eee
handler t2 read a>=(18);
handler t2 read b>=(18);
a b
18 eee
handler t2 read a>(18);
handler t2 read b>(18);
a b
19 fff
handler t2 read a<=(18);
handler t2 read b<=(18);
a b
18 eee
handler t2 read a<(18);
handler t2 read b<(18);
a b
17 ddd
handler t2 read a first limit 5;
handler t2 read a=(15);
a b
handler t2 read a>=(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a>(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a<=(15);
a b
14 aaa
handler t2 read a<(15);
a b
14 aaa
handler t2 read a=(54);
a b
handler t2 read a>=(54);
a b
handler t2 read a>(54);
a b
handler t2 read a<=(54);
a b
25 xxx
handler t2 read a<(54);
a b
25 xxx
handler t2 read a=(1);
a b
handler t2 read a>=(1);
a b
14 aaa
handler t2 read a>(1);
a b
14 aaa
handler t2 read a<=(1);
a b
handler t2 read a<(1);
a b
handler t2 read b first limit 5;
a b
14 aaa
15 bbb
16 ccc
16 xxx
17 ddd
handler t2 read a next limit 3;
a b
18 eee
handler t2 read b next limit 3;
a b
19 fff
19 yyy
handler t2 read a prev limit 10;
20 ggg
handler t2 read b prev limit 10;
a b
19 yyy
19 fff
18 eee
17 ddd
16 xxx
16 ccc
15 bbb
14 aaa
handler t2 read a>=(16) limit 4;
handler t2 read b>=(16) limit 4;
a b
16 ccc
16 xxx
17 ddd
18 eee
handler t2 read a>=(16) limit 2,2;
handler t2 read b>=(16) limit 2,2;
a b
17 ddd
18 eee
select * from t1 where a>=16 order by a,b limit 2,2;
a b
17 ddd
18 eee
handler t2 read a last limit 3;
a b
22 iii
21 hhh
20 ggg
handler t2 read a=(19);
25 xxx
24 xxx
23 xxx
handler t2 read b=(16) limit 1,3;
a b
16 xxx
handler t2 read b=(19);
a b
19 fff
handler t2 read a=(19) where b="yyy";
handler t2 read b=(19) where b="yyy";
a b
19 yyy
handler t2 read first;
@ -135,24 +179,22 @@ a b
handler t2 read next;
a b
19 fff
handler t2 read last;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
handler t2 close;
handler t1 open;
handler t1 read a next;
handler t1 read b next;
a b
14 aaa
handler t1 read a next;
handler t1 read b next;
a b
15 bbb
16 ccc
handler t1 close;
handler t1 open;
handler t1 read a prev;
a b
22 iii
25 xxx
handler t1 read a prev;
a b
21 hhh
24 xxx
handler t1 close;
handler t1 open as t2;
handler t2 read first;
@ -161,14 +203,176 @@ a b
alter table t1 engine = InnoDB;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open;
handler t1 read a=(20) limit 1,3;
a b
flush tables;
handler t1 read a=(20) limit 1,3;
a b
handler t1 close;
handler t1 open;
handler t1 read a=(25);
a b
25 xxx
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(14);
a b
14 aaa
handler t1 read a prev;
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a next;
a b
16 ccc
handler t1 close;
handler t1 open;
prepare stmt from 'handler t1 read a=(?) limit ?,?';
set @a=20,@b=1,@c=100;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=2,@c=1;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=0,@c=2;
execute stmt using @a,@b,@c;
a b
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a next limit ?';
handler t1 read a>=(21);
a b
21 hhh
set @a=3;
execute stmt using @a;
a b
22 iii
23 xxx
24 xxx
execute stmt using @a;
a b
25 xxx
execute stmt using @a;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b prev limit ?';
execute stmt using @a;
a b
25 xxx
24 xxx
23 xxx
execute stmt using @a;
a b
22 iii
21 hhh
20 ggg
execute stmt using @a;
a b
19 yyy
19 fff
18 eee
execute stmt using @a;
a b
17 ddd
16 xxx
16 ccc
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(?,?)';
set @a=14, @b='aaa';
execute stmt using @a,@b;
a b
14 aaa
set @a=14, @b='not found';
execute stmt using @a,@b;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(1+?) limit 10';
set @a=15;
execute stmt using @a;
a b
16 ccc
16 xxx
execute stmt using @a;
a b
16 ccc
16 xxx
deallocate prepare stmt;
prepare stmt from 'handler t1 read b>=(?) where a < ? limit 5';
set @a=17, @b=24;
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a=(?)';
set @a=17;
execute stmt using @a;
a b
17 ddd
alter table t1 add c int;
execute stmt using @a;
ERROR 42S02: Unknown table 't1' in HANDLER
deallocate prepare stmt;
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
handler t1 open;
prepare stmt from 'handler t1 read a=(?)';
flush tables;
set @a=17;
execute stmt using @a;
ERROR HY000: Prepared statement needs to be re-prepared
deallocate prepare stmt;
handler t1 close;
handler t1 open as t2;
drop table t1;
create table t1 (a int);
create table t1 (a int not null);
insert into t1 values (17);
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open as t2;
alter table t1 engine=MEMORY;
alter table t1 engine=CSV;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1;
@ -191,7 +395,7 @@ handler t1 read first;
a
6
drop table t1;
create table t1(a int, index(a));
create table t1(a int, index (a));
insert into t1 values (1), (2), (3);
handler t1 open;
handler t1 read a=(W);
@ -217,7 +421,7 @@ Ok
handler t close;
use test;
drop table t1;
create table t1 ( a int, b int, INDEX a (a) );
create table t1 ( a int, b int, INDEX a (a) );
insert into t1 values (1,2), (2,1);
handler t1 open;
handler t1 read a=(1) where b=2;
@ -229,148 +433,6 @@ handler t1 read a=(1) where b=1;
a b
handler t1 close;
drop table t1;
drop database if exists test_test;
create database test_test;
use test_test;
create table t1(table_id char(20) primary key);
insert into t1 values ('test_test.t1');
insert into t1 values ('');
handler t1 open;
handler t1 read first limit 9;
table_id
test_test.t1
create table t2(table_id char(20) primary key);
insert into t2 values ('test_test.t2');
insert into t2 values ('');
handler t2 open;
handler t2 read first limit 9;
table_id
test_test.t2
use test;
drop table if exists t1;
create table t1(table_id char(20) primary key);
insert into t1 values ('test.t1');
insert into t1 values ('');
handler t1 open;
ERROR 42000: Not unique table/alias: 't1'
use test;
handler test.t1 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler test_test.t1 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler t1 read first limit 9;
table_id
test_test.t1
handler test_test.t2 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler t2 read first limit 9;
table_id
test_test.t2
handler test_test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
drop table test_test.t1;
handler test_test.t2 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t2 close;
drop table test_test.t2;
drop database test_test;
use test;
handler test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
drop table test.t1;
drop database if exists test_test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
create database test_test;
use test_test;
create table t1 (c1 char(20));
insert into t1 values ('test_test.t1');
create table t3 (c1 char(20));
insert into t3 values ('test_test.t3');
handler t1 open;
handler t1 read first limit 9;
c1
test_test.t1
handler t1 open h1;
handler h1 read first limit 9;
c1
test_test.t1
use test;
create table t1 (c1 char(20));
create table t2 (c1 char(20));
create table t3 (c1 char(20));
insert into t1 values ('t1');
insert into t2 values ('t2');
insert into t3 values ('t3');
handler t1 open;
ERROR 42000: Not unique table/alias: 't1'
handler t2 open t1;
ERROR 42000: Not unique table/alias: 't1'
handler t3 open t1;
ERROR 42000: Not unique table/alias: 't1'
handler t1 read first limit 9;
c1
test_test.t1
handler test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler test.t1 open h1;
ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t1 open h1;
ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t3 open h3;
handler test.t1 open h2;
handler t1 read first limit 9;
c1
test_test.t1
handler h1 read first limit 9;
c1
test_test.t1
handler h2 read first limit 9;
c1
t1
handler h3 read first limit 9;
c1
test_test.t3
handler h2 read first limit 9;
c1
t1
handler test.h1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
handler h1 close;
handler h2 close;
handler t1 read first limit 9;
ERROR 42S02: Unknown table 't1' in HANDLER
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
ERROR 42S02: Unknown table 'h2' in HANDLER
handler h3 read first limit 9;
c1
test_test.t3
handler h3 read first limit 9;
c1
test_test.t3
use test_test;
handler h3 read first limit 9;
c1
test_test.t3
handler test.h3 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler h3 close;
use test;
drop table t3;
drop table t2;
drop table t1;
drop database test_test;
create table t1 (c1 char(20));
insert into t1 values ("t1");
handler t1 open as h1;
@ -496,6 +558,11 @@ no1 no2
HANDLER t1 READ `primary` PREV;
no1 no2
1 275
HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` NEXT;
no1 no2
2 8
DROP TABLE t1;
create table t1 (c1 int);
insert into t1 values (14397);
@ -516,14 +583,12 @@ ERROR 42S02: Table 'test.t1' doesn't exist
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
drop table if exists t1;
create table t1 (a int) ENGINE=MEMORY;
create table t1 (a int not null) ENGINE=CSV;
--> client 2
handler t1 open;
ERROR HY000: Table storage engine for 't1' doesn't have this option
--> client 1
drop table t1;
drop table if exists t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read a next;
@ -536,50 +601,9 @@ handler t1_alias READ a next where inexistent > 0;
ERROR 42S22: Unknown column 'inexistent' in 'field list'
handler t1_alias close;
drop table t1;
drop table if exists t1,t2;
create table t1 (c1 int);
create table t2 (c1 int);
insert into t1 values (1);
insert into t2 values (2);
connection: default
handler t1 open;
handler t1 read first;
c1
1
connection: flush
flush tables;;
connection: default
handler t2 open;
handler t2 read first;
c1
2
handler t1 read next;
c1
1
handler t1 close;
handler t2 close;
drop table t1,t2;
drop table if exists t1,t2;
create table t1 (c1 int);
connection: default
handler t1 open;
handler t1 read first;
c1
connection: flush
rename table t1 to t2;;
connection: default
handler t2 open;
handler t2 read first;
c1
handler t1 read next;
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
handler t2 close;
drop table t2;
drop table if exists t1;
create temporary table t1 (a int, b char(1), key a(a), key b(a,b));
create temporary table t1 (a int, b char(1), key a (a), key b (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
select a,b from t1;
a b
0 a
@ -592,24 +616,25 @@ a b
7 h
8 i
9 j
9 k
handler t1 open as a1;
handler a1 read a first;
a b
0 a
handler a1 read a next;
handler a1 read a=(1);
a b
1 b
handler a1 read a next;
a b
2 c
handler a1 read a next;
a b
3 d
select a,b from t1;
ERROR HY000: Can't reopen table: 'a1'
handler a1 read a prev;
a b
1 b
2 c
handler a1 read a prev;
a b
0 a
1 b
handler a1 read a=(6) where b="g";
a b
6 g
@ -626,39 +651,28 @@ a b
7 h
8 i
9 j
9 k
handler t1 open as a2;
handler a2 read a first;
a b
0 a
handler a2 read a last;
handler a2 read b=(9);
a b
9 j
handler a2 read a prev;
handler a2 read b next;
a b
9 k
handler a2 read b prev limit 2;
a b
9 j
8 i
handler a2 read b last;
a b
9 k
handler a2 read b prev;
a b
9 j
handler a2 close;
drop table t1;
drop table if exists t1,t2;
create table t1 (a int);
handler t1 open as t1_alias;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
flush tables;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias close;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read first;
a
drop table t1;
handler t1_alias read next;
ERROR 42S02: Unknown table 't1_alias' in HANDLER
create table t1 (a int);
create temporary table t2 (a int, key(a));
create temporary table t2 (a int, key (a));
handler t1 open as a1;
handler t2 open as a2;
handler a2 read a first;
@ -668,7 +682,7 @@ handler a2 read a next;
ERROR 42S02: Unknown table 'a2' in HANDLER
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
create table t1 (a int, key(a));
create table t1 (a int, key (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
@ -681,7 +695,7 @@ handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
create table t1 (a int, key(a));
create table t1 (a int, key (a));
handler t1 open as a1;
handler a1 read a first;
a
@ -689,7 +703,7 @@ rename table t1 to t2;
handler a1 read a first;
ERROR 42S02: Unknown table 'a1' in HANDLER
drop table t2;
create table t1 (a int, key(a));
create table t1 (a int, key (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
@ -705,41 +719,25 @@ handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
create table t1 (a int, b char(1), key a(a), key b(a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
handler t1 open;
handler t1 read a first;
a b
0 a
handler t1 read a next;
a b
1 b
flush tables;
handler t1 read a next;
a b
0 a
handler t1 read a next;
a b
1 b
flush tables with read lock;
handler t1 read a next;
a b
0 a
unlock tables;
drop table t1;
handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER
drop table if exists t1;
create table t1 (a int);
insert into t1 values (1);
handler t1 open;
alter table t1 engine=memory;
handler t1 read a next;
ERROR HY000: Table storage engine for 't1' doesn't have this option
handler t1 close;
drop table t1;
USE information_schema;
HANDLER COLUMNS OPEN;
ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
USE test;
#
# BUG#51877 - HANDLER interface causes invalid memory read
#
CREATE TABLE t1(a INT, KEY (a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
a
INSERT INTO t1 VALUES(1);
HANDLER t1 READ a NEXT;
a
HANDLER t1 CLOSE;
DROP TABLE t1;
CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
HANDLER t1 OPEN;
HANDLER t1 READ FIRST WHERE f2 <= 1;
f1 f2
1 1
HANDLER t1 READ `PRIMARY` PREV;
f1 f2
3 3
DROP TABLE t1;

View file

@ -0,0 +1,28 @@
# t/handler_innodb.test
#
# test of HANDLER ...
#
# Last update:
# 2006-07-31 ML test refactored (MySQL 5.1)
# code of t/handler.test and t/innodb_handler.test united
# main testing code put into handler.inc
# rename t/innodb_handler.test to t/handler_innodb.test
#
--source include/have_innodb.inc
let $engine_type= InnoDB;
--source init.inc
--source handler.inc
#
# LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX'
#
CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
HANDLER t1 OPEN;
HANDLER t1 READ FIRST WHERE f2 <= 1;
HANDLER t1 READ `PRIMARY` PREV;
DROP TABLE t1;

View file

@ -0,0 +1,261 @@
drop table if exists t1,t3,t4,t5;
drop database if exists test_test;
SET SESSION STORAGE_ENGINE = MyISAM;
drop table if exists t1,t3,t4,t5;
create table t1 (a int, b char(10), key a (a), key b (a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");
handler t1 open;
handler t1 read a=(SELECT 1);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
handler t1 read a=(1) FIRST;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIRST' at line 1
handler t1 read a=(1) NEXT;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NEXT' at line 1
handler t1 read last;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
handler t1 close;
drop table t1;
CREATE TABLE t1(a INT, PRIMARY KEY(a));
insert into t1 values(1),(2);
handler t1 open;
handler t1 read primary=(1);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary=(1)' at line 1
handler t1 read `primary`=(1);
a
1
handler t1 close;
drop table t1;
create database test_test;
use test_test;
create table t1(table_id char(20), primary key (table_id));
insert into t1 values ('test_test.t1');
insert into t1 values ('');
handler t1 open;
handler t1 read first limit 9;
table_id
test_test.t1
create table t2(table_id char(20), primary key (table_id));
insert into t2 values ('test_test.t2');
insert into t2 values ('');
handler t2 open;
handler t2 read first limit 9;
table_id
test_test.t2
use test;
create table t1(table_id char(20), primary key (table_id));
insert into t1 values ('test.t1');
insert into t1 values ('');
handler t1 open;
ERROR 42000: Not unique table/alias: 't1'
use test;
handler test.t1 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler test_test.t1 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler t1 read first limit 9;
table_id
test_test.t1
handler test_test.t2 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler t2 read first limit 9;
table_id
test_test.t2
handler test_test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
drop table test_test.t1;
handler test_test.t2 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t2 close;
drop table test_test.t2;
drop database test_test;
use test;
handler test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
drop table test.t1;
create database test_test;
use test_test;
create table t1 (c1 char(20));
insert into t1 values ('test_test.t1');
create table t3 (c1 char(20));
insert into t3 values ('test_test.t3');
handler t1 open;
handler t1 read first limit 9;
c1
test_test.t1
handler t1 open h1;
handler h1 read first limit 9;
c1
test_test.t1
use test;
create table t1 (c1 char(20));
create table t2 (c1 char(20));
create table t3 (c1 char(20));
insert into t1 values ('t1');
insert into t2 values ('t2');
insert into t3 values ('t3');
handler t1 open;
ERROR 42000: Not unique table/alias: 't1'
handler t2 open t1;
ERROR 42000: Not unique table/alias: 't1'
handler t3 open t1;
ERROR 42000: Not unique table/alias: 't1'
handler t1 read first limit 9;
c1
test_test.t1
handler test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler test.t1 open h1;
ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t1 open h1;
ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t3 open h3;
handler test.t1 open h2;
handler t1 read first limit 9;
c1
test_test.t1
handler h1 read first limit 9;
c1
test_test.t1
handler h2 read first limit 9;
c1
t1
handler h3 read first limit 9;
c1
test_test.t3
handler h2 read first limit 9;
c1
t1
handler test.h1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
handler h1 close;
handler h2 close;
handler t1 read first limit 9;
ERROR 42S02: Unknown table 't1' in HANDLER
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
ERROR 42S02: Unknown table 'h2' in HANDLER
handler h3 read first limit 9;
c1
test_test.t3
handler h3 read first limit 9;
c1
test_test.t3
use test_test;
handler h3 read first limit 9;
c1
test_test.t3
handler test.h3 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler h3 close;
use test;
drop table t3;
drop table t2;
drop table t1;
drop database test_test;
create table t1 (c1 int);
create table t2 (c1 int);
insert into t1 values (1);
insert into t2 values (2);
connection: default
handler t1 open;
handler t1 read first;
c1
1
connection: flush
flush tables;;
connection: default
handler t2 open;
handler t2 read first;
c1
2
handler t1 read next;
c1
1
handler t1 close;
handler t2 close;
drop table t1,t2;
create table t1 (a int);
handler t1 open as t1_alias;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
flush tables;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias close;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read first;
a
drop table t1;
handler t1_alias read next;
ERROR 42S02: Unknown table 't1_alias' in HANDLER
create table t1 (c1 int);
connection: default
handler t1 open;
handler t1 read first;
c1
connection: flush
rename table t1 to t2;;
connection: default
handler t2 open;
handler t2 read first;
c1
handler t1 read next;
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
handler t2 close;
drop table t2;
create table t1 (a int, b char(1), key a (a), key b (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
handler t1 open;
handler t1 read a first;
a b
0 a
handler t1 read a next;
a b
1 b
flush tables;
handler t1 read a next;
a b
0 a
handler t1 read a next;
a b
1 b
flush tables with read lock;
handler t1 read a next;
a b
0 a
unlock tables;
drop table t1;
handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER
drop table if exists t1;
create table t1 (a int not null);
insert into t1 values (1);
handler t1 open;
alter table t1 engine=csv;
handler t1 read a next;
ERROR HY000: Table storage engine for 't1' doesn't have this option
handler t1 close;
drop table t1;
USE information_schema;
HANDLER COLUMNS OPEN;
ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
PREPARE h_r FROM 'HANDLER t1 READ `PRIMARY` LAST';
ERROR 42S02: Unknown table 't1' in HANDLER

View file

@ -0,0 +1,313 @@
#
# Tests of handler interface that are system independent
#
# Handler tests don't work yet with embedded server
#
-- source include/not_embedded.inc
--disable_warnings
drop table if exists t1,t3,t4,t5;
drop database if exists test_test;
--enable_warnings
# Run tests with myisam (any engine should be ok)
let $engine_type= MyISAM;
--source init.inc
#
# Do some syntax checking
#
handler t1 open;
--error ER_PARSE_ERROR
handler t1 read a=(SELECT 1);
--error ER_PARSE_ERROR
handler t1 read a=(1) FIRST;
--error ER_PARSE_ERROR
handler t1 read a=(1) NEXT;
--error ER_PARSE_ERROR
handler t1 read last;
handler t1 close;
drop table t1;
CREATE TABLE t1(a INT, PRIMARY KEY(a));
insert into t1 values(1),(2);
handler t1 open;
--error ER_PARSE_ERROR
handler t1 read primary=(1);
handler t1 read `primary`=(1);
handler t1 close;
drop table t1;
#
# Check if two database names beginning the same are seen as different.
#
# This database begins like the usual 'test' database.
#
create database test_test;
use test_test;
eval create table t1(table_id char(20), primary key $key_type (table_id));
insert into t1 values ('test_test.t1');
insert into t1 values ('');
handler t1 open;
handler t1 read first limit 9;
eval create table t2(table_id char(20), primary key $key_type (table_id));
insert into t2 values ('test_test.t2');
insert into t2 values ('');
handler t2 open;
handler t2 read first limit 9;
#
# This is the usual 'test' database.
#
use test;
eval create table t1(table_id char(20), primary key $key_type (table_id));
insert into t1 values ('test.t1');
insert into t1 values ('');
--error 1066
handler t1 open;
#
# Check accessibility of all the tables.
#
use test;
--error 1064
handler test.t1 read first limit 9;
--error 1064
handler test_test.t1 read first limit 9;
handler t1 read first limit 9;
--error 1064
handler test_test.t2 read first limit 9;
handler t2 read first limit 9;
#
# Cleanup.
#
--error 1064
handler test_test.t1 close;
handler t1 close;
drop table test_test.t1;
--error 1064
handler test_test.t2 close;
handler t2 close;
drop table test_test.t2;
drop database test_test;
#
use test;
--error 1064
handler test.t1 close;
--error 1109
handler t1 close;
drop table test.t1;
#
# BUG#4335 one name can be handler open'ed many times
#
create database test_test;
use test_test;
create table t1 (c1 char(20));
insert into t1 values ('test_test.t1');
create table t3 (c1 char(20));
insert into t3 values ('test_test.t3');
handler t1 open;
handler t1 read first limit 9;
handler t1 open h1;
handler h1 read first limit 9;
use test;
create table t1 (c1 char(20));
create table t2 (c1 char(20));
create table t3 (c1 char(20));
insert into t1 values ('t1');
insert into t2 values ('t2');
insert into t3 values ('t3');
--error 1066
handler t1 open;
--error 1066
handler t2 open t1;
--error 1066
handler t3 open t1;
handler t1 read first limit 9;
--error 1064
handler test.t1 close;
--error 1066
handler test.t1 open h1;
--error 1066
handler test_test.t1 open h1;
handler test_test.t3 open h3;
handler test.t1 open h2;
handler t1 read first limit 9;
handler h1 read first limit 9;
handler h2 read first limit 9;
handler h3 read first limit 9;
handler h2 read first limit 9;
--error 1064
handler test.h1 close;
handler t1 close;
handler h1 close;
handler h2 close;
--error 1109
handler t1 read first limit 9;
--error 1109
handler h1 read first limit 9;
--error 1109
handler h2 read first limit 9;
handler h3 read first limit 9;
handler h3 read first limit 9;
use test_test;
handler h3 read first limit 9;
--error 1064
handler test.h3 read first limit 9;
handler h3 close;
use test;
drop table t3;
drop table t2;
drop table t1;
drop database test_test;
#
# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements
#
create table t1 (c1 int);
create table t2 (c1 int);
insert into t1 values (1);
insert into t2 values (2);
--echo connection: default
handler t1 open;
handler t1 read first;
connect (flush,localhost,root,,);
connection flush;
--echo connection: flush
--send flush tables;
connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Flushing tables";
--source include/wait_condition.inc
handler t2 open;
handler t2 read first;
handler t1 read next;
handler t1 close;
handler t2 close;
connection flush;
reap;
connection default;
drop table t1,t2;
disconnect flush;
#
# Bug#31397 Inconsistent drop table behavior of handler tables.
#
create table t1 (a int);
handler t1 open as t1_alias;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
flush tables;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias close;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read first;
drop table t1;
--error ER_UNKNOWN_TABLE
handler t1_alias read next;
#
# Bug#31409 RENAME TABLE causes server crash or deadlock when used with
# HANDLER statements
#
create table t1 (c1 int);
--echo connection: default
handler t1 open;
handler t1 read first;
connect (flush,localhost,root,,);
connection flush;
--echo connection: flush
--send rename table t1 to t2;
connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "rename table t1 to t2";
--source include/wait_condition.inc
handler t2 open;
handler t2 read first;
--error ER_NO_SUCH_TABLE
handler t1 read next;
handler t1 close;
handler t2 close;
connection flush;
reap;
connection default;
drop table t2;
disconnect flush;
# Flush tables causes handlers reopen
eval create table t1 (a int, b char(1), key a $key_type (a), key b $key_type (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
handler t1 open;
handler t1 read a first;
handler t1 read a next;
flush tables;
handler t1 read a next;
handler t1 read a next;
flush tables with read lock;
handler t1 read a next;
unlock tables;
drop table t1;
--error ER_UNKNOWN_TABLE
handler t1 read a next;
#
# Bug#41110: crash with handler command when used concurrently with alter table
# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int not null);
insert into t1 values (1);
handler t1 open;
connect(con1,localhost,root,,);
send alter table t1 engine=csv;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "rename result table" and info = "alter table t1 engine=csv";
--source include/wait_condition.inc
--error ER_ILLEGAL_HA
handler t1 read a next;
handler t1 close;
connection con1;
--reap
drop table t1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
#
# Bug#44151 using handler commands on information_schema tables crashes server
#
USE information_schema;
--error ER_WRONG_USAGE
HANDLER COLUMNS OPEN;
#
# LP#697622 Assertion `! is_set()' failed when preparing a HANDLER statement
#
--error ER_UNKNOWN_TABLE
PREPARE h_r FROM 'HANDLER t1 READ `PRIMARY` LAST';

View file

@ -1,56 +1,53 @@
SET SESSION STORAGE_ENGINE = MyISAM;
drop table if exists t1,t3,t4,t5;
create table t1 (a int, b char(10), key a(a), key b(a,b));
create table t1 (a int, b char(10), key a (a), key b (a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii");
(14,"aaa"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");
handler t1 open as t2;
handler t2 read a=(SELECT 1);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
handler t2 read a first;
handler t2 read b first;
a b
14 aaa
handler t2 read a next;
a b
15 bbb
handler t2 read a next;
handler t2 read b next;
a b
16 ccc
handler t2 read a prev;
handler t2 read b next;
a b
15 bbb
handler t2 read a last;
16 xxx
handler t2 read b prev;
a b
22 iii
handler t2 read a prev;
16 ccc
handler t2 read b last;
a b
21 hhh
handler t2 read a prev;
25 xxx
handler t2 read b prev;
a b
20 ggg
handler t2 read a first;
24 xxx
handler t2 read b prev;
a b
23 xxx
handler t2 read b first;
a b
14 aaa
handler t2 read a prev;
handler t2 read b prev;
a b
handler t2 read a last;
handler t2 read b last;
a b
22 iii
handler t2 read a prev;
25 xxx
handler t2 read b prev;
a b
21 hhh
handler t2 read a next;
24 xxx
handler t2 read b next;
a b
22 iii
handler t2 read a next;
25 xxx
handler t2 read b next;
a b
handler t2 read a=(15);
a b
15 bbb
handler t2 read a=(16);
handler t2 read a=(21);
a b
16 ccc
21 hhh
handler t2 read a=(19,"fff");
ERROR 42000: Too many key parts specified; max 1 parts allowed
handler t2 read b=(19,"fff");
@ -69,61 +66,108 @@ a b
handler t2 read a>=(11);
a b
14 aaa
handler t2 read a=(18);
handler t2 read b=(18);
a b
18 eee
handler t2 read a>=(18);
handler t2 read b>=(18);
a b
18 eee
handler t2 read a>(18);
handler t2 read b>(18);
a b
19 fff
handler t2 read a<=(18);
handler t2 read b<=(18);
a b
18 eee
handler t2 read a<(18);
handler t2 read b<(18);
a b
17 ddd
handler t2 read a first limit 5;
handler t2 read a=(15);
a b
handler t2 read a>=(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a>(15) limit 2;
a b
16 ccc
16 xxx
handler t2 read a<=(15);
a b
14 aaa
handler t2 read a<(15);
a b
14 aaa
handler t2 read a=(54);
a b
handler t2 read a>=(54);
a b
handler t2 read a>(54);
a b
handler t2 read a<=(54);
a b
25 xxx
handler t2 read a<(54);
a b
25 xxx
handler t2 read a=(1);
a b
handler t2 read a>=(1);
a b
14 aaa
handler t2 read a>(1);
a b
14 aaa
handler t2 read a<=(1);
a b
handler t2 read a<(1);
a b
handler t2 read b first limit 5;
a b
14 aaa
15 bbb
16 ccc
16 xxx
17 ddd
handler t2 read a next limit 3;
a b
18 eee
handler t2 read b next limit 3;
a b
19 fff
19 yyy
handler t2 read a prev limit 10;
20 ggg
handler t2 read b prev limit 10;
a b
19 yyy
19 fff
18 eee
17 ddd
16 xxx
16 ccc
15 bbb
14 aaa
handler t2 read a>=(16) limit 4;
handler t2 read b>=(16) limit 4;
a b
16 ccc
16 xxx
17 ddd
18 eee
handler t2 read a>=(16) limit 2,2;
handler t2 read b>=(16) limit 2,2;
a b
17 ddd
18 eee
select * from t1 where a>=16 order by a,b limit 2,2;
a b
17 ddd
18 eee
handler t2 read a last limit 3;
a b
22 iii
21 hhh
20 ggg
handler t2 read a=(19);
25 xxx
24 xxx
23 xxx
handler t2 read b=(16) limit 1,3;
a b
16 xxx
handler t2 read b=(19);
a b
19 fff
handler t2 read a=(19) where b="yyy";
handler t2 read b=(19) where b="yyy";
a b
19 yyy
handler t2 read first;
@ -135,24 +179,22 @@ a b
handler t2 read next;
a b
19 fff
handler t2 read last;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
handler t2 close;
handler t1 open;
handler t1 read a next;
handler t1 read b next;
a b
14 aaa
handler t1 read a next;
handler t1 read b next;
a b
15 bbb
16 ccc
handler t1 close;
handler t1 open;
handler t1 read a prev;
a b
22 iii
25 xxx
handler t1 read a prev;
a b
21 hhh
24 xxx
handler t1 close;
handler t1 open as t2;
handler t2 read first;
@ -161,14 +203,176 @@ a b
alter table t1 engine = MyISAM;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open;
handler t1 read a=(20) limit 1,3;
a b
flush tables;
handler t1 read a=(20) limit 1,3;
a b
handler t1 close;
handler t1 open;
handler t1 read a=(25);
a b
25 xxx
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a next;
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(1000);
a b
handler t1 read a prev;
a b
25 xxx
handler t1 read a=(14);
a b
14 aaa
handler t1 read a prev;
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a prev;
a b
handler t1 read a next;
a b
14 aaa
handler t1 read a=(1);
a b
handler t1 read a next;
a b
14 aaa
handler t1 close;
handler t1 open;
prepare stmt from 'handler t1 read a=(?) limit ?,?';
set @a=20,@b=1,@c=100;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=2,@c=1;
execute stmt using @a,@b,@c;
a b
set @a=20,@b=0,@c=2;
execute stmt using @a,@b,@c;
a b
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a next limit ?';
handler t1 read a>=(21);
a b
21 hhh
set @a=3;
execute stmt using @a;
a b
22 iii
23 xxx
24 xxx
execute stmt using @a;
a b
25 xxx
execute stmt using @a;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b prev limit ?';
execute stmt using @a;
a b
25 xxx
24 xxx
23 xxx
execute stmt using @a;
a b
22 iii
21 hhh
20 ggg
execute stmt using @a;
a b
19 yyy
19 fff
18 eee
execute stmt using @a;
a b
17 ddd
16 xxx
16 ccc
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(?,?)';
set @a=14, @b='aaa';
execute stmt using @a,@b;
a b
14 aaa
set @a=14, @b='not found';
execute stmt using @a,@b;
a b
deallocate prepare stmt;
prepare stmt from 'handler t1 read b=(1+?) limit 10';
set @a=15;
execute stmt using @a;
a b
16 ccc
16 xxx
execute stmt using @a;
a b
16 ccc
16 xxx
deallocate prepare stmt;
prepare stmt from 'handler t1 read b>=(?) where a < ? limit 5';
set @a=17, @b=24;
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
execute stmt using @a,@b;
a b
17 ddd
18 eee
19 fff
19 yyy
20 ggg
deallocate prepare stmt;
prepare stmt from 'handler t1 read a=(?)';
set @a=17;
execute stmt using @a;
a b
17 ddd
alter table t1 add c int;
execute stmt using @a;
ERROR 42S02: Unknown table 't1' in HANDLER
deallocate prepare stmt;
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
handler t1 open;
prepare stmt from 'handler t1 read a=(?)';
flush tables;
set @a=17;
execute stmt using @a;
ERROR HY000: Prepared statement needs to be re-prepared
deallocate prepare stmt;
handler t1 close;
handler t1 open as t2;
drop table t1;
create table t1 (a int);
create table t1 (a int not null);
insert into t1 values (17);
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open as t2;
alter table t1 engine=MEMORY;
alter table t1 engine=CSV;
handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1;
@ -191,7 +395,7 @@ handler t1 read first;
a
6
drop table t1;
create table t1(a int, index(a));
create table t1(a int, index (a));
insert into t1 values (1), (2), (3);
handler t1 open;
handler t1 read a=(W);
@ -217,7 +421,7 @@ Ok
handler t close;
use test;
drop table t1;
create table t1 ( a int, b int, INDEX a (a) );
create table t1 ( a int, b int, INDEX a (a) );
insert into t1 values (1,2), (2,1);
handler t1 open;
handler t1 read a=(1) where b=2;
@ -229,148 +433,6 @@ handler t1 read a=(1) where b=1;
a b
handler t1 close;
drop table t1;
drop database if exists test_test;
create database test_test;
use test_test;
create table t1(table_id char(20) primary key);
insert into t1 values ('test_test.t1');
insert into t1 values ('');
handler t1 open;
handler t1 read first limit 9;
table_id
test_test.t1
create table t2(table_id char(20) primary key);
insert into t2 values ('test_test.t2');
insert into t2 values ('');
handler t2 open;
handler t2 read first limit 9;
table_id
test_test.t2
use test;
drop table if exists t1;
create table t1(table_id char(20) primary key);
insert into t1 values ('test.t1');
insert into t1 values ('');
handler t1 open;
ERROR 42000: Not unique table/alias: 't1'
use test;
handler test.t1 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler test_test.t1 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler t1 read first limit 9;
table_id
test_test.t1
handler test_test.t2 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler t2 read first limit 9;
table_id
test_test.t2
handler test_test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
drop table test_test.t1;
handler test_test.t2 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t2 close;
drop table test_test.t2;
drop database test_test;
use test;
handler test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
drop table test.t1;
drop database if exists test_test;
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
create database test_test;
use test_test;
create table t1 (c1 char(20));
insert into t1 values ('test_test.t1');
create table t3 (c1 char(20));
insert into t3 values ('test_test.t3');
handler t1 open;
handler t1 read first limit 9;
c1
test_test.t1
handler t1 open h1;
handler h1 read first limit 9;
c1
test_test.t1
use test;
create table t1 (c1 char(20));
create table t2 (c1 char(20));
create table t3 (c1 char(20));
insert into t1 values ('t1');
insert into t2 values ('t2');
insert into t3 values ('t3');
handler t1 open;
ERROR 42000: Not unique table/alias: 't1'
handler t2 open t1;
ERROR 42000: Not unique table/alias: 't1'
handler t3 open t1;
ERROR 42000: Not unique table/alias: 't1'
handler t1 read first limit 9;
c1
test_test.t1
handler test.t1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler test.t1 open h1;
ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t1 open h1;
ERROR 42000: Not unique table/alias: 'h1'
handler test_test.t3 open h3;
handler test.t1 open h2;
handler t1 read first limit 9;
c1
test_test.t1
handler h1 read first limit 9;
c1
test_test.t1
handler h2 read first limit 9;
c1
t1
handler h3 read first limit 9;
c1
test_test.t3
handler h2 read first limit 9;
c1
t1
handler test.h1 close;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
handler t1 close;
handler h1 close;
handler h2 close;
handler t1 read first limit 9;
ERROR 42S02: Unknown table 't1' in HANDLER
handler h1 read first limit 9;
ERROR 42S02: Unknown table 'h1' in HANDLER
handler h2 read first limit 9;
ERROR 42S02: Unknown table 'h2' in HANDLER
handler h3 read first limit 9;
c1
test_test.t3
handler h3 read first limit 9;
c1
test_test.t3
use test_test;
handler h3 read first limit 9;
c1
test_test.t3
handler test.h3 read first limit 9;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
handler h3 close;
use test;
drop table t3;
drop table t2;
drop table t1;
drop database test_test;
create table t1 (c1 char(20));
insert into t1 values ("t1");
handler t1 open as h1;
@ -495,6 +557,11 @@ no1 no2
HANDLER t1 READ `primary` PREV;
no1 no2
1 275
HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` NEXT;
no1 no2
2 6
DROP TABLE t1;
create table t1 (c1 int);
insert into t1 values (14397);
@ -515,14 +582,12 @@ ERROR 42S02: Table 'test.t1' doesn't exist
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
drop table if exists t1;
create table t1 (a int) ENGINE=MEMORY;
create table t1 (a int not null) ENGINE=CSV;
--> client 2
handler t1 open;
ERROR HY000: Table storage engine for 't1' doesn't have this option
--> client 1
drop table t1;
drop table if exists t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read a next;
@ -535,50 +600,9 @@ handler t1_alias READ a next where inexistent > 0;
ERROR 42S22: Unknown column 'inexistent' in 'field list'
handler t1_alias close;
drop table t1;
drop table if exists t1,t2;
create table t1 (c1 int);
create table t2 (c1 int);
insert into t1 values (1);
insert into t2 values (2);
connection: default
handler t1 open;
handler t1 read first;
c1
1
connection: flush
flush tables;;
connection: default
handler t2 open;
handler t2 read first;
c1
2
handler t1 read next;
c1
1
handler t1 close;
handler t2 close;
drop table t1,t2;
drop table if exists t1,t2;
create table t1 (c1 int);
connection: default
handler t1 open;
handler t1 read first;
c1
connection: flush
rename table t1 to t2;;
connection: default
handler t2 open;
handler t2 read first;
c1
handler t1 read next;
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
handler t2 close;
drop table t2;
drop table if exists t1;
create temporary table t1 (a int, b char(1), key a(a), key b(a,b));
create temporary table t1 (a int, b char(1), key a (a), key b (a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
select a,b from t1;
a b
0 a
@ -591,24 +615,25 @@ a b
7 h
8 i
9 j
9 k
handler t1 open as a1;
handler a1 read a first;
a b
0 a
handler a1 read a next;
handler a1 read a=(1);
a b
1 b
handler a1 read a next;
a b
2 c
handler a1 read a next;
a b
3 d
select a,b from t1;
ERROR HY000: Can't reopen table: 'a1'
handler a1 read a prev;
a b
1 b
2 c
handler a1 read a prev;
a b
0 a
1 b
handler a1 read a=(6) where b="g";
a b
6 g
@ -625,39 +650,28 @@ a b
7 h
8 i
9 j
9 k
handler t1 open as a2;
handler a2 read a first;
a b
0 a
handler a2 read a last;
handler a2 read b=(9);
a b
9 j
handler a2 read a prev;
handler a2 read b next;
a b
9 k
handler a2 read b prev limit 2;
a b
9 j
8 i
handler a2 read b last;
a b
9 k
handler a2 read b prev;
a b
9 j
handler a2 close;
drop table t1;
drop table if exists t1,t2;
create table t1 (a int);
handler t1 open as t1_alias;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
flush tables;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias close;
drop table t1;
create table t1 (a int);
handler t1 open as t1_alias;
handler t1_alias read first;
a
drop table t1;
handler t1_alias read next;
ERROR 42S02: Unknown table 't1_alias' in HANDLER
create table t1 (a int);
create temporary table t2 (a int, key(a));
create temporary table t2 (a int, key (a));
handler t1 open as a1;
handler t2 open as a2;
handler a2 read a first;
@ -667,7 +681,7 @@ handler a2 read a next;
ERROR 42S02: Unknown table 'a2' in HANDLER
handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
create table t1 (a int, key(a));
create table t1 (a int, key (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
@ -680,7 +694,7 @@ handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
create table t1 (a int, key(a));
create table t1 (a int, key (a));
handler t1 open as a1;
handler a1 read a first;
a
@ -688,7 +702,7 @@ rename table t1 to t2;
handler a1 read a first;
ERROR 42S02: Unknown table 'a1' in HANDLER
drop table t2;
create table t1 (a int, key(a));
create table t1 (a int, key (a));
create table t2 like t1;
handler t1 open as a1;
handler t2 open as a2;
@ -703,44 +717,19 @@ handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER
handler a2 close;
drop table t1, t2;
create table t1 (a int, b char(1), key a(a), key b(a,b));
insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
handler t1 open;
handler t1 read a first;
a b
0 a
handler t1 read a next;
a b
1 b
flush tables;
handler t1 read a next;
a b
0 a
handler t1 read a next;
a b
1 b
flush tables with read lock;
handler t1 read a next;
a b
0 a
unlock tables;
drop table t1;
handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER
drop table if exists t1;
create table t1 (a int);
insert into t1 values (1);
handler t1 open;
alter table t1 engine=memory;
handler t1 read a next;
ERROR HY000: Table storage engine for 't1' doesn't have this option
handler t1 close;
drop table t1;
USE information_schema;
HANDLER COLUMNS OPEN;
ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
USE test;
#
# BUG#51877 - HANDLER interface causes invalid memory read
#
CREATE TABLE t1(a INT, KEY (a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
a
INSERT INTO t1 VALUES(1);
HANDLER t1 READ a NEXT;
a
1
HANDLER t1 CLOSE;
DROP TABLE t1;
#
# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
#
@ -757,19 +746,6 @@ HANDLER t1 READ FIRST;
ERROR 42S02: Unknown table 't1' in HANDLER
DROP TABLE t1;
#
# BUG#51877 - HANDLER interface causes invalid memory read
#
CREATE TABLE t1(a INT, KEY(a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
a
INSERT INTO t1 VALUES(1);
HANDLER t1 READ a NEXT;
a
1
HANDLER t1 CLOSE;
DROP TABLE t1;
#
# Bug #54007: assert in ha_myisam::index_next , HANDLER
#
CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));
@ -821,12 +797,13 @@ HANDLER t1 READ b NEXT;
a b
HANDLER t1 READ NEXT;
a b
2 20
HANDLER t1 READ NEXT;
a b
1 10
HANDLER t1 READ NEXT;
a b
4 40
HANDLER t1 READ NEXT;
a b
3 30
HANDLER t1 READ NEXT;
a b
HANDLER t1 CLOSE;
HANDLER t1 OPEN;
HANDLER t1 READ FIRST;

View file

@ -5,20 +5,14 @@
# Last update:
# 2006-07-31 ML test refactored (MySQL 5.1)
# code of t/handler.test and t/innodb_handler.test united
# main testing code put into include/handler.inc
# main testing code put into handler.inc
# rename t/handler.test to t/handler_myisam.test
#
# should work in embedded server after mysqltest is fixed
--source include/not_embedded.inc
let $engine_type= MyISAM;
let $other_engine_type= MEMORY;
# There is unfortunately no other all time available storage engine
# which supports the handler interface
let $other_handler_engine_type= MyISAM;
--source include/handler.inc
--source init.inc
--source handler.inc
--echo #
--echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
@ -37,18 +31,6 @@ TRUNCATE t1;
HANDLER t1 READ FIRST;
DROP TABLE t1;
--echo #
--echo # BUG#51877 - HANDLER interface causes invalid memory read
--echo #
CREATE TABLE t1(a INT, KEY(a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
INSERT INTO t1 VALUES(1);
HANDLER t1 READ a NEXT;
HANDLER t1 CLOSE;
DROP TABLE t1;
--echo #
--echo # Bug #54007: assert in ha_myisam::index_next , HANDLER
--echo #

View file

@ -2625,6 +2625,14 @@ ref NULL
rows 3
Extra Using index
DROP TABLE t1;
#
# ALTER TABLE IGNORE didn't ignore duplicates for unique add index
#
create table t1 (a int primary key, b int) engine = innodb;
insert into t1 values (1,1),(2,1);
alter ignore table t1 add unique `main` (b);
drop table t1;
#
End of 5.1 tests
#
# Test for bug #39932 "create table fails if column for FK is in different
@ -2664,7 +2672,7 @@ SELECT t1.pk FROM t1,t2
WHERE t1.pk = t2.pk AND t2.pk <> 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 11 Using where; Using index
1 SIMPLE t2 hash PRIMARY PRIMARY 4 test.t1.pk 13 Using index; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_range PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t1.pk 7 Using where; Using index; Using join buffer (flat, BNLH join)
SELECT t1.pk FROM t1,t2
WHERE t1.pk = t2.pk AND t2.pk <> 8;
pk

View file

@ -840,6 +840,17 @@ CREATE INDEX b ON t1(a,b,c,d);
DROP TABLE t1;
--echo #
--echo # ALTER TABLE IGNORE didn't ignore duplicates for unique add index
--echo #
create table t1 (a int primary key, b int) engine = innodb;
insert into t1 values (1,1),(2,1);
alter ignore table t1 add unique `main` (b);
drop table t1;
--echo #
--echo End of 5.1 tests
--echo #

View file

@ -1,6 +1,6 @@
select * from INFORMATION_SCHEMA.ENGINES where ENGINE="ARIA";
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
Aria YES Crash-safe tables with MyISAM heritage YES NO NO
Aria YES Crash-safe tables with MyISAM heritage NO NO NO
set global storage_engine=aria;
set session storage_engine=aria;
set global aria_page_checksum=0;
@ -2624,3 +2624,19 @@ KEY (v3)
INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1;
DELETE FROM t1;
drop table t1;
create table t1 (a int not null primary key, b blob) engine=maria transactional=1;
insert into t1 values(1,repeat('a',8000));
insert into t1 values(2,repeat('b',8000));
insert into t1 values(3,repeat('c',8000));
flush tables;
delete from t1 where a>1;
insert into t1 values(1,repeat('d',8000*3));
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
flush tables;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
repair table t1 extended;
Table Op Msg_type Msg_text
test.t1 repair status OK
drop table t1;

View file

@ -1,6 +1,6 @@
select * from INFORMATION_SCHEMA.ENGINES where ENGINE="ARIA";
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
Aria YES Crash-safe tables with MyISAM heritage YES NO NO
Aria YES Crash-safe tables with MyISAM heritage NO NO NO
set global storage_engine=aria;
set session storage_engine=aria;
set global aria_page_checksum=0;

View file

@ -6,6 +6,7 @@
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
--source include/have_maria.inc
--source include/long_test.inc
set global aria_log_file_size=4294967295;
let $MARIA_LOG=.;

View file

@ -1910,6 +1910,24 @@ INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1;
DELETE FROM t1;
drop table t1;
#
# Test of problem where REPAIR finds old deleted rows.
#
create table t1 (a int not null primary key, b blob) engine=maria transactional=1;
insert into t1 values(1,repeat('a',8000));
insert into t1 values(2,repeat('b',8000));
insert into t1 values(3,repeat('c',8000));
flush tables;
delete from t1 where a>1;
--error 1062
insert into t1 values(1,repeat('d',8000*3));
flush tables;
check table t1;
# This failed by finding 2 extra rows.
repair table t1 extended;
drop table t1;
#
# End of test
#

View file

@ -66,10 +66,10 @@ if ($found_garbage)
}
# Do a manual cleanup, because the following tests should not suffer from
# remaining files
--exec rm -f $MYSQLD_DATADIR/test/t1* || true
--exec perl -e "unlink(<$MYSQLD_DATADIR/test/t1*>)"
if ($with_directories)
{
--exec rm -f $MYSQLTEST_VARDIR/tmp/t1* || true
--exec perl -e "unlink(<$MYSQLD_DATADIR/test/tmp/t1*>)"
}
}
--enable_query_log

View file

@ -22,6 +22,8 @@
# any of the variables.
#
--source include/long_test.inc
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

View file

@ -22,6 +22,8 @@
# any of the variables.
#
--source include/long_test.inc
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

View file

@ -22,6 +22,8 @@
# any of the variables.
#
--source include/long_test.inc
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

View file

@ -22,6 +22,8 @@
# any of the variables.
#
--source include/long_test.inc
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

View file

@ -22,6 +22,8 @@
# any of the variables.
#
--source include/long_test.inc
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

View file

@ -22,6 +22,8 @@
# any of the variables.
#
--source include/long_test.inc
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

View file

@ -139,7 +139,7 @@ lock table t1 read;
update t1 set i= 10;
select * from t1;
Timeout in wait_condition.inc for select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "select * from t1"
where state = "Table Lock" and info = "select * from t1"
kill query ID;
i
ERROR 70100: Query execution was interrupted

View file

@ -48,7 +48,7 @@ insert t1 select * from t2;
connection locker;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "insert t1 select * from t2";
where state = "Table Lock" and info = "insert t1 select * from t2";
--source include/wait_condition.inc
drop table t2;
connection reader;
@ -72,7 +72,7 @@ connection locker;
# Sleep a bit till the insert of connection reader is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "insert t1 select * from t2";
where state = "Table Lock" and info = "insert t1 select * from t2";
--source include/wait_condition.inc
drop table t2;
connection reader;
@ -251,7 +251,7 @@ connection reader;
# Wait till connection writer is blocked
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "alter table t1 auto_increment=0";
where state = "Table Lock" and info = "alter table t1 auto_increment=0";
--source include/wait_condition.inc
send
alter table t1 auto_increment=0;
@ -259,7 +259,7 @@ connection locker;
# Wait till connection reader is blocked
let $wait_condition=
select count(*) = 2 from information_schema.processlist
where state = "Locked" and info = "alter table t1 auto_increment=0";
where state = "Table Lock" and info = "alter table t1 auto_increment=0";
--source include/wait_condition.inc
unlock tables;
connection writer;
@ -414,16 +414,16 @@ update t1 set i= 10;
connection reader;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "update t1 set i= 10";
where state = "Table Lock" and info = "update t1 set i= 10";
--source include/wait_condition.inc
send
select * from t1;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "select * from t1";
where state = "Table Lock" and info = "select * from t1";
--source include/wait_condition.inc
let $ID= `select id from information_schema.processlist where state = "Locked" and info = "update t1 set i= 10"`;
let $ID= `select id from information_schema.processlist where state = "Table Lock" and info = "update t1 set i= 10"`;
--replace_result $ID ID
eval kill query $ID;
connection reader;
@ -557,7 +557,7 @@ connection waiter;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "insert into t1 values(1)";
where state = "Table Lock" and info = "insert into t1 values(1)";
--source include/wait_condition.inc
let $tlwb= `show status like 'Table_locks_waited'`;
unlock tables;

View file

@ -38,6 +38,7 @@ STOP SLAVE SQL_THREAD;
[ On Slave1 ]
# To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
[ On Slave ]
@ -63,6 +64,7 @@ STOP SLAVE SQL_THREAD;
[ On Slave1 ]
# To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
[ On Slave ]
@ -89,6 +91,7 @@ STOP SLAVE SQL_THREAD;
[ On Slave1 ]
# To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
[ On Slave ]
@ -115,6 +118,7 @@ STOP SLAVE SQL_THREAD;
[ On Slave1 ]
# To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
[ On Slave ]

View file

@ -7,5 +7,6 @@
########################################################
-- source include/not_ndb_default.inc
-- source include/have_innodb.inc
-- source include/long_test.inc
let $engine_type=innodb;
-- source extra/rpl_tests/rpl_deadlock.test

View file

@ -10,6 +10,7 @@
-- source include/have_binlog_format_row.inc
# Slow test, don't run during staging part
-- source include/not_staging.inc
--source include/long_test.inc
-- source include/master-slave.inc
let $engine_type=INNODB;

View file

@ -37,9 +37,9 @@ INSERT INTO t1(name) VALUES('Record_7');
connection default;
## show processlist info and state ##
SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Locked" AND info LIKE "INSERT INTO t1%";
WHERE state= "Table Lock" AND info LIKE "INSERT INTO t1%";
state info
Locked INSERT INTO t1(name) VALUES('Record_7')
Table lock INSERT INTO t1(name) VALUES('Record_7')
## table contents befor UNLOCK ##
SELECT * FROM t1;
name

View file

@ -98,12 +98,12 @@ INSERT INTO t1(name) VALUES('Record_7');
connection default;
# wait until INSERT will be locked (low performance)
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Locked" AND info LIKE "INSERT INTO t1%";
WHERE state= "Table Lock" AND info LIKE "INSERT INTO t1%";
--source include/wait_condition.inc
--echo ## show processlist info and state ##
SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Locked" AND info LIKE "INSERT INTO t1%";
WHERE state= "Table Lock" AND info LIKE "INSERT INTO t1%";
--echo ## table contents befor UNLOCK ##
SELECT * FROM t1;
UNLOCK TABLES;

View file

@ -122,7 +122,7 @@ connection default;
--echo ** Wait till con0 is blocked **
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = 'Locked' AND info = '$my_select';
WHERE state = "Table Lock" AND info = '$my_select';
--source include/wait_condition.inc
UNLOCK TABLES;
@ -207,7 +207,7 @@ connection default;
--echo ** Wait till con0 is blocked **
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = 'Locked' AND info = '$my_select';
WHERE state = "Table Lock" AND info = '$my_select';
--source include/wait_condition.inc
UNLOCK TABLES;

View file

@ -139,7 +139,7 @@ send SELECT * FROM t1;
connection con0;
--echo wait until table is locked
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Locked';
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE state= "Table Lock";
--source include/wait_condition.inc
UNLOCK TABLES;

View file

@ -85,7 +85,7 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Locked' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state="Table Lock" AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
--source include/wait_condition.inc
--echo ** Asynchronous Execution **
@ -101,7 +101,7 @@ delimiter ;|
--echo ** Connection default **
connection default;
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Locked';
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE "Table Lock";
--source include/wait_condition.inc
UNLOCK TABLES;
@ -156,7 +156,7 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Locked' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state="Table Lock" AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
--source include/wait_condition.inc
--echo ** Asynchronous Execution **
@ -172,7 +172,7 @@ delimiter ;|
--echo ** Connection default **
connection default;
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Locked';
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE "Table Lock";
--source include/wait_condition.inc
UNLOCK TABLES;

View file

@ -13,9 +13,9 @@
# Change: Syntax changed
################################################################################
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
create table t1 (a int, b int as (a+1));
create table t1 (a int);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
create table t1 (a int not null);
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
alter table t1 add column b int as (a+1);
drop table t1;

View file

@ -1,7 +1,7 @@
SET @@session.storage_engine = 'archive';
create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int);
ERROR HY000: ARCHIVE storage engine does not support computed columns
create table t1 (a int not null);
alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
ERROR HY000: ARCHIVE storage engine does not support computed columns
drop table t1;

View file

@ -1,7 +1,7 @@
SET @@session.storage_engine = 'blackhole';
create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int);
ERROR HY000: BLACKHOLE storage engine does not support computed columns
create table t1 (a int not null);
alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
ERROR HY000: BLACKHOLE storage engine does not support computed columns
drop table t1;

View file

@ -1,7 +1,7 @@
SET @@session.storage_engine = 'CSV';
create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
ERROR HY000: CSV storage engine does not support computed columns
create table t1 (a int not null);
alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
ERROR HY000: CSV storage engine does not support computed columns
drop table t1;

View file

@ -1,7 +1,7 @@
SET @@session.storage_engine = 'memory';
create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int);
ERROR HY000: MEMORY storage engine does not support computed columns
create table t1 (a int not null);
alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
ERROR HY000: MEMORY storage engine does not support computed columns
drop table t1;

View file

@ -4,5 +4,5 @@ create table t2 (a int, b int as (a % 10));
insert into t1 values (1,default);
insert into t2 values (2,default);
create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
ERROR HY000: MRG_MYISAM storage engine does not support computed columns
drop table t1,t2;

View file

@ -76,7 +76,7 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent);
alter table t1 modify b int as (a % 2);
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
ERROR HY000: This is not yet supported for computed columns
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -87,7 +87,7 @@ drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) persistent;
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
ERROR HY000: This is not yet supported for computed columns
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (

View file

@ -76,7 +76,7 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent);
alter table t1 modify b int as (a % 2);
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
ERROR HY000: This is not yet supported for computed columns
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -87,7 +87,7 @@ drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) persistent;
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
ERROR HY000: This is not yet supported for computed columns
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (

View file

@ -27,7 +27,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
SET @@session.storage_engine = 'InnoDB';
#------------------------------------------------------------------------------#

View file

@ -32,7 +32,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
eval SET @@session.storage_engine = 'InnoDB';
let $skip_full_text_checks = 1;

View file

@ -33,7 +33,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
eval SET @@session.storage_engine = 'InnoDB';
##### Workarounds for known open engine specific bugs

View file

@ -41,13 +41,7 @@ SET @@session.storage_engine = 'CSV';
# Execute the tests to be applied to all storage engines
#------------------------------------------------------------------------------#
# Execute storage engine specific tests
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
create table t1 (a int, b int as (a+1));
create table t1 (a int not null);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
alter table t1 add column b int as (a+1);
drop table t1;
--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
#------------------------------------------------------------------------------#
# Cleanup

View file

@ -33,7 +33,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
eval SET @@session.storage_engine = 'InnoDB';
##### Workarounds for known open engine specific bugs

View file

@ -33,7 +33,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
eval SET @@session.storage_engine = 'InnoDB';
##### Workarounds for known open engine specific bugs

View file

@ -33,7 +33,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
eval SET @@session.storage_engine = 'InnoDB';
##### Workarounds for known open engine specific bugs

View file

@ -48,7 +48,7 @@ create table t1 (a int, b int as (a % 10));
create table t2 (a int, b int as (a % 10));
insert into t1 values (1,default);
insert into t2 values (2,default);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
drop table t1,t2;

View file

@ -35,7 +35,7 @@
##### Storage engine to be tested
# Set the session storage engine
--source include/have_innodb.inc
--source include/have_xtradb.inc
eval SET @@session.storage_engine = 'InnoDB';
##### Workarounds for known open engine specific bugs

Some files were not shown because too many files have changed in this diff Show more