Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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-03-02 20:50:49+03:00, evgen@stripped +5 -0
Bug#25126: A crash due to ORDER BY clause was fixed before the UPDATE
fields.
For an UPDATE statement the ORDER BY clause was fixed before the UPDATE
fields are. If the UPDATE list contains a field that doesn't exist then the
error will be thrown only after setting up ORDER BY clause. If the latter
references to a such field then the server will crash because the ORDER BY
clause supposed to be set up only after all fields are checked to be valid.
Now the mysql_prepare_update() function also sets up the UPDATE list and do
this before setting up of the ORDER BY clause.
mysql-test/r/update.result@stripped, 2007-03-02 20:47:48+03:00, evgen@stripped +4 -0
Added a test case for bug#25126: A crash due to ORDER BY clause was fixed before the UPDATE fields.
mysql-test/t/update.test@stripped, 2007-03-02 20:47:19+03:00, evgen@stripped +8 -0
Added a test case for bug#25126: A crash due to ORDER BY clause was fixed before the UPDATE fields.
sql/mysql_priv.h@stripped, 2007-03-02 20:50:13+03:00, evgen@stripped +1 -1
Bug#25126: A crash due to ORDER BY clause was fixed before the UPDATE
fields.
Updated the prototype of the mysql_prepare_update() function.
sql/sql_prepare.cc@stripped, 2007-03-02 20:49:41+03:00, evgen@stripped +1 -14
Bug#25126: A crash due to ORDER BY clause was fixed before the UPDATE
fields.
Updated call to the mysql_prepare_update() function.
sql/sql_update.cc@stripped, 2007-03-02 20:49:04+03:00, evgen@stripped +23 -26
Bug#25126: A crash due to ORDER BY clause was fixed before the UPDATE
fields.
Now the mysql_prepare_update() function also sets up the UPDATE list and do
this before setting up of the ORDER BY clause.
# 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: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/25126-bug-5.0-opt-mysql
--- 1.434/sql/mysql_priv.h 2007-03-02 00:10:23 +03:00
+++ 1.435/sql/mysql_priv.h 2007-03-02 20:50:13 +03:00
@@ -808,7 +808,7 @@
const char * old_name,
const char *new_db,
const char * new_name);
-bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
+bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, List<Item> &fields,
Item **conds, uint order_num, ORDER *order);
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
List<Item> &values,COND *conds,
--- 1.211/sql/sql_update.cc 2007-03-02 00:10:23 +03:00
+++ 1.212/sql/sql_update.cc 2007-03-02 20:49:04 +03:00
@@ -121,9 +121,6 @@
int error;
uint used_index= MAX_KEY;
bool need_sort= TRUE;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- uint want_privilege;
-#endif
uint table_count= 0;
query_id_t query_id=thd->query_id, timestamp_query_id;
ha_rows updated, found;
@@ -172,14 +169,6 @@
table->used_keys= table->s->keys_in_use;
table->quick_keys.clear_all();
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- /* TABLE_LIST contain right privilages request */
- want_privilege= table_list->grant.want_privilege;
-#endif
- if (mysql_prepare_update(thd, table_list, &conds, order_num, order))
- DBUG_RETURN(1);
-
- old_used_keys= table->used_keys; // Keys used in WHERE
/*
Change the query_id for the timestamp column so that we can
check if this is modified directly
@@ -189,14 +178,11 @@
timestamp_query_id=table->timestamp_field->query_id;
table->timestamp_field->query_id=thd->query_id-1;
}
+ if (mysql_prepare_update(thd, table_list, fields, &conds, order_num, order))
+ DBUG_RETURN(1);
+
+ old_used_keys= table->used_keys; // Keys used in WHERE
- /* Check the fields we are going to modify */
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- table_list->grant.want_privilege= table->grant.want_privilege= want_privilege;
- table_list->register_want_access(want_privilege);
-#endif
- if (setup_fields_with_no_wrap(thd, 0, fields, 1, 0, 0))
- DBUG_RETURN(1); /* purecov: inspected */
if (table_list->view && check_fields(thd, fields))
{
DBUG_RETURN(1);
@@ -604,7 +590,7 @@
FALSE OK
TRUE error
*/
-bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
+bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, List<Item> &fields,
Item **conds, uint order_num, ORDER *order)
{
Item *fake_conds= 0;
@@ -612,31 +598,42 @@
TABLE_LIST tables;
List<Item> all_fields;
SELECT_LEX *select_lex= &thd->lex->select_lex;
- DBUG_ENTER("mysql_prepare_update");
-
#ifndef NO_EMBEDDED_ACCESS_CHECKS
- table_list->grant.want_privilege= table->grant.want_privilege=
- (SELECT_ACL & ~table->grant.privilege);
- table_list->register_want_access(SELECT_ACL);
+ /* TABLE_LIST contain right privilages request */
+ uint want_privilege= table_list->grant.want_privilege;
#endif
+ DBUG_ENTER("mysql_prepare_update");
bzero((char*) &tables,sizeof(tables)); // For ORDER BY
tables.table= table;
tables.alias= table_list->alias;
thd->lex->allow_sum_func= 0;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ table_list->grant.want_privilege= table->grant.want_privilege=
+ (SELECT_ACL & ~table->grant.privilege);
+ table_list->register_want_access(SELECT_ACL);
+#endif
+
if (setup_tables_and_check_access(thd, &select_lex->context,
&select_lex->top_join_list,
table_list, conds,
&select_lex->leaf_tables,
FALSE, UPDATE_ACL, SELECT_ACL) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
- select_lex->setup_ref_array(thd, order_num) ||
+ select_lex->setup_ref_array(thd, order_num))
+ DBUG_RETURN(TRUE);
+
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ table_list->grant.want_privilege= table->grant.want_privilege= want_privilege;
+ table_list->register_want_access(want_privilege);
+#endif
+
+ if (setup_fields_with_no_wrap(thd, 0, fields, 1, 0, 0) ||
setup_order(thd, select_lex->ref_pointer_array,
table_list, all_fields, all_fields, order) ||
setup_ftfuncs(select_lex))
DBUG_RETURN(TRUE);
-
/* Check that we are not using table that we are updating in a sub select */
{
TABLE_LIST *duplicate;
--- 1.32/mysql-test/r/update.result 2007-02-22 16:11:00 +03:00
+++ 1.33/mysql-test/r/update.result 2007-03-02 20:47:48 +03:00
@@ -453,3 +453,7 @@
2 0.100000000000000000000000000000
3 NULL
DROP TABLE t1;
+create table t1(f1 int);
+update t1 set f2=1 order by f2;
+ERROR 42S22: Unknown column 'f2' in 'field list'
+drop table t1;
--- 1.30/mysql-test/t/update.test 2007-02-22 16:11:00 +03:00
+++ 1.31/mysql-test/t/update.test 2007-03-02 20:47:19 +03:00
@@ -368,3 +368,11 @@
SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Bug#25126: Wrong name resolution order leads to a crash
+#
+create table t1(f1 int);
+--error 1054
+update t1 set f2=1 order by f2;
+drop table t1;
--- 1.195/sql/sql_prepare.cc 2007-02-26 15:57:41 +03:00
+++ 1.196/sql/sql_prepare.cc 2007-03-02 20:49:41 +03:00
@@ -1112,9 +1112,6 @@
THD *thd= stmt->thd;
uint table_count= 0;
SELECT_LEX *select= &stmt->lex->select_lex;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- uint want_privilege;
-#endif
bool need_reopen;
DBUG_ENTER("mysql_test_update");
@@ -1150,21 +1147,11 @@
if (mysql_handle_derived(thd->lex, &mysql_derived_prepare))
goto error;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- /* TABLE_LIST contain right privilages request */
- want_privilege= table_list->grant.want_privilege;
-#endif
-
- if (mysql_prepare_update(thd, table_list, &select->where,
+ if (mysql_prepare_update(thd, table_list, select->item_list, &select->where,
select->order_list.elements,
(ORDER *) select->order_list.first))
goto error;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- table_list->grant.want_privilege= want_privilege;
- table_list->table->grant.want_privilege= want_privilege;
- table_list->register_want_access(want_privilege);
-#endif
thd->lex->select_lex.no_wrap_view_item= TRUE;
res= setup_fields(thd, 0, select->item_list, 1, 0, 0);
thd->lex->select_lex.no_wrap_view_item= FALSE;
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2428) BUG#25126 | eugene | 2 Mar |