mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon collecting stats for RocksDB table
Apply patch by Oleksandr Byelkin: Do not use "only index read" in analyzing indices if there is a field which present in the index only partially.
This commit is contained in:
@ -1801,6 +1801,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
bool is_single_comp_pk;
|
bool is_single_comp_pk;
|
||||||
|
bool is_partial_fields_present;
|
||||||
|
|
||||||
Index_prefix_calc(THD *thd, TABLE *table, KEY *key_info)
|
Index_prefix_calc(THD *thd, TABLE *table, KEY *key_info)
|
||||||
: index_table(table), index_info(key_info)
|
: index_table(table), index_info(key_info)
|
||||||
@ -1812,7 +1813,7 @@ public:
|
|||||||
prefixes= 0;
|
prefixes= 0;
|
||||||
LINT_INIT_STRUCT(calc_state);
|
LINT_INIT_STRUCT(calc_state);
|
||||||
|
|
||||||
is_single_comp_pk= FALSE;
|
is_partial_fields_present= is_single_comp_pk= FALSE;
|
||||||
uint pk= table->s->primary_key;
|
uint pk= table->s->primary_key;
|
||||||
if ((uint) (table->key_info - key_info) == pk &&
|
if ((uint) (table->key_info - key_info) == pk &&
|
||||||
table->key_info[pk].user_defined_key_parts == 1)
|
table->key_info[pk].user_defined_key_parts == 1)
|
||||||
@ -1834,7 +1835,10 @@ public:
|
|||||||
calculating the values of 'avg_frequency' for prefixes.
|
calculating the values of 'avg_frequency' for prefixes.
|
||||||
*/
|
*/
|
||||||
if (!key_info->key_part[i].field->part_of_key.is_set(keyno))
|
if (!key_info->key_part[i].field->part_of_key.is_set(keyno))
|
||||||
|
{
|
||||||
|
is_partial_fields_present= TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(state->last_prefix=
|
if (!(state->last_prefix=
|
||||||
new (thd->mem_root) Cached_item_field(thd,
|
new (thd->mem_root) Cached_item_field(thd,
|
||||||
@ -2633,7 +2637,13 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
|
|||||||
DBUG_RETURN(rc);
|
DBUG_RETURN(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
table->file->ha_start_keyread(index);
|
/*
|
||||||
|
Request "only index read" in case of absence of fields which are
|
||||||
|
partially in the index to avoid problems with partitioning (for example)
|
||||||
|
which want to get whole field value.
|
||||||
|
*/
|
||||||
|
if (!index_prefix_calc.is_partial_fields_present)
|
||||||
|
table->file->ha_start_keyread(index);
|
||||||
table->file->ha_index_init(index, TRUE);
|
table->file->ha_index_init(index, TRUE);
|
||||||
rc= table->file->ha_index_first(table->record[0]);
|
rc= table->file->ha_index_first(table->record[0]);
|
||||||
while (rc != HA_ERR_END_OF_FILE)
|
while (rc != HA_ERR_END_OF_FILE)
|
||||||
|
@ -27,3 +27,29 @@ ANALYZE TABLE t1;
|
|||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 analyze status OK
|
test.t1 analyze status OK
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon
|
||||||
|
# collecting stats for RocksDB table
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
pk INT,
|
||||||
|
f1 CHAR(255),
|
||||||
|
f2 TEXT,
|
||||||
|
f3 VARCHAR(255),
|
||||||
|
f4 TEXT,
|
||||||
|
PRIMARY KEY (pk),
|
||||||
|
KEY (f4(255))
|
||||||
|
) ENGINE=RocksDB
|
||||||
|
CHARSET utf8
|
||||||
|
COLLATE utf8_bin
|
||||||
|
PARTITION BY KEY (pk) PARTITIONS 2;
|
||||||
|
INSERT INTO t1 VALUES
|
||||||
|
(1,'foo','bar','foo','bar'), (2,'bar','foo','bar','foo');
|
||||||
|
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 'f2'
|
||||||
|
test.t1 analyze Warning Engine-independent statistics are not collected for column 'f4'
|
||||||
|
test.t1 analyze status OK
|
||||||
|
drop table t1;
|
||||||
|
# End of 10.2 tests
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
--source include/have_rocksdb.inc
|
--source include/have_rocksdb.inc
|
||||||
|
--source include/have_partition.inc
|
||||||
|
|
||||||
#
|
#
|
||||||
# ANALYZE TABLE statements
|
# ANALYZE TABLE statements
|
||||||
@ -29,3 +30,28 @@ INSERT INTO t1 VALUES (5,8),(6,10),(7,11),(8,12);
|
|||||||
ANALYZE TABLE t1;
|
ANALYZE TABLE t1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon
|
||||||
|
--echo # collecting stats for RocksDB table
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
pk INT,
|
||||||
|
f1 CHAR(255),
|
||||||
|
f2 TEXT,
|
||||||
|
f3 VARCHAR(255),
|
||||||
|
f4 TEXT,
|
||||||
|
PRIMARY KEY (pk),
|
||||||
|
KEY (f4(255))
|
||||||
|
) ENGINE=RocksDB
|
||||||
|
CHARSET utf8
|
||||||
|
COLLATE utf8_bin
|
||||||
|
PARTITION BY KEY (pk) PARTITIONS 2;
|
||||||
|
INSERT INTO t1 VALUES
|
||||||
|
(1,'foo','bar','foo','bar'), (2,'bar','foo','bar','foo');
|
||||||
|
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR ALL;
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
--echo # End of 10.2 tests
|
||||||
|
Reference in New Issue
Block a user