diff --git a/mysql-test/r/alias.result b/mysql-test/r/alias.result index 55397705bdf..5ed10b58929 100644 --- a/mysql-test/r/alias.result +++ b/mysql-test/r/alias.result @@ -70,3 +70,4 @@ INSERT INTO t1 VALUES ('40004712','000001','0020',0); UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr = "40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr ASC LIMIT 1; +drop table t1; diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result index 3be24305e09..525fd1a4495 100644 --- a/mysql-test/r/handler.result +++ b/mysql-test/r/handler.result @@ -146,3 +146,9 @@ alter table t1 type=MyISAM; handler t2 read first; Unknown table 't2' in HANDLER drop table t1; +create table t1(a int, index(a)); +insert into t1 values (1), (2), (3); +handler t1 open; +handler t1 read a=(W); +Unknown column 'W' in 'field list' +drop table t1; diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test index 0dafc62430e..57b46181fa1 100644 --- a/mysql-test/t/alias.test +++ b/mysql-test/t/alias.test @@ -81,3 +81,5 @@ INSERT INTO t1 VALUES ('40004712','000001','0020',0); UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr = "40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr ASC LIMIT 1; + +drop table t1; diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index 7020a4ab3d3..b1902c213bf 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -80,3 +80,13 @@ alter table t1 type=MyISAM; handler t2 read first; drop table t1; +# +#test for #751 +# +create table t1(a int, index(a)); +insert into t1 values (1), (2), (3); +handler t1 open; +--error 1054 +handler t1 read a=(W); +drop table t1; + diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index a98b6c13a00..c80c0444cb5 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -193,6 +193,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, Item *item; for (key_len=0 ; (item=it_ke++) ; key_part++) { + if (item->fix_fields(thd, tables)) + return -1; item->save_in_field(key_part->field, 1); key_len+=key_part->store_length; }