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
a787edd7
Commit
a787edd7
authored
Jun 26, 2014
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6395: Make ANALYZE UPDATE/DELETE handle the degenerate query plans.
parent
12d6f89b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
27 deletions
+67
-27
mysql-test/r/analyze_stmt.result
mysql-test/r/analyze_stmt.result
+19
-1
mysql-test/t/analyze_stmt.test
mysql-test/t/analyze_stmt.test
+15
-2
sql/sql_delete.cc
sql/sql_delete.cc
+21
-16
sql/sql_update.cc
sql/sql_update.cc
+12
-8
No files found.
mysql-test/r/analyze_stmt.result
View file @
a787edd7
...
...
@@ -214,4 +214,22 @@ analyze update t2,t1 set t2.i=5 where t2.a=t1.a;
ERROR 42S22: Unknown column 't2.a' in 'where clause'
analyze delete t1 from t2,t1 where t2.a=t1.a;
ERROR 42S22: Unknown column 't2.a' in 'where clause'
drop table t1,t2;
drop table t1, t2;
#
# MDEV-6395: ANALYZE UPDATE/DELETE with impossible where does not produce any output
#
create table t1 (a int, b int, key(a));
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
analyze delete from t1 where 1 > 2;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
analyze delete from t1 where a > 30 and a < 10;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
analyze update t1 set b=12345 where 1 > 2;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
analyze update t1 set b=12345 where a > 30 and a < 10;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
drop table t1;
mysql-test/t/analyze_stmt.test
View file @
a787edd7
#
# Tests for "ANALYZE $statement" feature
(PostgreSQL's analog is called EXPLAIN ANALYZE)
# Tests for "ANALYZE $statement" feature
#
--
disable_warnings
drop
table
if
exists
t0
,
t1
,
t2
,
t3
;
...
...
@@ -169,5 +169,18 @@ analyze update t2,t1 set t2.i=5 where t2.a=t1.a;
--
error
ER_BAD_FIELD_ERROR
analyze
delete
t1
from
t2
,
t1
where
t2
.
a
=
t1
.
a
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# MDEV-6395: ANALYZE UPDATE/DELETE with impossible where does not produce any output
--
echo
#
create
table
t1
(
a
int
,
b
int
,
key
(
a
));
insert
into
t1
values
(
1
,
1
),(
2
,
2
),(
3
,
3
),(
4
,
4
),(
5
,
5
);
analyze
delete
from
t1
where
1
>
2
;
analyze
delete
from
t1
where
a
>
30
and
a
<
10
;
analyze
update
t1
set
b
=
12345
where
1
>
2
;
analyze
update
t1
set
b
=
12345
where
a
>
30
and
a
<
10
;
drop
table
t1
;
sql/sql_delete.cc
View file @
a787edd7
...
...
@@ -281,7 +281,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
setup_order
(
thd
,
select_lex
->
ref_pointer_array
,
&
tables
,
fields
,
all_fields
,
order
))
{
delete
select
;
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
TRUE
);
}
...
...
@@ -332,8 +331,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_PRINT
(
"debug"
,
(
"Trying to use delete_all_rows()"
));
query_plan
.
set_delete_all_rows
(
maybe_deleted
);
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
if
(
!
(
error
=
table
->
file
->
ha_delete_all_rows
()))
{
...
...
@@ -362,8 +361,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
limit
=
0
;
query_plan
.
set_impossible_where
();
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
}
}
...
...
@@ -373,8 +372,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
free_underlaid_joins
(
thd
,
select_lex
);
query_plan
.
set_no_partitions
();
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
my_ok
(
thd
,
0
);
DBUG_RETURN
(
0
);
...
...
@@ -393,8 +392,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if
((
select
&&
select
->
check_quick
(
thd
,
safe_update
,
limit
))
||
!
limit
)
{
query_plan
.
set_impossible_where
();
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
delete
select
;
free_underlaid_joins
(
thd
,
select_lex
);
...
...
@@ -458,7 +457,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
- otherwise, execute the query plan
*/
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
goto
produce_explain_and_leave
;
query_plan
.
save_explain_data
(
thd
->
lex
->
explain
);
...
...
@@ -634,6 +633,7 @@ cleanup:
}
delete
select
;
select
=
NULL
;
transactional_table
=
table
->
file
->
has_transactions
();
if
(
!
transactional_table
&&
deleted
>
0
)
...
...
@@ -669,12 +669,11 @@ cleanup:
}
}
DBUG_ASSERT
(
transactional_table
||
!
deleted
||
thd
->
transaction
.
stmt
.
modified_non_trans_table
);
free_underlaid_joins
(
thd
,
select_lex
);
if
(
thd
->
lex
->
analyze_stmt
)
{
error
=
thd
->
lex
->
explain
->
send_explain
(
thd
);
}
else
goto
emit_explain_and_leave
;
free_underlaid_joins
(
thd
,
select_lex
);
if
(
error
<
0
||
(
thd
->
lex
->
ignore
&&
!
thd
->
is_error
()
&&
!
thd
->
is_fatal_error
))
{
...
...
@@ -687,8 +686,14 @@ cleanup:
DBUG_RETURN
(
error
>=
0
||
thd
->
is_error
());
/* Special exits */
exit_without_my_ok:
produce_explain_and_leave:
/*
We come here for various "degenerate" query plans: impossible WHERE,
no-partitions-used, impossible-range, etc.
*/
query_plan
.
save_explain_data
(
thd
->
lex
->
explain
);
emit_explain_and_leave:
int
err2
=
thd
->
lex
->
explain
->
send_explain
(
thd
);
delete
select
;
...
...
sql/sql_update.cc
View file @
a787edd7
...
...
@@ -382,8 +382,8 @@ int mysql_update(THD *thd,
{
limit
=
0
;
// Impossible WHERE
query_plan
.
set_impossible_where
();
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
}
}
...
...
@@ -404,8 +404,8 @@ int mysql_update(THD *thd,
free_underlaid_joins
(
thd
,
select_lex
);
query_plan
.
set_no_partitions
();
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
my_ok
(
thd
);
// No matching records
DBUG_RETURN
(
0
);
...
...
@@ -420,8 +420,8 @@ int mysql_update(THD *thd,
(
select
&&
select
->
check_quick
(
thd
,
safe_update
,
limit
)))
{
query_plan
.
set_impossible_where
();
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
if
(
thd
->
lex
->
describe
||
thd
->
lex
->
analyze_stmt
)
goto
produce_explain_and_leave
;
delete
select
;
free_underlaid_joins
(
thd
,
select_lex
);
...
...
@@ -516,7 +516,7 @@ int mysql_update(THD *thd,
- otherwise, execute the query plan
*/
if
(
thd
->
lex
->
describe
)
goto
exit_without_my_ok
;
goto
produce_explain_and_leave
;
query_plan
.
save_explain_data
(
thd
->
lex
->
explain
);
DBUG_EXECUTE_IF
(
"show_explain_probe_update_exec_start"
,
...
...
@@ -1029,7 +1029,11 @@ err:
thd
->
abort_on_warning
=
0
;
DBUG_RETURN
(
1
);
exit_without_my_ok:
produce_explain_and_leave:
/*
We come here for various "degenerate" query plans: impossible WHERE,
no-partitions-used, impossible-range, etc.
*/
query_plan
.
save_explain_data
(
thd
->
lex
->
explain
);
int
err2
=
thd
->
lex
->
explain
->
send_explain
(
thd
);
...
...
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