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
95 58 10 10
95 59 10 10
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;
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
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()
DBUG_ENTER("QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT");
if (!dont_free)
{
range_end();
file->extra(HA_EXTRA_NO_KEYREAD);
delete_dynamic(&ranges); /* ranges are allocated in alloc */
if (free_file)
/* file is NULL for CPK scan on covering ROR-intersection */
if (file)
{
DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file,
free_file));
file->reset();
file->close();
range_end();
file->extra(HA_EXTRA_NO_KEYREAD);
if (free_file)
{
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));
}
DBUG_VOID_RETURN;
......@@ -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
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
......@@ -3096,6 +3101,7 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_quick(PARAM *param,
delete quick_intrsect;
DBUG_RETURN(NULL);
}
quick->file= NULL;
quick_intrsect->cpk_quick= quick;
}
quick_intrsect->records= records;
......
......@@ -236,6 +236,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I
bool free_file;
protected:
friend class TRP_ROR_INTERSECT;
friend
QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
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