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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8d26e836
Commit
8d26e836
authored
Mar 23, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B26186-5.0-opt
parents
a27ddd70
ff716a3e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
16 deletions
+48
-16
mysql-test/r/delete.result
mysql-test/r/delete.result
+9
-0
mysql-test/t/delete.test
mysql-test/t/delete.test
+18
-0
sql/sql_delete.cc
sql/sql_delete.cc
+21
-16
No files found.
mysql-test/r/delete.result
View file @
8d26e836
...
...
@@ -214,3 +214,12 @@ select count(*) from t1;
count(*)
0
drop table t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
DELETE FROM t1 ORDER BY x;
ERROR 42S22: Unknown column 'x' in 'order clause'
DELETE FROM t1 ORDER BY t2.x;
ERROR 42S22: Unknown column 't2.x' in 'order clause'
DELETE FROM t1 ORDER BY (SELECT x);
ERROR 42S22: Unknown column 'x' in 'field list'
DROP TABLE t1;
mysql-test/t/delete.test
View file @
8d26e836
...
...
@@ -203,3 +203,21 @@ select * from t1 where a is null;
delete
from
t1
where
a
is
null
;
select
count
(
*
)
from
t1
;
drop
table
t1
;
#
# Bug #26186: delete order by, sometimes accept unknown column
#
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
);
--
error
ER_BAD_FIELD_ERROR
DELETE
FROM
t1
ORDER
BY
x
;
# even columns from a table not used in query (and not even existing)
--
error
ER_BAD_FIELD_ERROR
DELETE
FROM
t1
ORDER
BY
t2
.
x
;
# subquery (as long as the subquery from is valid or DUAL)
--
error
ER_BAD_FIELD_ERROR
DELETE
FROM
t1
ORDER
BY
(
SELECT
x
);
DROP
TABLE
t1
;
sql/sql_delete.cc
View file @
8d26e836
...
...
@@ -60,6 +60,27 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if
(
mysql_prepare_delete
(
thd
,
table_list
,
&
conds
))
DBUG_RETURN
(
TRUE
);
/* check ORDER BY even if it can be ignored */
if
(
order
&&
order
->
elements
)
{
TABLE_LIST
tables
;
List
<
Item
>
fields
;
List
<
Item
>
all_fields
;
bzero
((
char
*
)
&
tables
,
sizeof
(
tables
));
tables
.
table
=
table
;
tables
.
alias
=
table_list
->
alias
;
if
(
select_lex
->
setup_ref_array
(
thd
,
order
->
elements
)
||
setup_order
(
thd
,
select_lex
->
ref_pointer_array
,
&
tables
,
fields
,
all_fields
,
(
ORDER
*
)
order
->
first
))
{
delete
select
;
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
TRUE
);
}
}
const_cond
=
(
!
conds
||
conds
->
const_item
());
safe_update
=
test
(
thd
->
options
&
OPTION_SAFE_UPDATES
);
if
(
safe_update
&&
const_cond
)
...
...
@@ -148,24 +169,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
uint
length
=
0
;
SORT_FIELD
*
sortorder
;
TABLE_LIST
tables
;
List
<
Item
>
fields
;
List
<
Item
>
all_fields
;
ha_rows
examined_rows
;
bzero
((
char
*
)
&
tables
,
sizeof
(
tables
));
tables
.
table
=
table
;
tables
.
alias
=
table_list
->
alias
;
if
(
select_lex
->
setup_ref_array
(
thd
,
order
->
elements
)
||
setup_order
(
thd
,
select_lex
->
ref_pointer_array
,
&
tables
,
fields
,
all_fields
,
(
ORDER
*
)
order
->
first
))
{
delete
select
;
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
TRUE
);
}
if
((
!
select
||
table
->
quick_keys
.
is_clear_all
())
&&
limit
!=
HA_POS_ERROR
)
usable_index
=
get_index_for_order
(
table
,
(
ORDER
*
)(
order
->
first
),
limit
);
...
...
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