Commit c01b3d91 authored by Sachin's avatar Sachin

MDEV-22551 Server crashes in skip_trailing_space upon ANALYZE on table with...

MDEV-22551 Server crashes in skip_trailing_space upon ANALYZE on table with long unique, or Assertion `marked_for_read()' fails

If Blob(or parent) field read_set is not set then Do not calc hash in
that case.
parent 0552ed86
......@@ -277,3 +277,17 @@ create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2)));
INSERT INTO t2 VALUES (1, 'foo', default);
DROP TABLE t1, t2;
SET binlog_row_image= FULL;
CREATE TABLE t1 (id INT, f TEXT UNIQUE, d DATE, PRIMARY KEY (id)) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1,NULL,'2001-11-16'),
(2,NULL,'2007-07-01'),
(3,NULL,'2020-02-03'),
(4,NULL,'1971-05-24'),
(5,NULL,'1971-05-24'),
(6,NULL,'1985-02-07');
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 'f'
test.t1 analyze status OK
DROP TABLE t1;
......@@ -356,3 +356,20 @@ INSERT INTO t2 VALUES (1, 'foo', default);
# Cleanup
DROP TABLE t1, t2;
SET binlog_row_image= FULL;
#
# MDEV-22551 Server crashes in skip_trailing_space upon ANALYZE on table with long unique, or Assertion `marked_for_read()' fails
#
CREATE TABLE t1 (id INT, f TEXT UNIQUE, d DATE, PRIMARY KEY (id)) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1,NULL,'2001-11-16'),
(2,NULL,'2007-07-01'),
(3,NULL,'2020-02-03'),
(4,NULL,'1971-05-24'),
(5,NULL,'1971-05-24'),
(6,NULL,'1985-02-07');
ANALYZE TABLE t1 PERSISTENT FOR ALL;
# Cleanup
DROP TABLE t1;
......@@ -1734,6 +1734,22 @@ static void calc_hash_for_unique(ulong &nr1, ulong &nr2, String *str)
cs->coll->hash_sort(cs, (uchar *)str->ptr(), str->length(), &nr1, &nr2);
}
bool Item_func_hash::is_field_read_bitmap_set(Item *item)
{
Field *t_field;
if (item->type() == Item::FIELD_ITEM)
t_field= static_cast<Item_field *>(item)->field;
else
{
Item_func_left *fnc= static_cast<Item_func_left *>(item);
t_field= static_cast<Item_field *>(fnc->arguments()[0])->field;
}
if (bitmap_is_set(t_field->table->read_set, t_field->field_index))
return true;
return false;
}
longlong Item_func_hash::val_int()
{
DBUG_EXECUTE_IF("same_long_unique_hash", return 9;);
......@@ -1742,16 +1758,18 @@ longlong Item_func_hash::val_int()
String * str;
for(uint i= 0;i<arg_count;i++)
{
if(!is_field_read_bitmap_set(args[i]))
goto null_value;
str = args[i]->val_str();
if(args[i]->null_value)
{
null_value= 1;
return 0;
}
goto null_value;
calc_hash_for_unique(nr1, nr2, str);
}
null_value= 0;
return (longlong)nr1;
null_value:
null_value= 1;
return 0;
}
......
......@@ -1035,6 +1035,7 @@ class Item_func_hash: public Item_int_func
{}
longlong val_int();
bool fix_length_and_dec();
bool is_field_read_bitmap_set(Item *item);
const Type_handler *type_handler() const { return &type_handler_long; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_hash>(thd, this); }
......
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