Commit 8bb16e1e authored by evgen@moonbone.local's avatar evgen@moonbone.local

Merge moonbone.local:/work/latest-4.1-opt-mysql

into  moonbone.local:/work/latest-5.0-opt-mysql
parents 1d92b6cd fc0e206c
...@@ -176,6 +176,14 @@ create table t1 (a int); ...@@ -176,6 +176,14 @@ create table t1 (a int);
delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5; delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5; delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
drop table t1; drop table t1;
create table t1(f1 int primary key);
insert into t1 values (4),(3),(1),(2);
delete from t1 where (@a:= f1) order by f1 limit 1;
select @a;
@a
1
drop table t1;
End of 4.1 tests
CREATE TABLE t1 (a int not null,b int not null); CREATE TABLE t1 (a int not null,b int not null);
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b)); CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b)); CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
......
...@@ -1084,6 +1084,18 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1084,6 +1084,18 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab') Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
DROP TABLE t1; DROP TABLE t1;
create table t1(f1 varchar(4));
explain extended select encode(f1,'zxcv') as 'enc' from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
Warnings:
Note 1003 select encode(test.t1.f1,'zxcv') AS `enc` from test.t1
explain extended select decode(f1,'zxcv') as 'enc' from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
Warnings:
Note 1003 select decode(test.t1.f1,'zxcv') AS `enc` from test.t1
drop table t1;
End of 4.1 tests End of 4.1 tests
create table t1 (d decimal default null); create table t1 (d decimal default null);
insert into t1 values (null); insert into t1 values (null);
......
...@@ -163,6 +163,17 @@ delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5; ...@@ -163,6 +163,17 @@ delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5; delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
drop table t1; drop table t1;
#
# Bug#17711: DELETE doesn't use index when ORDER BY, LIMIT and
# non-restricting WHERE is present.
#
create table t1(f1 int primary key);
insert into t1 values (4),(3),(1),(2);
delete from t1 where (@a:= f1) order by f1 limit 1;
select @a;
drop table t1;
--echo End of 4.1 tests
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -730,6 +730,14 @@ EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab'; ...@@ -730,6 +730,14 @@ EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
DROP TABLE t1; DROP TABLE t1;
#
# Bug#23409: ENCODE() and DECODE() functions aren't printed correctly
#
create table t1(f1 varchar(4));
explain extended select encode(f1,'zxcv') as 'enc' from t1;
explain extended select decode(f1,'zxcv') as 'enc' from t1;
drop table t1;
--echo End of 4.1 tests --echo End of 4.1 tests
# #
......
...@@ -1694,6 +1694,19 @@ String *Item_func_encode::val_str(String *str) ...@@ -1694,6 +1694,19 @@ String *Item_func_encode::val_str(String *str)
return res; return res;
} }
void Item_func_encode::print(String *str)
{
str->append(func_name());
str->append('(');
args[0]->print(str);
str->append(',');
str->append('\'');
str->append(seed);
str->append('\'');
str->append(')');
}
String *Item_func_decode::val_str(String *str) String *Item_func_decode::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
......
...@@ -358,19 +358,24 @@ class Item_func_encode :public Item_str_func ...@@ -358,19 +358,24 @@ class Item_func_encode :public Item_str_func
{ {
protected: protected:
SQL_CRYPT sql_crypt; SQL_CRYPT sql_crypt;
String seed;
public: public:
Item_func_encode(Item *a, char *seed): Item_func_encode(Item *a, char *seed_arg):
Item_str_func(a),sql_crypt(seed) {} Item_str_func(a), sql_crypt(seed_arg)
{
seed.copy(seed_arg, strlen(seed_arg), default_charset_info);
}
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "encode"; } const char *func_name() const { return "encode"; }
void print(String *str);
}; };
class Item_func_decode :public Item_func_encode class Item_func_decode :public Item_func_encode
{ {
public: public:
Item_func_decode(Item *a, char *seed): Item_func_encode(a,seed) {} Item_func_decode(Item *a, char *seed_arg): Item_func_encode(a, seed_arg) {}
String *val_str(String *); String *val_str(String *);
const char *func_name() const { return "decode"; } const char *func_name() const { return "decode"; }
}; };
......
...@@ -162,7 +162,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ...@@ -162,7 +162,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (!select && limit != HA_POS_ERROR) if ((!select || table->quick_keys.is_clear_all()) && limit != HA_POS_ERROR)
usable_index= get_index_for_order(table, (ORDER*)(order->first), limit); usable_index= get_index_for_order(table, (ORDER*)(order->first), limit);
if (usable_index == MAX_KEY) if (usable_index == MAX_KEY)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment