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
b535307c
Commit
b535307c
authored
Jun 26, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into dl145s.mysql.com:/dev/shm/mhansson/my51-bug28677
parents
a0fa27cf
25f08443
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
54 deletions
+91
-54
mysql-test/r/errors.result
mysql-test/r/errors.result
+14
-0
mysql-test/t/errors.test
mysql-test/t/errors.test
+13
-0
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sql_insert.cc
sql/sql_insert.cc
+62
-50
sql/sql_select.cc
sql/sql_select.cc
+1
-4
No files found.
mysql-test/r/errors.result
View file @
b535307c
...
...
@@ -41,3 +41,17 @@ SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
a
1
DROP TABLE t1;
CREATE TABLE t1( a INT );
SELECT b FROM t1;
ERROR 42S22: Unknown column 'b' in 'field list'
SHOW ERRORS;
Level Code Message
Error 1054 Unknown column 'b' in 'field list'
CREATE TABLE t2 SELECT b FROM t1;
ERROR 42S22: Unknown column 'b' in 'field list'
SHOW ERRORS;
Level Code Message
Error 1054 Unknown column 'b' in 'field list'
INSERT INTO t1 SELECT b FROM t1;
ERROR 42S22: Unknown column 'b' in 'field list'
DROP TABLE t1;
mysql-test/t/errors.test
View file @
b535307c
...
...
@@ -53,4 +53,17 @@ INSERT INTO t1 VALUES(2),(3);
SELECT
a
FROM
t1
WHERE
a
IN
(
1
,
(
SELECT
IF
(
1
=
0
,
1
,
2
/
0
)));
DROP
TABLE
t1
;
#
# Bug #28677: SELECT on missing column gives extra error
#
CREATE
TABLE
t1
(
a
INT
);
--
error
ER_BAD_FIELD_ERROR
SELECT
b
FROM
t1
;
SHOW
ERRORS
;
--
error
ER_BAD_FIELD_ERROR
CREATE
TABLE
t2
SELECT
b
FROM
t1
;
SHOW
ERRORS
;
--
error
ER_BAD_FIELD_ERROR
INSERT
INTO
t1
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
# End of 5.0 tests
sql/sql_class.h
View file @
b535307c
...
...
@@ -1983,6 +1983,7 @@ class select_insert :public select_result_interceptor {
virtual
bool
can_rollback_data
()
{
return
0
;
}
void
send_error
(
uint
errcode
,
const
char
*
err
);
bool
send_eof
();
void
abort
();
/* not implemented: select_insert is never re-used in prepared statements */
void
cleanup
();
};
...
...
sql/sql_insert.cc
View file @
b535307c
...
...
@@ -3020,57 +3020,8 @@ void select_insert::send_error(uint errcode,const char *err)
{
DBUG_ENTER
(
"select_insert::send_error"
);
/* Avoid an extra 'unknown error' message if we already reported an error */
if
(
errcode
!=
ER_UNKNOWN_ERROR
&&
!
thd
->
net
.
report_error
)
my_message
(
errcode
,
err
,
MYF
(
0
));
my_message
(
errcode
,
err
,
MYF
(
0
));
/*
If the creation of the table failed (due to a syntax error, for
example), no table will have been opened and therefore 'table'
will be NULL. In that case, we still need to execute the rollback
and the end of the function.
*/
if
(
table
)
{
/*
If we are not in prelocked mode, we end the bulk insert started
before.
*/
if
(
!
thd
->
prelocked_mode
)
table
->
file
->
ha_end_bulk_insert
();
/*
If at least one row has been inserted/modified and will stay in
the table (the table doesn't have transactions) we must write to
the binlog (and the error code will make the slave stop).
For many errors (example: we got a duplicate key error while
inserting into a MyISAM table), no row will be added to the table,
so passing the error to the slave will not help since there will
be an error code mismatch (the inserts will succeed on the slave
with no error).
If table creation failed, the number of rows modified will also be
zero, so no check for that is made.
*/
if
(
info
.
copied
||
info
.
deleted
||
info
.
updated
)
{
DBUG_ASSERT
(
table
!=
NULL
);
if
(
!
table
->
file
->
has_transactions
())
{
if
(
mysql_bin_log
.
is_open
())
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
,
thd
->
query_length
,
table
->
file
->
has_transactions
(),
FALSE
);
if
(
!
thd
->
current_stmt_binlog_row_based
&&
!
table
->
s
->
tmp_table
&&
!
can_rollback_data
())
thd
->
no_trans_update
.
all
=
TRUE
;
query_cache_invalidate3
(
thd
,
table
,
1
);
}
}
table
->
file
->
ha_release_auto_increment
();
}
ha_rollback_stmt
(
thd
);
DBUG_VOID_RETURN
;
}
...
...
@@ -3160,6 +3111,59 @@ bool select_insert::send_eof()
DBUG_RETURN
(
0
);
}
void
select_insert
::
abort
()
{
DBUG_ENTER
(
"select_insert::abort"
);
/*
If the creation of the table failed (due to a syntax error, for
example), no table will have been opened and therefore 'table'
will be NULL. In that case, we still need to execute the rollback
and the end of the function.
*/
if
(
table
)
{
/*
If we are not in prelocked mode, we end the bulk insert started
before.
*/
if
(
!
thd
->
prelocked_mode
)
table
->
file
->
ha_end_bulk_insert
();
/*
If at least one row has been inserted/modified and will stay in
the table (the table doesn't have transactions) we must write to
the binlog (and the error code will make the slave stop).
For many errors (example: we got a duplicate key error while
inserting into a MyISAM table), no row will be added to the table,
so passing the error to the slave will not help since there will
be an error code mismatch (the inserts will succeed on the slave
with no error).
If table creation failed, the number of rows modified will also be
zero, so no check for that is made.
*/
if
(
info
.
copied
||
info
.
deleted
||
info
.
updated
)
{
DBUG_ASSERT
(
table
!=
NULL
);
if
(
!
table
->
file
->
has_transactions
())
{
if
(
mysql_bin_log
.
is_open
())
thd
->
binlog_query
(
THD
::
ROW_QUERY_TYPE
,
thd
->
query
,
thd
->
query_length
,
table
->
file
->
has_transactions
(),
FALSE
);
if
(
!
thd
->
current_stmt_binlog_row_based
&&
!
table
->
s
->
tmp_table
&&
!
can_rollback_data
())
thd
->
no_trans_update
.
all
=
TRUE
;
query_cache_invalidate3
(
thd
,
table
,
1
);
}
}
table
->
file
->
ha_release_auto_increment
();
}
ha_rollback_stmt
(
thd
);
DBUG_VOID_RETURN
;
}
/***************************************************************************
CREATE TABLE (SELECT) ...
...
...
@@ -3596,6 +3600,14 @@ void select_create::abort()
{
DBUG_ENTER
(
"select_create::abort"
);
/*
Disable binlog, because we "roll back" partial inserts in ::abort
by removing the table, even for non-transactional tables.
*/
tmp_disable_binlog
(
thd
);
select_insert
::
abort
();
reenable_binlog
(
thd
);
/*
We roll back the statement, including truncating the transaction
cache of the binary log, if the statement failed.
...
...
sql/sql_select.cc
View file @
b535307c
...
...
@@ -261,11 +261,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
thd
->
net
.
report_error
));
res
|=
thd
->
net
.
report_error
;
if
(
unlikely
(
res
))
{
/* If we had a another error reported earlier then this will be ignored */
result
->
send_error
(
ER_UNKNOWN_ERROR
,
ER
(
ER_UNKNOWN_ERROR
));
result
->
abort
();
}
DBUG_RETURN
(
res
);
}
...
...
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