Commit 646bf2d8 authored by unknown's avatar unknown

WL#2985 "Partition pruning", "do pruning for UPDATE/DELETE": Post-merge fixes

parent 67f1a02a
......@@ -304,21 +304,56 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t1 where b > 1 and b < 3 and (a =1 or a =2);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1_sp2,p2_sp2 system NULL NULL NULL NULL 1
DROP TABLE IF EXISTS `t1`;
drop table t1;
create table t1 (a int) partition by list(a) (
partition p0 values in (1,2),
partition p1 values in (3,4)
);
insert into t1 values (1),(1),(2),(2),(3),(4),(3),(4);
flush status;
update t1 set a=100 where a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
flush status;
update t1 set a=100 where a+1=5+1;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 10
flush status;
delete from t1 where a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
flush status;
delete from t1 where a+1=5+1;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 10
create table t2 like t1;
insert into t2 select * from t2;
flush status;
update t1,t2 set t1.a=1000, t2.a=1000 where t1.a=5 and t2.a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
flush status;
delete t1,t2 from t1, t2 where t1.a=5 and t2.a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
drop table t1,t2;
CREATE TABLE `t1` (
`a` int(11) default NULL
);
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
DROP TABLE IF EXISTS `t2`;
Warnings:
Note 1051 Unknown table 't2'
CREATE TABLE `t2` (
`a` int(11) default NULL,
KEY `a` (`a`)
) ;
insert into t2 select A.a + 10*(B.a + 10* C.a) from t1 A, t1 B, t1 C ;
insert into t1 select a from t2;
DROP TABLE IF EXISTS `t2`;
drop table t2;
CREATE TABLE `t2` (
`a` int(11) default NULL,
`b` int(11) default NULL
......@@ -367,23 +402,23 @@ flush status;
update t2 set a = 1002 where a = 1001;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 1015
Handler_read_rnd_next 0
flush status;
update t2 set b = 6 where a = 600;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 1015
Handler_read_rnd_next 201
flush status;
update t2 set b = 6 where a > 600 and a < 800;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 1015
Handler_read_rnd_next 201
flush status;
delete from t2 where a > 600;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 1015
DROP TABLE IF EXISTS `t2`;
Handler_read_rnd_next 402
drop table t2;
CREATE TABLE `t2` (
`a` int(11) default NULL,
`b` int(11) default NULL,
......@@ -510,42 +545,3 @@ show status like 'Handler_read_next';
Variable_name Value
Handler_read_next 0
drop table t1, t2;
drop table t1;
create table t1 (a int) partition by list(a) (
partition p0 values in (1,2),
partition p1 values in (3,4)
);
insert into t1 values (1),(1),(2),(2),(3),(4),(3),(4);
flush status;
update t1 set a=100 where a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
flush status;
update t1 set a=100 where a+1=5+1;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 10
flush status;
delete from t1 where a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
flush status;
delete from t1 where a+1=5+1;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 10
create table t2 like t1;
insert into t2 select * from t2;
flush status;
update t1,t2 set t1.a=1000, t2.a=1000 where t1.a=5 and t2.a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 3
flush status;
delete t1,t2 from t1, t2 where t1.a=5 and t2.a=5;
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 3
drop table t1,t2;
......@@ -316,25 +316,24 @@ delete t1,t2 from t1, t2 where t1.a=5 and t2.a=5;
show status like 'Handler_read_rnd_next';
drop table t1,t2;
# WL# 2986
DROP TABLE IF EXISTS `t1`;
#
# WL#2986 Tests (Checking if partition pruning results are used at query
# execution phase)
#
CREATE TABLE `t1` (
`a` int(11) default NULL
);
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` int(11) default NULL,
KEY `a` (`a`)
) ;
insert into t2 select A.a + 10*(B.a + 10* C.a) from t1 A, t1 B, t1 C ;
insert into t1 select a from t2;
DROP TABLE IF EXISTS `t2`;
drop table t2;
CREATE TABLE `t2` (
`a` int(11) default NULL,
`b` int(11) default NULL
......@@ -377,8 +376,7 @@ flush status;
delete from t2 where a > 600;
show status like 'Handler_read_rnd_next';
DROP TABLE IF EXISTS `t2`;
drop table t2;
CREATE TABLE `t2` (
`a` int(11) default NULL,
`b` int(11) default NULL,
......@@ -448,5 +446,6 @@ show status like 'Handler_read_prev';
show status like 'Handler_read_next';
drop table t1, t2;
# No tests for NULLs in RANGE(monotonic_expr()) - they depend on BUG#15447
# being fixed.
......@@ -52,7 +52,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
table_list->view_db.str, table_list->view_name.str);
DBUG_RETURN(TRUE);
}
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
thd->proc_info="init";
table->map=1;
......@@ -79,6 +78,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) &&
!(table->triggers && table->triggers->has_delete_triggers()))
{
/* Update the table->file->records number */
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
ha_rows const maybe_deleted= table->file->records;
/*
If all rows shall be deleted, we always log this statement-based
......@@ -108,12 +109,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
send_ok(thd); // No matching records
DBUG_RETURN(0);
}
/*
Update the table->records number (note: we probably could remove the
previous file->info() call)
*/
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
#endif
/* Update the table->file->records number */
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
table->used_keys.clear_all();
table->quick_keys.clear_all(); // Can't use 'only index'
......
......@@ -168,7 +168,6 @@ int mysql_update(THD *thd,
thd->proc_info="init";
table= table_list->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
/* Calculate "table->used_keys" based on the WHERE */
table->used_keys= table->s->keys_in_use;
......@@ -252,12 +251,9 @@ int mysql_update(THD *thd,
send_ok(thd); // No matching records
DBUG_RETURN(0);
}
/*
Update the table->records number (note: we probably could remove the
previous file->info() call)
*/
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
#endif
/* Update the table->file->records number */
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
select= make_select(table, 0, 0, conds, 0, &error);
if (error || !limit ||
......
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