Commit 630f27a4 authored by marko's avatar marko

branches/zip: Merge 2155:2213 from branches/5.1.

(Revisions 2146:2155 were already merged.)
parent 7e62ee83
......@@ -3889,6 +3889,16 @@ ha_innobase::update_row(
error = convert_error_code_to_mysql(error, user_thd);
if (error == 0 /* success */
&& uvect->n_fields == 0 /* no columns were updated */) {
/* This is the same as success, but instructs
MySQL that the row is not really updated and it
should not increase the count of updated rows.
This is fix for http://bugs.mysql.com/29157 */
error = HA_ERR_RECORD_IS_THE_SAME;
}
/* Tell InnoDB server that there might be work for
utility threads: */
......@@ -5935,7 +5945,9 @@ ha_innobase::info(
stats.index_file_length = ((ulonglong)
ib_table->stat_sum_of_other_index_sizes)
* UNIV_PAGE_SIZE;
stats.delete_length = 0;
stats.delete_length =
fsp_get_available_space_in_free_extents(
ib_table->space);
stats.check_time = 0;
if (stats.records == 0) {
......
......@@ -111,10 +111,6 @@ struct read_view_struct{
dulint undo_no; /* (0, 0) or if type is VIEW_HIGH_GRANULARITY
transaction undo_no when this high-granularity
consistent read view was created */
ibool can_be_too_old; /* TRUE if the system has had to purge old
versions which this read view should be able
to access: the read view can bump into the
DB_MISSING_HISTORY error */
dulint low_limit_no; /* The view does not need to see the undo
logs for transactions whose transaction number
is strictly smaller (<) than this value: they
......
......@@ -925,7 +925,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 4 NULL # Using index
explain select a,b from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 4 NULL # Using index
1 SIMPLE t1 index NULL PRIMARY 4 NULL #
explain select a,b,c from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL #
......@@ -1049,6 +1049,19 @@ n d
1 30
2 20
drop table t1,t2;
drop table if exists t1, t2;
CREATE TABLE t1 (a int, PRIMARY KEY (a));
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
create trigger trg_del_t2 after delete on t2 for each row
insert into t1 values (1);
insert into t1 values (1);
insert into t2 values (1),(2);
delete t2 from t2;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
count(*)
2
drop table t1, t2;
create table t1 (a int, b int) engine=innodb;
insert into t1 values(20,null);
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
......@@ -1140,14 +1153,14 @@ UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
SELECT * from t1;
a b
1 1
102 2
103 3
4 4
5 5
6 6
7 7
8 8
9 9
102 2
103 3
drop table t1;
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
......@@ -1171,7 +1184,6 @@ a b
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
select * from t1;
a b
201 1
102 2
103 3
104 4
......@@ -1183,10 +1195,11 @@ a b
110 10
111 11
112 12
201 1
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
select * from t1;
a b
201 1
102 12
103 3
104 4
105 5
......@@ -1196,34 +1209,34 @@ a b
109 9
110 10
111 11
102 12
112 12
201 1
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
select * from t1;
a b
201 1
102 12
103 5
104 6
106 6
105 7
106 6
107 7
108 8
109 9
110 10
111 11
102 12
112 12
201 1
select * from t2;
a b
1 1
2 2
3 13
4 14
5 15
6 6
7 7
8 8
9 9
3 13
4 14
5 15
drop table t1,t2;
CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
......@@ -1274,11 +1287,11 @@ insert into t1 (id) values (null),(null),(null),(null),(null);
update t1 set fk=69 where fk is null order by id limit 1;
SELECT * from t1;
id fk
1 69
2 NULL
3 NULL
4 NULL
5 NULL
1 69
drop table t1;
create table t1 (a int not null, b int not null, key (a));
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
......@@ -1714,10 +1727,10 @@ Variable_name Value
Innodb_page_size 16384
show status like "Innodb_rows_deleted";
Variable_name Value
Innodb_rows_deleted 69
Innodb_rows_deleted 70
show status like "Innodb_rows_inserted";
Variable_name Value
Innodb_rows_inserted 1080
Innodb_rows_inserted 1082
show status like "Innodb_rows_updated";
Variable_name Value
Innodb_rows_updated 885
......@@ -1755,6 +1768,8 @@ show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 8
set global innodb_thread_concurrency=1001;
Warnings:
Warning 1292 Truncated incorrect thread_concurrency value: '1001'
show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 1000
......@@ -1774,6 +1789,8 @@ show variables like "innodb_concurrency_tickets";
Variable_name Value
innodb_concurrency_tickets 1000
set global innodb_concurrency_tickets=0;
Warnings:
Warning 1292 Truncated incorrect concurrency_tickets value: '0'
show variables like "innodb_concurrency_tickets";
Variable_name Value
innodb_concurrency_tickets 1
......@@ -2407,8 +2424,8 @@ insert into t1 (b) values (1);
replace into t1 (b) values (2), (1), (3);
select * from t1;
a b
3 1
2 2
3 1
4 3
truncate table t1;
insert into t1 (b) values (1);
......@@ -2417,8 +2434,8 @@ replace into t1 (b) values (1);
replace into t1 (b) values (3);
select * from t1;
a b
3 1
2 2
3 1
4 3
drop table t1;
create table t1 (rowid int not null auto_increment, val int not null,primary
......
......@@ -720,6 +720,38 @@ select * from t1;
select * from t2;
drop table t1,t2;
#
# Bug #29136 erred multi-delete on trans table does not rollback
#
# prepare
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
CREATE TABLE t1 (a int, PRIMARY KEY (a));
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
create trigger trg_del_t2 after delete on t2 for each row
insert into t1 values (1);
insert into t1 values (1);
insert into t2 values (1),(2);
# exec cases A, B - see multi_update.test
# A. send_error() w/o send_eof() branch
--error ER_DUP_ENTRY
delete t2 from t2;
# check
select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
# cleanup bug#29136
drop table t1, t2;
#
# Testing of IFNULL
#
......
......@@ -211,7 +211,6 @@ read_view_oldest_copy_or_open_new(
view_copy->low_limit_no = old_view->low_limit_no;
view_copy->low_limit_id = old_view->low_limit_id;
view_copy->can_be_too_old = FALSE;
if (n > 0) {
/* The last active transaction has the smallest id: */
......@@ -257,8 +256,6 @@ read_view_open_now(
view->low_limit_no = trx_sys->max_trx_id;
view->low_limit_id = view->low_limit_no;
view->can_be_too_old = FALSE;
n = 0;
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
......@@ -427,8 +424,6 @@ read_cursor_view_create_for_mysql(
view->low_limit_no = trx_sys->max_trx_id;
view->low_limit_id = view->low_limit_no;
view->can_be_too_old = FALSE;
n = 0;
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
......
......@@ -3339,6 +3339,66 @@ funct_exit:
return((int) err);
}
/***********************************************************************
Drop all foreign keys in a database, see Bug#18942.
Called at the end of row_drop_database_for_mysql(). */
static
ulint
drop_all_foreign_keys_in_db(
/*========================*/
/* out: error code or DB_SUCCESS */
const char* name, /* in: database name which ends to '/' */
trx_t* trx) /* in: transaction handle */
{
pars_info_t* pinfo;
ulint err;
ut_a(name[strlen(name) - 1] == '/');
pinfo = pars_info_create();
pars_info_add_str_literal(pinfo, "dbname", name);
/* true if for_name is not prefixed with dbname */
#define TABLE_NOT_IN_THIS_DB \
"SUBSTR(for_name, 0, LENGTH(:dbname)) <> :dbname"
err = que_eval_sql(pinfo,
"PROCEDURE DROP_ALL_FOREIGN_KEYS_PROC () IS\n"
"foreign_id CHAR;\n"
"for_name CHAR;\n"
"found INT;\n"
"DECLARE CURSOR cur IS\n"
"SELECT ID, FOR_NAME FROM SYS_FOREIGN\n"
"WHERE FOR_NAME >= :dbname\n"
"LOCK IN SHARE MODE\n"
"ORDER BY FOR_NAME;\n"
"BEGIN\n"
"found := 1;\n"
"OPEN cur;\n"
"WHILE found = 1 LOOP\n"
" FETCH cur INTO foreign_id, for_name;\n"
" IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
" ELSIF (" TABLE_NOT_IN_THIS_DB ") THEN\n"
" found := 0;\n"
" ELSIF (1=1) THEN\n"
" DELETE FROM SYS_FOREIGN_COLS\n"
" WHERE ID = foreign_id;\n"
" DELETE FROM SYS_FOREIGN\n"
" WHERE ID = foreign_id;\n"
" END IF;\n"
"END LOOP;\n"
"CLOSE cur;\n"
"COMMIT WORK;\n"
"END;\n",
FALSE, /* do not reserve dict mutex,
we are already holding it */
trx);
return(err);
}
/*************************************************************************
Drops a database for MySQL. */
......@@ -3409,6 +3469,19 @@ loop:
}
}
if (err == DB_SUCCESS) {
/* after dropping all tables try to drop all leftover
foreign keys in case orphaned ones exist */
err = (int) drop_all_foreign_keys_in_db(name, trx);
if (err != DB_SUCCESS) {
fputs("InnoDB: DROP DATABASE ", stderr);
ut_print_name(stderr, trx, TRUE, name);
fprintf(stderr, " failed with error %d while "
"dropping all foreign keys", err);
}
}
trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx);
......
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