Commit 4f5dea43 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup

* remove dead code
* simplify the check for table->s->next_number_index
* misc
parent 947eeaa6
#
# MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling
#
select variable_name from information_schema.session_status where variable_name =
(select variable_name from information_schema.session_status where variable_name = 'uptime');
variable_name
......@@ -6,6 +9,9 @@ select variable_name from information_schema.session_variables where variable_na
(select variable_name from information_schema.session_variables where variable_name = 'basedir');
variable_name
BASEDIR
#
# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
#
create table t1 (x int);
create table t2 (x int);
create table t3 (x int);
......@@ -18,3 +24,4 @@ t2
t3
t4
drop table t1, t2, t3, t4;
# End of 5.5 tests
#
# MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling
#
--echo #
--echo # MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling
--echo #
select variable_name from information_schema.session_status where variable_name =
(select variable_name from information_schema.session_status where variable_name = 'uptime');
select variable_name from information_schema.session_variables where variable_name =
(select variable_name from information_schema.session_variables where variable_name = 'basedir');
#
# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
#
--echo #
--echo # MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
--echo #
create table t1 (x int);
create table t2 (x int);
create table t3 (x int);
......@@ -17,3 +17,5 @@ create table t4 AS select table_name from information_schema.TABLES where table_
delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
select * from t4 order by table_name;
drop table t1, t2, t3, t4;
--echo # End of 5.5 tests
......@@ -163,7 +163,7 @@
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
@@ -220,12 +220,12 @@
5959 3
show status like 'handler_read_next';
show /*a*/ status like 'handler_read_next';
Variable_name Value
-Handler_read_next 3
+Handler_read_next 9
......@@ -177,7 +177,7 @@
select max(l_orderkey) from lineitem
where l_partkey between 1 and 10 group by l_partkey;
@@ -243,9 +243,9 @@
show status like 'handler_read%';
show /*b*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 21
......@@ -199,7 +199,7 @@
select max(l_orderkey) from lineitem
where l_suppkey in (1,4) group by l_suppkey;
@@ -265,9 +265,9 @@
show status like 'handler_read%';
show /*c*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 6
......
......@@ -14,7 +14,7 @@ flush status;
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
count(*)
1
show status like 'handler_read%';
show /*1*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -35,7 +35,7 @@ select count(*) from lineitem use index(primary)
where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
count(*)
1
show status like 'handler_read%';
show /*2*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -56,7 +56,7 @@ select count(*) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
count(*)
1
show status like 'handler_read%';
show /*3*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -79,7 +79,7 @@ l_orderkey l_linenumber
1088 3
1217 1
1221 3
show status like 'handler_read%';
show /*4*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -98,7 +98,7 @@ flush status;
select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
min(l_orderkey)
130
show status like 'handler_read%';
show /*5*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -119,7 +119,7 @@ select min(l_orderkey) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
min(l_orderkey)
1088
show status like 'handler_read%';
show /*6*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -140,7 +140,7 @@ select max(l_linenumber) from lineitem
where l_shipdate='1992-07-01' and l_orderkey=130;
max(l_linenumber)
2
show status like 'handler_read%';
show /*7*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
......@@ -166,7 +166,7 @@ or l_receiptdate='1992-07-01' and l_orderkey=5603;
l_orderkey l_linenumber
130 2
5603 2
show status like 'handler_read%';
show /*8*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 2
......@@ -193,7 +193,7 @@ l_orderkey l_linenumber
130 2
5603 2
5959 3
show status like 'handler_read%';
show /*9*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 2
......@@ -218,7 +218,7 @@ l_orderkey l_linenumber
130 2
5603 2
5959 3
show status like 'handler_read_next';
show /*a*/ status like 'handler_read_next';
Variable_name Value
Handler_read_next 3
explain
......@@ -240,7 +240,7 @@ max(l_orderkey)
5894
5859
5632
show status like 'handler_read%';
show /*b*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 21
......@@ -262,7 +262,7 @@ where l_suppkey in (1,4) group by l_suppkey;
max(l_orderkey)
5988
5984
show status like 'handler_read%';
show /*c*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 6
......@@ -292,7 +292,7 @@ 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
show status like 'handler_read%';
show /*d*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 3
......@@ -457,7 +457,7 @@ select * from t1, t2 where t2.a=t1.a and t2.b < 2;
a pk a b
0 0 0 0
1 1 1 1
show status like 'handler_read%';
show /*e*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 10
......
......@@ -34,7 +34,7 @@ explain
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
flush status;
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
show status like 'handler_read%';
show /*1*/ status like 'handler_read%';
explain
select count(*) from lineitem use index(primary)
......@@ -42,7 +42,7 @@ select count(*) from lineitem use index(primary)
flush status;
select count(*) from lineitem use index(primary)
where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
show status like 'handler_read%';
show /*2*/ status like 'handler_read%';
explain
select count(*) from lineitem
......@@ -50,7 +50,7 @@ select count(*) from lineitem
flush status;
select count(*) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
show status like 'handler_read%';
show /*3*/ status like 'handler_read%';
explain
select l_orderkey, l_linenumber from lineitem
......@@ -58,13 +58,13 @@ select l_orderkey, l_linenumber from lineitem
flush status;
select l_orderkey, l_linenumber from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
show status like 'handler_read%';
show /*4*/ status like 'handler_read%';
explain
select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
flush status;
select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
show status like 'handler_read%';
show /*5*/ status like 'handler_read%';
explain
select min(l_orderkey) from lineitem
......@@ -72,7 +72,7 @@ select min(l_orderkey) from lineitem
flush status;
select min(l_orderkey) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
show status like 'handler_read%';
show /*6*/ status like 'handler_read%';
explain
select max(l_linenumber) from lineitem
......@@ -80,7 +80,7 @@ select max(l_linenumber) from lineitem
flush status;
select max(l_linenumber) from lineitem
where l_shipdate='1992-07-01' and l_orderkey=130;
show status like 'handler_read%';
show /*7*/ status like 'handler_read%';
explain
select l_orderkey, l_linenumber
......@@ -92,7 +92,7 @@ select l_orderkey, l_linenumber
from lineitem use index (i_l_shipdate, i_l_receiptdate)
where l_shipdate='1992-07-01' and l_orderkey=130
or l_receiptdate='1992-07-01' and l_orderkey=5603;
show status like 'handler_read%';
show /*8*/ status like 'handler_read%';
--replace_column 7 #
explain
......@@ -105,7 +105,7 @@ select l_orderkey, l_linenumber
from lineitem use index (i_l_shipdate, i_l_receiptdate)
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
show status like 'handler_read%';
show /*9*/ status like 'handler_read%';
--replace_column 7 # 9 # 10 Using
explain
......@@ -116,7 +116,7 @@ flush status;
select l_orderkey, l_linenumber from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
show status like 'handler_read_next';
show /*a*/ status like 'handler_read_next';
--replace_column 9 #
explain
......@@ -125,7 +125,7 @@ select max(l_orderkey) from lineitem
flush status;
select max(l_orderkey) from lineitem
where l_partkey between 1 and 10 group by l_partkey;
show status like 'handler_read%';
show /*b*/ status like 'handler_read%';
--replace_column 9 #
explain
......@@ -134,7 +134,7 @@ select max(l_orderkey) from lineitem
flush status;
select max(l_orderkey) from lineitem
where l_suppkey in (1,4) group by l_suppkey;
show status like 'handler_read%';
show /*c*/ status like 'handler_read%';
create index i_p_retailprice on part(p_retailprice);
......@@ -151,7 +151,7 @@ select o_orderkey, p_partkey
lineitem use index (i_l_partkey), orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
show status like 'handler_read%';
show /*d*/ status like 'handler_read%';
--enable_ps2_protocol
--echo #
......@@ -327,7 +327,7 @@ explain
select * from t1, t2 where t2.a=t1.a and t2.b < 2;
flush status;
select * from t1, t2 where t2.a=t1.a and t2.b < 2;
show status like 'handler_read%';
show /*e*/ status like 'handler_read%';
--enable_ps2_protocol
drop table t1,t2;
......
......@@ -503,7 +503,6 @@ start transaction;
alter table tmp alter column a set default 8;
unlock tables;
drop table t2;
--source include/have_innodb.inc
--echo #
--echo # MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table
......@@ -642,7 +641,6 @@ insert into t1 values (0);
check table t1 extended;
drop table t1;
--echo #
--echo # MDEV-32837 long unique does not work like unique key when using replace
--echo #
......
call mtr.add_suppression("Can't find record in '.*'");
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
drop table if exists t1,t2,t3;
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
KEY string_data (STRING_DATA)
......
......@@ -7,12 +7,6 @@
call mtr.add_suppression("Can't find record in '.*'");
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
# Initialise
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
SET SQL_WARNINGS=1;
#
# Test problem with CHECK TABLE;
#
......
drop table if exists t1, t2, t3, t4;
drop view if exists v1;
drop database if exists mysqltest;
drop function if exists f1;
drop function if exists f2;
drop procedure if exists p1;
connect addconroot1, localhost, root,,;
connect addconroot2, localhost, root,,;
connect addconwithoutdb, localhost, root,,*NO-ONE*;
......
......@@ -7,15 +7,6 @@
# Basic triggers test
#
--disable_warnings
drop table if exists t1, t2, t3, t4;
drop view if exists v1;
drop database if exists mysqltest;
drop function if exists f1;
drop function if exists f2;
drop procedure if exists p1;
--enable_warnings
# Create additional connections used through test
connect (addconroot1, localhost, root,,);
connect (addconroot2, localhost, root,,);
......
#
# MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER
#
set @save_alter_algorithm= @@session.alter_algorithm;
SET SESSION alter_algorithm=4;
CREATE TABLE t1(a INT) engine=myisam PARTITION BY RANGE(a) SUBPARTITION BY KEY(a) (PARTITION p0 VALUES LESS THAN (10) (SUBPARTITION s0,SUBPARTITION s1), PARTITION p1 VALUES LESS THAN (20) (SUBPARTITION s2,SUBPARTITION s3));
......@@ -18,9 +21,16 @@ ALTER TABLE t1 ADD COLUMN c INT;
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY
DROP table if exists t1;
set @@session.alter_algorithm= @save_alter_algorithm;
#
# MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata |
# ERROR 1507 (HY000): Error in list of partitions to DROP
#
CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3));
ALTER TABLE t1 DROP PARTITION p;
DROP TABLE if exists t1;
#
# MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition
#
CREATE TABLE t1 (i INT);
CREATE VIEW v1 as SELECT * FROM t1;
CREATE TABLE t2 (i INT);
......@@ -28,3 +38,4 @@ ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ;
ERROR 42000: Can't open table
DROP VIEW v1;
DROP TABLE t1, t2;
# End of 10.5 tests
call mtr.add_suppression("..test.t1_will_crash");
call mtr.add_suppression("Got an error from unknown thread");
call mtr.add_suppression("Table 't1_will_crash' is marked as crashed and should be repaired");
CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM;
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
FLUSH TABLES;
......
#
# General errors with ALTER TABLE and partitions that doesn't have to be run
# General bugs with ALTER TABLE and partitions that doesn't have to be run
# on all engines
#
--source include/have_partition.inc
#
# MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER
#
--echo #
--echo # MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER
--echo #
set @save_alter_algorithm= @@session.alter_algorithm;
SET SESSION alter_algorithm=4;
......@@ -19,18 +19,18 @@ DROP table if exists t1;
set @@session.alter_algorithm= @save_alter_algorithm;
#
# MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata |
# ERROR 1507 (HY000): Error in list of partitions to DROP
#
--echo #
--echo # MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata |
--echo # ERROR 1507 (HY000): Error in list of partitions to DROP
--echo #
CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3));
ALTER TABLE t1 DROP PARTITION p;
DROP TABLE if exists t1;
#
# MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition
#
--echo #
--echo # MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition
--echo #
CREATE TABLE t1 (i INT);
CREATE VIEW v1 as SELECT * FROM t1;
CREATE TABLE t2 (i INT);
......@@ -38,3 +38,5 @@ CREATE TABLE t2 (i INT);
ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ;
DROP VIEW v1;
DROP TABLE t1, t2;
--echo # End of 10.5 tests
# test the auto-recover (--myisam-recover) of partitioned myisam tables
--disable_query_log
call mtr.add_suppression("..test.t1_will_crash");
call mtr.add_suppression("Got an error from unknown thread");
call mtr.add_suppression("Table 't1_will_crash' is marked as crashed and should be repaired");
--enable_query_log
--source include/have_partition.inc
--disable_warnings
--disable_query_log
drop table if exists t1_will_crash;
--enable_query_log
--enable_warnings
CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM;
INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
......
......@@ -4915,8 +4915,7 @@ handler::ha_check_and_repair(THD *thd)
int
handler::ha_disable_indexes(uint mode)
{
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
DBUG_ASSERT(table->s->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK);
mark_trx_read_write();
return disable_indexes(mode);
......@@ -4932,8 +4931,7 @@ handler::ha_disable_indexes(uint mode)
int
handler::ha_enable_indexes(uint mode)
{
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
DBUG_ASSERT(table->s->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK);
mark_trx_read_write();
return enable_indexes(mode);
......
......@@ -1881,7 +1881,7 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink)
was used. This ensures that we don't get a problem when the
whole range of the key has been used.
*/
if (info->handle_duplicates == DUP_REPLACE && table->next_number_field &&
if (info->handle_duplicates == DUP_REPLACE &&
key_nr == table->s->next_number_index && insert_id_for_cur_row > 0)
goto err;
if (table->file->has_dup_ref())
......
......@@ -3209,6 +3209,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
goto err; // Wrong field definition
reg_field->flags |= AUTO_INCREMENT_FLAG;
}
else
share->next_number_index= MAX_KEY;
if (share->blob_fields)
{
......@@ -8926,7 +8928,7 @@ void TABLE::period_prepare_autoinc()
if (!found_next_number_field)
return;
/* Don't generate a new value if the autoinc index is WITHOUT OVERLAPS */
DBUG_ASSERT(s->next_number_index != (uint)-1);
DBUG_ASSERT(s->next_number_index < MAX_KEY);
if (key_info[s->next_number_index].without_overlaps)
return;
......
......@@ -279,51 +279,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
mi_print_error(info->s, HA_ERR_CRASHED);
mi_mark_crashed(info); /* Fatal error found */
}
#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND
/* Close the isam and data files as Win32 can't drop an open table */
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
{
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
error=end_io_cache(&info->rec_cache);
}
if (info->lock_type != F_UNLCK && ! info->was_locked)
{
info->was_locked=info->lock_type;
if (mi_lock_database(info,F_UNLCK))
error=my_errno;
info->lock_type = F_UNLCK;
}
if (share->kfile >= 0)
{
/*
We don't need to call _mi_decrement_open_count() if we are
dropping the table, as the files will be removed anyway. If we
are aborted before the files is removed, it's better to not
call it as in that case the automatic repair on open will add
the missing index entries
*/
if (function != HA_EXTRA_PREPARE_FOR_DROP)
_mi_decrement_open_count(info);
if (mysql_file_close(share->kfile,MYF(0)))
error=my_errno;
}
{
LIST *list_element ;
for (list_element=myisam_open_list ;
list_element ;
list_element=list_element->next)
{
MI_INFO *tmpinfo=(MI_INFO*) list_element->data;
if (tmpinfo->s == info->s)
{
if (tmpinfo->dfile >= 0 && mysql_file_close(tmpinfo->dfile, MYF(0)))
error = my_errno;
tmpinfo->dfile= -1;
}
}
}
share->kfile= -1; /* Files aren't open anymore */
#endif
mysql_mutex_unlock(&share->intern_lock);
mysql_mutex_unlock(&THR_LOCK_myisam);
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment