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
c6b48c6f
Commit
c6b48c6f
authored
Dec 01, 2002
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix of error handling
parent
2ccb0eeb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
20 deletions
+74
-20
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+20
-2
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+20
-2
sql/sql_delete.cc
sql/sql_delete.cc
+5
-3
sql/sql_insert.cc
sql/sql_insert.cc
+7
-6
sql/sql_parse.cc
sql/sql_parse.cc
+12
-0
sql/sql_union.cc
sql/sql_union.cc
+1
-1
sql/sql_update.cc
sql/sql_update.cc
+9
-6
No files found.
mysql-test/r/subselect.result
View file @
c6b48c6f
...
...
@@ -413,6 +413,8 @@ a b
2 12
update t1 set b= (select b from t1);
INSERT TABLE 't1' isn't allowed in FROM table list
update t1 set b= (select b from t2);
Subselect returns more than 1 record
update t1 set b= (select b from t2 where t1.a = t2.a);
select * from t1;
a b
...
...
@@ -434,6 +436,8 @@ a b
2 12
delete from t1 where b = (select b from t1);
INSERT TABLE 't1' isn't allowed in FROM table list
delete from t1 where b = (select b from t2);
Subselect returns more than 1 record
delete from t1 where b = (select b from t2 where t1.a = t2.a);
select * from t1;
a b
...
...
@@ -459,6 +463,8 @@ a b
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
INSERT TABLE 't12' isn't allowed in FROM table list
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
Subselect returns more than 1 record
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
select * from t11;
a b
...
...
@@ -471,9 +477,13 @@ a b
drop table t11, t12, t2;
CREATE TABLE t1 (x int);
create table t2 (a int);
create table t3 (a int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
INSERT TABLE 't1' isn't allowed in FROM table list
INSERT INTO t1 (x) VALUES ((SELECT a FROM t3));
Subselect returns more than 1 record
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1;
x
...
...
@@ -501,14 +511,18 @@ x
3
3
0
drop table t1, t2;
drop table t1, t2
, t3
;
CREATE TABLE t1 (x int not null, y int, primary key (x));
create table t2 (a int);
create table t3 (a int);
insert into t2 values (1);
insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
INSERT TABLE 't1' isn't allowed in FROM table list
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
Subselect returns more than 1 record
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
select * from t1;
x y
...
...
@@ -533,7 +547,7 @@ x y
1 3
4 2
2 1
drop table t1, t2;
drop table t1, t2
, t3
;
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT *);
No tables used
drop table if exists t;
...
...
@@ -575,4 +589,8 @@ SELECT * FROM t;
id
1
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1);
UPDATE t SET id=(SELECT * FROM t1);
Subselect returns more than 1 record
drop table t;
mysql-test/t/subselect.test
View file @
c6b48c6f
...
...
@@ -247,6 +247,8 @@ insert into t2 values (1, 21),(2, 22),(3, 23);
select
*
from
t1
;
--
error
1093
update
t1
set
b
=
(
select
b
from
t1
);
--
error
1240
update
t1
set
b
=
(
select
b
from
t2
);
update
t1
set
b
=
(
select
b
from
t2
where
t1
.
a
=
t2
.
a
);
select
*
from
t1
;
drop
table
t1
,
t2
;
...
...
@@ -260,6 +262,8 @@ select * from t1;
select
*
from
t1
where
b
=
(
select
b
from
t2
where
t1
.
a
=
t2
.
a
);
--
error
1093
delete
from
t1
where
b
=
(
select
b
from
t1
);
--
error
1240
delete
from
t1
where
b
=
(
select
b
from
t2
);
delete
from
t1
where
b
=
(
select
b
from
t2
where
t1
.
a
=
t2
.
a
);
select
*
from
t1
;
drop
table
t1
,
t2
;
...
...
@@ -276,6 +280,8 @@ select * from t11;
select
*
from
t12
;
--
error
1093
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t12
where
t11
.
a
=
t12
.
a
);
--
error
1240
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t2
);
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t2
where
t11
.
a
=
t2
.
a
);
select
*
from
t11
;
select
*
from
t12
;
...
...
@@ -284,9 +290,13 @@ drop table t11, t12, t2;
#insert with subselects
CREATE
TABLE
t1
(
x
int
);
create
table
t2
(
a
int
);
create
table
t3
(
a
int
);
insert
into
t2
values
(
1
);
insert
into
t3
values
(
1
),(
2
);
--
error
1093
INSERT
INTO
t1
(
x
)
VALUES
((
SELECT
x
FROM
t1
));
--
error
1240
INSERT
INTO
t1
(
x
)
VALUES
((
SELECT
a
FROM
t3
));
INSERT
INTO
t1
(
x
)
VALUES
((
SELECT
a
FROM
t2
));
select
*
from
t1
;
insert
into
t2
values
(
1
);
...
...
@@ -300,15 +310,19 @@ INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
INSERT
DELAYED
INTO
t1
(
x
)
VALUES
((
SELECT
SUM
(
x
)
FROM
t2
));
--
sleep
1
select
*
from
t1
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
,
t3
;
#replace with subselects
CREATE
TABLE
t1
(
x
int
not
null
,
y
int
,
primary
key
(
x
));
create
table
t2
(
a
int
);
create
table
t3
(
a
int
);
insert
into
t2
values
(
1
);
insert
into
t3
values
(
1
),(
2
);
select
*
from
t1
;
--
error
1093
replace
into
t1
(
x
,
y
)
VALUES
((
SELECT
x
FROM
t1
),
(
SELECT
a
+
1
FROM
t2
));
--
error
1240
replace
into
t1
(
x
,
y
)
VALUES
((
SELECT
a
FROM
t3
),
(
SELECT
a
+
1
FROM
t2
));
replace
into
t1
(
x
,
y
)
VALUES
((
SELECT
a
FROM
t2
),
(
SELECT
a
+
1
FROM
t2
));
select
*
from
t1
;
replace
into
t1
(
x
,
y
)
VALUES
((
SELECT
a
FROM
t2
),
(
SELECT
a
+
2
FROM
t2
));
...
...
@@ -321,7 +335,7 @@ replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2
select
*
from
t1
;
replace
LOW_PRIORITY
into
t1
(
x
,
y
)
VALUES
((
SELECT
a
+
1
FROM
t2
),
(
SELECT
a
FROM
t2
));
select
*
from
t1
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
,
t3
;
--
error
1096
SELECT
*
FROM
(
SELECT
1
)
WHERE
1
IN
(
SELECT
*
);
...
...
@@ -339,4 +353,8 @@ SELECT * FROM t WHERE id IN (SELECT 5 UNION SELECT 2);
--
error
1093
INSERT
INTO
t
VALUES
((
SELECT
*
FROM
t
));
SELECT
*
FROM
t
;
CREATE
TABLE
t1
(
id
int
(
11
)
default
NULL
,
KEY
id
(
id
))
TYPE
=
MyISAM
CHARSET
=
latin1
;
INSERT
INTO
t1
values
(
1
),(
1
);
--
error
1240
UPDATE
t
SET
id
=
(
SELECT
*
FROM
t1
);
drop
table
t
;
sql/sql_delete.cc
View file @
c6b48c6f
...
...
@@ -140,9 +140,11 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
deleted
=
0L
;
init_ftfuncs
(
thd
,
&
thd
->
lex
.
select_lex
,
1
);
thd
->
proc_info
=
"updating"
;
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
)
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
&&
!
thd
->
net
.
report_error
)
{
if
(
!
(
select
&&
select
->
skipp_record
()))
// thd->net.report_error is tested to disallow delete row on error
if
(
!
(
select
&&
select
->
skipp_record
())
&&
!
thd
->
net
.
report_error
)
{
if
(
!
(
error
=
table
->
file
->
delete_row
(
table
->
record
[
0
])))
{
...
...
@@ -205,7 +207,7 @@ cleanup:
thd
->
lock
=
0
;
}
delete
select
;
if
(
error
>=
0
)
// Fatal error
if
(
error
>=
0
||
thd
->
net
.
report_error
)
send_error
(
thd
,
thd
->
killed
?
ER_SERVER_SHUTDOWN
:
0
);
else
{
...
...
sql/sql_insert.cc
View file @
c6b48c6f
...
...
@@ -235,9 +235,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
if
(
fields
.
elements
||
!
value_count
)
{
restore_record
(
table
,
2
);
// Get empty record
if
(
fill_record
(
fields
,
*
values
)
||
check_null_fields
(
thd
,
table
))
if
(
fill_record
(
fields
,
*
values
)
||
thd
->
net
.
report_error
||
check_null_fields
(
thd
,
table
))
{
if
(
values_list
.
elements
!=
1
)
if
(
values_list
.
elements
!=
1
&&
!
thd
->
net
.
report_error
)
{
info
.
records
++
;
continue
;
...
...
@@ -252,9 +253,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
restore_record
(
table
,
2
);
// Get empty record
else
table
->
record
[
0
][
0
]
=
table
->
record
[
2
][
0
];
// Fix delete marker
if
(
fill_record
(
table
->
field
,
*
values
))
if
(
fill_record
(
table
->
field
,
*
values
)
||
thd
->
net
.
report_error
)
{
if
(
values_list
.
elements
!=
1
)
if
(
values_list
.
elements
!=
1
&&
!
thd
->
net
.
report_error
)
{
info
.
records
++
;
continue
;
...
...
@@ -1349,7 +1350,7 @@ bool select_insert::send_data(List<Item> &values)
fill_record
(
*
fields
,
values
);
else
fill_record
(
table
->
field
,
values
);
if
(
write_record
(
table
,
&
info
))
if
(
thd
->
net
.
report_error
||
write_record
(
table
,
&
info
))
return
1
;
if
(
table
->
next_number_field
)
// Clear for next record
{
...
...
@@ -1463,7 +1464,7 @@ bool select_create::send_data(List<Item> &values)
return
0
;
}
fill_record
(
field
,
values
);
if
(
write_record
(
table
,
&
info
))
if
(
thd
->
net
.
report_error
||
write_record
(
table
,
&
info
))
return
1
;
if
(
table
->
next_number_field
)
// Clear for next record
{
...
...
sql/sql_parse.cc
View file @
c6b48c6f
...
...
@@ -1900,6 +1900,8 @@ mysql_execute_command(THD *thd)
(
ORDER
*
)
select_lex
->
order_list
.
first
,
select_lex
->
select_limit
,
lex
->
duplicates
);
if
(
thd
->
net
.
report_error
)
res
=
-
1
;
break
;
case
SQLCOM_UPDATE_MULTI
:
if
(
check_access
(
thd
,
UPDATE_ACL
,
tables
->
db
,
&
tables
->
grant
.
privilege
))
...
...
@@ -1959,6 +1961,8 @@ mysql_execute_command(THD *thd)
SELECT_NO_JOIN_CACHE
,
result
,
unit
,
select_lex
,
0
);
delete
result
;
if
(
thd
->
net
.
report_error
)
res
=
-
1
;
}
else
res
=
-
1
;
// Error is not sent
...
...
@@ -1976,6 +1980,8 @@ mysql_execute_command(THD *thd)
goto
error
;
res
=
mysql_insert
(
thd
,
tables
,
lex
->
field_list
,
lex
->
many_values
,
lex
->
duplicates
);
if
(
thd
->
net
.
report_error
)
res
=
-
1
;
break
;
}
case
SQLCOM_REPLACE_SELECT
:
...
...
@@ -2020,6 +2026,8 @@ mysql_execute_command(THD *thd)
if
((
result
=
new
select_insert
(
tables
->
table
,
&
lex
->
field_list
,
lex
->
duplicates
)))
res
=
handle_select
(
thd
,
lex
,
result
);
if
(
thd
->
net
.
report_error
)
res
=
-
1
;
}
else
res
=
-
1
;
...
...
@@ -2050,6 +2058,8 @@ mysql_execute_command(THD *thd)
res
=
mysql_delete
(
thd
,
tables
,
select_lex
->
where
,
(
ORDER
*
)
select_lex
->
order_list
.
first
,
select_lex
->
select_limit
,
select_lex
->
options
);
if
(
thd
->
net
.
report_error
)
res
=
-
1
;
break
;
}
case
SQLCOM_DELETE_MULTI
:
...
...
@@ -2122,6 +2132,8 @@ mysql_execute_command(THD *thd)
select_lex
->
options
|
thd
->
options
|
SELECT_NO_JOIN_CACHE
,
result
,
unit
,
select_lex
,
0
);
if
(
thd
->
net
.
report_error
)
res
=
-
1
;
delete
result
;
}
else
...
...
sql/sql_union.cc
View file @
c6b48c6f
...
...
@@ -76,7 +76,7 @@ bool select_union::send_data(List<Item> &values)
return
0
;
}
fill_record
(
table
->
field
,
values
);
if
(
(
write_record
(
table
,
&
info
)
))
if
(
thd
->
net
.
report_error
||
write_record
(
table
,
&
info
))
{
if
(
thd
->
net
.
last_errno
==
ER_RECORD_FILE_FULL
)
{
...
...
sql/sql_update.cc
View file @
c6b48c6f
...
...
@@ -281,7 +281,7 @@ int mysql_update(THD *thd,
if
(
!
(
select
&&
select
->
skipp_record
()))
{
store_record
(
table
,
1
);
if
(
fill_record
(
fields
,
values
))
if
(
fill_record
(
fields
,
values
)
||
thd
->
net
.
report_error
)
break
;
/* purecov: inspected */
found
++
;
if
(
compare_record
(
table
,
query_id
))
...
...
@@ -605,7 +605,7 @@ bool multi_update::send_data(List<Item> &values)
// Only one table being updated receives a completely different treatment
table
->
status
|=
STATUS_UPDATED
;
store_record
(
table
,
1
);
if
(
fill_record
(
fields
,
real_values
))
if
(
fill_record
(
fields
,
real_values
)
||
thd
->
net
.
report_error
)
return
1
;
found
++
;
if
(
/* compare_record(table, query_id) && */
...
...
@@ -644,7 +644,8 @@ bool multi_update::send_data(List<Item> &values)
{
table
->
status
|=
STATUS_UPDATED
;
store_record
(
table
,
1
);
if
(
fill_record
(
*
fields_by_tables
[
0
],
values_by_table
))
if
(
fill_record
(
*
fields_by_tables
[
0
],
values_by_table
)
||
thd
->
net
.
report_error
)
return
1
;
found
++
;
if
(
/*compare_record(table, query_id) && */
...
...
@@ -667,8 +668,8 @@ bool multi_update::send_data(List<Item> &values)
table
->
file
->
ref_length
,
system_charset_info
));
fill_record
(
tmp_tables
[
secure_counter
]
->
field
,
values_by_table
);
error
=
write_record
(
tmp_tables
[
secure_counter
],
&
(
infos
[
secure_counter
]));
error
=
thd
->
net
.
report_error
||
write_record
(
tmp_tables
[
secure_counter
],
&
(
infos
[
secure_counter
]));
if
(
error
)
{
error
=-
1
;
...
...
@@ -774,8 +775,10 @@ int multi_update::do_updates (bool from_send_error)
table
->
status
|=
STATUS_UPDATED
;
store_record
(
table
,
1
);
local_error
=
(
fill_record
(
*
fields_by_tables
[
counter
+
1
],
list
)
||
thd
->
net
.
report_error
||
/* compare_record(table, query_id) || */
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
]));
table
->
file
->
update_row
(
table
->
record
[
1
],
table
->
record
[
0
]));
if
(
local_error
)
{
table
->
file
->
print_error
(
local_error
,
MYF
(
0
));
...
...
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