diff options
author | unknown <bell@sanja.is.com.ua> | 2003-04-05 09:29:28 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-04-05 09:29:28 +0300 |
commit | 933e16a388704a449fba42fa1eee0b139ecf27a3 (patch) | |
tree | ffac8504b24d3edf10316c26976cce754bba41fc | |
parent | 308362a0e38e47fae2022ef54e93f7deb6aaa7a5 (diff) | |
download | mariadb-git-933e16a388704a449fba42fa1eee0b139ecf27a3.tar.gz |
fixed st_select_lex initialization
fixed mustiupdate subselect compatibility
(bug 217)
mysql-test/r/subselect.result:
test of multi-update & subselect
mysql-test/t/subselect.test:
test of multi-update & subselect
sql/sql_update.cc:
added subselect compatibility to query cache
sql/sql_yacc.yy:
right st_select_lex initialization
layout fix
-rw-r--r-- | mysql-test/r/subselect.result | 17 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 17 | ||||
-rw-r--r-- | sql/sql_update.cc | 6 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 4 |
4 files changed, 40 insertions, 4 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 795348f1897..72fc8dc2997 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1082,3 +1082,20 @@ Invalid use of group function UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); Invalid use of group function drop table t1; +CREATE TABLE t1 ( +id int(11) default NULL +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3); +CREATE TABLE t2 ( +id int(11) default NULL, +name varchar(15) default NULL +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita'); +update t1, t2 set t2.name='lenka' where t2.id in (select id from t1); +select * from t2; +id name +4 vita +1 lenka +2 lenka +1 lenka +drop table t1,t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 39dfd4c72e6..e6ae86aa839 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -673,3 +673,20 @@ UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i)); -- error 1111 UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); drop table t1; + +# +# Multi update test +# +CREATE TABLE t1 ( + id int(11) default NULL +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3); +CREATE TABLE t2 ( + id int(11) default NULL, + name varchar(15) default NULL +) TYPE=MyISAM CHARSET=latin1; + +INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita'); +update t1, t2 set t2.name='lenka' where t2.id in (select id from t1); +select * from t2; +drop table t1,t2; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index ec1183819dc..3e72f79da62 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -400,6 +400,7 @@ int mysql_multi_update(THD *thd, table_list->grant.want_privilege=(SELECT_ACL & ~table_list->grant.privilege); if ((res=open_and_lock_tables(thd,table_list))) DBUG_RETURN(res); + fix_tables_pointers(thd->lex.all_selects_list); thd->select_limit=HA_POS_ERROR; if (setup_fields(thd, 0, table_list, *fields, 1, 0, 0)) @@ -408,7 +409,7 @@ int mysql_multi_update(THD *thd, /* Count tables and setup timestamp handling */ - for (tl= (TABLE_LIST*) table_list ; tl ; tl=tl->next) + for (tl= select_lex->get_table_list() ; tl ; tl=tl->next) { TABLE *table= tl->table; if (table->timestamp_field) @@ -426,7 +427,8 @@ int mysql_multi_update(THD *thd, List<Item> total_list; res= mysql_select(thd, &select_lex->ref_pointer_array, - table_list, select_lex->with_wild, total_list, + select_lex->get_table_list(), select_lex->with_wild, + total_list, conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, (ORDER *)NULL, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f30bfbc594a..bbab102e0b9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3369,8 +3369,8 @@ update: UPDATE_SYM { LEX *lex= Lex; + mysql_init_select(lex); lex->sql_command= SQLCOM_UPDATE; - lex->select_lex.init_order(); } opt_low_priority opt_ignore join_table_list SET update_list where_clause opt_order_clause delete_limit_clause @@ -3378,7 +3378,7 @@ update: LEX *lex= Lex; Select->set_lock_for_tables($3); if (lex->select_lex.table_list.elements > 1) - lex->sql_command=SQLCOM_UPDATE_MULTI; + lex->sql_command= SQLCOM_UPDATE_MULTI; } ; |