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-14 21:30:01+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 1) Factoring out the rollback functionality from select_result::send_error
into new public method rollback_statement and making send_error call it. 2) Making
handle_select call rollback_statement if an error message was published already.
mysql-test/r/errors.result@stripped, 2007-06-14 21:29:59+03:00, mhansson@stripped +6 -0
Bug#28677: test result
mysql-test/t/errors.test@stripped, 2007-06-14 21:29:59+03:00, mhansson@stripped +8 -0
Bug#28677: test case
sql/sql_class.h@stripped, 2007-06-14 21:29:59+03:00, mhansson@stripped +3 -0
Bug#28677: declaration of new function in select_result, select_insert and
select_create, i.e. down the hierarchy.
sql/sql_insert.cc@stripped, 2007-06-14 21:29:59+03:00, mhansson@stripped +19 -0
Bug#28677: definition of rollback_statement and the call to it from send_error, in
order to avoid code duplication.
sql/sql_select.cc@stripped, 2007-06-14 21:30:00+03:00, mhansson@stripped +5 -2
Bug#28677: The decision whether to publish an "Unknown error" or not.
# 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-14 21:29:59 +03:00
@@ -1842,6 +1842,7 @@ public:
virtual bool send_data(List<Item> &items)=0;
virtual bool initialize_tables (JOIN *join=0) { return 0; }
virtual void send_error(uint errcode,const char *err);
+ virtual void rollback_statement() {}
virtual bool send_eof()=0;
/**
Check if this query returns a result set and therefore is allowed in
@@ -1950,6 +1951,7 @@ class select_insert :public select_resul
bool send_data(List<Item> &items);
virtual void store_values(List<Item> &values);
void send_error(uint errcode,const char *err);
+ void rollback_statement();
bool send_eof();
/* not implemented: select_insert is never re-used in prepared statements */
void cleanup();
@@ -1978,6 +1980,7 @@ public:
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
void store_values(List<Item> &values);
void send_error(uint errcode,const char *err);
+ void rollback_statement();
bool send_eof();
void abort();
};
--- 1.237/sql/sql_insert.cc 2007-05-16 10:49:11 +03:00
+++ 1.238/sql/sql_insert.cc 2007-06-14 21:29:59 +03:00
@@ -2861,6 +2861,14 @@ void select_insert::send_error(uint errc
DBUG_ENTER("select_insert::send_error");
my_message(errcode, err, MYF(0));
+ rollback_statement();
+
+ DBUG_VOID_RETURN;
+}
+
+void select_insert::rollback_statement()
+{
+ DBUG_ENTER("select_insert::rollback_statement");
if (!table)
{
@@ -2897,6 +2905,7 @@ void select_insert::send_error(uint errc
query_cache_invalidate3(thd, table, 1);
}
ha_rollback_stmt(thd);
+
DBUG_VOID_RETURN;
}
@@ -3218,6 +3227,16 @@ void select_create::send_error(uint errc
reenable_binlog(thd);
}
+void select_create::rollback_statement()
+{
+ /*
+ 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::rollback_statement();
+ reenable_binlog(thd);
+}
bool select_create::send_eof()
{
--- 1.521/sql/sql_select.cc 2007-05-15 23:16:08 +03:00
+++ 1.522/sql/sql_select.cc 2007-06-14 21:30:00 +03:00
@@ -259,8 +259,11 @@ bool handle_select(THD *thd, LEX *lex, s
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));
+ /* If we reported an error earlier, don't report another. */
+ if (thd->warn_list.elements == 0)
+ result->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR));
+ else
+ result->rollback_statement();
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-14 21:29:59 +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-14 21:29:59 +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
| Thread |
|---|
| • bk commit into 5.0 tree (mhansson:1.2498) BUG#28677 | mhansson | 14 Jun |