Commit 838eaec7 authored by sergefp@mysql.com's avatar sergefp@mysql.com

Fix and testcase for BUG#4984

 The crash is eliminated but still it is weird/inefficent that ROR-intersection is used when performing updates in empty table.
parent c92db89c
...@@ -97,3 +97,24 @@ pk1 pk2 key1 key2 ...@@ -97,3 +97,24 @@ pk1 pk2 key1 key2
95 58 10 10 95 58 10 10
95 59 10 10 95 59 10 10
drop table t1; drop table t1;
create table t1
(
RUNID varchar(22),
SUBMITNR varchar(5),
ORDERNR char(1) ,
PROGRAMM varchar(8),
TESTID varchar(4),
UCCHECK char(1),
ETEXT varchar(80),
ETEXT_TYPE char(1),
INFO char(1),
SEVERITY tinyint(3),
TADIRFLAG char(1),
PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
WHERE
`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
`TESTID`='' AND `UCCHECK`='';
drop table t1;
...@@ -81,4 +81,28 @@ explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; ...@@ -81,4 +81,28 @@ explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
drop table t1; drop table t1;
# Testcase for BUG#4984
create table t1
(
RUNID varchar(22),
SUBMITNR varchar(5),
ORDERNR char(1) ,
PROGRAMM varchar(8),
TESTID varchar(4),
UCCHECK char(1),
ETEXT varchar(80),
ETEXT_TYPE char(1),
INFO char(1),
SEVERITY tinyint(3),
TADIRFLAG char(1),
PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
WHERE
`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
`TESTID`='' AND `UCCHECK`='';
drop table t1;
...@@ -748,10 +748,12 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() ...@@ -748,10 +748,12 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
{ {
DBUG_ENTER("QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT"); DBUG_ENTER("QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT");
if (!dont_free) if (!dont_free)
{
/* file is NULL for CPK scan on covering ROR-intersection */
if (file)
{ {
range_end(); range_end();
file->extra(HA_EXTRA_NO_KEYREAD); file->extra(HA_EXTRA_NO_KEYREAD);
delete_dynamic(&ranges); /* ranges are allocated in alloc */
if (free_file) if (free_file)
{ {
DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file, DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file,
...@@ -759,6 +761,8 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() ...@@ -759,6 +761,8 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
file->reset(); file->reset();
file->close(); file->close();
} }
}
delete_dynamic(&ranges); /* ranges are allocated in alloc */
free_root(&alloc,MYF(0)); free_root(&alloc,MYF(0));
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -1666,7 +1670,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, ...@@ -1666,7 +1670,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
objects are not allowed so don't use ROR-intersection for objects are not allowed so don't use ROR-intersection for
table deletes. table deletes.
*/ */
if (thd->lex->sql_command != SQLCOM_DELETE) if ((thd->lex->sql_command != SQLCOM_DELETE) )//&&
// (thd->lex->sql_command != SQLCOM_UPDATE))
{ {
/* /*
Get best non-covering ROR-intersection plan and prepare data for Get best non-covering ROR-intersection plan and prepare data for
...@@ -3096,6 +3101,7 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_quick(PARAM *param, ...@@ -3096,6 +3101,7 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_quick(PARAM *param,
delete quick_intrsect; delete quick_intrsect;
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
quick->file= NULL;
quick_intrsect->cpk_quick= quick; quick_intrsect->cpk_quick= quick;
} }
quick_intrsect->records= records; quick_intrsect->records= records;
......
...@@ -236,6 +236,7 @@ protected: ...@@ -236,6 +236,7 @@ protected:
bool free_file; bool free_file;
protected: protected:
friend class TRP_ROR_INTERSECT;
friend friend
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
struct st_table_ref *ref); struct st_table_ref *ref);
......
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