mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 10:31:54 +01:00
MDEV-5093, MDEV-5094:
- Make EXPLAIN {PARTITIONS,EXTENDED} {UPDATE,DELETE} work.
This commit is contained in:
parent
6519ca51dd
commit
5e4044e92c
7 changed files with 81 additions and 8 deletions
|
@ -138,3 +138,26 @@ i i
|
||||||
0 0
|
0 0
|
||||||
9 9
|
9 9
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-5093, MDEV-5094: EXPLAIN PARTITIONS and EXPLAIN EXTENDED do not
|
||||||
|
# work for EXPLAIN UPDATE.
|
||||||
|
#
|
||||||
|
create table t1 (i int);
|
||||||
|
explain partitions update t1 set i = 3;
|
||||||
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 0
|
||||||
|
create table t2 (a int, b int) partition by hash(a) partitions 5;
|
||||||
|
insert into t2 values (0,0),(1,1),(2,2),(3,3),(4,4);
|
||||||
|
explain partitions update t2 set b=3 where a in (3,4);
|
||||||
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 2 Using where
|
||||||
|
explain partitions delete from t2 where a in (3,4);
|
||||||
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 2 Using where
|
||||||
|
explain extended update t2 set b=3 where a in (3,4);
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||||
|
explain extended delete from t2 where a in (3,4);
|
||||||
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
|
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||||
|
drop table t1,t2;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#
|
#
|
||||||
# MariaDB tests for EXPLAIN UPDATE/DELETE.
|
# MariaDB tests for EXPLAIN UPDATE/DELETE.
|
||||||
#
|
#
|
||||||
|
--source include/have_partition.inc
|
||||||
|
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
drop table if exists t0, t1;
|
drop table if exists t0, t1;
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
@ -115,3 +117,22 @@ INSERT INTO t1 VALUES (7),(0),(9);
|
||||||
SELECT * FROM t1 INNER JOIN ( SELECT DISTINCT * FROM t1 ) AS sq ON (sq.i = t1.i);
|
SELECT * FROM t1 INNER JOIN ( SELECT DISTINCT * FROM t1 ) AS sq ON (sq.i = t1.i);
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-5093, MDEV-5094: EXPLAIN PARTITIONS and EXPLAIN EXTENDED do not
|
||||||
|
--echo # work for EXPLAIN UPDATE.
|
||||||
|
--echo #
|
||||||
|
create table t1 (i int);
|
||||||
|
explain partitions update t1 set i = 3;
|
||||||
|
|
||||||
|
create table t2 (a int, b int) partition by hash(a) partitions 5;
|
||||||
|
insert into t2 values (0,0),(1,1),(2,2),(3,3),(4,4);
|
||||||
|
|
||||||
|
explain partitions update t2 set b=3 where a in (3,4);
|
||||||
|
explain partitions delete from t2 where a in (3,4);
|
||||||
|
|
||||||
|
explain extended update t2 set b=3 where a in (3,4);
|
||||||
|
explain extended delete from t2 where a in (3,4);
|
||||||
|
|
||||||
|
drop table t1,t2;
|
||||||
|
|
||||||
|
|
|
@ -796,7 +796,7 @@ int QPF_update::print_explain(QPF_query *query, select_result_sink *output,
|
||||||
1, /* id */
|
1, /* id */
|
||||||
select_type,
|
select_type,
|
||||||
table_name.c_ptr(),
|
table_name.c_ptr(),
|
||||||
// partitions,
|
used_partitions_set? used_partitions.c_ptr() : NULL,
|
||||||
jtype,
|
jtype,
|
||||||
possible_keys_line.length()? possible_keys_line.c_ptr(): NULL,
|
possible_keys_line.length()? possible_keys_line.c_ptr(): NULL,
|
||||||
key_str.length()? key_str.c_ptr() : NULL,
|
key_str.length()? key_str.c_ptr() : NULL,
|
||||||
|
|
|
@ -454,6 +454,9 @@ public:
|
||||||
|
|
||||||
const char *select_type;
|
const char *select_type;
|
||||||
|
|
||||||
|
StringBuffer<32> used_partitions;
|
||||||
|
bool used_partitions_set;
|
||||||
|
|
||||||
bool impossible_where;
|
bool impossible_where;
|
||||||
StringBuffer<64> table_name;
|
StringBuffer<64> table_name;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "records.h" // init_read_record,
|
#include "records.h" // init_read_record,
|
||||||
#include "sql_derived.h" // mysql_handle_list_of_derived
|
#include "sql_derived.h" // mysql_handle_list_of_derived
|
||||||
// end_read_record
|
// end_read_record
|
||||||
|
#include "sql_partition.h" // make_used_partitions_str
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@brief
|
@brief
|
||||||
|
@ -92,7 +92,24 @@ void Update_plan::save_qpf_intern(QPF_query *query, QPF_update *qpf)
|
||||||
|
|
||||||
select_lex->set_explain_type(TRUE);
|
select_lex->set_explain_type(TRUE);
|
||||||
qpf->select_type= select_lex->type;
|
qpf->select_type= select_lex->type;
|
||||||
|
/* Partitions */
|
||||||
|
{
|
||||||
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
|
partition_info *part_info;
|
||||||
|
if ((part_info= table->part_info))
|
||||||
|
{
|
||||||
|
make_used_partitions_str(part_info, &qpf->used_partitions);
|
||||||
|
qpf->used_partitions_set= true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qpf->used_partitions_set= false;
|
||||||
|
#else
|
||||||
|
/* just produce empty column if partitioning is not compiled in */
|
||||||
|
qpf->used_partitions_set= false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Set jtype */
|
/* Set jtype */
|
||||||
if (select && select->quick)
|
if (select && select->quick)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22331,7 +22331,7 @@ int print_explain_row(select_result_sink *result,
|
||||||
uint select_number,
|
uint select_number,
|
||||||
const char *select_type,
|
const char *select_type,
|
||||||
const char *table_name,
|
const char *table_name,
|
||||||
//const char *partitions, (todo)
|
const char *partitions,
|
||||||
enum join_type jtype,
|
enum join_type jtype,
|
||||||
const char *possible_keys,
|
const char *possible_keys,
|
||||||
const char *index,
|
const char *index,
|
||||||
|
@ -22351,7 +22351,15 @@ int print_explain_row(select_result_sink *result,
|
||||||
item_list.push_back(new Item_string(table_name,
|
item_list.push_back(new Item_string(table_name,
|
||||||
strlen(table_name), cs));
|
strlen(table_name), cs));
|
||||||
if (options & DESCRIBE_PARTITIONS)
|
if (options & DESCRIBE_PARTITIONS)
|
||||||
item_list.push_back(item_null); // psergey-todo: produce proper value
|
{
|
||||||
|
if (partitions)
|
||||||
|
{
|
||||||
|
item_list.push_back(new Item_string(partitions,
|
||||||
|
strlen(partitions), cs));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
item_list.push_back(item_null);
|
||||||
|
}
|
||||||
|
|
||||||
const char *jtype_str= join_type_str[jtype];
|
const char *jtype_str= join_type_str[jtype];
|
||||||
item_list.push_back(new Item_string(jtype_str,
|
item_list.push_back(new Item_string(jtype_str,
|
||||||
|
@ -22377,8 +22385,9 @@ int print_explain_row(select_result_sink *result,
|
||||||
item_list.push_back(new Item_int(rows,
|
item_list.push_back(new Item_int(rows,
|
||||||
MY_INT64_NUM_DECIMAL_DIGITS));
|
MY_INT64_NUM_DECIMAL_DIGITS));
|
||||||
/* 'filtered' */
|
/* 'filtered' */
|
||||||
|
const double filtered=100.0;
|
||||||
if (options & DESCRIBE_EXTENDED)
|
if (options & DESCRIBE_EXTENDED)
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(new Item_float(filtered, 2));
|
||||||
|
|
||||||
/* 'Extra' */
|
/* 'Extra' */
|
||||||
item_list.push_back(new Item_string(extra, strlen(extra), cs));
|
item_list.push_back(new Item_string(extra, strlen(extra), cs));
|
||||||
|
@ -22489,7 +22498,7 @@ void explain_append_mrr_info(QUICK_RANGE_SELECT *quick, String *res)
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// TODO: join with make_possible_keys_line ?
|
||||||
void append_possible_keys(String *str, TABLE *table, key_map possible_keys)
|
void append_possible_keys(String *str, TABLE *table, key_map possible_keys)
|
||||||
{
|
{
|
||||||
uint j;
|
uint j;
|
||||||
|
|
|
@ -1853,7 +1853,7 @@ int print_explain_row(select_result_sink *result,
|
||||||
uint select_number,
|
uint select_number,
|
||||||
const char *select_type,
|
const char *select_type,
|
||||||
const char *table_name,
|
const char *table_name,
|
||||||
//const char *partitions, (todo)
|
const char *partitions,
|
||||||
enum join_type jtype,
|
enum join_type jtype,
|
||||||
const char *possible_keys,
|
const char *possible_keys,
|
||||||
const char *index,
|
const char *index,
|
||||||
|
|
Loading…
Add table
Reference in a new issue