From: mhansson Date: June 18 2007 12:32pm Subject: bk commit into 5.0 tree (mhansson:1.2498) BUG#28677 List-Archive: http://lists.mysql.com/commits/28992 X-Bug: 28677 Message-Id: <20070618123211.970B93604D@linux-st28.site> Below is the list of changes that have just been committed into a local 5.0 repository of martin. When martin does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-06-18 15:32:05+03:00, mhansson@stripped +5 -0 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@stripped, 2007-06-18 15:32:03+03:00, mhansson@stripped +6 -0 Bug#28677: test result mysql-test/t/errors.test@stripped, 2007-06-18 15:32:03+03:00, mhansson@stripped +8 -0 Bug#28677: test case sql/sql_class.h@stripped, 2007-06-18 15:32:03+03:00, mhansson@stripped +1 -0 Bug#28677: overriding abort() sql/sql_insert.cc@stripped, 2007-06-18 15:32:03+03:00, mhansson@stripped +51 -41 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@stripped, 2007-06-18 15:32:03+03:00, mhansson@stripped +1 -4 Bug#28677: No need to pusblish an error here # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: mhansson # Host: linux-st28.site # Root: /home/martin/mysql/src/bug28677/my50-bug28677 --- 1.331/sql/sql_class.h 2007-05-15 12:56:04 +03:00 +++ 1.332/sql/sql_class.h 2007-06-18 15:32:03 +03:00 @@ -1951,6 +1951,7 @@ class select_insert :public select_resul virtual void store_values(List &values); 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(); }; --- 1.237/sql/sql_insert.cc 2007-05-16 10:49:11 +03:00 +++ 1.238/sql/sql_insert.cc 2007-06-18 15:32:03 +03:00 @@ -2862,41 +2862,6 @@ void select_insert::send_error(uint errc 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(Listnet.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); } --- 1.11/mysql-test/r/errors.result 2007-04-04 13:38:18 +03:00 +++ 1.12/mysql-test/r/errors.result 2007-06-18 15:32:03 +03:00 @@ -41,3 +41,9 @@ SELECT a FROM t1 WHERE a IN(1, (SELECT I 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' --- 1.17/mysql-test/t/errors.test 2007-04-04 13:38:18 +03:00 +++ 1.18/mysql-test/t/errors.test 2007-06-18 15:32:03 +03:00 @@ -53,4 +53,12 @@ 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 1054 +SELECT b FROM t1; +SHOW ERRORS; + # End of 5.0 tests