Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
5e4044e9
Commit
5e4044e9
authored
Oct 04, 2013
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-5093, MDEV-5094:
- Make EXPLAIN {PARTITIONS,EXTENDED} {UPDATE,DELETE} work.
parent
6519ca51
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
8 deletions
+81
-8
mysql-test/r/explain_non_select.result
mysql-test/r/explain_non_select.result
+23
-0
mysql-test/t/explain_non_select.test
mysql-test/t/explain_non_select.test
+21
-0
sql/opt_qpf.cc
sql/opt_qpf.cc
+1
-1
sql/opt_qpf.h
sql/opt_qpf.h
+3
-0
sql/sql_delete.cc
sql/sql_delete.cc
+19
-2
sql/sql_select.cc
sql/sql_select.cc
+13
-4
sql/sql_select.h
sql/sql_select.h
+1
-1
No files found.
mysql-test/r/explain_non_select.result
View file @
5e4044e9
...
...
@@ -138,3 +138,26 @@ i i
0 0
9 9
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;
mysql-test/t/explain_non_select.test
View file @
5e4044e9
#
# MariaDB tests for EXPLAIN UPDATE/DELETE.
#
--
source
include
/
have_partition
.
inc
--
disable_warnings
drop
table
if
exists
t0
,
t1
;
--
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
);
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
;
sql/opt_qpf.cc
View file @
5e4044e9
...
...
@@ -796,7 +796,7 @@ int QPF_update::print_explain(QPF_query *query, select_result_sink *output,
1
,
/* id */
select_type
,
table_name
.
c_ptr
(),
// partitions
,
used_partitions_set
?
used_partitions
.
c_ptr
()
:
NULL
,
jtype
,
possible_keys_line
.
length
()
?
possible_keys_line
.
c_ptr
()
:
NULL
,
key_str
.
length
()
?
key_str
.
c_ptr
()
:
NULL
,
...
...
sql/opt_qpf.h
View file @
5e4044e9
...
...
@@ -454,6 +454,9 @@ public:
const
char
*
select_type
;
StringBuffer
<
32
>
used_partitions
;
bool
used_partitions_set
;
bool
impossible_where
;
StringBuffer
<
64
>
table_name
;
...
...
sql/sql_delete.cc
View file @
5e4044e9
...
...
@@ -40,7 +40,7 @@
#include "records.h" // init_read_record,
#include "sql_derived.h" // mysql_handle_list_of_derived
// end_read_record
#include "sql_partition.h" // make_used_partitions_str
/*
@brief
...
...
@@ -92,6 +92,23 @@ void Update_plan::save_qpf_intern(QPF_query *query, QPF_update *qpf)
select_lex
->
set_explain_type
(
TRUE
);
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 */
if
(
select
&&
select
->
quick
)
...
...
sql/sql_select.cc
View file @
5e4044e9
...
...
@@ -22331,7 +22331,7 @@ int print_explain_row(select_result_sink *result,
uint
select_number
,
const
char
*
select_type
,
const
char
*
table_name
,
//const char *partitions, (todo)
const
char
*
partitions
,
enum
join_type
jtype
,
const
char
*
possible_keys
,
const
char
*
index
,
...
...
@@ -22351,7 +22351,15 @@ int print_explain_row(select_result_sink *result,
item_list
.
push_back
(
new
Item_string
(
table_name
,
strlen
(
table_name
),
cs
));
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
];
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
,
MY_INT64_NUM_DECIMAL_DIGITS
));
/* 'filtered' */
const
double
filtered
=
100.0
;
if
(
options
&
DESCRIBE_EXTENDED
)
item_list
.
push_back
(
item_null
);
item_list
.
push_back
(
new
Item_float
(
filtered
,
2
)
);
/* 'Extra' */
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
)
{
uint
j
;
...
...
sql/sql_select.h
View file @
5e4044e9
...
...
@@ -1853,7 +1853,7 @@ int print_explain_row(select_result_sink *result,
uint
select_number
,
const
char
*
select_type
,
const
char
*
table_name
,
//const char *partitions, (todo)
const
char
*
partitions
,
enum
join_type
jtype
,
const
char
*
possible_keys
,
const
char
*
index
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment