Commit bb7f37ab authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

merge

parents 24521828 5343d4c9
...@@ -494,3 +494,5 @@ vio/test-ssl ...@@ -494,3 +494,5 @@ vio/test-ssl
vio/test-sslclient vio/test-sslclient
vio/test-sslserver vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
innobase/stamp-h1
stamp-h1
...@@ -8202,6 +8202,10 @@ The following startup variables/options have been renamed: ...@@ -8202,6 +8202,10 @@ The following startup variables/options have been renamed:
The startup options @code{record_buffer}, @code{sort_buffer} and The startup options @code{record_buffer}, @code{sort_buffer} and
@code{warnings} will still work in MySQL 4.0 but are deprecated. @code{warnings} will still work in MySQL 4.0 but are deprecated.
@item @item
The mysqld option @code{--safe_show_database} doesn't work anymore. One
should instead give the @code{SHOW DATABASES} privileges to everyone that
need to see all databases.
@item
The following SQL variables have changed name. The following SQL variables have changed name.
@c arjen note: New table, not yet measured for O'Reilly/DocBook. @c arjen note: New table, not yet measured for O'Reilly/DocBook.
@multitable @columnfractions .50 .50 @multitable @columnfractions .50 .50
...@@ -19879,7 +19883,6 @@ differ somewhat: ...@@ -19879,7 +19883,6 @@ differ somewhat:
| query_cache_limit | 1048576 | | query_cache_limit | 1048576 |
| query_cache_size | 0 | | query_cache_size | 0 |
| query_cache_type | ON | | query_cache_type | ON |
| safe_show_database | OFF |
| server_id | 0 | | server_id | 0 |
| slave_net_timeout | 3600 | | slave_net_timeout | 3600 |
| skip_external_locking | ON | | skip_external_locking | ON |
...@@ -20314,7 +20317,8 @@ This may be set (only numeric) to ...@@ -20314,7 +20317,8 @@ This may be set (only numeric) to
Don't show databases for which the user doesn't have any database or Don't show databases for which the user doesn't have any database or
table privileges. This can improve security if you're concerned about table privileges. This can improve security if you're concerned about
people being able to see what databases other users have. See also people being able to see what databases other users have. See also
@code{skip_show_database}. @code{skip_show_database}. This option is deprecated as one should instead
use the @code{SHOW DATABASES} privilege instead.
@item @code{server_id} @item @code{server_id}
The value of the @code{--server-id} option. The value of the @code{--server-id} option.
...@@ -20327,7 +20331,7 @@ Is ON if we only allow local (socket) connections. ...@@ -20327,7 +20331,7 @@ Is ON if we only allow local (socket) connections.
@item @code{skip_show_database} @item @code{skip_show_database}
This prevents people from doing @code{SHOW DATABASES} if they don't have This prevents people from doing @code{SHOW DATABASES} if they don't have
the @code{PROCESS} privilege. This can improve security if you're the @code{SHOW DATABASE} privilege. This can improve security if you're
concerned about people being able to see what databases other users concerned about people being able to see what databases other users
have. See also @code{safe_show_database}. have. See also @code{safe_show_database}.
...@@ -23683,7 +23687,7 @@ started}, your slaves may fail. ...@@ -23683,7 +23687,7 @@ started}, your slaves may fail.
Please see the following table for an indication of master-slave Please see the following table for an indication of master-slave
compatibility between different versions. With regard to version 4.0, compatibility between different versions. With regard to version 4.0,
we recommend using same version on both sides. we recommend using at least 4.0.4 on both sides.
@c FIX arjen 2002-07-17 new table, not yet measured for XML/DocBook. @c FIX arjen 2002-07-17 new table, not yet measured for XML/DocBook.
@multitable @columnfractions .10 .15 .15 .10 .10 .10 @multitable @columnfractions .10 .15 .15 .10 .10 .10
...@@ -24350,7 +24354,7 @@ may be used with @code{IO_THREAD} and @code{SQL_THREAD} options. (Slave) ...@@ -24350,7 +24354,7 @@ may be used with @code{IO_THREAD} and @code{SQL_THREAD} options. (Slave)
@tab Re-enables update logging if the user has the @code{SUPER} privilege. @tab Re-enables update logging if the user has the @code{SUPER} privilege.
Ignored otherwise. (Master) Ignored otherwise. (Master)
@item @code{GLOBAL SET SQL_SLAVE_SKIP_COUNTER=n} @item @code{SET GLOBAL SQL_SLAVE_SKIP_COUNTER=n}
@tab Skip the next @code{n} events from the master. Only valid when @tab Skip the next @code{n} events from the master. Only valid when
the slave thread is not running, otherwise, gives an error. Useful for the slave thread is not running, otherwise, gives an error. Useful for
recovering from replication glitches. recovering from replication glitches.
...@@ -25510,7 +25514,7 @@ temporary table to hold the result. This typically happens if you do an ...@@ -25510,7 +25514,7 @@ temporary table to hold the result. This typically happens if you do an
@code{ORDER BY} on a different column set than you did a @code{GROUP @code{ORDER BY} on a different column set than you did a @code{GROUP
BY} on. BY} on.
@item Where used @item Using where (was @code{where used})
A @code{WHERE} clause will be used to restrict which rows will be A @code{WHERE} clause will be used to restrict which rows will be
matched against the next table or sent to the client. If you don't have matched against the next table or sent to the client. If you don't have
this information and the table is of type @code{ALL} or @code{index}, this information and the table is of type @code{ALL} or @code{index},
...@@ -25670,7 +25674,7 @@ Executing the @code{EXPLAIN} statement again produces this result: ...@@ -25670,7 +25674,7 @@ Executing the @code{EXPLAIN} statement again produces this result:
@example @example
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 where used tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 Using where
do ALL PRIMARY NULL NULL NULL 2135 do ALL PRIMARY NULL NULL NULL 2135
range checked for each record (key map: 1) range checked for each record (key map: 1)
et_1 ALL PRIMARY NULL NULL NULL 74 et_1 ALL PRIMARY NULL NULL NULL 74
...@@ -25696,7 +25700,7 @@ Now @code{EXPLAIN} produces the output shown here: ...@@ -25696,7 +25700,7 @@ Now @code{EXPLAIN} produces the output shown here:
@example @example
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
et ALL PRIMARY NULL NULL NULL 74 et ALL PRIMARY NULL NULL NULL 74
tt ref AssignedPC, ActualPC 15 et.EMPLOYID 52 where used tt ref AssignedPC, ActualPC 15 et.EMPLOYID 52 Using where
ClientID, ClientID,
ActualPC ActualPC
et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1 et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1
...@@ -25719,7 +25723,7 @@ Now the join is perfect, and @code{EXPLAIN} produces this result: ...@@ -25719,7 +25723,7 @@ Now the join is perfect, and @code{EXPLAIN} produces this result:
@example @example
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
tt ALL AssignedPC NULL NULL NULL 3872 where used tt ALL AssignedPC NULL NULL NULL 3872 Using where
ClientID, ClientID,
ActualPC ActualPC
et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1 et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1
...@@ -28868,7 +28872,6 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them. ...@@ -28868,7 +28872,6 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item read_buffer_size @tab num @tab GLOBAL | SESSION @item read_buffer_size @tab num @tab GLOBAL | SESSION
@item read_rnd_buffer_size @tab num @tab GLOBAL | SESSION @item read_rnd_buffer_size @tab num @tab GLOBAL | SESSION
@item rpl_recovery_rank @tab num @tab GLOBAL @item rpl_recovery_rank @tab num @tab GLOBAL
@item safe_show_database @tab bool @tab GLOBAL
@item server_id @tab num @tab GLOBAL @item server_id @tab num @tab GLOBAL
@item slave_compressed_protocol @tab bool @tab GLOBAL @item slave_compressed_protocol @tab bool @tab GLOBAL
@item slave_net_timeout @tab num @tab GLOBAL @item slave_net_timeout @tab num @tab GLOBAL
...@@ -38698,8 +38701,8 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2) ...@@ -38698,8 +38701,8 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
* Table and index:: Table and Index Structures * Table and index:: Table and Index Structures
* File space management:: File Space Management and Disk I/O * File space management:: File Space Management and Disk I/O
* Error handling:: Error Handling * Error handling:: Error Handling
* InnoDB change history:: InnoDB Change History
* InnoDB restrictions:: Restrictions on InnoDB Tables * InnoDB restrictions:: Restrictions on InnoDB Tables
* InnoDB change history:: InnoDB Change History
* InnoDB contact information:: InnoDB Contact Information. * InnoDB contact information:: InnoDB Contact Information.
@end menu @end menu
...@@ -50735,6 +50738,7 @@ this means that the version has not yet been released! ...@@ -50735,6 +50738,7 @@ this means that the version has not yet been released!
@c Please don't add a new version here without also updating ../configure.in! @c Please don't add a new version here without also updating ../configure.in!
@menu @menu
* News-4.1.x::
* News-4.0.x:: Changes in release 4.0.x (Beta) * News-4.0.x:: Changes in release 4.0.x (Beta)
* News-3.23.x:: Changes in release 3.23.x (Stable) * News-3.23.x:: Changes in release 3.23.x (Stable)
* News-3.22.x:: Changes in release 3.22.x (Older; Still supported) * News-3.22.x:: Changes in release 3.22.x (Older; Still supported)
...@@ -50744,7 +50748,77 @@ this means that the version has not yet been released! ...@@ -50744,7 +50748,77 @@ this means that the version has not yet been released!
@end menu @end menu
@node News-4.0.x, News-3.23.x, News, News @node News-4.1.x, News-4.0.x, News, News
@appendixsec Changes in release 4.1.x (Alpha)
@cindex changes, version 4.1
Version 4.1 of the MySQL server includes many enhancements and new features:
@itemize @bullet
@item
Sub selects: @code{SELECT * from t1 where t1.a=(SELECT t2.b FROM t2)}.
@item
Character sets to be defined per column, table and database.
@item
Unicode (UTF8) support.
@item
Derived tables: @code{SELECT a from t1, (select * from t2) WHERE t1.a=t2.a}
@item
@code{BTREE} index on @code{HEAP} tables.
@item
Support for GIS (Geometrical data).
@item
@code{SHOW WARNINGS}; Shows warnings for the last command.
@end itemize
For a full list of changes, please refer to the changelog sections for
each individual 4.1.x release.
@menu
* News-4.1.0::
@end menu
@node News-4.1.0, , News-4.1.x, News-4.1.x
@appendixsubsec Changes in release 4.1.0
@itemize
@item
One can specify many temporary directories to be used in a round-robin
fasion with: @code{--tmpdir=dirname1:dirname2:dirname3}.
@item
Sub selects: @code{SELECT * from t1 where t1.a=(SELECT t2.b FROM t2)}.
@item
Character sets to be defined per column, table and database.
@item
Unicode (UTF8) support.
@item
Derived tables: @code{SELECT a from t1, (select * from t2) WHERE t1.a=t2.a}
@item
@code{BTREE} index on @code{HEAP} tables.
@item
Faster embedded server.
@item
One can add a comment per column in @code{CREATE TABLE}.
@item
@code{SHOW FULL COLUMNS FROM table_name} shows column comments.
@item
@code{ALTER DATABASE}.
@item
Support for GIS (Geometrical data).
@item
@code{SHOW WARNINGS}; Shows warnings from the last command.
@item
One can specify a column type for a colum in @code{CREATE TABLE
... SELECT} by defining the column in the @code{CREATE} part
@example
CREATE TABLE foo (a tinyint not null) SELECT b+1 AS 'a' FROM bar;
@end example
@end itemize
@node News-4.0.x, News-3.23.x, News-4.1.x, News
@appendixsec Changes in release 4.0.x (Beta) @appendixsec Changes in release 4.0.x (Beta)
@cindex changes, version 4.0 @cindex changes, version 4.0
...@@ -50815,9 +50889,16 @@ each individual 4.0.x release. ...@@ -50815,9 +50889,16 @@ each individual 4.0.x release.
@appendixsubsec Changes in release 4.0.5 @appendixsubsec Changes in release 4.0.5
@itemize @itemize
@item @item
Removed a condition that temp table with index on column that can be NULL has When one uses the @code{--open-files-limit=#} option to @code{mysqld_safe}
to be MyISAM. This was OK for 3.23, but not needed in 4.*. This resulted in it's now passed on to @code{mysqld}
slowdown in many queries since 4.0.2 @item
Fixed that @code{GROUP BY} on columns that may have a @code{NULL} value
doesn't always use disk based temporary tables.
@item
Changed output from @code{EXPLAIN} from @code{'where used'} to
@code{'Using where'} to make it more in line with other output.
@item
Removed variable @code{safe_show_database} as it was not used anymore.
@item @item
Small code improvement in multi-table updates Small code improvement in multi-table updates
@item @item
...@@ -51684,6 +51765,9 @@ not yet 100% confident in this code. ...@@ -51684,6 +51765,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.54 @appendixsubsec Changes in release 3.23.54
@itemize @itemize
@item @item
Allow one to start multiple MySQL servers on windows (code backported
from 4.0.2).
@item
Fixed a problem with BDB and @code{ALTER TABLE}. Fixed a problem with BDB and @code{ALTER TABLE}.
@item @item
Fixed reference to freed memory when doing complicated @code{GROUP BY Fixed reference to freed memory when doing complicated @code{GROUP BY
...@@ -52510,8 +52594,9 @@ long as @code{server-id} is set and valid @file{master.info} is present. ...@@ -52510,8 +52594,9 @@ long as @code{server-id} is set and valid @file{master.info} is present.
Partial updates (terminated with kill) are now logged with a special error Partial updates (terminated with kill) are now logged with a special error
code to the binary log. Slave will refuse to execute them if the error code code to the binary log. Slave will refuse to execute them if the error code
indicates the update was terminated abnormally, and will have to be recovered indicates the update was terminated abnormally, and will have to be recovered
with @code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START} after a manual sanity with @code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START} after a manual
check/correction of data integrity. sanity check/correction of data integrity. Update: In 4.0.3 and above
you have to use @code{SET GLOBAL}.
@item @item
Fixed bug that erroneously logged a drop of internal temporary table Fixed bug that erroneously logged a drop of internal temporary table
on thread termination to the binary log -- this bug affected replication. on thread termination to the binary log -- this bug affected replication.
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT}; OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC};
static int record = 0, opt_sleep=0; static int record = 0, opt_sleep=0;
static char *db = 0, *pass=0; static char *db = 0, *pass=0;
...@@ -1845,6 +1845,9 @@ static struct my_option my_long_options[] = ...@@ -1845,6 +1845,9 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Suppress all normal output. Synonym for --quiet.", {"silent", 's', "Suppress all normal output. Synonym for --quiet.",
(gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
"Don't use the memory allocation checking", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Sleep always this many seconds on sleep commands", {"sleep", 'T', "Sleep always this many seconds on sleep commands",
(gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
...@@ -1944,6 +1947,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -1944,6 +1947,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (read_server_arguments(argument)) if (read_server_arguments(argument))
die(NullS); die(NullS);
break; break;
case OPT_SKIP_SAFEMALLOC:
#ifdef SAFEMALLOC
sf_malloc_quick=1;
#endif
break;
case 'V': case 'V':
print_version(); print_version();
exit(0); exit(0);
...@@ -2301,6 +2309,7 @@ static void var_from_env(const char* name, const char* def_val) ...@@ -2301,6 +2309,7 @@ static void var_from_env(const char* name, const char* def_val)
static void init_var_hash() static void init_var_hash()
{ {
VAR* v; VAR* v;
DBUG_ENTER("init_var_hash");
if (hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0))) if (hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed"); die("Variable hash initialization failed");
var_from_env("MASTER_MYPORT", "9306"); var_from_env("MASTER_MYPORT", "9306");
...@@ -2309,6 +2318,7 @@ static void init_var_hash() ...@@ -2309,6 +2318,7 @@ static void init_var_hash()
var_from_env("BIG_TEST", opt_big_test ? "1" : "0"); var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
v=var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "63",0); v=var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "63",0);
hash_insert(&var_hash, (byte*)v); hash_insert(&var_hash, (byte*)v);
DBUG_VOID_RETURN;
} }
......
...@@ -119,7 +119,16 @@ ...@@ -119,7 +119,16 @@
#define _H_STRINGS #define _H_STRINGS
#define _SYS_STREAM_H #define _SYS_STREAM_H
/* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */ /* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */
#define ulonglong2double(A) my_ulonglong2double(A)
#define my_off_t2double(A) my_ulonglong2double(A)
#ifdef __cplusplus
extern "C" {
#endif
double my_ulonglong2double(unsigned long long A);
#ifdef __cplusplus
}
#endif #endif
#endif /* _AIX */
#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ #ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */
#undef HAVE_SNPRINTF #undef HAVE_SNPRINTF
......
...@@ -369,6 +369,7 @@ fi ...@@ -369,6 +369,7 @@ fi
[ -d $MYSQL_TEST_DIR/var ] || mkdir $MYSQL_TEST_DIR/var [ -d $MYSQL_TEST_DIR/var ] || mkdir $MYSQL_TEST_DIR/var
[ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp [ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp
[ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run [ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run
[ -d $MYSQL_TEST_DIR/var/log ] || mkdir $MYSQL_TEST_DIR/var/log
if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi
E=`$EXPR $COLUMNS - 8` E=`$EXPR $COLUMNS - 8`
...@@ -454,7 +455,7 @@ fi ...@@ -454,7 +455,7 @@ fi
MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \ MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
--user=$DBUSER --password=$DBPASSWD --silent -v \ --user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \
--tmpdir=$MYSQL_TMP_DIR" --tmpdir=$MYSQL_TMP_DIR"
MYSQL_TEST_BIN=$MYSQL_TEST MYSQL_TEST_BIN=$MYSQL_TEST
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS" MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
......
...@@ -140,13 +140,13 @@ id parent_id level ...@@ -140,13 +140,13 @@ id parent_id level
1010 102 2 1010 102 2
explain select level from t1 where level=1; explain select level from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 1 where used; Using index t1 ref level level 1 const 1 Using where; Using index
explain select level,id from t1 where level=1; explain select level,id from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 1 where used; Using index t1 ref level level 1 const 1 Using where; Using index
explain select level,id,parent_id from t1 where level=1; explain select level,id,parent_id from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 1 where used t1 ref level level 1 const 1 Using where
select level,id from t1 where level=1; select level,id from t1 where level=1;
level id level id
1 1002 1 1002
...@@ -625,7 +625,7 @@ id parent_id level ...@@ -625,7 +625,7 @@ id parent_id level
1016 102 2 1016 102 2
explain select level from t1 where level=1; explain select level from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 1 where used; Using index t1 ref level level 1 const 1 Using where; Using index
select level,id from t1 where level=1; select level,id from t1 where level=1;
level id level id
1 1004 1 1004
......
...@@ -3,7 +3,7 @@ CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id)); ...@@ -3,7 +3,7 @@ CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
insert into t1 values ('000000000001'),('000000000002'); insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001; explain select * from t1 where id=000000000001;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 12 NULL 2 where used; Using index t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
select * from t1 where id=000000000001; select * from t1 where id=000000000001;
id id
000000000001 000000000001
......
...@@ -63,7 +63,7 @@ insert into t1 (b) values ("hello"),("my"),("world"); ...@@ -63,7 +63,7 @@ insert into t1 (b) values ("hello"),("my"),("world");
create table t2 (key (b)) select * from t1; create table t2 (key (b)) select * from t1;
explain select * from t2 where b="world"; explain select * from t2 where b="world";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ref B B 21 const 1 where used t2 ref B B 21 const 1 Using where
select * from t2 where b="world"; select * from t2 where b="world";
a B a B
3 world 3 world
......
...@@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; ...@@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t3 index a a 5 NULL 6 Using index; Using temporary t3 index a a 5 NULL 6 Using index; Using temporary
t2 index a a 4 NULL 5 Using index; Distinct t2 index a a 4 NULL 5 Using index; Distinct
t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 where used; Distinct t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
a a
1 1
...@@ -190,7 +190,7 @@ insert into t3 select * from t4; ...@@ -190,7 +190,7 @@ insert into t3 select * from t4;
explain select distinct t1.a from t1,t3 where t1.a=t3.a; explain select distinct t1.a from t1,t3 where t1.a=t3.a;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 2 Using index; Using temporary t1 index PRIMARY PRIMARY 4 NULL 2 Using index; Using temporary
t3 ref a a 5 t1.a 10 where used; Using index; Distinct t3 ref a a 5 t1.a 10 Using where; Using index; Distinct
select distinct t1.a from t1,t3 where t1.a=t3.a; select distinct t1.a from t1,t3 where t1.a=t3.a;
a a
1 1
...@@ -278,10 +278,10 @@ table type possible_keys key key_len ref rows Extra ...@@ -278,10 +278,10 @@ table type possible_keys key key_len ref rows Extra
t1 index id id 4 NULL 2 Using index; Using temporary t1 index id id 4 NULL 2 Using index; Using temporary
t2 index id id 8 NULL 1 Using index; Distinct t2 index id id 8 NULL 1 Using index; Distinct
t3 index id id 8 NULL 1 Using index; Distinct t3 index id id 8 NULL 1 Using index; Distinct
j_lj_t2 index id id 4 NULL 2 where used; Using index; Distinct j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct
t2_lj index id id 8 NULL 1 where used; Using index; Distinct t2_lj index id id 8 NULL 1 Using where; Using index; Distinct
j_lj_t3 index id id 4 NULL 2 where used; Using index; Distinct j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct
t3_lj index id id 8 NULL 1 where used; Using index; Distinct t3_lj index id id 8 NULL 1 Using where; Using index; Distinct
SELECT DISTINCT SELECT DISTINCT
t1.id t1.id
from from
......
...@@ -10,13 +10,13 @@ id str ...@@ -10,13 +10,13 @@ id str
3 foo 3 foo
explain select * from t1 where str is null; explain select * from t1 where str is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref str str 11 const 1 where used t1 ref str str 11 const 1 Using where
explain select * from t1 where str="foo"; explain select * from t1 where str="foo";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 const str str 11 const 1 t1 const str str 11 const 1
explain select * from t1 ignore key (str) where str="foo"; explain select * from t1 ignore key (str) where str="foo";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4 where used t1 ALL NULL NULL NULL NULL 4 Using where
explain select * from t1 use key (str,str) where str="foo"; explain select * from t1 use key (str,str) where str="foo";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 const str str 11 const 1 t1 const str str 11 const 1
......
...@@ -234,10 +234,10 @@ userid count(*) ...@@ -234,10 +234,10 @@ userid count(*)
1 2 1 2
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range spID spID 5 NULL 2 where used; Using index t1 range spID spID 5 NULL 2 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range spID spID 5 NULL 2 where used; Using index t1 range spID spID 5 NULL 2 Using where; Using index
select spid,count(*) from t1 where spid between 1 and 2 group by spid; select spid,count(*) from t1 where spid between 1 and 2 group by spid;
spid count(*) spid count(*)
1 1 1 1
......
...@@ -66,7 +66,7 @@ a ...@@ -66,7 +66,7 @@ a
alter table t1 type=myisam; alter table t1 type=myisam;
explain select * from t1 where a in (869751,736494,226312,802616); explain select * from t1 where a in (869751,736494,226312,802616);
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range uniq_id uniq_id 4 NULL 4 where used; Using index t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
drop table t1; drop table t1;
create table t1 (x int not null, y int not null, key x(x), unique y(y)) create table t1 (x int not null, y int not null, key x(x), unique y(y))
type=heap; type=heap;
...@@ -159,17 +159,17 @@ create table t1 (btn char(10) not null, key(btn)) type=heap; ...@@ -159,17 +159,17 @@ create table t1 (btn char(10) not null, key(btn)) type=heap;
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
explain select * from t1 where btn like "q%"; explain select * from t1 where btn like "q%";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL btn NULL NULL NULL 14 where used t1 ALL btn NULL NULL NULL 14 Using where
select * from t1 where btn like "q%"; select * from t1 where btn like "q%";
btn btn
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn; alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
update t1 set new_col=btn; update t1 set new_col=btn;
explain select * from t1 where btn="a"; explain select * from t1 where btn="a";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL btn NULL NULL NULL 14 where used t1 ALL btn NULL NULL NULL 14 Using where
explain select * from t1 where btn="a" and new_col="a"; explain select * from t1 where btn="a" and new_col="a";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref btn btn 11 const,const 10 where used t1 ref btn btn 11 const,const 10 Using where
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int default NULL, a int default NULL,
...@@ -182,7 +182,7 @@ SELECT * FROM t1 WHERE a=NULL; ...@@ -182,7 +182,7 @@ SELECT * FROM t1 WHERE a=NULL;
a b a b
explain SELECT * FROM t1 WHERE a IS NULL; explain SELECT * FROM t1 WHERE a IS NULL;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a a 5 const 10 where used t1 ref a a 5 const 10 Using where
SELECT * FROM t1 WHERE a<=>NULL; SELECT * FROM t1 WHERE a<=>NULL;
a b a b
NULL 99 NULL 99
...@@ -190,7 +190,7 @@ SELECT * FROM t1 WHERE b=NULL; ...@@ -190,7 +190,7 @@ SELECT * FROM t1 WHERE b=NULL;
a b a b
explain SELECT * FROM t1 WHERE b IS NULL; explain SELECT * FROM t1 WHERE b IS NULL;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref b b 5 const 1 where used t1 ref b b 5 const 1 Using where
SELECT * FROM t1 WHERE b<=>NULL; SELECT * FROM t1 WHERE b<=>NULL;
a b a b
99 NULL 99 NULL
......
...@@ -140,13 +140,13 @@ id parent_id level ...@@ -140,13 +140,13 @@ id parent_id level
1015 102 2 1015 102 2
explain select level from t1 where level=1; explain select level from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 12 where used; Using index t1 ref level level 1 const 12 Using where; Using index
explain select level,id from t1 where level=1; explain select level,id from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 12 where used; Using index t1 ref level level 1 const 12 Using where; Using index
explain select level,id,parent_id from t1 where level=1; explain select level,id,parent_id from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 12 where used t1 ref level level 1 const 12 Using where
select level,id from t1 where level=1; select level,id from t1 where level=1;
level id level id
1 1002 1 1002
...@@ -597,7 +597,7 @@ id parent_id level ...@@ -597,7 +597,7 @@ id parent_id level
1016 102 2 1016 102 2
explain select level from t1 where level=1; explain select level from t1 where level=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 6 where used; Using index t1 ref level level 1 const 6 Using where; Using index
select level,id from t1 where level=1; select level,id from t1 where level=1;
level id level id
1 1004 1 1004
...@@ -759,7 +759,7 @@ create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h ...@@ -759,7 +759,7 @@ create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h
insert into t1 values (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); insert into t1 values (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);
explain select * from t1 where a > 0 and a < 50; explain select * from t1 where a > 0 and a < 50;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range PRIMARY PRIMARY 4 NULL 1 where used t1 range PRIMARY PRIMARY 4 NULL 1 Using where
drop table t1; drop table t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb; create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
......
...@@ -95,7 +95,7 @@ Impossible WHERE noticed after reading const tables ...@@ -95,7 +95,7 @@ Impossible WHERE noticed after reading const tables
explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 7 t1 ALL NULL NULL NULL NULL 7
t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 where used t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 Using where
select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
grp a c id a c d a grp a c id a c d a
1 1 a 1 1 a 1 1 1 1 a 1 1 a 1 1
...@@ -313,11 +313,11 @@ Lilliana Angelovska NULL NULL ...@@ -313,11 +313,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; explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 3 t1 ALL NULL NULL NULL NULL 3
t2 ALL NULL NULL NULL NULL 3 where used; Not exists t2 ALL NULL NULL NULL NULL 3 Using where; Not exists
explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 3 t1 ALL NULL NULL NULL NULL 3
t2 ALL NULL NULL NULL NULL 3 where used t2 ALL NULL NULL NULL NULL 3 Using where
select count(*) from t1 left join t2 on (t1.id = t2.owner); select count(*) from t1 left join t2 on (t1.id = t2.owner);
count(*) count(*)
4 4
...@@ -333,11 +333,11 @@ Lilliana Angelovska NULL NULL ...@@ -333,11 +333,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; explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 3 t1 ALL NULL NULL NULL NULL 3
t2 ALL NULL NULL NULL NULL 3 where used; Not exists t2 ALL NULL NULL NULL NULL 3 Using where; Not exists
explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 3 t1 ALL NULL NULL NULL NULL 3
t2 ALL NULL NULL NULL NULL 3 where used t2 ALL NULL NULL NULL NULL 3 Using where
select count(*) from t2 right join t1 on (t1.id = t2.owner); select count(*) from t2 right join t1 on (t1.id = t2.owner);
count(*) count(*)
4 4
...@@ -620,7 +620,7 @@ INSERT INTO t2 VALUES (1,1); ...@@ -620,7 +620,7 @@ INSERT INTO t2 VALUES (1,1);
explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 2 t1 ALL NULL NULL NULL NULL 2
t2 index id id 8 NULL 1 where used; Using index; Not exists t2 index id id 8 NULL 1 Using where; Using index; Not exists
SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
id name id idx id name id idx
2 no NULL NULL 2 no NULL NULL
...@@ -640,7 +640,7 @@ insert into t2 values (10,1),(20,2),(30,3); ...@@ -640,7 +640,7 @@ insert into t2 values (10,1),(20,2),(30,3);
explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 index NULL PRIMARY 4 NULL 3 Using index t2 index NULL PRIMARY 4 NULL 3 Using index
t1 eq_ref PRIMARY PRIMARY 2 const 1 where used; Using index t1 eq_ref PRIMARY PRIMARY 2 const 1 Using where; Using index
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
fooID barID fooID fooID barID fooID
10 1 NULL 10 1 NULL
......
...@@ -36,7 +36,7 @@ a a a a ...@@ -36,7 +36,7 @@ a a a a
explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5 t1 ALL a NULL NULL NULL 5
t2 ALL b NULL NULL NULL 5 where used t2 ALL b NULL NULL NULL 5 Using where
select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a;
a b a b a b a b
A B a a A B a a
......
...@@ -35,10 +35,10 @@ insert into t1 select NULL,message from t2; ...@@ -35,10 +35,10 @@ insert into t1 select NULL,message from t2;
create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2); create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2);
explain select * from t3 where a < 10; explain select * from t3 where a < 10;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t3 range a a 4 NULL 10 where used t3 range a a 4 NULL 10 Using where
explain select * from t3 where a > 10 and a < 20; explain select * from t3 where a > 10 and a < 20;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t3 range a a 4 NULL 10 where used t3 range a a 4 NULL 10 Using where
select * from t3 where a = 10; select * from t3 where a = 10;
a b a b
10 Testing 10 Testing
......
...@@ -3,37 +3,37 @@ create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam; ...@@ -3,37 +3,37 @@ create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
explain select * from t1 where a is null; explain select * from t1 where a is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a a 5 const 3 where used; Using index t1 ref a a 5 const 3 Using where; Using index
explain select * from t1 where a is null and b = 2; explain select * from t1 where a is null and b = 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 9 const,const 1 where used; Using index t1 ref a,b a 9 const,const 1 Using where; Using index
explain select * from t1 where a is null and b = 7; explain select * from t1 where a is null and b = 7;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 9 const,const 1 where used; Using index t1 ref a,b a 9 const,const 1 Using where; Using index
explain select * from t1 where a=2 and b = 2; explain select * from t1 where a=2 and b = 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 const a,b a 9 const,const 1 t1 const a,b a 9 const,const 1
explain select * from t1 where a<=>b limit 2; explain select * from t1 where a<=>b limit 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index NULL a 9 NULL 12 where used; Using index t1 index NULL a 9 NULL 12 Using where; Using index
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3; explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a,b a 9 NULL 3 where used; Using index t1 range a,b a 9 NULL 3 Using where; Using index
explain select * from t1 where (a is null or a = 7) and b=7; explain select * from t1 where (a is null or a = 7) and b=7;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b b 4 const 2 where used t1 ref a,b b 4 const 2 Using where
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2; explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 3 where used; Using index t1 ref a,b a 5 const 3 Using where; Using index
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3; explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a,b a 9 NULL 2 where used; Using index t1 range a,b a 9 NULL 2 Using where; Using index
explain select * from t1 where a > 1 and a < 3 limit 1; explain select * from t1 where a > 1 and a < 3 limit 1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 5 NULL 1 where used; Using index t1 range a a 5 NULL 1 Using where; Using index
explain select * from t1 where a > 8 and a < 9; explain select * from t1 where a > 8 and a < 9;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 5 NULL 1 where used; Using index t1 range a a 5 NULL 1 Using where; Using index
select * from t1 where a is null; select * from t1 where a is null;
a b a b
NULL 7 NULL 7
...@@ -66,43 +66,43 @@ NULL 9 ...@@ -66,43 +66,43 @@ NULL 9
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
explain select * from t1 where a is null and b = 2; explain select * from t1 where a is null and b = 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 3 where used t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a is null and b = 2 and c=0; explain select * from t1 where a is null and b = 2 and c=0;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 3 where used t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a is null and b = 7 and c=0; explain select * from t1 where a is null and b = 7 and c=0;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 3 where used t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a=2 and b = 2; explain select * from t1 where a=2 and b = 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 1 where used t1 ref a,b a 5 const 1 Using where
explain select * from t1 where a<=>b limit 2; explain select * from t1 where a<=>b limit 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 12 where used t1 ALL NULL NULL NULL NULL 12 Using where
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3; explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a,b a 5 NULL 5 where used t1 range a,b a 5 NULL 5 Using where
explain select * from t1 where (a is null or a = 7) and b=7 and c=0; explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a,b a 5 NULL 4 where used t1 range a,b a 5 NULL 4 Using where
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2; explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 3 where used t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3; explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a,b a 5 const 3 where used t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a > 1 and a < 3 limit 1; explain select * from t1 where a > 1 and a < 3 limit 1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 5 NULL 1 where used t1 range a a 5 NULL 1 Using where
explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1; explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a,b a 5 NULL 4 where used t1 range a,b a 5 NULL 4 Using where
explain select * from t1 where a > 8 and a < 9; explain select * from t1 where a > 8 and a < 9;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 5 NULL 1 where used t1 range a a 5 NULL 1 Using where
explain select * from t1 where b like "6%"; explain select * from t1 where b like "6%";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range b b 12 NULL 1 where used t1 range b b 12 NULL 1 Using where
select * from t1 where a is null; select * from t1 where a is null;
a b c a b c
NULL 7 0 NULL 7 0
...@@ -152,7 +152,7 @@ INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4 ...@@ -152,7 +152,7 @@ INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4
INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL); INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
explain select id from t1 where uniq_id is null; explain select id from t1 where uniq_id is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref idx1 idx1 5 const 1 where used t1 ref idx1 idx1 5 const 1 Using where
explain select id from t1 where uniq_id =1; explain select id from t1 where uniq_id =1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 const idx1 idx1 5 const 1 t1 const idx1 idx1 5 const 1
......
...@@ -264,13 +264,13 @@ create table t1 (a int not null, b int, c varchar(10), key (a, b, c)); ...@@ -264,13 +264,13 @@ create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 20 NULL 2 where used; Using index t1 range a a 20 NULL 2 Using where; Using index
select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
a b c a b c
1 NULL b 1 NULL b
explain select * from t1 where a >= 1 and a < 3 order by a desc; explain select * from t1 where a >= 1 and a < 3 order by a desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 4 NULL 10 where used; Using index t1 range a a 4 NULL 10 Using where; Using index
select * from t1 where a >= 1 and a < 3 order by a desc; select * from t1 where a >= 1 and a < 3 order by a desc;
a b c a b c
2 3 c 2 3 c
...@@ -286,7 +286,7 @@ a b c ...@@ -286,7 +286,7 @@ a b c
1 NULL NULL 1 NULL NULL
explain select * from t1 where a = 1 order by a desc, b desc; explain select * from t1 where a = 1 order by a desc, b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a a 4 const 5 where used; Using index t1 ref a a 4 const 5 Using where; Using index
select * from t1 where a = 1 order by a desc, b desc; select * from t1 where a = 1 order by a desc, b desc;
a b c a b c
1 3 b 1 3 b
...@@ -297,30 +297,30 @@ a b c ...@@ -297,30 +297,30 @@ a b c
1 NULL NULL 1 NULL NULL
explain select * from t1 where a = 1 and b is null order by a desc, b desc; explain select * from t1 where a = 1 and b is null order by a desc, b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a a 9 const,const 2 where used; Using index; Using filesort t1 ref a a 9 const,const 2 Using where; Using index; Using filesort
select * from t1 where a = 1 and b is null order by a desc, b desc; select * from t1 where a = 1 and b is null order by a desc, b desc;
a b c a b c
1 NULL NULL 1 NULL NULL
1 NULL b 1 NULL b
explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 8 where used; Using index; Using filesort t1 range a a 9 NULL 8 Using where; Using index; Using filesort
explain select * from t1 where a = 2 and b >0 order by a desc,b desc; explain select * from t1 where a = 2 and b >0 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 5 where used; Using index t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b is null order by a desc,b desc; explain select * from t1 where a = 2 and b is null order by a desc,b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref a a 9 const,const 1 where used; Using index; Using filesort t1 ref a a 9 const,const 1 Using where; Using index; Using filesort
explain select * from t1 where a = 2 and (b is null or b > 0) order by a explain select * from t1 where a = 2 and (b is null or b > 0) order by a
desc,b desc; desc,b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 6 where used; Using index t1 range a a 9 NULL 6 Using where; Using index
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 5 where used; Using index t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 9 NULL 2 where used; Using index; Using filesort t1 range a a 9 NULL 2 Using where; Using index; Using filesort
alter table t1 modify b int not null, modify c varchar(10) not null; alter table t1 modify b int not null, modify c varchar(10) not null;
explain select * from t1 order by a, b, c; explain select * from t1 order by a, b, c;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
...@@ -356,14 +356,14 @@ a b c ...@@ -356,14 +356,14 @@ a b c
1 0 1 0
explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 18 NULL 3 where used; Using index t1 range a a 18 NULL 3 Using where; Using index
select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
a b c a b c
1 1 b 1 1 b
1 1 b 1 1 b
explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc; explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 4 NULL 6 where used; Using index t1 range a a 4 NULL 6 Using where; Using index
select * from t1 where a < 2 and b <= 1 order by a desc, b desc; select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
a b c a b c
1 1 b 1 1 b
...@@ -387,7 +387,7 @@ a b c ...@@ -387,7 +387,7 @@ a b c
1 1 1 1
explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 8 NULL 10 where used; Using index t1 range a a 8 NULL 10 Using where; Using index
select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
a b c a b c
2 1 b 2 1 b
...@@ -399,7 +399,7 @@ a b c ...@@ -399,7 +399,7 @@ a b c
1 0 1 0
explain select * from t1 where a between 0 and 1 order by a desc, b desc; explain select * from t1 where a between 0 and 1 order by a desc, b desc;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 range a a 4 NULL 5 where used; Using index t1 range a a 4 NULL 5 Using where; Using index
select * from t1 where a between 0 and 1 order by a desc, b desc; select * from t1 where a between 0 and 1 order by a desc, b desc;
a b c a b c
1 3 b 1 3 b
...@@ -452,24 +452,24 @@ EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and ...@@ -452,24 +452,24 @@ EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index t1 index PRIMARY PRIMARY 4 NULL 6 Using index
t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1 t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 where used; Using index t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr; EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index t1 index PRIMARY PRIMARY 4 NULL 6 Using index
t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 where used t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where
EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1 t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 where used; Using index t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid; EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 where used t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr; EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 where used t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 Using where
drop table t1,t2,t3; drop table t1,t2,t3;
CREATE TABLE t1 ( CREATE TABLE t1 (
`titre` char(80) NOT NULL default '', `titre` char(80) NOT NULL default '',
......
...@@ -1328,19 +1328,19 @@ select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; ...@@ -1328,19 +1328,19 @@ select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
fld3 fld3
explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ref fld3 fld3 30 const 1 where used; Using index t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 index NULL fld3 30 NULL 1199 where used; Using index t2 index NULL fld3 30 NULL 1199 Using where; Using index
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 index NULL fld3 30 NULL 1199 where used; Using index t2 index NULL fld3 30 NULL 1199 Using where; Using index
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ref fld3 fld3 30 const 1 where used; Using index t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ref fld3 fld3 30 const 1 where used; Using index t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 ignore index (fld3,not_used); explain select fld3 from t2 ignore index (fld3,not_used);
Key column 'not_used' doesn't exist in table Key column 'not_used' doesn't exist in table
explain select fld3 from t2 use index (not_used); explain select fld3 from t2 use index (not_used);
...@@ -1351,7 +1351,7 @@ honeysuckle ...@@ -1351,7 +1351,7 @@ honeysuckle
honoring honoring
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 range fld3 fld3 30 NULL 2 where used; Using index t2 range fld3 fld3 30 NULL 2 Using where; Using index
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
fld1 fld3 fld1 fld3
148504 Colombo 148504 Colombo
...@@ -1371,7 +1371,7 @@ fld1 ...@@ -1371,7 +1371,7 @@ fld1
250502 250502
explain select fld1 from t2 where fld1=250501 or fld1="250502"; explain select fld1 from t2 where fld1=250501 or fld1="250502";
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 range fld1 fld1 4 NULL 2 where used; Using index t2 range fld1 fld1 4 NULL 2 Using where; Using index
select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
fld1 fld1
250501 250501
...@@ -1380,7 +1380,7 @@ fld1 ...@@ -1380,7 +1380,7 @@ fld1
250601 250601
explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 range fld1 fld1 4 NULL 4 where used; Using index t2 range fld1 fld1 4 NULL 4 Using where; Using index
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
fld1 fld3 fld1 fld3
218401 faithful 218401 faithful
...@@ -1807,8 +1807,8 @@ select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr orde ...@@ -1807,8 +1807,8 @@ select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr orde
fld3 fld3
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ALL fld1 NULL NULL NULL 1199 where used; Using temporary; Using filesort t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 where used; Using index t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 Using where; Using index
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
...@@ -2575,11 +2575,11 @@ companynr companyname ...@@ -2575,11 +2575,11 @@ companynr companyname
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ALL NULL NULL NULL NULL 1199 t2 ALL NULL NULL NULL NULL 1199
t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 where used; Not exists t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t4 ALL NULL NULL NULL NULL 12 t4 ALL NULL NULL NULL NULL 12
t2 ALL NULL NULL NULL NULL 1199 where used; Not exists t2 ALL NULL NULL NULL NULL 1199 Using where; Not exists
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr companynr companynr
37 36 37 36
...@@ -2587,7 +2587,7 @@ companynr companynr ...@@ -2587,7 +2587,7 @@ companynr companynr
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ALL NULL NULL NULL NULL 1199 Using temporary t2 ALL NULL NULL NULL NULL 1199 Using temporary
t4 index NULL PRIMARY 1 NULL 12 where used; Using index t4 index NULL PRIMARY 1 NULL 12 Using where; Using index
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; 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 fld1 companynr fld3 period
038008 37 reporters 1008 038008 37 reporters 1008
......
...@@ -72,3 +72,25 @@ id val elt(two.val,'one','two') ...@@ -72,3 +72,25 @@ id val elt(two.val,'one','two')
2 1 one 2 1 one
4 2 two 4 2 two
drop table t1,t2; drop table t1,t2;
drop table if exists t1;
CREATE TABLE t1 (
d datetime default NULL
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40');
flush status;
select * from t1 group by d;
d
2002-10-24 14:50:32
2002-10-24 14:50:33
2002-10-24 14:50:34
2002-10-24 14:50:35
2002-10-24 14:50:36
2002-10-24 14:50:37
2002-10-24 14:50:38
2002-10-24 14:50:39
2002-10-24 14:50:40
show status like "created_tmp%tables";
Variable_name Value
Created_tmp_disk_tables 0
Created_tmp_tables 1
drop table t1;
...@@ -76,5 +76,5 @@ date numfacture expedition ...@@ -76,5 +76,5 @@ date numfacture expedition
0000-00-00 00:00:00 1212 0001-00-00 00:00:00 0000-00-00 00:00:00 1212 0001-00-00 00:00:00
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref expedition expedition 8 const 1 where used t1 ref expedition expedition 8 const 1 Using where
drop table t1; drop table t1;
...@@ -19,14 +19,14 @@ i @vv1:=if(sv1.i,1,0) @vv2:=if(sv2.i,1,0) @vv3:=if(sv3.i,1,0) @vv1+@vv2+@vv3 ...@@ -19,14 +19,14 @@ i @vv1:=if(sv1.i,1,0) @vv2:=if(sv2.i,1,0) @vv3:=if(sv3.i,1,0) @vv1+@vv2+@vv3
2 1 0 0 1 2 1 0 0 1
explain select * from t1 where i=@vv1; explain select * from t1 where i=@vv1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref i i 4 const 1 where used t1 ref i i 4 const 1 Using where
explain select * from t1 where @vv1:=@vv1+1 and i=@vv1; explain select * from t1 where @vv1:=@vv1+1 and i=@vv1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 3 where used t1 ALL NULL NULL NULL NULL 3 Using where
explain select @vv1:=i from t1 where i=@vv1; explain select @vv1:=i from t1 where i=@vv1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 index NULL i 4 NULL 3 where used; Using index t1 index NULL i 4 NULL 3 Using where; Using index
explain select * from t1 where i=@vv1; explain select * from t1 where i=@vv1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref i i 4 const 1 where used t1 ref i i 4 const 1 Using where
drop table t1,t2; drop table t1,t2;
...@@ -108,7 +108,6 @@ show global variables like 'table_type'; ...@@ -108,7 +108,6 @@ show global variables like 'table_type';
Variable_name Value Variable_name Value
table_type INNODB table_type INNODB
set GLOBAL query_cache_size=100000; set GLOBAL query_cache_size=100000;
set GLOBAL safe_show_database=0;
set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000; set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000;
show variables like 'myisam_max_sort_file_size'; show variables like 'myisam_max_sort_file_size';
Variable_name Value Variable_name Value
...@@ -276,7 +275,6 @@ set global query_cache_type=demand; ...@@ -276,7 +275,6 @@ set global query_cache_type=demand;
set read_buffer_size=100; set read_buffer_size=100;
set read_rnd_buffer_size=100; set read_rnd_buffer_size=100;
set global rpl_recovery_rank=100; set global rpl_recovery_rank=100;
set global safe_show_database=1;
set global server_id=100; set global server_id=100;
set global slave_net_timeout=100; set global slave_net_timeout=100;
set global slow_launch_time=100; set global slow_launch_time=100;
......
...@@ -60,3 +60,21 @@ insert into t2 values (1,1),(2,1),(3,1),(4,2); ...@@ -60,3 +60,21 @@ insert into t2 values (1,1),(2,1),(3,1),(4,2);
# do a query using ELT, a join and an ORDER BY. # do a query using ELT, a join and an ORDER BY.
select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id; select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
drop table t1,t2; drop table t1,t2;
#
# In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based
# temporary table when a memory based one would be good enough.
drop table if exists t1;
CREATE TABLE t1 (
d datetime default NULL
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40');
flush status;
select * from t1 group by d;
show status like "created_tmp%tables";
drop table t1;
...@@ -65,7 +65,6 @@ set table_type=MYISAM, table_type="HEAP", global table_type="INNODB"; ...@@ -65,7 +65,6 @@ set table_type=MYISAM, table_type="HEAP", global table_type="INNODB";
show local variables like 'table_type'; show local variables like 'table_type';
show global variables like 'table_type'; show global variables like 'table_type';
set GLOBAL query_cache_size=100000; set GLOBAL query_cache_size=100000;
set GLOBAL safe_show_database=0;
set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000; set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000;
show variables like 'myisam_max_sort_file_size'; show variables like 'myisam_max_sort_file_size';
...@@ -188,7 +187,6 @@ set global query_cache_type=demand; ...@@ -188,7 +187,6 @@ set global query_cache_type=demand;
set read_buffer_size=100; set read_buffer_size=100;
set read_rnd_buffer_size=100; set read_rnd_buffer_size=100;
set global rpl_recovery_rank=100; set global rpl_recovery_rank=100;
set global safe_show_database=1;
set global server_id=100; set global server_id=100;
set global slave_net_timeout=100; set global slave_net_timeout=100;
set global slow_launch_time=100; set global slow_launch_time=100;
......
...@@ -215,6 +215,7 @@ then ...@@ -215,6 +215,7 @@ then
if test -n "$open_files" if test -n "$open_files"
then then
ulimit -n $open_files ulimit -n $open_files
args="open-files-limit=$open_files $args"
fi fi
if test -n "$core_file_size" if test -n "$core_file_size"
then then
......
...@@ -274,7 +274,7 @@ static char* pidfile_name_ptr= pidfile_name; ...@@ -274,7 +274,7 @@ static char* pidfile_name_ptr= pidfile_name;
static pthread_t select_thread; static pthread_t select_thread;
static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0; static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0;
my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool opt_safe_show_db=0, lower_case_table_names, opt_old_rpl_compat; my_bool lower_case_table_names, opt_old_rpl_compat;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0; my_bool opt_log_slave_updates= 0;
...@@ -3226,8 +3226,7 @@ struct my_option my_long_options[] = ...@@ -3226,8 +3226,7 @@ struct my_option my_long_options[] =
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
{"safe-show-database", OPT_SAFE_SHOW_DB, {"safe-show-database", OPT_SAFE_SHOW_DB,
"Deprecated option; One should use GRANT SHOW DATABASES instead...", "Deprecated option; One should use GRANT SHOW DATABASES instead...",
(gptr*) &opt_safe_show_db, (gptr*) &opt_safe_show_db, 0, GET_BOOL, NO_ARG, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
0, 0, 0, 0, 0, 0},
#endif #endif
{"safe-user-create", OPT_SAFE_USER_CREATE, {"safe-user-create", OPT_SAFE_USER_CREATE,
"Don't allow new user creation by the user who has no write privileges to the mysql.user table", "Don't allow new user creation by the user who has no write privileges to the mysql.user table",
......
...@@ -195,8 +195,6 @@ sys_var_thd_enum sys_query_cache_type("query_cache_type", ...@@ -195,8 +195,6 @@ sys_var_thd_enum sys_query_cache_type("query_cache_type",
&SV::query_cache_type, &SV::query_cache_type,
&query_cache_type_typelib); &query_cache_type_typelib);
#endif /* HAVE_QUERY_CACHE */ #endif /* HAVE_QUERY_CACHE */
sys_var_bool_ptr sys_safe_show_db("safe_show_database",
&opt_safe_show_db);
sys_var_long_ptr sys_server_id("server_id",&server_id); sys_var_long_ptr sys_server_id("server_id",&server_id);
sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol", sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
&opt_slave_compressed_protocol); &opt_slave_compressed_protocol);
...@@ -356,7 +354,6 @@ sys_var *sys_variables[]= ...@@ -356,7 +354,6 @@ sys_var *sys_variables[]=
&sys_read_buff_size, &sys_read_buff_size,
&sys_read_rnd_buff_size, &sys_read_rnd_buff_size,
&sys_rpl_recovery_rank, &sys_rpl_recovery_rank,
&sys_safe_show_db,
&sys_safe_updates, &sys_safe_updates,
&sys_select_limit, &sys_select_limit,
&sys_server_id, &sys_server_id,
...@@ -499,7 +496,6 @@ struct show_var_st init_vars[]= { ...@@ -499,7 +496,6 @@ struct show_var_st init_vars[]= {
{sys_query_cache_size.name, (char*) &sys_query_cache_size, SHOW_SYS}, {sys_query_cache_size.name, (char*) &sys_query_cache_size, SHOW_SYS},
{sys_query_cache_type.name, (char*) &sys_query_cache_type, SHOW_SYS}, {sys_query_cache_type.name, (char*) &sys_query_cache_type, SHOW_SYS},
#endif /* HAVE_QUERY_CACHE */ #endif /* HAVE_QUERY_CACHE */
{sys_safe_show_db.name, (char*) &sys_safe_show_db, SHOW_SYS},
{sys_server_id.name, (char*) &sys_server_id, SHOW_SYS}, {sys_server_id.name, (char*) &sys_server_id, SHOW_SYS},
{sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS}, {sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS},
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
......
...@@ -1732,7 +1732,7 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error) ...@@ -1732,7 +1732,7 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error)
"Slave: query '%s' partially completed on the master \ "Slave: query '%s' partially completed on the master \
and was aborted. There is a chance that your master is inconsistent at this \ and was aborted. There is a chance that your master is inconsistent at this \
point. If you are sure that your master is ok, run this query manually on the\ point. If you are sure that your master is ok, run this query manually on the\
slave and then restart the slave with SET SQL_SLAVE_SKIP_COUNTER=1;\ slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;\
SLAVE START;", thd->query); SLAVE START;", thd->query);
rli->last_slave_errno = expected_error; rli->last_slave_errno = expected_error;
sql_print_error("%s",rli->last_slave_error); sql_print_error("%s",rli->last_slave_error);
......
...@@ -77,9 +77,10 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent) ...@@ -77,9 +77,10 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
{ {
if (!thd->query) if (!thd->query)
{ {
/* The client used the old obsolete mysql_create_db() call */
thd->query = path; thd->query = path;
thd->query_length = (uint) (strxmov(path,"create database ", db, NullS)- thd->query_length = (uint) (strxmov(path,"create database `", db, "`",
path); NullS) - path);
} }
{ {
mysql_update_log.write(thd,thd->query, thd->query_length); mysql_update_log.write(thd,thd->query, thd->query_length);
......
...@@ -7193,56 +7193,32 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -7193,56 +7193,32 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
{ {
if (tab->use_quick == 2) if (tab->use_quick == 2)
{ {
sprintf(buff_ptr,"range checked for each record (index map: %u)", sprintf(buff_ptr,"; Range checked for each record (index map: %u)",
tab->keys); tab->keys);
buff_ptr=strend(buff_ptr); buff_ptr=strend(buff_ptr);
} }
else else
buff_ptr=strmov(buff_ptr,"where used"); buff_ptr=strmov(buff_ptr,"; Using where");
} }
if (key_read) if (key_read)
{ buff_ptr= strmov(buff_ptr,"; Using index");
if (buff != buff_ptr)
{
buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
}
buff_ptr=strmov(buff_ptr,"Using index");
}
if (table->reginfo.not_exists_optimize) if (table->reginfo.not_exists_optimize)
{ buff_ptr= strmov(buff_ptr,"; Not exists");
if (buff != buff_ptr)
{
buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
}
buff_ptr=strmov(buff_ptr,"Not exists");
}
if (need_tmp_table) if (need_tmp_table)
{ {
need_tmp_table=0; need_tmp_table=0;
if (buff != buff_ptr) buff_ptr= strmov(buff_ptr,"; Using temporary");
{
buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
}
buff_ptr=strmov(buff_ptr,"Using temporary");
} }
if (need_order) if (need_order)
{ {
need_order=0; need_order=0;
if (buff != buff_ptr) buff_ptr= strmov(buff_ptr,"; Using filesort");
{
buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
}
buff_ptr=strmov(buff_ptr,"Using filesort");
}
if (distinct & test_all_bits(used_tables,thd->used_tables))
{
if (buff != buff_ptr)
{
buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
}
buff_ptr=strmov(buff_ptr,"Distinct");
} }
item_list.push_back(new Item_string(buff,(uint) (buff_ptr - buff))); if (distinct && test_all_bits(used_tables,thd->used_tables))
buff_ptr= strmov(buff_ptr,"; Distinct");
if (buff_ptr == buff)
buff_ptr+= 2;
item_list.push_back(new Item_string(buff+2,(uint) (buff_ptr - buff)-2));
// For next iteration // For next iteration
used_tables|=table->map; used_tables|=table->map;
if (result->send_data(item_list)) if (result->send_data(item_list))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment