diff options
author | unknown <mhansson/martin@linux-st28.site> | 2007-06-18 16:35:01 +0300 |
---|---|---|
committer | unknown <mhansson/martin@linux-st28.site> | 2007-06-18 16:35:01 +0300 |
commit | 3d31e3d641ed8a4420546449e5e25dcafe51f22f (patch) | |
tree | 4d65c5f245153c9a76e6e4e0a6fd69b70a0d05c8 /sql/sql_insert.cc | |
parent | 14cb59d8bb0531cec3955fb3718455e7742d5db8 (diff) | |
download | mariadb-git-3d31e3d641ed8a4420546449e5e25dcafe51f22f.tar.gz |
Bug#28677: SELECT on missing column gives extra error
The method select_insert::send_error does two things, it rolls back a statement
being executed and outputs an error message. But when a
nonexistent column is referenced, an error message has been published already and
there is no need to publish another.
Fixed by moving all functionality beyond publishing an error message into
select_insert::abort() and calling only that function.
mysql-test/r/errors.result:
Bug#28677: test result
mysql-test/t/errors.test:
Bug#28677: test case
sql/sql_class.h:
Bug#28677: overriding abort()
sql/sql_insert.cc:
Bug#28677:
- moved everything beyond producing an error message out of select_insert::send_error
and into new override select_insert::abort()
- made corresponding move of code from select_create::send_error to select_create::abort
sql/sql_select.cc:
Bug#28677: No need to pusblish an error here
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5720758128e..02c5012b0c5 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2862,41 +2862,6 @@ void select_insert::send_error(uint errcode,const char *err) my_message(errcode, err, MYF(0)); - if (!table) - { - /* - This can only happen when using CREATE ... SELECT and the table was not - created becasue of an syntax error - */ - DBUG_VOID_RETURN; - } - if (!thd->prelocked_mode) - table->file->end_bulk_insert(); - /* - If at least one row has been inserted/modified and will stay in the table - (the table doesn't have transactions) (example: we got a duplicate key - error while inserting into a MyISAM table) we must write to the binlog (and - the error code will make the slave stop). - */ - if ((info.copied || info.deleted || info.updated) && - !table->file->has_transactions()) - { - if (last_insert_id) - thd->insert_id(last_insert_id); // For binary log - if (mysql_bin_log.is_open()) - { - Query_log_event qinfo(thd, thd->query, thd->query_length, - table->file->has_transactions(), FALSE); - mysql_bin_log.write(&qinfo); - } - if (!table->s->tmp_table) - thd->no_trans_update.all= TRUE; - } - if (info.copied || info.deleted || info.updated) - { - query_cache_invalidate3(thd, table, 1); - } - ha_rollback_stmt(thd); DBUG_VOID_RETURN; } @@ -2952,6 +2917,49 @@ bool select_insert::send_eof() DBUG_RETURN(0); } +void select_insert::abort() +{ + DBUG_ENTER("select_insert::abort"); + + if (!table) + { + /* + This can only happen when using CREATE ... SELECT and the table was not + created becasue of an syntax error + */ + DBUG_VOID_RETURN; + } + if (!thd->prelocked_mode) + table->file->end_bulk_insert(); + /* + If at least one row has been inserted/modified and will stay in the table + (the table doesn't have transactions) (example: we got a duplicate key + error while inserting into a MyISAM table) we must write to the binlog (and + the error code will make the slave stop). + */ + if ((info.copied || info.deleted || info.updated) && + !table->file->has_transactions()) + { + if (last_insert_id) + thd->insert_id(last_insert_id); // For binary log + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, thd->query, thd->query_length, + table->file->has_transactions(), FALSE); + mysql_bin_log.write(&qinfo); + } + if (!table->s->tmp_table) + thd->no_trans_update.all= TRUE; + } + if (info.copied || info.deleted || info.updated) + { + query_cache_invalidate3(thd, table, 1); + } + ha_rollback_stmt(thd); + + DBUG_VOID_RETURN; + +} /*************************************************************************** CREATE TABLE (SELECT) ... @@ -3209,13 +3217,7 @@ void select_create::store_values(List<Item> &values) void select_create::send_error(uint errcode,const char *err) { - /* - 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::send_error(errcode, err); - reenable_binlog(thd); } @@ -3240,6 +3242,14 @@ bool select_create::send_eof() void 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); + if (lock) { mysql_unlock_tables(thd, lock); |