diff options
-rw-r--r-- | mysql-test/r/subselect.result | 7 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 14 | ||||
-rw-r--r-- | sql/set_var.cc | 43 | ||||
-rw-r--r-- | sql/sql_do.cc | 1 |
4 files changed, 60 insertions, 5 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 6e35b6e78c1..4b234f73800 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1439,3 +1439,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort drop table if exists t2, t3; +create table t1 (s1 int); +insert into t1 values (1); +insert into t1 values (2); +set sort_buffer_size = (select s1 from t1); +ERROR 21000: Subquery returns more than 1 row +do (select * from t1); +drop table t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 9ba91c7e0a6..c9fc946a2bc 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -951,6 +951,7 @@ select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; drop table t1,t2; + # # correct ALL optimisation # @@ -960,8 +961,21 @@ insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); explain select * from t3 where a >= all (select b from t2); +# # optimized static ALL/ANY with grouping +# insert into t2 values (2,2), (2,1), (3,3), (3,1); select * from t3 where a > all (select max(b) from t2 group by a); explain select * from t3 where a > all (select max(b) from t2 group by a); drop table if exists t2, t3; + +# +# DO and SET with errors +# +create table t1 (s1 int); +insert into t1 values (1); +insert into t1 values (2); +-- error 1241 +set sort_buffer_size = (select s1 from t1); +do (select * from t1); +drop table t1; diff --git a/sql/set_var.cc b/sql/set_var.cc index a5024363545..ed9d508638b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -859,6 +859,8 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type) bool sys_var_long_ptr::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; pthread_mutex_lock(&LOCK_global_system_variables); if (option_limits) *value= (ulong) getopt_ull_limit_value(tmp, option_limits); @@ -878,6 +880,8 @@ void sys_var_long_ptr::set_default(THD *thd, enum_var_type type) bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; pthread_mutex_lock(&LOCK_global_system_variables); if (option_limits) *value= (ulonglong) getopt_ull_limit_value(tmp, option_limits); @@ -925,6 +929,8 @@ byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) bool sys_var_thd_ulong::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; /* Don't use bigger value than given with --maximum-variable-name=.. */ if ((ulong) tmp > max_system_variables.*offset) @@ -964,6 +970,8 @@ byte *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type, bool sys_var_thd_ha_rows::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; /* Don't use bigger value than given with --maximum-variable-name=.. */ if ((ha_rows) tmp > max_system_variables.*offset) @@ -1010,6 +1018,8 @@ byte *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type, bool sys_var_thd_ulonglong::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; if ((ulonglong) tmp > max_system_variables.*offset) tmp= max_system_variables.*offset; @@ -1581,6 +1591,9 @@ void sys_var_collation_server::set_default(THD *thd, enum_var_type type) bool sys_var_key_buffer_size::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; + NAMED_LIST *list; LEX_STRING *base_name= &var->base; @@ -1676,7 +1689,11 @@ int set_var_collation_client::update(THD *thd) bool sys_var_timestamp::update(THD *thd, set_var *var) { - thd->set_time((time_t) var->value->val_int()); + time_t tmp= (time_t) var->value->val_int(); + if (thd->net.report_error) + return 1; + + thd->set_time(tmp); return 0; } @@ -1697,7 +1714,11 @@ byte *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type, bool sys_var_last_insert_id::update(THD *thd, set_var *var) { - thd->insert_id(var->value->val_int()); + ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; + + thd->insert_id(tmp); return 0; } @@ -1712,7 +1733,11 @@ byte *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type, bool sys_var_insert_id::update(THD *thd, set_var *var) { - thd->next_insert_id=var->value->val_int(); + ulonglong tmp= var->value->val_int(); + if (thd->net.report_error) + return 1; + + thd->next_insert_id= tmp; return 0; } @@ -1779,13 +1804,21 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var) bool sys_var_rand_seed1::update(THD *thd, set_var *var) { - thd->rand.seed1= (ulong) var->value->val_int(); + ulong tmp= (ulong) var->value->val_int(); + if (thd->net.report_error) + return 1; + + thd->rand.seed1= tmp; return 0; } bool sys_var_rand_seed2::update(THD *thd, set_var *var) { - thd->rand.seed2= (ulong) var->value->val_int(); + ulong tmp= (ulong) var->value->val_int(); + if (thd->net.report_error) + return 1; + + thd->rand.seed2= tmp; return 0; } diff --git a/sql/sql_do.cc b/sql/sql_do.cc index f25c4632e1e..25a8359f3d2 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values) DBUG_RETURN(-1); while ((value = li++)) value->val_int(); + thd->clear_error(); // DO always is OK send_ok(thd); DBUG_RETURN(0); } |