From cfc99ce45c30254e9730baaece196028ab7b0d2f Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sat, 4 Jan 2003 16:33:42 +0200 Subject: [PATCH] fixed SET with subselect --- mysql-test/r/subselect.result | 7 +++++++ mysql-test/t/subselect.test | 5 +++++ sql/sql_parse.cc | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 38a8e0368c6..97191567cc9 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -848,6 +848,13 @@ do @a:=(SELECT a from t); select @a; @a 1 +set @a:=2; +set @a:=(SELECT a from t); +select @a; +@a +1 drop table t; do (SELECT a from t); Table 'test.t' doesn't exist +set @a:=(SELECT a from t); +Table 'test.t' doesn't exist diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index de07df1905b..608657e69d5 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -468,6 +468,11 @@ create table t (a int); insert into t values (1); do @a:=(SELECT a from t); select @a; +set @a:=2; +set @a:=(SELECT a from t); +select @a; drop table t; -- error 1146 do (SELECT a from t); +-- error 1146 +set @a:=(SELECT a from t); \ No newline at end of file diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e74c7e35328..74c64232cec 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2470,9 +2470,16 @@ mysql_execute_command(THD *thd) break; } case SQLCOM_SET_OPTION: - if (!(res=sql_set_variables(thd, &lex->var_list))) + if (tables && ((res= check_table_access(thd, SELECT_ACL, tables)) || + (res= open_and_lock_tables(thd,tables)))) + break; + fix_tables_pointers(lex->all_selects_list); + if (!(res= sql_set_variables(thd, &lex->var_list))) send_ok(thd); + if (thd->net.report_error) + res= -1; break; + case SQLCOM_UNLOCK_TABLES: unlock_locked_tables(thd); if (thd->options & OPTION_TABLE_LOCK)