Commit ed0f3856 authored by unknown's avatar unknown

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.


mysql-test/r/index_merge_ror_cpk.result:
  Fix and testcase for BUG#4984
mysql-test/t/index_merge_ror_cpk.test:
  Fix and testcase for BUG#4984
sql/opt_range.cc:
  Don't call index_end() for CPK quick select inside of a ROR-intersection.
sql/opt_range.h:
  Fix and testcase for BUG#4984
parent 0ee657d1
...@@ -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;
...@@ -749,16 +749,20 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() ...@@ -749,16 +749,20 @@ 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)
{ {
range_end(); /* file is NULL for CPK scan on covering ROR-intersection */
file->extra(HA_EXTRA_NO_KEYREAD); if (file)
delete_dynamic(&ranges); /* ranges are allocated in alloc */
if (free_file)
{ {
DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file, range_end();
free_file)); file->extra(HA_EXTRA_NO_KEYREAD);
file->reset(); if (free_file)
file->close(); {
DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file,
free_file));
file->reset();
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 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I ...@@ -236,6 +236,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I
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