Merge 10.0-base -> 10.0.

Also fixed a bug in sql_update.cc: the code of mysql_update() lacked
a call of set_statistics_for_table().
This commit is contained in:
Igor Babaev 2013-01-10 22:33:23 -08:00
commit 1ef07d0845
156 changed files with 12024 additions and 1662 deletions

View file

@ -1936,7 +1936,9 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
{
create_stmt_ptr= (*row)[i];
create_stmt_len= lengths[i];
#ifndef DBUG_OFF
body_found= 1;
#endif
}
else
{

View file

@ -18,8 +18,8 @@ export DEB_BUILD_OPTIONS="nocheck"
# Find major.minor version.
#
source ./VERSION
UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}"
RELEASE_EXTRA=${MYSQL_VERSION_EXTRA}
UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}"
RELEASE_EXTRA=""
RELEASE_NAME=mariadb
PATCHLEVEL=""

View file

@ -51,9 +51,6 @@ word32 PBKDF2_HMAC<T>::DeriveKey(byte* derived, word32 dLen, const byte* pwd,
if (dLen > MaxDerivedKeyLength())
return 0;
if (iterations < 0)
return 0;
ByteBlock buffer(T::DIGEST_SIZE);
HMAC<T> hmac;

View file

@ -383,7 +383,8 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename);
int maria_disable_indexes(MARIA_HA *info);
int maria_enable_indexes(MARIA_HA *info);
int maria_indexes_are_disabled(MARIA_HA *info);
void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows);
void maria_disable_indexes_for_rebuild(MARIA_HA *info, ha_rows rows,
my_bool all_keys);
my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
my_bool force);

View file

@ -335,6 +335,12 @@ enum ha_base_keytype {
#define HA_CREATE_DELAY_KEY_WRITE 64
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
/* Flags used by start_bulk_insert */
#define HA_CREATE_UNIQUE_INDEX_BY_SORT 1
/*
The following flags (OR-ed) are passed to handler::info() method.
The method copies misc handler information out of the storage engine

View file

@ -63,6 +63,8 @@
#define T_ZEROFILL_KEEP_LSN ((ulonglong) 1L << 33)
/** If repair should not bump create_rename_lsn */
#define T_NO_CREATE_RENAME_LSN ((ulonglong) 1L << 33)
#define T_CREATE_UNIQUE_BY_SORT ((ulonglong) 1L << 34)
#define T_SUPPRESS_ERR_HANDLING ((ulonglong) 1L << 35)
#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)

View file

@ -75,7 +75,8 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/debug_sync.cc ../sql/opt_table_elimination.cc
../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc
../sql/sql_select.cc ../sql/sql_servers.cc
../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc
../sql/sql_show.cc ../sql/sql_state.c
../sql/sql_statistics.cc ../sql/sql_string.cc
../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc
../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc
../sql/sql_update.cc ../sql/sql_view.cc ../sql/sql_profile.cc

View file

@ -0,0 +1,65 @@
--echo #
--echo # mdev-539: fast build of unique/primary indexes for MyISAM/Aria
--echo #
--disable_warnings
DROP DATABASE IF EXISTS dbt3_s001;
--enable_warnings
CREATE DATABASE dbt3_s001;
use dbt3_s001;
--disable_query_log
--disable_result_log
--disable_warnings
--source include/dbt3_s001.inc
--enable_warnings
--enable_result_log
--enable_query_log
drop index `primary` on lineitem;
show create table lineitem;
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
drop index `primary` on lineitem;
select * from lineitem where l_orderkey=1 and l_linenumber=2;
insert into lineitem values
(1,68,9,2,36,34850.16,0.07,0.06,'N','O','1996-04-12','1996-02-28','1996-04-20','TAKE BACK RETURN','MAIL','slyly bold pinto beans detect s');
select * from lineitem where l_orderkey=1 and l_linenumber=2;
--error ER_DUP_ENTRY
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
select * from lineitem where l_orderkey=1 and l_linenumber=2;
delete from lineitem where l_orderkey=1 and l_linenumber=2 and l_discount=0.07;
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
select * from lineitem where l_orderkey=1 and l_linenumber=2;
create unique index i_c_name on customer(c_name);
show create table customer;
select * from customer where c_name='Customer#000000003';
drop index i_c_name on customer;
insert into customer values
(303,'Customer#000000003','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
select * from customer where c_name='Customer#000000003';
--error ER_DUP_ENTRY
alter table customer add unique index i_c_name(c_name);
show create table customer;
select * from customer where c_name='Customer#000000003';
delete from customer where c_custkey=303;
select * from customer where c_name='Customer#000000003';
alter table customer add unique index i_c_name(c_name);
show create table customer;
select * from customer where c_name='Customer#000000003';
drop index `primary` on customer;
show create table customer;
insert into customer values
(3,'Customer#000000303','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
alter ignore table customer add primary key (c_custkey);
show create table customer;
select * from customer where c_custkey=3;
DROP DATABASE dbt3_s001;

View file

@ -0,0 +1,5 @@
if (`select count(*) < 3 from information_schema.tables
where table_schema = 'mysql' and table_name in ('table_stats','column_stats','index_stats')`)
{
--skip Needs stat tables
}

View file

@ -0,0 +1 @@
--use-stat-tables='complementary'

View file

@ -16,3 +16,6 @@ show create table proc;
show create table event;
show create table general_log;
show create table slow_log;
show create table table_stats;
show create table column_stats;
show create table index_stats;

View file

@ -0,0 +1,25 @@
CREATE TABLE Country (
Code char(3) NOT NULL default '',
Name char(52) NOT NULL default '',
SurfaceArea float(10,2) NOT NULL default '0.00',
Population int(11) NOT NULL default '0',
Capital int(11) default NULL,
PRIMARY KEY (Code),
UNIQUE INDEX (Name)
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE City (
ID int(11) NOT NULL auto_increment,
Name char(35) NOT NULL default '',
Country char(3) NOT NULL default '',
Population int(11) NOT NULL default '0',
PRIMARY KEY (ID),
INDEX (Population),
INDEX (Country)
) CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE CountryLanguage (
Country char(3) NOT NULL default '',
Language char(30) NOT NULL default '',
Percentage float(3,1) NOT NULL default '0.0',
PRIMARY KEY (Country, Language),
INDEX (Percentage)
) CHARACTER SET utf8 COLLATE utf8_bin;

View file

@ -7,6 +7,7 @@ performance_schema
test
show tables in mysql;
Tables_in_mysql
column_stats
columns_priv
db
event
@ -17,6 +18,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -29,6 +31,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second

View file

@ -176,12 +176,12 @@ create table t1 (a int, b int);
alter table t1 add unique (a,b), add key (b);
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a A NULL NULL NULL YES BTREE
t1 0 a 2 b A NULL NULL NULL YES BTREE
t1 0 a 1 a A 3 NULL NULL YES BTREE
t1 0 a 2 b A 300 NULL NULL YES BTREE
t1 1 b 1 b A 100 NULL NULL YES BTREE
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t1 analyze status Table is already up to date
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a A 3 NULL NULL YES BTREE

View file

@ -0,0 +1,252 @@
#
set @@storage_engine= Aria;
#
# mdev-539: fast build of unique/primary indexes for MyISAM/Aria
#
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
drop index `primary` on lineitem;
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
PRIMARY KEY (`l_orderkey`,`l_linenumber`),
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
drop index `primary` on lineitem;
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
insert into lineitem values
(1,68,9,2,36,34850.16,0.07,0.06,'N','O','1996-04-12','1996-02-28','1996-04-20','TAKE BACK RETURN','MAIL','slyly bold pinto beans detect s');
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
1 68 9 2 36 34850.16 0.07 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
alter table lineitem add primary key (l_orderkey, l_linenumber);
ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY'
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
1 68 9 2 36 34850.16 0.07 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
delete from lineitem where l_orderkey=1 and l_linenumber=2 and l_discount=0.07;
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
PRIMARY KEY (`l_orderkey`,`l_linenumber`),
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
create unique index i_c_name on customer(c_name);
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
drop index i_c_name on customer;
insert into customer values
(303,'Customer#000000003','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
303 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
alter table customer add unique index i_c_name(c_name);
ERROR 23000: Duplicate entry 'Customer#000000003' for key 'i_c_name'
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
303 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
delete from customer where c_custkey=303;
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
alter table customer add unique index i_c_name(c_name);
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
drop index `primary` on customer;
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
insert into customer values
(3,'Customer#000000303','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
alter ignore table customer add primary key (c_custkey);
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from customer where c_custkey=3;
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
DROP DATABASE dbt3_s001;
set @@storage_engine= default;

View file

@ -0,0 +1,252 @@
#
set @@storage_engine= MyISAM;
#
# mdev-539: fast build of unique/primary indexes for MyISAM/Aria
#
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
drop index `primary` on lineitem;
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
PRIMARY KEY (`l_orderkey`,`l_linenumber`),
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop index `primary` on lineitem;
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
insert into lineitem values
(1,68,9,2,36,34850.16,0.07,0.06,'N','O','1996-04-12','1996-02-28','1996-04-20','TAKE BACK RETURN','MAIL','slyly bold pinto beans detect s');
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
1 68 9 2 36 34850.16 0.07 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
alter table lineitem add primary key (l_orderkey, l_linenumber);
ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY'
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
1 68 9 2 36 34850.16 0.07 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
delete from lineitem where l_orderkey=1 and l_linenumber=2 and l_discount=0.07;
alter table lineitem add primary key (l_orderkey, l_linenumber);
show create table lineitem;
Table Create Table
lineitem CREATE TABLE `lineitem` (
`l_orderkey` int(11) NOT NULL DEFAULT '0',
`l_partkey` int(11) DEFAULT NULL,
`l_suppkey` int(11) DEFAULT NULL,
`l_linenumber` int(11) NOT NULL DEFAULT '0',
`l_quantity` double DEFAULT NULL,
`l_extendedprice` double DEFAULT NULL,
`l_discount` double DEFAULT NULL,
`l_tax` double DEFAULT NULL,
`l_returnflag` char(1) DEFAULT NULL,
`l_linestatus` char(1) DEFAULT NULL,
`l_shipDATE` date DEFAULT NULL,
`l_commitDATE` date DEFAULT NULL,
`l_receiptDATE` date DEFAULT NULL,
`l_shipinstruct` char(25) DEFAULT NULL,
`l_shipmode` char(10) DEFAULT NULL,
`l_comment` varchar(44) DEFAULT NULL,
PRIMARY KEY (`l_orderkey`,`l_linenumber`),
KEY `i_l_shipdate` (`l_shipDATE`),
KEY `i_l_suppkey_partkey` (`l_partkey`,`l_suppkey`),
KEY `i_l_partkey` (`l_partkey`),
KEY `i_l_suppkey` (`l_suppkey`),
KEY `i_l_receiptdate` (`l_receiptDATE`),
KEY `i_l_orderkey` (`l_orderkey`),
KEY `i_l_orderkey_quantity` (`l_orderkey`,`l_quantity`),
KEY `i_l_commitdate` (`l_commitDATE`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from lineitem where l_orderkey=1 and l_linenumber=2;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
create unique index i_c_name on customer(c_name);
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
drop index i_c_name on customer;
insert into customer values
(303,'Customer#000000003','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
303 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
alter table customer add unique index i_c_name(c_name);
ERROR 23000: Duplicate entry 'Customer#000000003' for key 'i_c_name'
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
303 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
delete from customer where c_custkey=303;
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
alter table customer add unique index i_c_name(c_name);
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from customer where c_name='Customer#000000003';
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
drop index `primary` on customer;
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into customer values
(3,'Customer#000000303','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
alter ignore table customer add primary key (c_custkey);
show create table customer;
Table Create Table
customer CREATE TABLE `customer` (
`c_custkey` int(11) NOT NULL,
`c_name` varchar(25) DEFAULT NULL,
`c_address` varchar(40) DEFAULT NULL,
`c_nationkey` int(11) DEFAULT NULL,
`c_phone` char(15) DEFAULT NULL,
`c_acctbal` double DEFAULT NULL,
`c_mktsegment` char(10) DEFAULT NULL,
`c_comment` varchar(117) DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
UNIQUE KEY `i_c_name` (`c_name`),
KEY `i_c_nationkey` (`c_nationkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from customer where c_custkey=3;
c_custkey c_name c_address c_nationkey c_phone c_acctbal c_mktsegment c_comment
3 Customer#000000003 MG9kdTD2WBHm 1 11-719-748-3364 7498.12 AUTOMOBILE special packages wake. slyly reg
DROP DATABASE dbt3_s001;
set @@storage_engine= default;

View file

@ -1,6 +1,7 @@
drop table if exists t1,t2;
show tables;
Tables_in_mysql
column_stats
columns_priv
db
event
@ -11,6 +12,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -23,6 +25,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -40,6 +43,7 @@ grant ALL on *.* to test@localhost identified by "gambling";
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
show tables;
Tables_in_mysql
column_stats
columns_priv
db
event
@ -50,6 +54,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -62,6 +67,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -87,6 +93,7 @@ ERROR HY000: Password hash should be a 41-digit hexadecimal number
set password=old_password('gambling3');
show tables;
Tables_in_mysql
column_stats
columns_priv
db
event
@ -97,6 +104,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -109,6 +117,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second

View file

@ -2403,3 +2403,30 @@ a b
1 1
drop table t1;
#
# Checking that CREATE IF NOT EXISTS is not blocked by running SELECT
#
create table t1 (a int, b int) engine=myisam;
create table t2 (a int, b int) engine=myisam;
insert into t1 values (1,1);
lock tables t1 read;
set @@lock_wait_timeout=5;
create table if not exists t1 (a int, b int);
Warnings:
Note 1050 Table 't1' already exists
create table if not exists t1 (a int, b int) select 2,2;
Warnings:
Note 1050 Table 't1' already exists
create table if not exists t1 like t2;
Warnings:
Note 1050 Table 't1' already exists
create table t1 (a int, b int);
ERROR 42S01: Table 't1' already exists
create table t1 (a int, b int) select 2,2;
ERROR 42S01: Table 't1' already exists
create table t1 like t2;
ERROR 42S01: Table 't1' already exists
select * from t1;
a b
1 1
unlock tables;
drop table t1,t2;

View file

@ -81,6 +81,7 @@ TRIGGERS
USER_PRIVILEGES
USER_STATISTICS
VIEWS
column_stats
columns_priv
db
event
@ -91,6 +92,7 @@ help_keyword
help_relation
help_topic
host
index_stats
plugin
proc
procs_priv
@ -102,6 +104,7 @@ t2
t3
t4
t5
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -120,6 +123,7 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
table_stats table_stats
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
@ -141,6 +145,7 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
table_stats table_stats
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
@ -162,6 +167,7 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
table_stats table_stats
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
@ -1934,6 +1940,26 @@ event_object_table trigger_name
# Switching to connection 'default'.
#
#
# MDEV-3818: Query against view over IS tables worse than equivalent query without view
#
create view v1 as select table_schema, table_name, column_name from information_schema.columns;
explain extended
select column_name from v1
where (table_schema = "osm") and (table_name = "test");
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE columns ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL NULL Using where; Open_frm_only; Scanned 0 databases
Warnings:
Note 1003 select `information_schema`.`columns`.`COLUMN_NAME` AS `column_name` from `information_schema`.`columns` where ((`information_schema`.`columns`.`TABLE_SCHEMA` = 'osm') and (`information_schema`.`columns`.`TABLE_NAME` = 'test'))
explain extended
select information_schema.columns.column_name as column_name
from information_schema.columns
where (information_schema.columns.table_schema = 'osm') and (information_schema.columns.table_name = 'test');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE columns ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL NULL Using where; Open_frm_only; Scanned 0 databases
Warnings:
Note 1003 select `information_schema`.`columns`.`COLUMN_NAME` AS `column_name` from `information_schema`.`columns` where ((`information_schema`.`columns`.`TABLE_SCHEMA` = 'osm') and (`information_schema`.`columns`.`TABLE_NAME` = 'test'))
drop view v1;
#
# Clean-up.
drop database mysqltest;
#

View file

@ -418,4 +418,4 @@ Wildcard: inf_rmation_schema
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
table_schema count(*)
information_schema 58
mysql 23
mysql 26

View file

@ -19,6 +19,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -28,6 +29,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -40,6 +42,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK

View file

@ -0,0 +1,21 @@
CREATE TABLE A (
pk INTEGER AUTO_INCREMENT PRIMARY KEY,
fdate DATE
) ENGINE=MyISAM;
CREATE PROCEDURE p_analyze()
BEGIN
DECLARE attempts INTEGER DEFAULT 100;
wl_loop: WHILE attempts > 0 DO
ANALYZE TABLE A;
SET attempts = attempts - 1;
END WHILE wl_loop;
END |
CREATE FUNCTION rnd3() RETURNS INT
BEGIN
RETURN ROUND(3 * RAND() + 0.5);
END |
SET GLOBAL use_stat_tables = PREFERABLY;
DROP TABLE A;
DROP PROCEDURE p_analyze;
DROP FUNCTION rnd3;
SET GLOBAL use_stat_tables = DEFAULT;

View file

@ -7,6 +7,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -16,6 +17,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -27,6 +29,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -49,6 +52,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -58,6 +62,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -69,6 +74,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -91,6 +97,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -100,6 +107,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -111,6 +119,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -136,6 +145,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -145,6 +155,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -156,6 +167,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -184,6 +196,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -193,6 +206,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -204,6 +218,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -235,6 +250,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -244,6 +260,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -255,6 +272,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -289,6 +307,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -298,6 +317,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -309,6 +329,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK

View file

@ -9,6 +9,7 @@ mtr
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -18,6 +19,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -29,6 +31,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK

View file

@ -3,6 +3,7 @@ drop view if exists v1;
drop database if exists client_test_db;
mtr.global_suppressions OK
mtr.test_suppressions OK
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -12,6 +13,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -23,6 +25,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -32,6 +35,7 @@ mysql.time_zone_transition_type OK
mysql.user OK
mtr.global_suppressions Table is already up to date
mtr.test_suppressions Table is already up to date
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -41,6 +45,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
note : Table does not support optimize, doing recreate + analyze instead
status : OK
@ -56,6 +61,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -63,6 +69,7 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
@ -72,6 +79,7 @@ mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
@ -83,6 +91,7 @@ mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@ -90,6 +99,7 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
mysql.column_stats Table is already up to date
mysql.columns_priv Table is already up to date
mysql.db Table is already up to date
mysql.event Table is already up to date
@ -99,6 +109,7 @@ mysql.help_keyword Table is already up to date
mysql.help_relation Table is already up to date
mysql.help_topic Table is already up to date
mysql.host Table is already up to date
mysql.index_stats Table is already up to date
mysql.innodb_index_stats
note : Table does not support optimize, doing recreate + analyze instead
status : OK
@ -114,6 +125,7 @@ mysql.servers Table is already up to date
mysql.slave_master_info Table is already up to date
mysql.slave_relay_log_info Table is already up to date
mysql.slave_worker_info Table is already up to date
mysql.table_stats Table is already up to date
mysql.tables_priv Table is already up to date
mysql.time_zone Table is already up to date
mysql.time_zone_leap_second Table is already up to date

View file

@ -918,6 +918,9 @@ The following options may be given as the first argument:
Prohibit update of a VIEW, which does not contain a key
of the underlying table and the query uses a LIMIT clause
(usually get from GUI tools)
--use-stat-tables=name
Specifies how to use system statistics tables. Possible
values are NEVER, COMPLEMENTARY, PREVERABLY
-u, --user=name Run mysqld daemon as user.
--userstat Enables statistics gathering for USER_STATISTICS,
CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS
@ -1198,6 +1201,7 @@ transaction-isolation REPEATABLE-READ
transaction-prealloc-size 4096
transaction-read-only FALSE
updatable-views-with-limit YES
use-stat-tables NEVER
userstat FALSE
verbose TRUE
wait-timeout 28800

View file

@ -1576,7 +1576,7 @@ update t1 set c1=lpad(id+1000, 12, ' '), c2=lpad(id+10000, 15, ' ');
alter table t1 add unique index (c1), add unique index (c2), add index (c3);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t1 analyze status Table is already up to date
explain
select * from t1 where (c1=' 100000' or c2=' 2000000');
id select_type table type possible_keys key key_len ref rows Extra

View file

@ -1,5 +1,6 @@
drop table if exists t0, t1, t2, t3, t4;
drop view if exists v1;
set debug_sync='RESET';
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int);
@ -1076,3 +1077,4 @@ show explain for foo;
ERROR HY000: You may only use constant expressions in this statement
# End
drop table t0;
set debug_sync='RESET';

View file

@ -0,0 +1,383 @@
select @@global.use_stat_tables;
@@global.use_stat_tables
COMPLEMENTARY
select @@session.use_stat_tables;
@@session.use_stat_tables
COMPLEMENTARY
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
select * from mysql.table_stats;
db_name table_name cardinality
dbt3_s001 customer 150
dbt3_s001 lineitem 6005
dbt3_s001 nation 25
dbt3_s001 orders 1500
dbt3_s001 part 200
dbt3_s001 partsupp 700
dbt3_s001 region 5
dbt3_s001 supplier 10
select * from mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111
set optimizer_switch=@save_optimizer_switch;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
EXPLAIN select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 179 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
n_name revenue
PERU 321915.8715
ARGENTINA 69817.1451
set optimizer_switch=@save_optimizer_switch;
delete from mysql.index_stats;
select * from mysql.table_stats;
db_name table_name cardinality
dbt3_s001 customer 150
dbt3_s001 lineitem 6005
dbt3_s001 nation 25
dbt3_s001 orders 1500
dbt3_s001 part 200
dbt3_s001 partsupp 700
dbt3_s001 region 5
dbt3_s001 supplier 10
select * from mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111
select * from mysql.table_stats where table_name='orders';
db_name table_name cardinality
dbt3_s001 orders 1500
select * from mysql.index_stats where table_name='orders';
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15.0000
select (select cardinality from mysql.table_stats where table_name='orders') /
(select avg_frequency from mysql.index_stats
where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
n_distinct
1126.0416
select count(distinct o_orderdate) from orders;
count(distinct o_orderdate)
1126
select (select cardinality from mysql.table_stats where table_name='orders') /
(select avg_frequency from mysql.index_stats
where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
n_distinct
100.0000
select count(distinct o_custkey) from orders;
count(distinct o_custkey)
100
show index from orders;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
orders 0 PRIMARY 1 o_orderkey A 1500 NULL NULL BTREE
orders 1 i_o_orderdate 1 o_orderDATE A 1126 NULL NULL YES BTREE
orders 1 i_o_custkey 1 o_custkey A 100 NULL NULL YES BTREE
select index_name, column_name, cardinality from information_schema.statistics
where table_name='orders';
index_name column_name cardinality
PRIMARY o_orderkey 1500
i_o_orderdate o_orderDATE 1126
i_o_custkey o_custkey 100
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
EXPLAIN select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 179 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
n_name revenue
PERU 321915.8715
ARGENTINA 69817.1451
set optimizer_switch=@save_optimizer_switch;
EXPLAIN select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
from (select extract(year from o_orderdate) as o_year,
l_extendedprice * (1-l_discount) as volume,
n2.n_name as nation
from part, supplier, lineitem, orders, customer,
nation n1, nation n2, region
where p_partkey = l_partkey and s_suppkey = l_suppkey
and l_orderkey = o_orderkey and o_custkey = c_custkey
and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey
and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey
and o_orderdate between date '1995-01-01' and date '1996-12-31'
and p_type = 'STANDARD BRUSHED STEEL' ) as all_nations
group by o_year
order by o_year;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders ALL PRIMARY,i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
from (select extract(year from o_orderdate) as o_year,
l_extendedprice * (1-l_discount) as volume,
n2.n_name as nation
from part, supplier, lineitem, orders, customer,
nation n1, nation n2, region
where p_partkey = l_partkey and s_suppkey = l_suppkey
and l_orderkey = o_orderkey and o_custkey = c_custkey
and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey
and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey
and o_orderdate between date '1995-01-01' and date '1996-12-31'
and p_type = 'STANDARD BRUSHED STEEL' ) as all_nations
group by o_year
order by o_year;
o_year mkt_share
1995 0.4495521838895718
1996 0.024585468215352495
EXPLAIN select nation, o_year, sum(amount) as sum_profit
from (select n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from part, supplier, lineitem, partsupp, orders, nation
where s_suppkey = l_suppkey and ps_suppkey = l_suppkey
and ps_partkey = l_partkey and p_partkey = l_partkey
and o_orderkey = l_orderkey and s_nationkey = n_nationkey
and p_name like '%green%') as profit
group by nation, o_year
order by nation, o_year desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE supplier ALL PRIMARY,i_s_nationkey NULL NULL NULL 10 Using where; Using temporary; Using filesort
1 SIMPLE nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
1 SIMPLE partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70
1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.supplier.s_suppkey 8
1 SIMPLE orders eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1
select nation, o_year, sum(amount) as sum_profit
from (select n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from part, supplier, lineitem, partsupp, orders, nation
where s_suppkey = l_suppkey and ps_suppkey = l_suppkey
and ps_partkey = l_partkey and p_partkey = l_partkey
and o_orderkey = l_orderkey and s_nationkey = n_nationkey
and p_name like '%green%') as profit
group by nation, o_year
order by nation, o_year desc;
nation o_year sum_profit
ARGENTINA 1997 18247.873399999993
ARGENTINA 1996 7731.089399999995
ARGENTINA 1995 134490.5697
ARGENTINA 1994 36767.101500000004
ARGENTINA 1993 35857.08
ARGENTINA 1992 35740
ETHIOPIA 1998 2758.7801999999992
ETHIOPIA 1997 19419.294599999997
ETHIOPIA 1995 51231.87439999999
ETHIOPIA 1994 3578.9478999999974
ETHIOPIA 1992 1525.8234999999986
IRAN 1998 37817.229600000006
IRAN 1997 52643.77359999999
IRAN 1996 70143.7761
IRAN 1995 84094.58260000001
IRAN 1994 18140.925599999995
IRAN 1993 78655.1676
IRAN 1992 87142.23960000002
IRAQ 1998 22860.8082
IRAQ 1997 93676.24359999999
IRAQ 1996 45103.3242
IRAQ 1994 36010.728599999995
IRAQ 1993 33221.9399
IRAQ 1992 47755.05900000001
KENYA 1998 44194.831999999995
KENYA 1997 57578.36259999999
KENYA 1996 59195.90210000001
KENYA 1995 79262.6278
KENYA 1994 102360.66609999999
KENYA 1993 128422.0196
KENYA 1992 181517.2089
MOROCCO 1998 41797.823199999984
MOROCCO 1997 23685.801799999994
MOROCCO 1996 62115.19579999998
MOROCCO 1995 42442.64300000001
MOROCCO 1994 48655.878000000004
MOROCCO 1993 22926.744400000003
MOROCCO 1992 32239.8088
PERU 1998 86999.36459999997
PERU 1997 121110.41070000001
PERU 1996 177040.40759999995
PERU 1995 122247.94520000002
PERU 1994 88046.25329999998
PERU 1993 49379.813799999996
PERU 1992 80646.86050000001
UNITED KINGDOM 1998 50577.25560000001
UNITED KINGDOM 1997 114288.8605
UNITED KINGDOM 1996 147684.46480000002
UNITED KINGDOM 1995 225267.65759999998
UNITED KINGDOM 1994 140595.5864
UNITED KINGDOM 1993 322548.49210000003
UNITED KINGDOM 1992 67747.88279999999
UNITED STATES 1998 3957.0431999999996
UNITED STATES 1997 94729.5704
UNITED STATES 1996 79297.85670000002
UNITED STATES 1995 62201.23360000001
UNITED STATES 1994 43075.629899999985
UNITED STATES 1993 27168.486199999996
UNITED STATES 1992 34092.366
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
EXPLAIN select o_orderkey, p_partkey
from part, lineitem, orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders ref PRIMARY,i_o_orderdate i_o_orderdate 4 const 1
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 SIMPLE part eq_ref PRIMARY,i_p_retailprice PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
select o_orderkey, p_partkey
from part, lineitem, orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
o_orderkey p_partkey
5895 200
set optimizer_switch=@save_optimizer_switch;
DROP DATABASE dbt3_s001;
use test;
#
# Bug mdev-473: ANALYZE table locked for write
#
set use_stat_tables='complementary';
create table t1 (i int);
lock table t1 write;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
alter table t1 add column a varchar(8);
drop table t1;
#
# Bug mdev-487: memory leak in ANALYZE with stat tables
#
SET use_stat_tables = 'preferably';
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
DELETE FROM t1 WHERE a=1;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP TABLE t1;
#
# Bug mdev-518: corrupted/missing statistical tables
#
CREATE TABLE t1 (i int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
FLUSH TABLE t1;
SET use_stat_tables='never';
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
FLUSH TABLES;
SET use_stat_tables='preferably';
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;

View file

@ -0,0 +1,70 @@
SET SESSION STORAGE_ENGINE='InnoDB';
select @@global.use_stat_tables;
@@global.use_stat_tables
NEVER
select @@session.use_stat_tables;
@@session.use_stat_tables
NEVER
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
#
# Bug mdev-503: optimizer ignores setting use_stat_tables='preferably'
#
flush tables
customer, lineitem, nation, orders, part, partsupp, region, supplier;
set use_stat_tables='never';
EXPLAIN select sql_calc_found_rows straight_join
l_orderkey, sum(l_extendedprice*(1-l_discount)) as revenue,
o_orderdate, o_shippriority
from orders, customer, lineitem
where c_mktsegment = 'BUILDING' and c_custkey = o_custkey
and l_orderkey = o_orderkey and o_orderdate < date '1995-03-15'
and l_shipdate > date '1995-03-15'
group by l_orderkey, o_orderdate, o_shippriority
order by revenue desc, o_orderdate
limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders ALL PRIMARY,i_o_orderdate,i_o_custkey NULL NULL NULL # Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey # Using where
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey # Using where
set use_stat_tables='preferably';
EXPLAIN select sql_calc_found_rows straight_join
l_orderkey, sum(l_extendedprice*(1-l_discount)) as revenue,
o_orderdate, o_shippriority
from orders, customer, lineitem
where c_mktsegment = 'BUILDING' and c_custkey = o_custkey
and l_orderkey = o_orderkey and o_orderdate < date '1995-03-15'
and l_shipdate > date '1995-03-15'
group by l_orderkey, o_orderdate, o_shippriority
order by revenue desc, o_orderdate
limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders ALL PRIMARY,i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
flush tables customer, orders, lineitem;
EXPLAIN select sql_calc_found_rows straight_join
l_orderkey, sum(l_extendedprice*(1-l_discount)) as revenue,
o_orderdate, o_shippriority
from orders, customer, lineitem
where c_mktsegment = 'BUILDING' and c_custkey = o_custkey
and l_orderkey = o_orderkey and o_orderdate < date '1995-03-15'
and l_shipdate > date '1995-03-15'
group by l_orderkey, o_orderdate, o_shippriority
order by revenue desc, o_orderdate
limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders ALL PRIMARY,i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
# End of the test case for mdev-503
set optimizer_switch=@save_optimizer_switch;
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -0,0 +1,412 @@
SET SESSION STORAGE_ENGINE='InnoDB';
set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
select @@global.use_stat_tables;
@@global.use_stat_tables
COMPLEMENTARY
select @@session.use_stat_tables;
@@session.use_stat_tables
COMPLEMENTARY
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
select * from mysql.table_stats;
db_name table_name cardinality
dbt3_s001 customer 150
dbt3_s001 lineitem 6005
dbt3_s001 nation 25
dbt3_s001 orders 1500
dbt3_s001 part 200
dbt3_s001 partsupp 700
dbt3_s001 region 5
dbt3_s001 supplier 10
select * from mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111
set optimizer_switch=@save_optimizer_switch;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
EXPLAIN select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 211 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1
1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.customer.c_nationkey 1 Using index
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
n_name revenue
PERU 321915.8715
ARGENTINA 69817.1451
set optimizer_switch=@save_optimizer_switch;
delete from mysql.index_stats;
select * from mysql.table_stats;
db_name table_name cardinality
dbt3_s001 customer 150
dbt3_s001 lineitem 6005
dbt3_s001 nation 25
dbt3_s001 orders 1500
dbt3_s001 part 200
dbt3_s001 partsupp 700
dbt3_s001 region 5
dbt3_s001 supplier 10
select * from mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 customer i_c_nationkey 2 1.0000
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_shipdate 2 1.0149
dbt3_s001 lineitem i_l_shipdate 3 1.0000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030
dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_partkey 2 1.0089
dbt3_s001 lineitem i_l_partkey 3 1.0000
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey 2 1.2073
dbt3_s001 lineitem i_l_suppkey 3 1.0000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_receiptdate 2 1.0152
dbt3_s001 lineitem i_l_receiptdate 3 1.0000
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey 2 1.0000
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_orderkey_quantity 3 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_commitdate 2 1.0364
dbt3_s001 lineitem i_l_commitdate 3 1.0000
dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 nation i_n_regionkey 2 1.0000
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_orderdate 2 1.0000
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 orders i_o_custkey 2 1.0000
dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 part i_p_retailprice 2 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_partkey 2 1.0000
dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 partsupp i_ps_suppkey 2 1.0000
dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111
dbt3_s001 supplier i_s_nationkey 2 1.0000
select * from mysql.table_stats where table_name='orders';
db_name table_name cardinality
dbt3_s001 orders 1500
select * from mysql.index_stats where table_name='orders';
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_orderdate 2 1.0000
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 orders i_o_custkey 2 1.0000
select (select cardinality from mysql.table_stats where table_name='orders') /
(select avg_frequency from mysql.index_stats
where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
n_distinct
1126.0416
select count(distinct o_orderdate) from orders;
count(distinct o_orderdate)
1126
select (select cardinality from mysql.table_stats where table_name='orders') /
(select avg_frequency from mysql.index_stats
where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
n_distinct
100.0000
select count(distinct o_custkey) from orders;
count(distinct o_custkey)
100
show index from orders;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
orders 0 PRIMARY 1 o_orderkey A 1500 NULL NULL BTREE
orders 1 i_o_orderdate 1 o_orderDATE A 1126 NULL NULL YES BTREE
orders 1 i_o_custkey 1 o_custkey A 100 NULL NULL YES BTREE
select index_name, column_name, cardinality from information_schema.statistics
where table_name='orders';
index_name column_name cardinality
PRIMARY o_orderkey 1500
i_o_orderdate o_orderDATE 1126
i_o_custkey o_custkey 100
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
EXPLAIN select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_custkey i_o_orderdate 4 NULL 211 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1
1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.customer.c_nationkey 1 Using index
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
n_name revenue
PERU 321915.8715
ARGENTINA 69817.1451
set optimizer_switch=@save_optimizer_switch;
EXPLAIN select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
from (select extract(year from o_orderdate) as o_year,
l_extendedprice * (1-l_discount) as volume,
n2.n_name as nation
from part, supplier, lineitem, orders, customer,
nation n1, nation n2, region
where p_partkey = l_partkey and s_suppkey = l_suppkey
and l_orderkey = o_orderkey and o_custkey = c_custkey
and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey
and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey
and o_orderdate between date '1995-01-01' and date '1996-12-31'
and p_type = 'STANDARD BRUSHED STEEL' ) as all_nations
group by o_year
order by o_year;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders ALL PRIMARY,i_o_orderdate,i_o_custkey NULL NULL NULL 1500 Using where; Using temporary; Using filesort
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_partkey 1 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
from (select extract(year from o_orderdate) as o_year,
l_extendedprice * (1-l_discount) as volume,
n2.n_name as nation
from part, supplier, lineitem, orders, customer,
nation n1, nation n2, region
where p_partkey = l_partkey and s_suppkey = l_suppkey
and l_orderkey = o_orderkey and o_custkey = c_custkey
and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey
and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey
and o_orderdate between date '1995-01-01' and date '1996-12-31'
and p_type = 'STANDARD BRUSHED STEEL' ) as all_nations
group by o_year
order by o_year;
o_year mkt_share
1995 0.4495521838895718
1996 0.024585468215352495
EXPLAIN select nation, o_year, sum(amount) as sum_profit
from (select n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from part, supplier, lineitem, partsupp, orders, nation
where s_suppkey = l_suppkey and ps_suppkey = l_suppkey
and ps_partkey = l_partkey and p_partkey = l_partkey
and o_orderkey = l_orderkey and s_nationkey = n_nationkey
and p_name like '%green%') as profit
group by nation, o_year
order by nation, o_year desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE supplier index PRIMARY,i_s_nationkey i_s_nationkey 5 NULL 10 Using where; Using index; Using temporary; Using filesort
1 SIMPLE nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
1 SIMPLE partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_suppkey 4 dbt3_s001.supplier.s_suppkey 70
1 SIMPLE part eq_ref PRIMARY PRIMARY 4 dbt3_s001.partsupp.ps_partkey 1 Using where
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.supplier.s_suppkey 8
1 SIMPLE orders eq_ref PRIMARY PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1
select nation, o_year, sum(amount) as sum_profit
from (select n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from part, supplier, lineitem, partsupp, orders, nation
where s_suppkey = l_suppkey and ps_suppkey = l_suppkey
and ps_partkey = l_partkey and p_partkey = l_partkey
and o_orderkey = l_orderkey and s_nationkey = n_nationkey
and p_name like '%green%') as profit
group by nation, o_year
order by nation, o_year desc;
nation o_year sum_profit
ARGENTINA 1997 18247.873399999993
ARGENTINA 1996 7731.089399999995
ARGENTINA 1995 134490.5697
ARGENTINA 1994 36767.101500000004
ARGENTINA 1993 35857.08
ARGENTINA 1992 35740
ETHIOPIA 1998 2758.7801999999992
ETHIOPIA 1997 19419.294599999997
ETHIOPIA 1995 51231.87439999999
ETHIOPIA 1994 3578.9478999999974
ETHIOPIA 1992 1525.8234999999986
IRAN 1998 37817.229600000006
IRAN 1997 52643.77359999999
IRAN 1996 70143.7761
IRAN 1995 84094.58260000001
IRAN 1994 18140.925599999995
IRAN 1993 78655.1676
IRAN 1992 87142.23960000002
IRAQ 1998 22860.8082
IRAQ 1997 93676.24359999999
IRAQ 1996 45103.3242
IRAQ 1994 36010.728599999995
IRAQ 1993 33221.9399
IRAQ 1992 47755.05900000001
KENYA 1998 44194.831999999995
KENYA 1997 57578.36259999999
KENYA 1996 59195.90210000001
KENYA 1995 79262.6278
KENYA 1994 102360.66609999999
KENYA 1993 128422.0196
KENYA 1992 181517.2089
MOROCCO 1998 41797.823199999984
MOROCCO 1997 23685.801799999994
MOROCCO 1996 62115.19579999998
MOROCCO 1995 42442.64300000001
MOROCCO 1994 48655.878000000004
MOROCCO 1993 22926.744400000003
MOROCCO 1992 32239.8088
PERU 1998 86999.36459999997
PERU 1997 121110.41070000001
PERU 1996 177040.40759999995
PERU 1995 122247.94520000002
PERU 1994 88046.25329999998
PERU 1993 49379.813799999996
PERU 1992 80646.86050000001
UNITED KINGDOM 1998 50577.25560000001
UNITED KINGDOM 1997 114288.8605
UNITED KINGDOM 1996 147684.46480000002
UNITED KINGDOM 1995 225267.65759999998
UNITED KINGDOM 1994 140595.5864
UNITED KINGDOM 1993 322548.49210000003
UNITED KINGDOM 1992 67747.88279999999
UNITED STATES 1998 3957.0431999999996
UNITED STATES 1997 94729.5704
UNITED STATES 1996 79297.85670000002
UNITED STATES 1995 62201.23360000001
UNITED STATES 1994 43075.629899999985
UNITED STATES 1993 27168.486199999996
UNITED STATES 1992 34092.366
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
EXPLAIN select o_orderkey, p_partkey
from part, lineitem, orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE part range PRIMARY,i_p_retailprice i_p_retailprice 9 NULL 1 Using where; Using index
1 SIMPLE orders ref PRIMARY,i_o_orderdate i_o_orderdate 4 const 1 Using index
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 9 dbt3_s001.part.p_partkey,dbt3_s001.orders.o_orderkey 1 Using index
select o_orderkey, p_partkey
from part, lineitem, orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
o_orderkey p_partkey
5895 200
set optimizer_switch=@save_optimizer_switch;
DROP DATABASE dbt3_s001;
use test;
#
# Bug mdev-473: ANALYZE table locked for write
#
set use_stat_tables='complementary';
create table t1 (i int);
lock table t1 write;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
alter table t1 add column a varchar(8);
drop table t1;
#
# Bug mdev-487: memory leak in ANALYZE with stat tables
#
SET use_stat_tables = 'preferably';
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
DELETE FROM t1 WHERE a=1;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP TABLE t1;
#
# Bug mdev-518: corrupted/missing statistical tables
#
CREATE TABLE t1 (i int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
FLUSH TABLE t1;
SET use_stat_tables='never';
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
FLUSH TABLES;
SET use_stat_tables='preferably';
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -0,0 +1,222 @@
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
select * from mysql.table_stats;
db_name table_name cardinality
dbt3_s001 customer 150
dbt3_s001 lineitem 6005
dbt3_s001 nation 25
dbt3_s001 orders 1500
dbt3_s001 part 200
dbt3_s001 partsupp 700
dbt3_s001 region 5
dbt3_s001 supplier 10
select * from mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111
flush table lineitem;
set use_stat_tables='never';
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
revenue
77949.91860000002
set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24 ;
set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
revenue
77949.91860000002
revenue
77949.91860000002
set use_stat_tables='preferably';
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
delete from mysql.index_stats
where table_name='lineitem' and
index_name in ('i_l_shipdate', 'i_l_receiptdate');
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
delete from mysql.index_stats
where table_name='lineitem' and index_name= 'i_l_shipdate';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_collection_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_receiptdate);
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
set debug_sync='RESET';
set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for all;
set debug_sync='now WAIT_FOR parked';
use dbt3_s001;
set use_stat_tables='never';
set debug_sync='now SIGNAL finish';
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
set @save_global_use_stat_tables=@@global.use_stat_tables;
set global use_stat_tables='preferably';
set debug_sync='RESET';
set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1';
set debug_sync='thr_multi_lock_after_thr_lock SIGNAL go2 EXECUTE 2';
use dbt3_s001;
analyze table lineitem persistent for all;
set debug_sync='open_and_process_table WAIT_FOR parker';
set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2';
use dbt3_s001;
select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68;
db_name table_name index_name prefix_arity avg_frequency l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
dbt3_s001 lineitem i_l_shipdate 1 2.6500 1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
set debug_sync='RESET';
set global use_stat_tables=@save_global_use_stat_tables;
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;

View file

@ -0,0 +1,233 @@
SET SESSION STORAGE_ENGINE='InnoDB';
set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
select * from mysql.table_stats;
db_name table_name cardinality
dbt3_s001 customer 150
dbt3_s001 lineitem 6005
dbt3_s001 nation 25
dbt3_s001 orders 1500
dbt3_s001 part 200
dbt3_s001 partsupp 700
dbt3_s001 region 5
dbt3_s001 supplier 10
select * from mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111
flush table lineitem;
set use_stat_tables='never';
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
revenue
77949.91860000002
set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24 ;
set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
revenue
77949.91860000002
revenue
77949.91860000002
set use_stat_tables='preferably';
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
delete from mysql.index_stats
where table_name='lineitem' and
index_name in ('i_l_shipdate', 'i_l_receiptdate');
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
delete from mysql.index_stats
where table_name='lineitem' and index_name= 'i_l_shipdate';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_collection_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_receiptdate);
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
set debug_sync='RESET';
set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for all;
set debug_sync='now WAIT_FOR parked';
use dbt3_s001;
set use_stat_tables='never';
select * from lineitem where l_orderkey=1 and l_partkey=156;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
1 156 4 1 17 17954.55 0.04 0.02 N O 1996-03-13 1996-02-12 1996-03-22 DELIVER IN PERSON TRUCK blithely regular ideas caj
delete from lineitem where l_orderkey=1 and l_partkey=156;
select * from lineitem where l_orderkey=1 and l_partkey=156;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
set debug_sync='now SIGNAL finish';
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 lineitem PRIMARY 1 4.0027
dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7155
dbt3_s001 lineitem i_l_orderkey 1 4.0027
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0027
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_partkey 1 30.0200
dbt3_s001 lineitem i_l_receiptdate 1 2.6473
dbt3_s001 lineitem i_l_shipdate 1 2.6496
dbt3_s001 lineitem i_l_suppkey 1 600.4000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0200
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5771
set @save_global_use_stat_tables=@@global.use_stat_tables;
set global use_stat_tables='preferably';
set debug_sync='RESET';
set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1';
set debug_sync='thr_multi_lock_after_thr_lock SIGNAL go2 EXECUTE 2';
use dbt3_s001;
analyze table lineitem persistent for all;
set debug_sync='open_and_process_table WAIT_FOR parker';
set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2';
use dbt3_s001;
select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68;
db_name table_name index_name prefix_arity avg_frequency l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
dbt3_s001 lineitem i_l_shipdate 1 2.6496 1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
set debug_sync='RESET';
set global use_stat_tables=@save_global_use_stat_tables;
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -0,0 +1,12 @@
#
# Bug mdev-3866: valgrind complain from ANALYZE on a table with BIT field
#
SET use_stat_tables = 'preferably';
CREATE TABLE t1 (pk int PRIMARY KEY, a bit(1), INDEX idx(a)
) ENGINE=MyISAM PARTITION BY KEY(pk) PARTITIONS 2;
INSERT INTO t1 VALUES (1,1),(2,0),(3,0),(4,1);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
SET use_stat_tables = DEFAULT;
DROP TABLE t1;

View file

@ -0,0 +1,26 @@
#
# Bug mdev-463: assertion failure when running ANALYZE with RBR on
#
SET GLOBAL use_stat_tables = PREFERABLY;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP TABLE t1;
SET GLOBAL use_stat_tables = DEFAULT;
SET use_stat_tables = PREFERABLY;
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
ALTER TABLE t1 ANALYZE PARTITION p1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 246 Server ver: #, Binlog ver: #
master-bin.000001 246 Binlog_checkpoint 1 286 master-bin.000001
master-bin.000001 286 Query 1 386 use `test`; CREATE TABLE t1 (i INT) ENGINE=InnoDB
master-bin.000001 386 Query 1 465 use `test`; ANALYZE TABLE t1
master-bin.000001 465 Query 1 569 use `test`; DROP TABLE `t1` /* generated by server */
master-bin.000001 569 Query 1 705 use `test`; CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2
master-bin.000001 705 Query 1 803 use `test`; ALTER TABLE t1 ANALYZE PARTITION p1
SET use_stat_tables = DEFAULT;
DROP TABLE t1;

View file

@ -0,0 +1,41 @@
include/master-slave.inc
[connection master]
#
# Bug mdev-485: unexpected failure with replication of DROP/ALTER table
# when RBR is on
#
CREATE TABLE t1 ( a int, b int ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP INDEX idx1 ON t1;
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
ALTER TABLE t1 DROP COLUMN b;
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
ALTER TABLE t1 RENAME to s;
DROP TABLE s;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
ALTER TABLE t1 CHANGE COLUMN b c int ;
DROP TABLE t1;
include/rpl_end.inc

File diff suppressed because it is too large Load diff

View file

@ -108,7 +108,7 @@ Handler_mrr_key_refills 0
Handler_mrr_rowid_refills 0
Handler_prepare 18
Handler_read_first 0
Handler_read_key 3
Handler_read_key 9
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
@ -124,7 +124,7 @@ Handler_update 5
Handler_write 7
select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key";
handler_read_key
3
9
set @@global.userstat=0;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ

View file

@ -2247,5 +2247,36 @@ MAX(a) bb
NULL NULL
drop table t1, t2;
set optimizer_switch=@subselect4_tmp;
#
# MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN subquery with SUM and DISTINCT
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(9);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (8);
SELECT * FROM t1
WHERE (1, 1) IN (SELECT a, SUM(DISTINCT a) FROM t1, t2 GROUP BY a);
a
1
9
drop table t1, t2;
#
# MDEV-3902 Assertion `record_length == m_record_length' failed at Filesort_buffer::alloc_sort_buffer
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (pk INT PRIMARY KEY, b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,1),(2,7);
CREATE TABLE t3 (c INT) ENGINE=MyISAM;
INSERT INTO t3 VALUES (8);
SELECT * FROM t1
WHERE (1, 5) IN (SELECT b, SUM(DISTINCT b) FROM t2, t3 GROUP BY b);
a
SELECT * FROM t2 AS alias1, t2 AS alias2
WHERE EXISTS ( SELECT 1 ) AND (alias2.pk = alias1.b )
ORDER BY alias1.b;
pk b pk b
1 1 1 1
drop table t1, t2, t3;
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;

View file

@ -399,10 +399,10 @@ WHERE Code = Country GROUP BY Code)
order by Country;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY CountryLanguage index NULL PRIMARY 33 NULL 984 Using where; Using index
3 MATERIALIZED CountryLanguage index PRIMARY PRIMARY 33 NULL 984 Using index; Using temporary
3 MATERIALIZED Country eq_ref PRIMARY PRIMARY 3 world.CountryLanguage.Country 1 Using index
2 MATERIALIZED CountryLanguage index PRIMARY PRIMARY 33 NULL 984 Using index; Using temporary
2 MATERIALIZED Country eq_ref PRIMARY PRIMARY 3 world.CountryLanguage.Country 1 Using index
3 MATERIALIZED Country index PRIMARY PRIMARY 3 NULL 239 Using index
3 MATERIALIZED CountryLanguage ref PRIMARY PRIMARY 3 world.Country.Code 4 Using index
2 MATERIALIZED Country index PRIMARY PRIMARY 3 NULL 239 Using index
2 MATERIALIZED CountryLanguage ref PRIMARY PRIMARY 3 world.Country.Code 4 Using index
select count(*)
from CountryLanguage
where

View file

@ -1,5 +1,6 @@
show tables;
Tables_in_db
column_stats
columns_priv
db
event
@ -10,6 +11,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -22,6 +24,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -269,5 +272,36 @@ slow_log CREATE TABLE `slow_log` (
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show create table table_stats;
Table Create Table
table_stats CREATE TABLE `table_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`column_name` varchar(64) COLLATE utf8_bin NOT NULL,
`min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nulls_ratio` decimal(12,4) DEFAULT NULL,
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`prefix_arity` int(11) unsigned NOT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
show tables;
Tables_in_test

View file

@ -1,5 +1,6 @@
show tables;
Tables_in_db
column_stats
columns_priv
db
event
@ -10,6 +11,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -22,6 +24,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -269,5 +272,36 @@ slow_log CREATE TABLE `slow_log` (
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show create table table_stats;
Table Create Table
table_stats CREATE TABLE `table_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`column_name` varchar(64) COLLATE utf8_bin NOT NULL,
`min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nulls_ratio` double DEFAULT NULL,
`avg_length` double DEFAULT NULL,
`avg_frequency` double DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`prefix_arity` int(11) unsigned NOT NULL,
`avg_frequency` double DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
show tables;
Tables_in_test

View file

@ -1,5 +1,6 @@
show tables;
Tables_in_db
column_stats
columns_priv
db
event
@ -10,6 +11,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -22,6 +24,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -269,5 +272,36 @@ slow_log CREATE TABLE `slow_log` (
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show create table table_stats;
Table Create Table
table_stats CREATE TABLE `table_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`column_name` varchar(64) COLLATE utf8_bin NOT NULL,
`min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nulls_ratio` double DEFAULT NULL,
`avg_length` double DEFAULT NULL,
`avg_frequency` double DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`prefix_arity` int(11) unsigned NOT NULL,
`avg_frequency` double DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
show tables;
Tables_in_test

View file

@ -1,5 +1,6 @@
show tables;
Tables_in_db
column_stats
columns_priv
db
event
@ -10,6 +11,7 @@ help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
ndb_binlog_index
@ -22,6 +24,7 @@ slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
@ -269,5 +272,36 @@ slow_log CREATE TABLE `slow_log` (
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show create table table_stats;
Table Create Table
table_stats CREATE TABLE `table_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`column_name` varchar(64) COLLATE utf8_bin NOT NULL,
`min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nulls_ratio` double DEFAULT NULL,
`avg_length` double DEFAULT NULL,
`avg_frequency` double DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
`db_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`prefix_arity` int(11) unsigned NOT NULL,
`avg_frequency` double DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
show tables;
Tables_in_test

View file

@ -11,6 +11,7 @@ Note 1265 Data truncated for column 'c1' at row 1
INSERT IGNORE INTO t1 (c1) VALUES(NOW());
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Warning 1062 Duplicate entry '2007-02-13' for key 'c1'
SELECT * FROM t1;
c1
2007-02-13
@ -20,6 +21,8 @@ CREATE TABLE t1(c1 YEAR NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(1999);
INSERT INTO t1 (c1) VALUES(2000);
INSERT IGNORE INTO t1 (c1) VALUES(1999);
Warnings:
Warning 1062 Duplicate entry '1999' for key 'c1'
SELECT * FROM t1;
c1
1999
@ -36,6 +39,7 @@ Note 1265 Data truncated for column 'c1' at row 1
INSERT IGNORE INTO t1 (c1) VALUES(NOW());
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Warning 1062 Duplicate entry '09:09:33' for key 'c1'
SELECT * FROM t1;
c1
09:09:33
@ -45,6 +49,8 @@ CREATE TABLE t1(c1 YEAR NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(1999);
INSERT INTO t1 (c1) VALUES(2000);
INSERT IGNORE INTO t1 (c1) VALUES(1999);
Warnings:
Warning 1062 Duplicate entry '1999' for key 'c1'
SELECT * FROM t1;
c1
1999
@ -55,6 +61,8 @@ SET TIMESTAMP=1171346973;
INSERT INTO t1 (c1) VALUES(NOW());
INSERT INTO t1 (c1) VALUES(ADDTIME(NOW(),'1 01:01:01'));
INSERT IGNORE INTO t1 (c1) VALUES(NOW());
Warnings:
Warning 1062 Duplicate entry '2007-02-13 09:09:33' for key 'c1'
SELECT * FROM t1;
c1
2007-02-13 09:09:33
@ -64,6 +72,8 @@ CREATE TABLE t1(c1 YEAR NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(1999);
INSERT INTO t1 (c1) VALUES(2000);
INSERT IGNORE INTO t1 (c1) VALUES(1999);
Warnings:
Warning 1062 Duplicate entry '1999' for key 'c1'
SELECT * FROM t1;
c1
1999
@ -74,6 +84,8 @@ SET TIMESTAMP=1171346973;
INSERT INTO t1 (c1) VALUES(NOW());
INSERT INTO t1 (c1) VALUES(ADDTIME(NOW(),'1 01:01:01'));
INSERT IGNORE INTO t1 (c1) VALUES(NOW());
Warnings:
Warning 1062 Duplicate entry '2007-02-13 09:09:33' for key 'c1'
SELECT * FROM t1;
c1
2007-02-13 09:09:33
@ -83,6 +95,8 @@ CREATE TABLE t1(c1 YEAR NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(1999);
INSERT INTO t1 (c1) VALUES(2000);
INSERT IGNORE INTO t1 (c1) VALUES(1999);
Warnings:
Warning 1062 Duplicate entry '1999' for key 'c1'
SELECT * FROM t1;
c1
1999

View file

@ -27,11 +27,13 @@ Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Note 1265 Data truncated for column 'c2' at row 1
Note 1265 Data truncated for column 'c3' at row 1
Warning 1062 Duplicate entry '2007-02-13-2007-02-13-2007-02-13' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),ADDTIME(NOW(),'1 01:01:01'));
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Note 1265 Data truncated for column 'c2' at row 1
Note 1265 Data truncated for column 'c3' at row 1
Warning 1062 Duplicate entry '2007-02-13-2007-02-13-2007-02-14' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
2007-02-13 2007-02-13 2007-02-13
@ -45,7 +47,11 @@ INSERT INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
INSERT INTO t1 (c1,c2,c3) VALUES(1999,2000,1999);
INSERT INTO t1 (c1,c2,c3) VALUES(2000,1999,1999);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,1999);
Warnings:
Warning 1062 Duplicate entry '1999-1999-1999' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
Warnings:
Warning 1062 Duplicate entry '1999-1999-2000' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
1999 1999 1999
@ -80,11 +86,13 @@ Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Note 1265 Data truncated for column 'c2' at row 1
Note 1265 Data truncated for column 'c3' at row 1
Warning 1062 Duplicate entry '09:09:33-09:09:33-09:09:33' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),ADDTIME(NOW(),'1 01:01:01'));
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Note 1265 Data truncated for column 'c2' at row 1
Note 1265 Data truncated for column 'c3' at row 1
Warning 1062 Duplicate entry '09:09:33-09:09:33-10:10:34' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
09:09:33 09:09:33 09:09:33
@ -98,7 +106,11 @@ INSERT INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
INSERT INTO t1 (c1,c2,c3) VALUES(1999,2000,1999);
INSERT INTO t1 (c1,c2,c3) VALUES(2000,1999,1999);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,1999);
Warnings:
Warning 1062 Duplicate entry '1999-1999-1999' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
Warnings:
Warning 1062 Duplicate entry '1999-1999-2000' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
1999 1999 1999
@ -113,7 +125,11 @@ INSERT INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),ADDTIME(NOW(),'1 01:01:01'));
INSERT INTO t1 (c1,c2,c3) VALUES(NOW(),ADDTIME(NOW(),'1 01:01:01'),NOW());
INSERT INTO t1 (c1,c2,c3) VALUES(ADDTIME(NOW(),'1 01:01:01'),NOW(),NOW());
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),NOW());
Warnings:
Warning 1062 Duplicate entry '2007-02-13 09:09:33-2007-02-13 09:09:33-2007-02-13 09:09:33' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),ADDTIME(NOW(),'1 01:01:01'));
Warnings:
Warning 1062 Duplicate entry '2007-02-13 09:09:33-2007-02-13 09:09:33-2007-02-14 10:10:34' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
2007-02-13 09:09:33 2007-02-13 09:09:33 2007-02-13 09:09:33
@ -127,7 +143,11 @@ INSERT INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
INSERT INTO t1 (c1,c2,c3) VALUES(1999,2000,1999);
INSERT INTO t1 (c1,c2,c3) VALUES(2000,1999,1999);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,1999);
Warnings:
Warning 1062 Duplicate entry '1999-1999-1999' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
Warnings:
Warning 1062 Duplicate entry '1999-1999-2000' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
1999 1999 1999
@ -142,7 +162,11 @@ INSERT INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),ADDTIME(NOW(),'1 01:01:01'));
INSERT INTO t1 (c1,c2,c3) VALUES(NOW(),ADDTIME(NOW(),'1 01:01:01'),NOW());
INSERT INTO t1 (c1,c2,c3) VALUES(ADDTIME(NOW(),'1 01:01:01'),NOW(),NOW());
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),NOW());
Warnings:
Warning 1062 Duplicate entry '2007-02-13 09:09:33-2007-02-13 09:09:33-2007-02-13 09:09:33' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(NOW(),NOW(),ADDTIME(NOW(),'1 01:01:01'));
Warnings:
Warning 1062 Duplicate entry '2007-02-13 09:09:33-2007-02-13 09:09:33-2007-02-14 10:10:34' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
2007-02-13 09:09:33 2007-02-13 09:09:33 2007-02-13 09:09:33
@ -156,7 +180,11 @@ INSERT INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
INSERT INTO t1 (c1,c2,c3) VALUES(1999,2000,1999);
INSERT INTO t1 (c1,c2,c3) VALUES(2000,1999,1999);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,1999);
Warnings:
Warning 1062 Duplicate entry '1999-1999-1999' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(1999,1999,2000);
Warnings:
Warning 1062 Duplicate entry '1999-1999-2000' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
1999 1999 1999

View file

@ -8,8 +8,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -29,8 +35,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -50,8 +62,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -71,8 +89,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -92,8 +116,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -113,8 +143,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -134,8 +170,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -155,8 +197,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -176,8 +224,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -197,8 +251,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -218,8 +278,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -239,8 +305,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -260,8 +332,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10
@ -281,8 +359,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES(11,11,10);
INSERT INTO t1 (c1,c2,c3) VALUES(11,10,11);
INSERT INTO t1 (c1,c2,c3) VALUES(10,11,11);
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,10);
Warnings:
Warning 1062 Duplicate entry '10-10-10' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,10,11);
Warnings:
Warning 1062 Duplicate entry '10-10-11' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES(10,11,11);
Warnings:
Warning 1062 Duplicate entry '10-11-11' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
10 10 10

View file

@ -8,8 +8,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES('def','def','abc');
INSERT INTO t1 (c1,c2,c3) VALUES('def','abc','def');
INSERT INTO t1 (c1,c2,c3) VALUES('abc','def','def');
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-abc' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','def');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-def' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','def','def');
Warnings:
Warning 1062 Duplicate entry 'abc-def-def' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
abc abc abc
@ -29,8 +35,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES('def','def','abc');
INSERT INTO t1 (c1,c2,c3) VALUES('def','abc','def');
INSERT INTO t1 (c1,c2,c3) VALUES('abc','def','def');
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-abc' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','def');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-def' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','def','def');
Warnings:
Warning 1062 Duplicate entry 'abc-def-def' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
abc abc abc
@ -50,8 +62,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES('def','def','abc');
INSERT INTO t1 (c1,c2,c3) VALUES('def','abc','def');
INSERT INTO t1 (c1,c2,c3) VALUES('abc','def','def');
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-abc' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','def');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-def' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','def','def');
Warnings:
Warning 1062 Duplicate entry 'abc-def-def' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
abc
@ -65,8 +83,14 @@ INSERT INTO t1 (c1,c2,c3) VALUES('def','def','abc');
INSERT INTO t1 (c1,c2,c3) VALUES('def','abc','def');
INSERT INTO t1 (c1,c2,c3) VALUES('abc','def','def');
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-abc' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','abc','def');
Warnings:
Warning 1062 Duplicate entry 'abc-abc-def' for key 'c1'
INSERT IGNORE INTO t1 (c1,c2,c3) VALUES('abc','def','def');
Warnings:
Warning 1062 Duplicate entry 'abc-def-def' for key 'c1'
SELECT * FROM t1;
c1 c2 c3
abc abc abc

View file

@ -3,6 +3,8 @@ CREATE TABLE t1(c1 TINYINT NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -12,6 +14,8 @@ CREATE TABLE t1(c1 SMALLINT NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -21,6 +25,8 @@ CREATE TABLE t1(c1 MEDIUMINT NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -30,6 +36,8 @@ CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -39,6 +47,8 @@ CREATE TABLE t1(c1 INTEGER NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -48,6 +58,8 @@ CREATE TABLE t1(c1 BIGINT NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -57,6 +69,8 @@ CREATE TABLE t1(c1 DECIMAL NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -66,6 +80,8 @@ CREATE TABLE t1(c1 DEC NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -75,6 +91,8 @@ CREATE TABLE t1(c1 FIXED NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -84,6 +102,8 @@ CREATE TABLE t1(c1 NUMERIC NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -93,6 +113,8 @@ CREATE TABLE t1(c1 DOUBLE NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -102,6 +124,8 @@ CREATE TABLE t1(c1 REAL NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -111,6 +135,8 @@ CREATE TABLE t1(c1 DOUBLE PRECISION NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10
@ -120,6 +146,8 @@ CREATE TABLE t1(c1 FLOAT NOT NULL PRIMARY KEY);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'PRIMARY'
SELECT * FROM t1;
c1
10

View file

@ -3,6 +3,8 @@ CREATE TABLE t1(c1 TINYINT NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -12,6 +14,8 @@ CREATE TABLE t1(c1 SMALLINT NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -21,6 +25,8 @@ CREATE TABLE t1(c1 MEDIUMINT NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -30,6 +36,8 @@ CREATE TABLE t1(c1 INT NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -39,6 +47,8 @@ CREATE TABLE t1(c1 INTEGER NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -48,6 +58,8 @@ CREATE TABLE t1(c1 BIGINT NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -57,6 +69,8 @@ CREATE TABLE t1(c1 DECIMAL NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -66,6 +80,8 @@ CREATE TABLE t1(c1 DEC NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -75,6 +91,8 @@ CREATE TABLE t1(c1 FIXED NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -84,6 +102,8 @@ CREATE TABLE t1(c1 NUMERIC NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -93,6 +113,8 @@ CREATE TABLE t1(c1 DOUBLE NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -102,6 +124,8 @@ CREATE TABLE t1(c1 REAL NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -111,6 +135,8 @@ CREATE TABLE t1(c1 DOUBLE PRECISION NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10
@ -120,6 +146,8 @@ CREATE TABLE t1(c1 FLOAT NULL UNIQUE);
INSERT INTO t1 (c1) VALUES(10);
INSERT INTO t1 (c1) VALUES(11);
INSERT IGNORE INTO t1 (c1) VALUES(10);
Warnings:
Warning 1062 Duplicate entry '10' for key 'c1'
SELECT * FROM t1;
c1
10

View file

@ -2,6 +2,8 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
TRUNCATE TABLE t1;
Warnings:
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
1 abc

View file

@ -1,6 +1,8 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_unique_error1.inc' INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Warnings:
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
1 abc
@ -10,6 +12,8 @@ c1 c2
DROP TABLE t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_unique_error1.inc' IGNORE INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Warnings:
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
1 abc

View file

@ -4,6 +4,9 @@ INSERT INTO t1 VALUES(3,'a');
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES(3,'a');
Warnings:
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
1 abc

View file

@ -2,6 +2,8 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
INSERT INTO t1 VALUES(3,'a');
LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_unique_error2.inc' INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Warnings:
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
1 abc
@ -12,6 +14,8 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
INSERT INTO t1 VALUES(3,'a');
LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_unique_error2.inc' IGNORE INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Warnings:
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
1 abc

View file

@ -12,6 +12,10 @@ Tables_in_test
t1
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
TRUNCATE TABLE t1;
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '0' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
0 def

View file

@ -1,6 +1,10 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_unique_error1.inc' INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (@c1,c2) SET c1 = @c1 % 2;
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '0' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
0 def
@ -8,6 +12,10 @@ c1 c2
DROP TABLE t1;
CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 TEXT);
LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_unique_error1.inc' IGNORE INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (@c1,c2) SET c1 = @c1 % 2;
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '0' for key 'PRIMARY'
SELECT * FROM t1 ORDER BY c1;
c1 c2
0 def

View file

@ -2399,8 +2399,9 @@ INSERT INTO t3 VALUES(0,-128,1,2,3,4,5),(255,127,6,7,8,9,10);
INSERT INTO t4 VALUES(-128,0,1,2,3,4,5,5),(127,255,6,7,8,9,10,10);
INSERT INTO t5 VALUES(0,-128,1,2,3,4,5,5),(255,127,6,7,8,9,10,10);
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
ERROR 22003: Out of range value for column 'c1' at row 1
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t4;
c1 c2 c3 c4 c5 c6 c7 c8
-101 102 103 104 105 106 107 108
@ -3760,20 +3761,12 @@ c1 c2 c3 c4 c5 c6 c7
0 124 27 28 29 30 31
SELECT * FROM t2 WHERE c1 = 256 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 256 ORDER BY c1,c6 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 256 ORDER BY c1,c6 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 256 ORDER BY c1,c6 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 <> 256 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
0 NULL 5 6 NULL 0 NULL
@ -5316,20 +5309,12 @@ c1 c2 c3 c4 c5 c6 c7
0 -128 26 27 28 29 30
SELECT * FROM t3 WHERE c2 = 128 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 128 ORDER BY c2,c7 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 128 ORDER BY c2,c7 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 128 ORDER BY c2,c7 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 <> 128 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
0 -128 1 2 3 4 5
@ -8006,8 +7991,9 @@ INSERT INTO t3 VALUES(0,-32768,1,2,3,4,5),(255,-128,6,7,8,9,10),(65535,32767,11,
INSERT INTO t4 VALUES(-32768,0,1,2,3,4,5,5),(-128,255,6,7,8,9,10,10),(32767,65535,11,12,13,14,15,15);
INSERT INTO t5 VALUES(0,-32768,1,2,3,4,5,5),(255,-128,6,7,8,9,10,10),(65535,32767,11,12,13,14,15,15);
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
ERROR 23000: Duplicate entry '32767' for key 'PRIMARY'
ERROR 22003: Out of range value for column 'c1' at row 1
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t4;
c1 c2 c3 c4 c5 c6 c7 c8
-101 102 103 104 105 106 107 108
@ -9410,20 +9396,12 @@ c1 c2 c3 c4 c5 c6 c7
0 124 27 28 29 30 31
SELECT * FROM t2 WHERE c1 = 65536 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 65536 ORDER BY c1,c6 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 65536 ORDER BY c1,c6 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 65536 ORDER BY c1,c6 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 <> 65536 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
0 NULL 5 6 NULL 0 NULL
@ -11018,20 +10996,12 @@ c1 c2 c3 c4 c5 c6 c7
0 -32768 26 27 28 29 30
SELECT * FROM t3 WHERE c2 = 32768 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 32768 ORDER BY c2,c7 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 32768 ORDER BY c2,c7 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 32768 ORDER BY c2,c7 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 <> 32768 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
0 -32768 1 2 3 4 5
@ -13718,8 +13688,9 @@ INSERT INTO t3 VALUES(0,-8388608,1,2,3,4,5),(255,-32768,6,7,8,9,10),(65535,-128,
INSERT INTO t4 VALUES(-8388608,0,1,2,3,4,5,5),(-32768,255,6,7,8,9,10,10),(-128,65535,11,12,13,14,15,15),(8388607,16777215,16,17,18,19,20,20);
INSERT INTO t5 VALUES(0,-8388608,1,2,3,4,5,5),(255,-32768,6,7,8,9,10,10),(65535,-128,11,12,13,14,15,15),(16777215,8388607,16,17,18,19,20,20);
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
ERROR 23000: Duplicate entry '8388607' for key 'PRIMARY'
ERROR 22003: Out of range value for column 'c1' at row 1
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t4;
c1 c2 c3 c4 c5 c6 c7 c8
-101 102 103 104 105 106 107 108
@ -15165,20 +15136,12 @@ c1 c2 c3 c4 c5 c6 c7
0 124 27 28 29 30 31
SELECT * FROM t2 WHERE c1 = 16777216 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 16777216 ORDER BY c1,c6 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 16777216 ORDER BY c1,c6 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 16777216 ORDER BY c1,c6 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 <> 16777216 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
0 NULL 5 6 NULL 0 NULL
@ -16825,20 +16788,12 @@ c1 c2 c3 c4 c5 c6 c7
0 -8388608 26 27 28 29 30
SELECT * FROM t3 WHERE c2 = 8388608 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 8388608 ORDER BY c2,c7 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 8388608 ORDER BY c2,c7 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 8388608 ORDER BY c2,c7 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 <> 8388608 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
0 -8388608 1 2 3 4 5
@ -19535,8 +19490,9 @@ INSERT INTO t3 VALUES(0,-2147483648,1,2,3,4,5),(255,-8388608,6,7,8,9,10),(65535,
INSERT INTO t4 VALUES(-2147483648,0,1,2,3,4,5,5),(-8388608,255,6,7,8,9,10,10),(-32768,65535,11,12,13,14,15,15),(-128,16777215,16,17,18,19,20,20),(2147483647,4294967295,21,22,23,24,25,25);
INSERT INTO t5 VALUES(0,-2147483648,1,2,3,4,5,5),(255,-8388608,6,7,8,9,10,10),(65535,-32768,11,12,13,14,15,15),(16777215,-128,16,17,18,19,20,20),(4294967295,2147483647,21,22,23,24,25,25);
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
ERROR 23000: Duplicate entry '2147483647' for key 'PRIMARY'
ERROR 22003: Out of range value for column 'c1' at row 1
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t4;
c1 c2 c3 c4 c5 c6 c7 c8
-101 102 103 104 105 106 107 108
@ -21025,20 +20981,12 @@ c1 c2 c3 c4 c5 c6 c7
0 124 27 28 29 30 31
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 <> 4294967296 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
0 NULL 5 6 NULL 0 NULL
@ -22737,20 +22685,12 @@ c1 c2 c3 c4 c5 c6 c7
0 -2147483648 26 27 28 29 30
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 <> 2147483648 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
0 -2147483648 1 2 3 4 5
@ -25457,8 +25397,9 @@ INSERT INTO t3 VALUES(0,-2147483648,1,2,3,4,5),(255,-8388608,6,7,8,9,10),(65535,
INSERT INTO t4 VALUES(-2147483648,0,1,2,3,4,5,5),(-8388608,255,6,7,8,9,10,10),(-32768,65535,11,12,13,14,15,15),(-128,16777215,16,17,18,19,20,20),(2147483647,4294967295,21,22,23,24,25,25);
INSERT INTO t5 VALUES(0,-2147483648,1,2,3,4,5,5),(255,-8388608,6,7,8,9,10,10),(65535,-32768,11,12,13,14,15,15),(16777215,-128,16,17,18,19,20,20),(4294967295,2147483647,21,22,23,24,25,25);
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
ERROR 23000: Duplicate entry '2147483647' for key 'PRIMARY'
ERROR 22003: Out of range value for column 'c1' at row 1
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
ERROR 22003: Out of range value for column 'c1' at row 1
SELECT * FROM t4;
c1 c2 c3 c4 c5 c6 c7 c8
-101 102 103 104 105 106 107 108
@ -26947,20 +26888,12 @@ c1 c2 c3 c4 c5 c6 c7
0 124 27 28 29 30 31
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 = 4294967296 ORDER BY c1,c6 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
SELECT * FROM t2 WHERE c1 <> 4294967296 ORDER BY c1,c6;
c1 c2 c3 c4 c5 c6 c7
0 NULL 5 6 NULL 0 NULL
@ -28659,20 +28592,12 @@ c1 c2 c3 c4 c5 c6 c7
0 -2147483648 26 27 28 29 30
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 2147483648 ORDER BY c2,c7 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 <> 2147483648 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
0 -2147483648 1 2 3 4 5
@ -31379,7 +31304,7 @@ INSERT INTO t3 VALUES(0,-9223372036854775808,1,2,3,4,5),(255,-2147483648,6,7,8,9
INSERT INTO t4 VALUES(-9223372036854775808,0,1,2,3,4,5,5),(-2147483648,255,6,7,8,9,10,10),(-8388608,65535,11,12,13,14,15,15),(-32768,16777215,16,17,18,19,20,20),(-128,4294967295,21,22,23,24,25,25),(9223372036854775807,18446744073709551615,26,27,28,29,30,30);
INSERT INTO t5 VALUES(0,-9223372036854775808,1,2,3,4,5,5),(255,-2147483648,6,7,8,9,10,10),(65535,-8388608,11,12,13,14,15,15),(16777215,-32768,16,17,18,19,20,20),(4294967295,-128,21,22,23,24,25,25),(18446744073709551615,9223372036854775807,26,27,28,29,30,30);
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
ERROR 22003: Out of range value for column 'c1' at row 1
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
ERROR HY000: Failed to read auto-increment value from storage engine
SELECT * FROM t4;
@ -34577,20 +34502,12 @@ c1 c2 c3 c4 c5 c6 c7
0 -9223372036854775808 31 32 33 34 35
SELECT * FROM t3 WHERE c2 = 9223372036854775808 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 9223372036854775808 ORDER BY c2,c7 LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 9223372036854775808 ORDER BY c2,c7 DESC;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 = 9223372036854775808 ORDER BY c2,c7 DESC LIMIT 2;
c1 c2 c3 c4 c5 c6 c7
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t3 WHERE c2 <> 9223372036854775808 ORDER BY c2,c7;
c1 c2 c3 c4 c5 c6 c7
0 -9223372036854775808 1 2 3 4 5

View file

@ -5072,8 +5072,12 @@ INSERT INTO t3(c1,c2) VALUES('34 9:23','34 9:23') /* throws error as row exists
ERROR 23000: Duplicate entry '825:23:00-825:23:00' for key 'idx'
INSERT IGNORE INTO t1(c1,c2) VALUES('10:22:33','10:22:34') /* doesn't throw error */;
INSERT IGNORE INTO t2(c1,c2) VALUES('12:34:56.78','12:34:56.78') /*doesn't throw error */;
Warnings:
Warning 1062 Duplicate entry '12:34:56-12:34:56' for key 'PRIMARY'
INSERT IGNORE INTO t1(c1,c2) VALUES('10:22:34','34 9:23') /*doesn't throw error */;
INSERT IGNORE INTO t3(c1,c2) VALUES('34 9:23','34 9:23') /*doesn't throw error */;
Warnings:
Warning 1062 Duplicate entry '825:23:00-825:23:00' for key 'idx'
SELECT * FROM t1 WHERE c1='10:23:33' /* no rows */;
c1 c2 c3
INSERT INTO t1(c1) VALUES('10:22:33') ON DUPLICATE KEY UPDATE c1='10:23:33';

View file

@ -3124,9 +3124,17 @@ ERROR 23000: Duplicate entry '2069' for key 'c2'
INSERT INTO t3(c1,c2) VALUES(00,00);
ERROR 23000: Duplicate entry '0000-0000' for key 'idx'
INSERT IGNORE INTO t1(c1,c2) VALUES(01,'99');
Warnings:
Warning 1062 Duplicate entry '2001' for key 'PRIMARY'
INSERT IGNORE INTO t2(c1,c2) VALUES('1999','1999');
Warnings:
Warning 1062 Duplicate entry '1999-1999' for key 'PRIMARY'
INSERT IGNORE INTO t1(c1,c2) VALUES('2098','69');
Warnings:
Warning 1062 Duplicate entry '2069' for key 'c2'
INSERT IGNORE INTO t3(c1,c2) VALUES(00,00);
Warnings:
Warning 1062 Duplicate entry '0000-0000' for key 'idx'
SELECT * FROM t1 WHERE c1='01' /* Returns 1 row */;
c1 c2 c3 c4
2001 2001 1998-12-28 1998-12-28 11:30:45
@ -6081,9 +6089,17 @@ ERROR 23000: Duplicate entry '69' for key 'c2'
INSERT INTO t3(c1,c2) VALUES(00,00);
ERROR 23000: Duplicate entry '00-00' for key 'idx'
INSERT IGNORE INTO t1(c1,c2) VALUES(01,'99');
Warnings:
Warning 1062 Duplicate entry '01' for key 'PRIMARY'
INSERT IGNORE INTO t2(c1,c2) VALUES('1999','1999');
Warnings:
Warning 1062 Duplicate entry '99-99' for key 'PRIMARY'
INSERT IGNORE INTO t1(c1,c2) VALUES('2098','69');
Warnings:
Warning 1062 Duplicate entry '69' for key 'c2'
INSERT IGNORE INTO t3(c1,c2) VALUES(00,00);
Warnings:
Warning 1062 Duplicate entry '00-00' for key 'idx'
SELECT * FROM t1 WHERE c1='01' /* Returns 1 row */;
c1 c2 c3 c4
01 01 1998-12-28 1998-12-28 11:30:45

File diff suppressed because it is too large Load diff

View file

@ -56,8 +56,6 @@ Warning 1264 Out of range value for column 'c2' at row 3
SELECT COUNT(*) FROM t1 WHERE c1=4294967296 AND c2=2147483648 /* no rows */;
COUNT(*)
0
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t1 WHERE c1=4294967295 AND c2=2147483647;
c1 c2 c3
4294967295 2147483647 10
@ -1152,8 +1150,6 @@ Warning 1264 Out of range value for column 'c2' at row 3
SELECT COUNT(*) FROM t1 WHERE c1=256 AND c2=128 /* no rows */;
COUNT(*)
0
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t1 WHERE c1=255 AND c2=127;
c1 c2 c3
255 127 10
@ -1926,8 +1922,6 @@ Warning 1264 Out of range value for column 'c2' at row 3
SELECT COUNT(*) FROM t1 WHERE c1=65536 AND c2=32768 /* no rows */;
COUNT(*)
0
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t1 WHERE c1=65535 AND c2=32767;
c1 c2 c3
65535 32767 10
@ -2675,8 +2669,6 @@ Warning 1264 Out of range value for column 'c2' at row 3
SELECT COUNT(*) FROM t1 WHERE c1=16777216 AND c2=8388608 /* no rows */;
COUNT(*)
0
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t1 WHERE c1=16777215 AND c2=8388607;
c1 c2 c3
16777215 8388607 10
@ -3424,8 +3416,6 @@ Warning 1264 Out of range value for column 'c2' at row 3
SELECT COUNT(*) FROM t1 WHERE c1=18446744073709551616 AND c2=9223372036854775808 /* no rows */;
COUNT(*)
0
Warnings:
Warning 1264 Out of range value for column 'c2' at row 1
SELECT * FROM t1 WHERE c1=18446744073709551615 AND c2=9223372036854775807;
c1 c2 c3
18446744073709551615 9223372036854775807 10

View file

@ -761,11 +761,10 @@ INSERT INTO t2 VALUES(0,-128,1,2,3,4,5),(255,127,6,7,8,9,10);
INSERT INTO t3 VALUES(0,-128,1,2,3,4,5),(255,127,6,7,8,9,10);
INSERT INTO t4 VALUES(-128,0,1,2,3,4,5,5),(127,255,6,7,8,9,10,10);
INSERT INTO t5 VALUES(0,-128,1,2,3,4,5,5),(255,127,6,7,8,9,10,10);
--error ER_DUP_ENTRY
--error 167
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
--disable_warnings
--error 167
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
--enable_warnings
--sorted_result
SELECT * FROM t4;
@ -2120,11 +2119,10 @@ INSERT INTO t2 VALUES(0,-32768,1,2,3,4,5),(255,-128,6,7,8,9,10),(65535,32767,11,
INSERT INTO t3 VALUES(0,-32768,1,2,3,4,5),(255,-128,6,7,8,9,10),(65535,32767,11,12,13,14,15);
INSERT INTO t4 VALUES(-32768,0,1,2,3,4,5,5),(-128,255,6,7,8,9,10,10),(32767,65535,11,12,13,14,15,15);
INSERT INTO t5 VALUES(0,-32768,1,2,3,4,5,5),(255,-128,6,7,8,9,10,10),(65535,32767,11,12,13,14,15,15);
--error ER_DUP_ENTRY
--error 167
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
--disable_warnings
--error 167
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
--enable_warnings
--sorted_result
SELECT * FROM t4;
@ -3479,11 +3477,10 @@ INSERT INTO t2 VALUES(0,-8388608,1,2,3,4,5),(255,-32768,6,7,8,9,10),(65535,-128,
INSERT INTO t3 VALUES(0,-8388608,1,2,3,4,5),(255,-32768,6,7,8,9,10),(65535,-128,11,12,13,14,15),(16777215,8388607,16,17,18,19,20);
INSERT INTO t4 VALUES(-8388608,0,1,2,3,4,5,5),(-32768,255,6,7,8,9,10,10),(-128,65535,11,12,13,14,15,15),(8388607,16777215,16,17,18,19,20,20);
INSERT INTO t5 VALUES(0,-8388608,1,2,3,4,5,5),(255,-32768,6,7,8,9,10,10),(65535,-128,11,12,13,14,15,15),(16777215,8388607,16,17,18,19,20,20);
--error ER_DUP_ENTRY
--error 167
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
--disable_warnings
--error 167
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
--enable_warnings
--sorted_result
SELECT * FROM t4;
@ -4838,11 +4835,10 @@ INSERT INTO t2 VALUES(0,-2147483648,1,2,3,4,5),(255,-8388608,6,7,8,9,10),(65535,
INSERT INTO t3 VALUES(0,-2147483648,1,2,3,4,5),(255,-8388608,6,7,8,9,10),(65535,-32768,11,12,13,14,15),(16777215,-128,16,17,18,19,20),(4294967295,2147483647,21,22,23,24,25);
INSERT INTO t4 VALUES(-2147483648,0,1,2,3,4,5,5),(-8388608,255,6,7,8,9,10,10),(-32768,65535,11,12,13,14,15,15),(-128,16777215,16,17,18,19,20,20),(2147483647,4294967295,21,22,23,24,25,25);
INSERT INTO t5 VALUES(0,-2147483648,1,2,3,4,5,5),(255,-8388608,6,7,8,9,10,10),(65535,-32768,11,12,13,14,15,15),(16777215,-128,16,17,18,19,20,20),(4294967295,2147483647,21,22,23,24,25,25);
--error ER_DUP_ENTRY
--error 167
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
--disable_warnings
--error 167
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
--enable_warnings
--sorted_result
SELECT * FROM t4;
@ -6197,11 +6193,10 @@ INSERT INTO t2 VALUES(0,-2147483648,1,2,3,4,5),(255,-8388608,6,7,8,9,10),(65535,
INSERT INTO t3 VALUES(0,-2147483648,1,2,3,4,5),(255,-8388608,6,7,8,9,10),(65535,-32768,11,12,13,14,15),(16777215,-128,16,17,18,19,20),(4294967295,2147483647,21,22,23,24,25);
INSERT INTO t4 VALUES(-2147483648,0,1,2,3,4,5,5),(-8388608,255,6,7,8,9,10,10),(-32768,65535,11,12,13,14,15,15),(-128,16777215,16,17,18,19,20,20),(2147483647,4294967295,21,22,23,24,25,25);
INSERT INTO t5 VALUES(0,-2147483648,1,2,3,4,5,5),(255,-8388608,6,7,8,9,10,10),(65535,-32768,11,12,13,14,15,15),(16777215,-128,16,17,18,19,20,20),(4294967295,2147483647,21,22,23,24,25,25);
--error ER_DUP_ENTRY
--error 167
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
--disable_warnings
--error 167
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;
--enable_warnings
--sorted_result
SELECT * FROM t4;
@ -7555,7 +7550,7 @@ INSERT INTO t2 VALUES(0,-9223372036854775808,1,2,3,4,5),(255,-2147483648,6,7,8,9
INSERT INTO t3 VALUES(0,-9223372036854775808,1,2,3,4,5),(255,-2147483648,6,7,8,9,10),(65535,-8388608,11,12,13,14,15),(16777215,-32768,16,17,18,19,20),(4294967295,-128,21,22,23,24,25),(18446744073709551615,9223372036854775807,26,27,28,29,30);
INSERT INTO t4 VALUES(-9223372036854775808,0,1,2,3,4,5,5),(-2147483648,255,6,7,8,9,10,10),(-8388608,65535,11,12,13,14,15,15),(-32768,16777215,16,17,18,19,20,20),(-128,4294967295,21,22,23,24,25,25),(9223372036854775807,18446744073709551615,26,27,28,29,30,30);
INSERT INTO t5 VALUES(0,-9223372036854775808,1,2,3,4,5,5),(255,-2147483648,6,7,8,9,10,10),(65535,-8388608,11,12,13,14,15,15),(16777215,-32768,16,17,18,19,20,20),(4294967295,-128,21,22,23,24,25,25),(18446744073709551615,9223372036854775807,26,27,28,29,30,30);
--error ER_DUP_ENTRY
--error 167
INSERT INTO t4(c2,c3) VALUES(31,32) /* tries to increment out of range */;
--error ER_AUTOINC_READ_FAILED
INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */;

View file

@ -9,6 +9,14 @@ def mysql columns_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(
def mysql columns_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
def mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
def mysql columns_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql column_stats max_value 5 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255) select,insert,update,references
def mysql column_stats min_value 4 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255) select,insert,update,references
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
def mysql column_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql db Alter_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
def mysql db Alter_routine_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
def mysql db Create_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
@ -97,6 +105,11 @@ def mysql host Select_priv 3 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci e
def mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
def mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
def mysql host Update_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
def mysql index_stats avg_frequency 5 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
def mysql index_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql index_stats index_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql index_stats prefix_arity 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned PRI select,insert,update,references
def mysql index_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
def mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned PRI select,insert,update,references
def mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL NULL latin1 latin1_swedish_ci varchar(255) select,insert,update,references
@ -213,6 +226,9 @@ def mysql tables_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin
def mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references
def mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
def mysql tables_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
def mysql table_stats cardinality 3 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select,insert,update,references
def mysql table_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql table_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references
def mysql time_zone Use_leap_seconds 2 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('Y','N') select,insert,update,references
def mysql time_zone_leap_second Correction 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
@ -302,6 +318,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
3.0000 char utf8 utf8_bin
3.0000 enum utf8 utf8_bin
3.0000 varchar utf8 utf8_bin
3.0000 char utf8 utf8_general_ci
3.0000 enum utf8 utf8_general_ci
3.0000 set utf8 utf8_general_ci
@ -318,6 +335,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
NULL bigint NULL NULL
NULL datetime NULL NULL
NULL decimal NULL NULL
NULL float NULL NULL
NULL int NULL NULL
NULL smallint NULL NULL
@ -347,6 +365,14 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
3.0000 mysql columns_priv Column_name char 64 192 utf8 utf8_bin char(64)
NULL mysql columns_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql columns_priv Column_priv set 31 93 utf8 utf8_general_ci set('Select','Insert','Update','References')
3.0000 mysql column_stats db_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql column_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql column_stats column_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql column_stats min_value varchar 255 765 utf8 utf8_bin varchar(255)
3.0000 mysql column_stats max_value varchar 255 765 utf8 utf8_bin varchar(255)
NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
3.0000 mysql db Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql db Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql db User char 16 48 utf8 utf8_bin char(16)
@ -435,6 +461,11 @@ NULL mysql help_topic help_category_id smallint NULL NULL NULL NULL smallint(5)
3.0000 mysql host Alter_routine_priv enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql host Execute_priv enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql host Trigger_priv enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql index_stats db_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql index_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql index_stats index_name varchar 64 192 utf8 utf8_bin varchar(64)
NULL mysql index_stats prefix_arity int NULL NULL NULL NULL int(11) unsigned
NULL mysql index_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql ndb_binlog_index Position bigint NULL NULL NULL NULL bigint(20) unsigned
1.0000 mysql ndb_binlog_index File varchar 255 255 latin1 latin1_swedish_ci varchar(255)
NULL mysql ndb_binlog_index epoch bigint NULL NULL NULL NULL bigint(20) unsigned
@ -551,6 +582,9 @@ NULL mysql slow_log server_id int NULL NULL NULL NULL int(10) unsigned
NULL mysql tables_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql tables_priv Table_priv set 98 294 utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger')
3.0000 mysql tables_priv Column_priv set 31 93 utf8 utf8_general_ci set('Select','Insert','Update','References')
3.0000 mysql table_stats db_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql table_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
NULL mysql table_stats cardinality bigint NULL NULL NULL NULL bigint(21) unsigned
NULL mysql time_zone Time_zone_id int NULL NULL NULL NULL int(10) unsigned
3.0000 mysql time_zone Use_leap_seconds enum 1 3 utf8 utf8_general_ci enum('Y','N')
NULL mysql time_zone_leap_second Transition_time bigint NULL NULL NULL NULL bigint(20)

View file

@ -9,6 +9,14 @@ def mysql columns_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(
def mysql columns_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
def mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
def mysql columns_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4)
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4)
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql column_stats max_value 5 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255)
def mysql column_stats min_value 4 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255)
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4)
def mysql column_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql db Alter_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
def mysql db Alter_routine_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
def mysql db Create_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
@ -97,6 +105,11 @@ def mysql host Select_priv 3 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci e
def mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
def mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
def mysql host Update_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
def mysql index_stats avg_frequency 5 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4)
def mysql index_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql index_stats index_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql index_stats prefix_arity 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned PRI
def mysql index_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
def mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned PRI
def mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL NULL latin1 latin1_swedish_ci varchar(255)
@ -213,6 +226,9 @@ def mysql tables_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin
def mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger')
def mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
def mysql tables_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
def mysql table_stats cardinality 3 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
def mysql table_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql table_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI
def mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI auto_increment
def mysql time_zone Use_leap_seconds 2 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('Y','N')
def mysql time_zone_leap_second Correction 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
@ -302,6 +318,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
3.0000 char utf8 utf8_bin
3.0000 enum utf8 utf8_bin
3.0000 varchar utf8 utf8_bin
3.0000 char utf8 utf8_general_ci
3.0000 enum utf8 utf8_general_ci
3.0000 set utf8 utf8_general_ci
@ -318,6 +335,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
NULL bigint NULL NULL
NULL datetime NULL NULL
NULL decimal NULL NULL
NULL float NULL NULL
NULL int NULL NULL
NULL smallint NULL NULL
@ -347,6 +365,14 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
3.0000 mysql columns_priv Column_name char 64 192 utf8 utf8_bin char(64)
NULL mysql columns_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql columns_priv Column_priv set 31 93 utf8 utf8_general_ci set('Select','Insert','Update','References')
3.0000 mysql column_stats db_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql column_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql column_stats column_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql column_stats min_value varchar 255 765 utf8 utf8_bin varchar(255)
3.0000 mysql column_stats max_value varchar 255 765 utf8 utf8_bin varchar(255)
NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
3.0000 mysql db Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql db Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql db User char 16 48 utf8 utf8_bin char(16)
@ -435,6 +461,11 @@ NULL mysql help_topic help_category_id smallint NULL NULL NULL NULL smallint(5)
3.0000 mysql host Alter_routine_priv enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql host Execute_priv enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql host Trigger_priv enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql index_stats db_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql index_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql index_stats index_name varchar 64 192 utf8 utf8_bin varchar(64)
NULL mysql index_stats prefix_arity int NULL NULL NULL NULL int(11) unsigned
NULL mysql index_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql ndb_binlog_index Position bigint NULL NULL NULL NULL bigint(20) unsigned
1.0000 mysql ndb_binlog_index File varchar 255 255 latin1 latin1_swedish_ci varchar(255)
NULL mysql ndb_binlog_index epoch bigint NULL NULL NULL NULL bigint(20) unsigned
@ -551,6 +582,9 @@ NULL mysql slow_log server_id int NULL NULL NULL NULL int(10) unsigned
NULL mysql tables_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql tables_priv Table_priv set 98 294 utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger')
3.0000 mysql tables_priv Column_priv set 31 93 utf8 utf8_general_ci set('Select','Insert','Update','References')
3.0000 mysql table_stats db_name varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 mysql table_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
NULL mysql table_stats cardinality bigint NULL NULL NULL NULL bigint(21) unsigned
NULL mysql time_zone Time_zone_id int NULL NULL NULL NULL int(10) unsigned
3.0000 mysql time_zone Use_leap_seconds enum 1 3 utf8 utf8_general_ci enum('Y','N')
NULL mysql time_zone_leap_second Transition_time bigint NULL NULL NULL NULL bigint(20)

View file

@ -75,6 +75,9 @@ table_schema, table_name, column_name
FROM information_schema.key_column_usage
WHERE constraint_catalog IS NOT NULL OR table_catalog IS NOT NULL;
constraint_catalog constraint_schema constraint_name table_catalog table_schema table_name column_name
def mysql PRIMARY def mysql column_stats db_name
def mysql PRIMARY def mysql column_stats table_name
def mysql PRIMARY def mysql column_stats column_name
def mysql PRIMARY def mysql columns_priv Host
def mysql PRIMARY def mysql columns_priv Db
def mysql PRIMARY def mysql columns_priv User
@ -96,6 +99,10 @@ def mysql PRIMARY def mysql help_topic help_topic_id
def mysql name def mysql help_topic name
def mysql PRIMARY def mysql host Host
def mysql PRIMARY def mysql host Db
def mysql PRIMARY def mysql index_stats db_name
def mysql PRIMARY def mysql index_stats table_name
def mysql PRIMARY def mysql index_stats index_name
def mysql PRIMARY def mysql index_stats prefix_arity
def mysql PRIMARY def mysql innodb_index_stats database_name
def mysql PRIMARY def mysql innodb_index_stats table_name
def mysql PRIMARY def mysql innodb_index_stats index_name
@ -123,6 +130,8 @@ def mysql PRIMARY def mysql slave_master_info Master_id
def mysql PRIMARY def mysql slave_relay_log_info Master_id
def mysql PRIMARY def mysql slave_worker_info Master_id
def mysql PRIMARY def mysql slave_worker_info Worker_id
def mysql PRIMARY def mysql table_stats db_name
def mysql PRIMARY def mysql table_stats table_name
def mysql PRIMARY def mysql tables_priv Host
def mysql PRIMARY def mysql tables_priv Db
def mysql PRIMARY def mysql tables_priv User

View file

@ -85,6 +85,9 @@ INDEX_COMMENT varchar(1024) NO
SELECT table_catalog, table_schema, table_name, index_schema, index_name
FROM information_schema.statistics WHERE table_catalog IS NOT NULL;
table_catalog table_schema table_name index_schema index_name
def mysql column_stats mysql PRIMARY
def mysql column_stats mysql PRIMARY
def mysql column_stats mysql PRIMARY
def mysql columns_priv mysql PRIMARY
def mysql columns_priv mysql PRIMARY
def mysql columns_priv mysql PRIMARY
@ -107,6 +110,10 @@ def mysql help_topic mysql PRIMARY
def mysql help_topic mysql name
def mysql host mysql PRIMARY
def mysql host mysql PRIMARY
def mysql index_stats mysql PRIMARY
def mysql index_stats mysql PRIMARY
def mysql index_stats mysql PRIMARY
def mysql index_stats mysql PRIMARY
def mysql ndb_binlog_index mysql PRIMARY
def mysql plugin mysql PRIMARY
def mysql proc mysql PRIMARY
@ -128,6 +135,8 @@ def mysql slave_master_info mysql PRIMARY
def mysql slave_relay_log_info mysql PRIMARY
def mysql slave_worker_info mysql PRIMARY
def mysql slave_worker_info mysql PRIMARY
def mysql table_stats mysql PRIMARY
def mysql table_stats mysql PRIMARY
def mysql tables_priv mysql PRIMARY
def mysql tables_priv mysql PRIMARY
def mysql tables_priv mysql PRIMARY

View file

@ -12,6 +12,9 @@ def mysql columns_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 5 Column_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 3 column_name A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
@ -29,6 +32,10 @@ def mysql help_topic 0 mysql name 1 name A #CARD# NULL NULL BTREE
def mysql help_topic 0 mysql PRIMARY 1 help_topic_id A #CARD# NULL NULL BTREE
def mysql host 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql host 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 4 prefix_arity A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE
@ -61,6 +68,8 @@ def mysql tables_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE
def mysql table_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql table_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql time_zone 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE
def mysql time_zone_leap_second 0 mysql PRIMARY 1 Transition_time A #CARD# NULL NULL BTREE
def mysql time_zone_name 0 mysql PRIMARY 1 Name A #CARD# NULL NULL BTREE

View file

@ -12,6 +12,9 @@ def mysql columns_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 5 Column_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 3 column_name A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
@ -29,6 +32,10 @@ def mysql help_topic 0 mysql name 1 name A #CARD# NULL NULL BTREE
def mysql help_topic 0 mysql PRIMARY 1 help_topic_id A #CARD# NULL NULL BTREE
def mysql host 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql host 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 4 prefix_arity A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE
@ -61,6 +68,8 @@ def mysql tables_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE
def mysql table_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql table_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql time_zone 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE
def mysql time_zone_leap_second 0 mysql PRIMARY 1 Transition_time A #CARD# NULL NULL BTREE
def mysql time_zone_name 0 mysql PRIMARY 1 Name A #CARD# NULL NULL BTREE
@ -80,6 +89,9 @@ def mysql columns_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE
def mysql columns_priv 0 mysql PRIMARY 5 Column_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql column_stats 0 mysql PRIMARY 3 column_name A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql db 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
@ -97,6 +109,10 @@ def mysql help_topic 0 mysql name 1 name A #CARD# NULL NULL BTREE
def mysql help_topic 0 mysql PRIMARY 1 help_topic_id A #CARD# NULL NULL BTREE
def mysql host 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql host 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE
def mysql index_stats 0 mysql PRIMARY 4 prefix_arity A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql innodb_index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE
@ -129,6 +145,8 @@ def mysql tables_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE
def mysql table_stats 0 mysql PRIMARY 1 db_name A #CARD# NULL NULL BTREE
def mysql table_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE
def mysql time_zone 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE
def mysql time_zone_leap_second 0 mysql PRIMARY 1 Transition_time A #CARD# NULL NULL BTREE
def mysql time_zone_name 0 mysql PRIMARY 1 Name A #CARD# NULL NULL BTREE

View file

@ -57,6 +57,7 @@ table_schema, table_name
FROM information_schema.table_constraints
WHERE constraint_catalog IS NOT NULL;
constraint_catalog constraint_schema constraint_name table_schema table_name
def mysql PRIMARY mysql column_stats
def mysql PRIMARY mysql columns_priv
def mysql PRIMARY mysql db
def mysql PRIMARY mysql event
@ -69,6 +70,7 @@ def mysql PRIMARY mysql help_relation
def mysql PRIMARY mysql help_topic
def mysql name mysql help_topic
def mysql PRIMARY mysql host
def mysql PRIMARY mysql index_stats
def mysql PRIMARY mysql innodb_index_stats
def mysql innodb_index_stats_ibfk_1 mysql innodb_index_stats
def mysql PRIMARY mysql innodb_table_stats
@ -81,6 +83,7 @@ def mysql PRIMARY mysql servers
def mysql PRIMARY mysql slave_master_info
def mysql PRIMARY mysql slave_relay_log_info
def mysql PRIMARY mysql slave_worker_info
def mysql PRIMARY mysql table_stats
def mysql PRIMARY mysql tables_priv
def mysql PRIMARY mysql time_zone
def mysql PRIMARY mysql time_zone_leap_second

View file

@ -8,6 +8,7 @@ WHERE table_schema = 'mysql'
ORDER BY table_schema,table_name,constraint_name;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
def mysql PRIMARY mysql columns_priv PRIMARY KEY
def mysql PRIMARY mysql column_stats PRIMARY KEY
def mysql PRIMARY mysql db PRIMARY KEY
def mysql PRIMARY mysql event PRIMARY KEY
def mysql PRIMARY mysql func PRIMARY KEY
@ -19,6 +20,7 @@ def mysql PRIMARY mysql help_relation PRIMARY KEY
def mysql name mysql help_topic UNIQUE
def mysql PRIMARY mysql help_topic PRIMARY KEY
def mysql PRIMARY mysql host PRIMARY KEY
def mysql PRIMARY mysql index_stats PRIMARY KEY
def mysql innodb_index_stats_ibfk_1 mysql innodb_index_stats FOREIGN KEY
def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY
def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY
@ -32,6 +34,7 @@ def mysql PRIMARY mysql slave_master_info PRIMARY KEY
def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY
def mysql PRIMARY mysql slave_worker_info PRIMARY KEY
def mysql PRIMARY mysql tables_priv PRIMARY KEY
def mysql PRIMARY mysql table_stats PRIMARY KEY
def mysql PRIMARY mysql time_zone PRIMARY KEY
def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY
def mysql PRIMARY mysql time_zone_name PRIMARY KEY

View file

@ -8,6 +8,7 @@ WHERE table_schema = 'mysql'
ORDER BY table_schema,table_name,constraint_name;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
def mysql PRIMARY mysql columns_priv PRIMARY KEY
def mysql PRIMARY mysql column_stats PRIMARY KEY
def mysql PRIMARY mysql db PRIMARY KEY
def mysql PRIMARY mysql event PRIMARY KEY
def mysql PRIMARY mysql func PRIMARY KEY
@ -19,6 +20,7 @@ def mysql PRIMARY mysql help_relation PRIMARY KEY
def mysql name mysql help_topic UNIQUE
def mysql PRIMARY mysql help_topic PRIMARY KEY
def mysql PRIMARY mysql host PRIMARY KEY
def mysql PRIMARY mysql index_stats PRIMARY KEY
def mysql innodb_index_stats_ibfk_1 mysql innodb_index_stats FOREIGN KEY
def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY
def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY
@ -32,6 +34,7 @@ def mysql PRIMARY mysql slave_master_info PRIMARY KEY
def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY
def mysql PRIMARY mysql slave_worker_info PRIMARY KEY
def mysql PRIMARY mysql tables_priv PRIMARY KEY
def mysql PRIMARY mysql table_stats PRIMARY KEY
def mysql PRIMARY mysql time_zone PRIMARY KEY
def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY
def mysql PRIMARY mysql time_zone_name PRIMARY KEY
@ -44,6 +47,7 @@ WHERE table_schema = 'mysql'
ORDER BY table_schema,table_name,constraint_name;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
def mysql PRIMARY mysql columns_priv PRIMARY KEY
def mysql PRIMARY mysql column_stats PRIMARY KEY
def mysql PRIMARY mysql db PRIMARY KEY
def mysql PRIMARY mysql event PRIMARY KEY
def mysql PRIMARY mysql func PRIMARY KEY
@ -55,6 +59,7 @@ def mysql PRIMARY mysql help_relation PRIMARY KEY
def mysql name mysql help_topic UNIQUE
def mysql PRIMARY mysql help_topic PRIMARY KEY
def mysql PRIMARY mysql host PRIMARY KEY
def mysql PRIMARY mysql index_stats PRIMARY KEY
def mysql innodb_index_stats_ibfk_1 mysql innodb_index_stats FOREIGN KEY
def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY
def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY
@ -68,6 +73,7 @@ def mysql PRIMARY mysql slave_master_info PRIMARY KEY
def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY
def mysql PRIMARY mysql slave_worker_info PRIMARY KEY
def mysql PRIMARY mysql tables_priv PRIMARY KEY
def mysql PRIMARY mysql table_stats PRIMARY KEY
def mysql PRIMARY mysql time_zone PRIMARY KEY
def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY
def mysql PRIMARY mysql time_zone_name PRIMARY KEY

View file

@ -37,6 +37,29 @@ user_comment Column privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME column_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Columns
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME db
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
@ -244,6 +267,29 @@ user_comment Host privileges; Merged with database privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME index_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Indexes
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME innodb_index_stats
TABLE_TYPE BASE TABLE
ENGINE InnoDB
@ -543,6 +589,29 @@ user_comment Table privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME table_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Tables
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME time_zone
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA

View file

@ -37,6 +37,29 @@ user_comment Column privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME column_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Columns
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME db
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
@ -244,6 +267,29 @@ user_comment Host privileges; Merged with database privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME index_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Indexes
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME innodb_index_stats
TABLE_TYPE BASE TABLE
ENGINE InnoDB
@ -543,6 +589,29 @@ user_comment Table privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME table_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Tables
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME time_zone
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
@ -720,6 +789,29 @@ user_comment Column privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME column_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Columns
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME db
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
@ -927,6 +1019,29 @@ user_comment Host privileges; Merged with database privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME index_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Indexes
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME innodb_index_stats
TABLE_TYPE BASE TABLE
ENGINE InnoDB
@ -1226,6 +1341,29 @@ user_comment Table privileges
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME table_stats
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_bin
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment Statistics on Tables
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA mysql
TABLE_NAME time_zone
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA

View file

@ -17,6 +17,7 @@ substring(object_name, locate("no_index_tab", object_name)) as short_name
from performance_schema.events_waits_history_long
where operation not like "tell"
and event_name like "wait/io/file/myisam/%"
having short_name <> ""
order by thread_id, event_id;
event_name short_source operation number_of_bytes short_name
wait/io/file/myisam/kfile mi_create.c: create NULL no_index_tab.MYI

View file

@ -57,7 +57,7 @@ ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1128: Table 'users' already exists
ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
ERROR 1050 (42S01) at line 1172: Table 'events_statements_summary_by_digest' already exists
ERROR 1644 (HY000) at line 1591: Unexpected content found in the performance_schema database.
ERROR 1644 (HY000) at line 1594: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
show tables like "user_table";
Tables_in_performance_schema (user_table)
@ -119,7 +119,7 @@ ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1128: Table 'users' already exists
ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
ERROR 1050 (42S01) at line 1172: Table 'events_statements_summary_by_digest' already exists
ERROR 1644 (HY000) at line 1591: Unexpected content found in the performance_schema database.
ERROR 1644 (HY000) at line 1594: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
show tables like "user_view";
Tables_in_performance_schema (user_view)
@ -179,7 +179,7 @@ ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1128: Table 'users' already exists
ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
ERROR 1050 (42S01) at line 1172: Table 'events_statements_summary_by_digest' already exists
ERROR 1644 (HY000) at line 1591: Unexpected content found in the performance_schema database.
ERROR 1644 (HY000) at line 1594: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
select name from mysql.proc where db='performance_schema';
name
@ -239,7 +239,7 @@ ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1128: Table 'users' already exists
ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
ERROR 1050 (42S01) at line 1172: Table 'events_statements_summary_by_digest' already exists
ERROR 1644 (HY000) at line 1591: Unexpected content found in the performance_schema database.
ERROR 1644 (HY000) at line 1594: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
select name from mysql.proc where db='performance_schema';
name
@ -299,7 +299,7 @@ ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1128: Table 'users' already exists
ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
ERROR 1050 (42S01) at line 1172: Table 'events_statements_summary_by_digest' already exists
ERROR 1644 (HY000) at line 1591: Unexpected content found in the performance_schema database.
ERROR 1644 (HY000) at line 1594: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
select name from mysql.event where db='performance_schema';
name

View file

@ -46,6 +46,7 @@ select event_name,
from performance_schema.events_waits_history_long
where operation not like "tell"
and event_name like "wait/io/file/myisam/%"
having short_name <> ""
order by thread_id, event_id;
# In case of failures, this will tell if file io are lost.

View file

@ -44,12 +44,10 @@ SET auto_increment_increment = 500;
SET auto_increment_offset = 300;
CREATE TABLE t1 (a TINYINT <CUSTOM_COL_OPTIONS> AUTO_INCREMENT, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
INSERT INTO t1 (a) VALUES (NULL);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
ERROR 22003: Out of range value for column 'a' at row 1
SELECT LAST_INSERT_ID();
LAST_INSERT_ID()
127
850
SELECT * FROM t1;
a
127
DROP TABLE t1;

View file

@ -739,6 +739,8 @@ y YEAR <CUSTOM_COL_OPTIONS> NOT NULL,
y4 YEAR(4) <CUSTOM_COL_OPTIONS> NOT NULL,
y2 YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d date # # #
@ -913,6 +915,8 @@ COUNT(c) COUNT(c2)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(2) NO NULL
@ -922,6 +926,9 @@ DROP TABLE t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL,
c2 YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(2) NO NULL

View file

@ -723,6 +723,8 @@ y YEAR <CUSTOM_COL_OPTIONS> NULL,
y4 YEAR(4) <CUSTOM_COL_OPTIONS> NULL,
y2 YEAR(2) <CUSTOM_COL_OPTIONS> NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d date # # #
@ -884,6 +886,8 @@ COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(2) YES NULL
@ -896,6 +900,10 @@ CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NULL,
c1 YEAR(2) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 YEAR(2) <CUSTOM_COL_OPTIONS> NULL DEFAULT '12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(2) YES NULL

View file

@ -47,6 +47,8 @@ a b
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
Warnings:
Warning 1062 Duplicate entry '1' for key 'a'
INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
SELECT * FROM t1;
a b
@ -85,6 +87,8 @@ a b
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
Warnings:
Warning 1062 Duplicate entry '1-a' for key 'a'
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
SELECT * FROM t1;
a b
@ -131,6 +135,8 @@ a b
5 e
6 f
INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
SELECT * FROM t1;
a b

View file

@ -7,6 +7,8 @@ y YEAR <CUSTOM_COL_OPTIONS>,
y4 YEAR(4) <CUSTOM_COL_OPTIONS>,
y2 YEAR(2) <CUSTOM_COL_OPTIONS>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d date # # #

View file

@ -0,0 +1,95 @@
SET @start_global_value = @@global.use_stat_tables;
SELECT @start_global_value;
@start_global_value
NEVER
SET @start_session_value = @@session.use_stat_tables;
SELECT @start_session_value;
@start_session_value
NEVER
SET @@global.use_stat_tables = 2;
SET @@global.use_stat_tables = DEFAULT;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
NEVER
SET @@global.use_stat_tables = 0;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
NEVER
SET @@global.use_stat_tables = 1;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
COMPLEMENTARY
SET @@global.use_stat_tables = 2;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
PREFERABLY
SET @@global.use_stat_tables = NEVER;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
NEVER
SET @@global.use_stat_tables = COMPLEMENTARY;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
COMPLEMENTARY
SET @@global.use_stat_tables = PREFERABLY;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
PREFERABLY
SET @@session.use_stat_tables = 0;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
NEVER
SET @@session.use_stat_tables = 1;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
COMPLEMENTARY
SET @@session.use_stat_tables = 2;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
PREFERABLY
SET @@session.use_stat_tables = NEVER;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
NEVER
SET @@session.use_stat_tables = PREFERABLY;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
PREFERABLY
SET @@session.use_stat_tables = COMPLEMENTARY;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
COMPLEMENTARY
set sql_mode=TRADITIONAL;
SET @@global.use_stat_tables = 10;
ERROR 42000: Variable 'use_stat_tables' can't be set to the value of '10'
SET @@global.use_stat_tables = -1024;
ERROR 42000: Variable 'use_stat_tables' can't be set to the value of '-1024'
SET @@global.use_stat_tables = 2.4;
ERROR 42000: Incorrect argument type to variable 'use_stat_tables'
SET @@global.use_stat_tables = OFF;
ERROR 42000: Variable 'use_stat_tables' can't be set to the value of 'OFF'
SET @@session.use_stat_tables = 10;
ERROR 42000: Variable 'use_stat_tables' can't be set to the value of '10'
SET @@session.use_stat_tables = -2;
ERROR 42000: Variable 'use_stat_tables' can't be set to the value of '-2'
SET @@session.use_stat_tables = 1.2;
ERROR 42000: Incorrect argument type to variable 'use_stat_tables'
SET @@session.use_stat_tables = ON;
ERROR 42000: Variable 'use_stat_tables' can't be set to the value of 'ON'
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='use_stat_tables';
VARIABLE_NAME VARIABLE_VALUE
USE_STAT_TABLES PREFERABLY
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE VARIABLE_NAME='use_stat_tables';
VARIABLE_NAME VARIABLE_VALUE
USE_STAT_TABLES COMPLEMENTARY
SET @@global.use_stat_tables = @start_global_value;
SELECT @@global.use_stat_tables;
@@global.use_stat_tables
NEVER
SET @@session.use_stat_tables = @start_session_value;
SELECT @@session.use_stat_tables;
@@session.use_stat_tables
NEVER
set sql_mode='';

View file

@ -0,0 +1,100 @@
--source include/load_sysvars.inc
#############################################################
# Save initial value #
#############################################################
SET @start_global_value = @@global.use_stat_tables;
SELECT @start_global_value;
SET @start_session_value = @@session.use_stat_tables;
SELECT @start_session_value;
###############################################################
# Display the DEFAULT value of use_stat_tables #
###############################################################
SET @@global.use_stat_tables = 2;
SET @@global.use_stat_tables = DEFAULT;
SELECT @@global.use_stat_tables;
##################################################################################
# Change the value of use_stat_tables to a valid value for GLOBAL Scope #
##################################################################################
SET @@global.use_stat_tables = 0;
SELECT @@global.use_stat_tables;
SET @@global.use_stat_tables = 1;
SELECT @@global.use_stat_tables;
SET @@global.use_stat_tables = 2;
SELECT @@global.use_stat_tables;
SET @@global.use_stat_tables = NEVER;
SELECT @@global.use_stat_tables;
SET @@global.use_stat_tables = COMPLEMENTARY;
SELECT @@global.use_stat_tables;
SET @@global.use_stat_tables = PREFERABLY;
SELECT @@global.use_stat_tables;
####################################################################################
# Change the value of use_stat_tables to a valid value for SESSION Scope #
####################################################################################
SET @@session.use_stat_tables = 0;
SELECT @@session.use_stat_tables;
SET @@session.use_stat_tables = 1;
SELECT @@session.use_stat_tables;
SET @@session.use_stat_tables = 2;
SELECT @@session.use_stat_tables;
SET @@session.use_stat_tables = NEVER;
SELECT @@session.use_stat_tables;
SET @@session.use_stat_tables = PREFERABLY;
SELECT @@session.use_stat_tables;
SET @@session.use_stat_tables = COMPLEMENTARY;
SELECT @@session.use_stat_tables;
#####################################################################
# Change the value of use_stat_tables to an invalid value #
#####################################################################
set sql_mode=TRADITIONAL;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.use_stat_tables = 10;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.use_stat_tables = -1024;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.use_stat_tables = 2.4;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.use_stat_tables = OFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.use_stat_tables = 10;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.use_stat_tables = -2;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.use_stat_tables = 1.2;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.use_stat_tables = ON;
###############################################################################
# Check if the value in GLOBAL & SESSION Tables matches value in variable #
###############################################################################
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='use_stat_tables';
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE VARIABLE_NAME='use_stat_tables';
####################################
# Restore initial value #
####################################
SET @@global.use_stat_tables = @start_global_value;
SELECT @@global.use_stat_tables;
SET @@session.use_stat_tables = @start_session_value;
SELECT @@session.use_stat_tables;
set sql_mode='';
######################################################
# END OF use_stat_tables TESTS #
######################################################

View file

@ -0,0 +1,7 @@
--echo #
set @@storage_engine= Aria;
--source include/alter_table_mdev539.inc
set @@storage_engine= default;

View file

@ -0,0 +1,7 @@
--echo #
set @@storage_engine= MyISAM;
--source include/alter_table_mdev539.inc
set @@storage_engine= default;

View file

@ -1996,4 +1996,28 @@ create table if not exists t1 (a int unique, b int)
ignore select 1 as a, 1 as b union select 1 as a, 2 as b;
select * from t1;
drop table t1;
--echo #
--echo # Checking that CREATE IF NOT EXISTS is not blocked by running SELECT
--echo #
create table t1 (a int, b int) engine=myisam;
create table t2 (a int, b int) engine=myisam;
insert into t1 values (1,1);
lock tables t1 read;
connect (user1,localhost,root,,test);
set @@lock_wait_timeout=5;
create table if not exists t1 (a int, b int);
create table if not exists t1 (a int, b int) select 2,2;
create table if not exists t1 like t2;
--error ER_TABLE_EXISTS_ERROR
create table t1 (a int, b int);
--error ER_TABLE_EXISTS_ERROR
create table t1 (a int, b int) select 2,2;
--error ER_TABLE_EXISTS_ERROR
create table t1 like t2;
disconnect user1;
connection default;
select * from t1;
unlock tables;
drop table t1,t2;

View file

@ -1789,6 +1789,24 @@ disconnect con12828477_1;
disconnect con12828477_2;
disconnect con12828477_3;
--echo #
--echo # MDEV-3818: Query against view over IS tables worse than equivalent query without view
--echo #
create view v1 as select table_schema, table_name, column_name from information_schema.columns;
explain extended
select column_name from v1
where (table_schema = "osm") and (table_name = "test");
explain extended
select information_schema.columns.column_name as column_name
from information_schema.columns
where (information_schema.columns.table_schema = 'osm') and (information_schema.columns.table_name = 'test');
drop view v1;
--echo #
--echo # Clean-up.
drop database mysqltest;

View file

@ -0,0 +1,77 @@
--disable_ps_protocol
CREATE TABLE A (
pk INTEGER AUTO_INCREMENT PRIMARY KEY,
fdate DATE
) ENGINE=MyISAM;
--delimiter |
CREATE PROCEDURE p_analyze()
BEGIN
DECLARE attempts INTEGER DEFAULT 100;
wl_loop: WHILE attempts > 0 DO
ANALYZE TABLE A;
SET attempts = attempts - 1;
END WHILE wl_loop;
END |
CREATE FUNCTION rnd3() RETURNS INT
BEGIN
RETURN ROUND(3 * RAND() + 0.5);
END |
--delimiter ;
SET GLOBAL use_stat_tables = PREFERABLY;
--let $trial = 100
--disable_query_log
--disable_result_log
--disable_warnings
while ($trial)
{
--connect (con1,localhost,root,,)
--send CALL p_analyze()
--connect (con2,localhost,root,,)
--send CALL p_analyze()
--let $run = 100
while ($run)
{
--connect (con3,localhost,root,,)
let $query = `SELECT CASE rnd3()
WHEN 1 THEN 'INSERT INTO A (pk) VALUES (NULL)'
WHEN 2 THEN 'DELETE FROM A LIMIT 1'
ELSE 'UPDATE A SET fdate = 2 LIMIT 1' END`;
--eval $query
--disconnect con3
--dec $run
}
--connection con2
--reap
--disconnect con2
--connection con1
--reap
--disconnect con1
--dec $trial
}
--enable_query_log
--enable_result_log
--enable_warnings
# Cleanup
--connection default
DROP TABLE A;
DROP PROCEDURE p_analyze;
DROP FUNCTION rnd3;
SET GLOBAL use_stat_tables = DEFAULT;

View file

@ -30,6 +30,7 @@ drop view if exists v1;
#
-- source include/not_embedded.inc
set debug_sync='RESET';
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -1113,3 +1114,8 @@ show explain for foo;
--echo # End
drop table t0;
connection default;
disconnect con1;
set debug_sync='RESET';

View file

@ -0,0 +1,207 @@
--source include/have_stat_tables.inc
select @@global.use_stat_tables;
select @@session.use_stat_tables;
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
--disable_warnings
DROP DATABASE IF EXISTS dbt3_s001;
--enable_warnings
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
--disable_query_log
--disable_result_log
--disable_warnings
--source include/dbt3_s001.inc
create index i_p_retailprice on part(p_retailprice);
delete from mysql.table_stats;
delete from mysql.column_stats;
delete from mysql.index_stats;
ANALYZE TABLE
customer, lineitem, nation, orders, part, partsupp, region, supplier;
FLUSH TABLE mysql.table_stats, mysql.index_stats;
--enable_warnings
--enable_result_log
--enable_query_log
select * from mysql.table_stats;
select * from mysql.index_stats;
set optimizer_switch=@save_optimizer_switch;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
let $Q5=
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
and l_suppkey = s_suppkey and c_nationkey = s_nationkey
and s_nationkey = n_nationkey and n_regionkey = r_regionkey
and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;
eval EXPLAIN $Q5;
eval $Q5;
set optimizer_switch=@save_optimizer_switch;
delete from mysql.index_stats;
--disable_query_log
--disable_result_log
--disable_warnings
ANALYZE TABLE
customer, lineitem, nation, orders, part, partsupp, region, supplier;
FLUSH TABLE mysql.table_stats, mysql.index_stats;
--enable_warnings
--enable_result_log
--enable_query_log
select * from mysql.table_stats;
select * from mysql.index_stats;
select * from mysql.table_stats where table_name='orders';
select * from mysql.index_stats where table_name='orders';
select (select cardinality from mysql.table_stats where table_name='orders') /
(select avg_frequency from mysql.index_stats
where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
select count(distinct o_orderdate) from orders;
select (select cardinality from mysql.table_stats where table_name='orders') /
(select avg_frequency from mysql.index_stats
where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
select count(distinct o_custkey) from orders;
show index from orders;
select index_name, column_name, cardinality from information_schema.statistics
where table_name='orders';
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off';
eval EXPLAIN $Q5;
eval $Q5;
set optimizer_switch=@save_optimizer_switch;
let $Q8=
select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
from (select extract(year from o_orderdate) as o_year,
l_extendedprice * (1-l_discount) as volume,
n2.n_name as nation
from part, supplier, lineitem, orders, customer,
nation n1, nation n2, region
where p_partkey = l_partkey and s_suppkey = l_suppkey
and l_orderkey = o_orderkey and o_custkey = c_custkey
and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey
and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey
and o_orderdate between date '1995-01-01' and date '1996-12-31'
and p_type = 'STANDARD BRUSHED STEEL' ) as all_nations
group by o_year
order by o_year;
eval EXPLAIN $Q8;
eval $Q8;
let $Q9=
select nation, o_year, sum(amount) as sum_profit
from (select n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from part, supplier, lineitem, partsupp, orders, nation
where s_suppkey = l_suppkey and ps_suppkey = l_suppkey
and ps_partkey = l_partkey and p_partkey = l_partkey
and o_orderkey = l_orderkey and s_nationkey = n_nationkey
and p_name like '%green%') as profit
group by nation, o_year
order by nation, o_year desc;
eval EXPLAIN $Q9;
eval $Q9;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
let $QQ1=
select o_orderkey, p_partkey
from part, lineitem, orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
eval EXPLAIN $QQ1;
eval $QQ1;
set optimizer_switch=@save_optimizer_switch;
DROP DATABASE dbt3_s001;
use test;
--echo #
--echo # Bug mdev-473: ANALYZE table locked for write
--echo #
set use_stat_tables='complementary';
create table t1 (i int);
lock table t1 write;
analyze table t1;
alter table t1 add column a varchar(8);
drop table t1;
--echo #
--echo # Bug mdev-487: memory leak in ANALYZE with stat tables
--echo #
SET use_stat_tables = 'preferably';
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
DELETE FROM t1 WHERE a=1;
ANALYZE TABLE t1;
DROP TABLE t1;
--echo #
--echo # Bug mdev-518: corrupted/missing statistical tables
--echo #
CREATE TABLE t1 (i int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
FLUSH TABLE t1;
SET use_stat_tables='never';
EXPLAIN SELECT * FROM t1;
--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD.save
FLUSH TABLES;
SET use_stat_tables='preferably';
--disable_warnings
EXPLAIN SELECT * FROM t1;
--enable_warnings
# Cleanup
--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD.save $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;

View file

@ -0,0 +1,78 @@
--source include/have_innodb.inc
SET SESSION STORAGE_ENGINE='InnoDB';
select @@global.use_stat_tables;
select @@session.use_stat_tables;
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
--disable_warnings
DROP DATABASE IF EXISTS dbt3_s001;
--enable_warnings
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
--disable_query_log
--disable_result_log
--disable_warnings
--source include/dbt3_s001.inc
delete from mysql.table_stats;
delete from mysql.column_stats;
delete from mysql.index_stats;
ANALYZE TABLE
customer, lineitem, nation, orders, part, partsupp, region, supplier;
--enable_warnings
--enable_result_log
--enable_query_log
--echo #
--echo # Bug mdev-503: optimizer ignores setting use_stat_tables='preferably'
--echo #
flush tables
customer, lineitem, nation, orders, part, partsupp, region, supplier;
let $Q3S=
select sql_calc_found_rows straight_join
l_orderkey, sum(l_extendedprice*(1-l_discount)) as revenue,
o_orderdate, o_shippriority
from orders, customer, lineitem
where c_mktsegment = 'BUILDING' and c_custkey = o_custkey
and l_orderkey = o_orderkey and o_orderdate < date '1995-03-15'
and l_shipdate > date '1995-03-15'
group by l_orderkey, o_orderdate, o_shippriority
order by revenue desc, o_orderdate
limit 10;
set use_stat_tables='never';
--replace_column 9 #
eval EXPLAIN $Q3S;
set use_stat_tables='preferably';
--replace_result 2 1
eval EXPLAIN $Q3S;
flush tables customer, orders, lineitem;
eval EXPLAIN $Q3S;
--echo # End of the test case for mdev-503
set optimizer_switch=@save_optimizer_switch;
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -0,0 +1,12 @@
--source include/have_innodb.inc
SET SESSION STORAGE_ENGINE='InnoDB';
set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
--source stat_tables.test
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -0,0 +1,245 @@
--source include/have_stat_tables.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
--disable_warnings
DROP DATABASE IF EXISTS dbt3_s001;
--enable_warnings
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
--disable_query_log
--disable_result_log
--disable_warnings
--source include/dbt3_s001.inc
delete from mysql.table_stats;
delete from mysql.column_stats;
delete from mysql.index_stats;
ANALYZE TABLE
customer, lineitem, nation, orders, part, partsupp, region, supplier;
--enable_warnings
--enable_result_log
--enable_query_log
select * from mysql.table_stats;
select * from mysql.index_stats;
#
# Test for parallel memory allocation for statistical data
#
# assumes that start the code of memory allocation for stats data has this line:
#
# DEBUG_SYNC(thd, "statistics_mem_alloc_start1");
# DEBUG_SYNC(thd, "statistics_mem_alloc_start2");
#
let $Q6=
select sum(l_extendedprice*l_discount) as revenue
from lineitem
where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
flush table lineitem;
set use_stat_tables='never';
eval $Q6;
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection con1;
set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
--send_eval $Q6
connection con2;
set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
--send_eval $Q6
connection con1;
--reap
connection con2;
--reap
connection default;
set use_stat_tables='preferably';
disconnect con1;
disconnect con2;
set debug_sync='RESET';
#
# Test for parallel statistics collection
#
# assumes that start of stats collection code has this line:
#
# DEBUG_SYNC(thd, "statistics_collection_start1");
# DEBUG_SYNC(thd, "statistics_collection_start2");
#
select * from mysql.index_stats where table_name='lineitem' order by index_name;
delete from mysql.index_stats
where table_name='lineitem' and
index_name in ('i_l_shipdate', 'i_l_receiptdate');
select * from mysql.index_stats where table_name='lineitem' order by index_name;
--disable_result_log
--disable_warnings
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
--enable_warnings
--enable_result_log
select * from mysql.index_stats where table_name='lineitem' order by index_name;
delete from mysql.index_stats
where table_name='lineitem' and index_name= 'i_l_shipdate';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection con1;
set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_collection_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
--send analyze table lineitem persistent for columns() indexes (i_l_shipdate)
connection con2;
set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
--send analyze table lineitem persistent for columns() indexes (i_l_receiptdate)
connection con1;
--disable_result_log
--disable_warnings
--reap
--enable_warnings
--enable_result_log
connection con2;
--disable_result_log
--disable_warnings
--reap
--enable_warnings
--enable_result_log
connection default;
disconnect con1;
disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
#
# Test for parallel statistics collection and update (innodb)
#
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
set debug_sync='RESET';
let $innodb_storage_engine= 0;
if (`SELECT UPPER(@@storage_engine) = 'INNODB'`)
{
let $innodb_storage_engine= 1;
}
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection con1;
set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
use dbt3_s001;
set use_stat_tables='preferably';
--send analyze table lineitem persistent for all
connection con2;
set debug_sync='now WAIT_FOR parked';
use dbt3_s001;
set use_stat_tables='never';
if ($innodb_storage_engine)
{
select * from lineitem where l_orderkey=1 and l_partkey=156;
delete from lineitem where l_orderkey=1 and l_partkey=156;
select * from lineitem where l_orderkey=1 and l_partkey=156;
}
set debug_sync='now SIGNAL finish';
connection con1;
--disable_result_log
--disable_warnings
--reap
--enable_warnings
--enable_result_log
connection default;
disconnect con1;
disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
#
# Bug mdev-3891: deadlock for ANALYZE and SELECT over mysql.index_stats
#
set @save_global_use_stat_tables=@@global.use_stat_tables;
set global use_stat_tables='preferably';
set debug_sync='RESET';
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection con1;
set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1';
set debug_sync='thr_multi_lock_after_thr_lock SIGNAL go2 EXECUTE 2';
use dbt3_s001;
--send analyze table lineitem persistent for all
connection con2;
set debug_sync='open_and_process_table WAIT_FOR parker';
set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2';
use dbt3_s001;
--send select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68
connection con1;
--disable_result_log
--disable_warnings
--reap
--enable_warnings
--enable_result_log
connection con2;
--disable_warnings
--reap
--enable_warnings
connection default;
disconnect con1;
disconnect con2;
set debug_sync='RESET';
set global use_stat_tables=@save_global_use_stat_tables;
DROP DATABASE dbt3_s001;
use test;
set use_stat_tables=@save_use_stat_tables;

View file

@ -0,0 +1,12 @@
--source include/have_innodb.inc
SET SESSION STORAGE_ENGINE='InnoDB';
set @save_optimizer_switch_for_stat_tables_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
--source stat_tables_par.test
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -0,0 +1,17 @@
--source include/have_partition.inc
--echo #
--echo # Bug mdev-3866: valgrind complain from ANALYZE on a table with BIT field
--echo #
SET use_stat_tables = 'preferably';
CREATE TABLE t1 (pk int PRIMARY KEY, a bit(1), INDEX idx(a)
) ENGINE=MyISAM PARTITION BY KEY(pk) PARTITIONS 2;
INSERT INTO t1 VALUES (1,1),(2,0),(3,0),(4,1);
ANALYZE TABLE t1;
SET use_stat_tables = DEFAULT;
DROP TABLE t1;

View file

@ -0,0 +1,31 @@
--source include/have_binlog_format_row.inc
--source include/have_innodb.inc
--source include/have_partition.inc
--echo #
--echo # Bug mdev-463: assertion failure when running ANALYZE with RBR on
--echo #
SET GLOBAL use_stat_tables = PREFERABLY;
--connect (con1,localhost,root,,)
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
ANALYZE TABLE t1;
# Cleanup
DROP TABLE t1;
SET GLOBAL use_stat_tables = DEFAULT;
--disconnect con1
--connection default
SET use_stat_tables = PREFERABLY;
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
ALTER TABLE t1 ANALYZE PARTITION p1;
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;
SET use_stat_tables = DEFAULT;
DROP TABLE t1;

View file

@ -0,0 +1,58 @@
--source include/have_stat_tables.inc
--source include/master-slave.inc
--source include/have_binlog_format_row.inc
--echo #
--echo # Bug mdev-485: unexpected failure with replication of DROP/ALTER table
--echo # when RBR is on
--echo #
CREATE TABLE t1 ( a int, b int ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
DROP TABLE t1;
--sync_slave_with_master
--connection master
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
DROP INDEX idx1 ON t1;
--sync_slave_with_master
--connection master
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
ALTER TABLE t1 DROP COLUMN b;
--sync_slave_with_master
--connection master
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
ALTER TABLE t1 RENAME to s;
--sync_slave_with_master
--connection master
DROP TABLE s;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
ALTER TABLE t1 CHANGE COLUMN b c int ;
--sync_slave_with_master
--connection master
DROP TABLE t1;
--source include/rpl_end.inc

View file

@ -0,0 +1,564 @@
--source include/have_stat_tables.inc
--source include/have_innodb.inc
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
set @save_use_stat_tables=@@use_stat_tables;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
set use_stat_tables='preferably';
CREATE TABLE t1 (
a int NOT NULL PRIMARY KEY,
b varchar(32),
c char(16),
d date,
e double,
f bit(3),
INDEX idx1 (b, e),
INDEX idx2 (c, d),
INDEX idx3 (d),
INDEX idx4 (e, b, d)
) ENGINE= MYISAM;
INSERT INTO t1 VALUES
(0, NULL, NULL, NULL, NULL, NULL),
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd', '1990-05-15', 0.1, b'100'),
(17, 'vvvvvvvvvvvvv', 'aaaa', '1989-03-12', 0.01, b'101'),
(1, 'vvvvvvvvvvvvv', NULL, '1989-03-12', 0.01, b'100'),
(12, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd', '1999-07-23', 0.112, b'001'),
(23, 'vvvvvvvvvvvvv', 'dddddddd', '1999-07-23', 0.1, b'100'),
(8, 'vvvvvvvvvvvvv', 'aaaa', '1999-07-23', 0.1, b'100'),
(22, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'aaaa', '1989-03-12', 0.112, b'001'),
(31, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'aaaa', '1999-07-23', 0.01, b'001'),
(10, NULL, 'aaaa', NULL, 0.01, b'010'),
(5, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd', '1999-07-23', 0.1, b'100'),
(15, 'vvvvvvvvvvvvv', 'ccccccccc', '1990-05-15', 0.1, b'010'),
(30, NULL, 'bbbbbb', NULL, NULL, b'100'),
(38, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb', NULL, NULL, NULL),
(18, 'zzzzzzzzzzzzzzzzzz', 'ccccccccc', '1990-05-15', 0.01, b'010'),
(9, 'yyy', 'bbbbbb', '1998-08-28', 0.01, NULL),
(29, 'vvvvvvvvvvvvv', 'dddddddd', '1999-07-23', 0.012, b'010'),
(3, 'yyy', 'dddddddd', '1990-05-15', 0.112, b'010'),
(39, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb', NULL, 0.01, b'100'),
(14, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'ccccccccc', '1990-05-15', 0.1, b'100'),
(40, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb', '1989-03-12', NULL, NULL),
(44, NULL, 'aaaa', '1989-03-12', NULL, b'010'),
(19, 'vvvvvvvvvvvvv', 'ccccccccc', '1990-05-15', 0.012, b'011'),
(21, 'zzzzzzzzzzzzzzzzzz', 'dddddddd', '1989-03-12', 0.112, b'100'),
(45, NULL, NULL, '1989-03-12', NULL, b'011'),
(2, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'ccccccccc', '1990-05-15', 0.1, b'001'),
(35, 'yyy', 'aaaa', '1990-05-15', 0.05, b'011'),
(4, 'vvvvvvvvvvvvv', 'dddddddd', '1999-07-23', 0.01, b'101'),
(47, NULL, 'aaaa', '1990-05-15', 0.05, b'010'),
(42, NULL, 'ccccccccc', '1989-03-12', 0.01, b'010'),
(32, NULL, 'bbbbbb', '1990-05-15', 0.01, b'011'),
(49, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww' , 'aaaa', '1990-05-15', NULL, NULL),
(43, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww' , 'bbbbbb', '1990-05-15', NULL, b'100'),
(37, 'yyy', NULL, '1989-03-12', 0.05, b'011'),
(41, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'ccccccccc', '1990-05-15', 0.05, NULL),
(34, 'yyy', NULL, NULL, NULL, NULL),
(33, 'zzzzzzzzzzzzzzzzzz', 'dddddddd', '1989-03-12', 0.05, b'011'),
(24, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd', '1990-05-15', 0.01, b'101'),
(11, 'yyy', 'ccccccccc', '1999-07-23', 0.1, NULL),
(25, 'zzzzzzzzzzzzzzzzzz', 'bbb', '1989-03-12', 0.01, b'101');
ANALYZE TABLE t1;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
SELECT COUNT(*) FROM t1;
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='a';
SELECT MIN(t1.a), MAX(t1.a),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.a)",
(SELECT COUNT(t1.a) FROM t1) /
(SELECT COUNT(DISTINCT t1.a) FROM t1) AS "AVG_FREQUENCY(t1.a)"
FROM t1;
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='b';
SELECT MIN(t1.b), MAX(t1.b),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.b)",
(SELECT COUNT(t1.b) FROM t1) /
(SELECT COUNT(DISTINCT t1.b) FROM t1) AS "AVG_FREQUENCY(t1.b)"
FROM t1;
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='c';
SELECT MIN(t1.c), MAX(t1.c),
(SELECT COUNT(*) FROM t1 WHERE t1.c IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.c)",
(SELECT COUNT(t1.c) FROM t1) /
(SELECT COUNT(DISTINCT t1.c) FROM t1) AS "AVG_FREQUENCY(t1.c)"
FROM t1;
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='d';
SELECT MIN(t1.d), MAX(t1.d),
(SELECT COUNT(*) FROM t1 WHERE t1.d IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.d)",
(SELECT COUNT(t1.d) FROM t1) /
(SELECT COUNT(DISTINCT t1.d) FROM t1) AS "AVG_FREQUENCY(t1.d)"
FROM t1;
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='e';
SELECT MIN(t1.e), MAX(t1.e),
(SELECT COUNT(*) FROM t1 WHERE t1.e IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.e)",
(SELECT COUNT(t1.e) FROM t1) /
(SELECT COUNT(DISTINCT t1.e) FROM t1) AS "AVG_FREQUENCY(t1.e)"
FROM t1;
SELECT * FROM mysql.index_stats
WHERE db_name='test' AND table_name='t1' AND index_name='idx1';
SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.b) FROM t1 WHERE t1.b IS NOT NULL)
AS 'ARITY 1',
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.b, t1.e) FROM t1
WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL)
AS 'ARITY 2';
SELECT * FROM mysql.index_stats
WHERE db_name='test' AND table_name='t1' AND index_name='idx2';
SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.c) FROM t1 WHERE t1.c IS NOT NULL)
AS 'ARITY 1',
(SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.c, t1.d) FROM t1
WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL)
AS 'ARITY 2';
SELECT * FROM mysql.index_stats
WHERE db_name='test' AND table_name='t1' AND index_name='idx3';
SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.d IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.d) FROM t1 WHERE t1.d IS NOT NULL)
AS 'ARITY 1';
SELECT * FROM mysql.index_stats
WHERE db_name='test' AND table_name='t1' AND index_name='idx4';
SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.e) FROM t1 WHERE t1.e IS NOT NULL)
AS 'ARITY 1',
(SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.e, t1.b) FROM t1
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL)
AS 'ARITY 2',
(SELECT COUNT(*) FROM t1
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.e, t1.b, t1.d) FROM t1
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
AS 'ARITY 3';
CREATE TABLE t3 (
a int NOT NULL PRIMARY KEY,
b varchar(32),
c char(16),
INDEX idx (c)
) ENGINE=MYISAM;
INSERT INTO t3 VALUES
(0, NULL, NULL),
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd'),
(17, 'vvvvvvvvvvvvv', 'aaaa'),
(1, 'vvvvvvvvvvvvv', NULL),
(12, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'),
(23, 'vvvvvvvvvvvvv', 'dddddddd'),
(8, 'vvvvvvvvvvvvv', 'aaaa'),
(22, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'aaaa'),
(31, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'aaaa'),
(10, NULL, 'aaaa'),
(5, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'),
(15, 'vvvvvvvvvvvvv', 'ccccccccc'),
(30, NULL, 'bbbbbb'),
(38, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb'),
(18, 'zzzzzzzzzzzzzzzzzz', 'ccccccccc'),
(9, 'yyy', 'bbbbbb'),
(29, 'vvvvvvvvvvvvv', 'dddddddd');
ANALYZE TABLE t3;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE t1 RENAME TO s1;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
RENAME TABLE s1 TO t1;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
DROP TABLE t3;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
CREATE TEMPORARY TABLE t0 (
a int NOT NULL PRIMARY KEY,
b varchar(32)
);
INSERT INTO t0 SELECT a,b FROM t1;
ALTER TABLE t1 CHANGE COLUMN b x varchar(32),
CHANGE COLUMN e y double;
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
ALTER TABLE t1 CHANGE COLUMN x b varchar(32),
CHANGE COLUMN y e double;
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
ALTER TABLE t1 RENAME TO s1, CHANGE COLUMN b x varchar(32);
SHOW CREATE TABLE s1;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE s1 RENAME TO t1, CHANGE COLUMN x b varchar(32);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE t1 CHANGE COLUMN b x varchar(30);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx4);
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval
SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/save_column_stats'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
FROM mysql.column_stats WHERE column_name='b';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval
SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/save_index_stats'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
FROM mysql.index_stats WHERE index_name IN ('idx1', 'idx4');
ALTER TABLE t1 CHANGE COLUMN b x varchar(30);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval
LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/save_column_stats'
INTO TABLE mysql.column_stats
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval
LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/save_index_stats'
INTO TABLE mysql.index_stats
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
remove_file $MYSQLTEST_VARDIR/tmp/save_column_stats;
remove_file $MYSQLTEST_VARDIR/tmp/save_index_stats;
ALTER TABLE t1 DROP COLUMN b;
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
DROP INDEX idx2 ON t1;
SHOW CREATE TABLE t1;
SELECT * FROM mysql.index_stats;
DROP INDEX idx1 ON t1;
DROP INDEX idx4 ON t1;
SHOW CREATE TABLE t1;
ALTER TABLE t1 ADD COLUMN b varchar(32);
CREATE INDEX idx1 ON t1(b, e);
CREATE INDEX idx2 ON t1(c, d);
CREATE INDEX idx4 ON t1(e, b, d);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a);
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE t1 DROP COLUMN b,
DROP INDEX idx1, DROP INDEX idx2, DROP INDEX idx4;
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ALTER TABLE t1 ADD COLUMN b varchar(32);
ALTER TABLE t1
ADD INDEX idx1 (b, e), ADD INDEX idx2 (c, d), ADD INDEX idx4 (e, b, d);
UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a);
SHOW CREATE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES();
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4);
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
DELETE FROM mysql.index_stats WHERE table_name='t1' AND index_name='primary';
SELECT * FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES(primary);
SELECT * FROM mysql.index_stats;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
CREATE TABLE t2 LIKE t1;
ALTER TABLE t2 ENGINE=InnoDB;
INSERT INTO t2 SELECT * FROM t1;
set optimizer_switch='extended_keys=off';
ANALYZE TABLE t2;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats ORDER BY column_name;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
set optimizer_switch='extended_keys=on';
ANALYZE TABLE t2;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats ORDER BY column_name;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ALTER TABLE t2 DROP PRIMARY KEY, DROP INDEX idx1;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
UPDATE t2 SET b=0 WHERE b IS NULL;
ALTER TABLE t2 ADD PRIMARY KEY (a,b);
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ALTER TABLE t2 CHANGE COLUMN b b varchar(30);
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ALTER TABLE t2 CHANGE COLUMN b b varchar(32);
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ALTER TABLE t2 DROP COLUMN b;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
set optimizer_switch='extended_keys=off';
ALTER TABLE t1
DROP INDEX idx1,
DROP INDEX idx4;
ALTER TABLE t1
MODIFY COLUMN b text,
ADD INDEX idx1 (b(4), e),
ADD INDEX idx4 (e, b(4), d);
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
ANALYZE TABLE t1;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
ANALYZE TABLE mysql.column_stats PERSISTENT FOR ALL;
ANALYZE TABLE mysql.column_stats;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
set use_stat_tables='never';
ANALYZE TABLE t1 PERSISTENT FOR ALL;
SELECT * FROM mysql.table_stats;
SELECT * FROM mysql.column_stats;
SELECT * FROM mysql.index_stats;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
DROP TABLE t1,t2;
set names utf8;
CREATE DATABASE world;
use world;
--source include/world_schema_utf8.inc
--disable_query_log
--disable_result_log
--disable_warnings
--source include/world.inc
--enable_warnings
--enable_result_log
--enable_query_log
set use_stat_tables='preferably';
--disable_result_log
ANALYZE TABLE Country, City, CountryLanguage;
--enable_result_log
SELECT UPPER(db_name), UPPER(table_name), cardinality
FROM mysql.table_stats;
SELECT UPPER(db_name), UPPER(table_name),
column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
FROM mysql.column_stats;
SELECT UPPER(db_name), UPPER(table_name),
index_name, prefix_arity, avg_frequency
FROM mysql.index_stats;
use test;
set use_stat_tables='never';
CREATE DATABASE world_innodb;
use world_innodb;
--source include/world_schema_utf8.inc
ALTER TABLE Country ENGINE=InnoDB;
ALTER TABLE City ENGINE=InnoDB;
ALTER TABLE CountryLanguage ENGINE=InnoDB;
--disable_query_log
--disable_result_log
--disable_warnings
--source include/world.inc
--enable_warnings
--enable_result_log
--enable_query_log
set use_stat_tables='preferably';
--disable_result_log
ANALYZE TABLE Country, City, CountryLanguage;
--enable_result_log
SELECT UPPER(db_name), UPPER(table_name), cardinality
FROM mysql.table_stats;
SELECT UPPER(db_name), UPPER(table_name),
column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
FROM mysql.column_stats;
SELECT UPPER(db_name), UPPER(table_name),
index_name, prefix_arity, avg_frequency
FROM mysql.index_stats;
use test;
DROP DATABASE world;
SELECT UPPER(db_name), UPPER(table_name), cardinality
FROM mysql.table_stats;
SELECT UPPER(db_name), UPPER(table_name),
column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
FROM mysql.column_stats;
SELECT UPPER(db_name), UPPER(table_name),
index_name, prefix_arity, avg_frequency
FROM mysql.index_stats;
DROP DATABASE world_innodb;
SELECT UPPER(db_name), UPPER(table_name), cardinality
FROM mysql.table_stats;
SELECT UPPER(db_name), UPPER(table_name),
column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
FROM mysql.column_stats;
SELECT UPPER(db_name), UPPER(table_name),
index_name, prefix_arity, avg_frequency
FROM mysql.index_stats;
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
set use_stat_tables=@save_use_stat_tables;

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