Commit c2c760bd authored by unknown's avatar unknown

merging bug 28701 to 5.1-opt

parent ea1a4ae2
......@@ -625,7 +625,7 @@ drop table t1;
create table t1 (a int, b int);
create view v1 as select a, sum(b) from t1 group by a;
select b from v1 use index (some_index) where b=1;
ERROR 42000: Incorrect usage of USE INDEX and VIEW
ERROR HY000: Incorrect usage of index hints and VIEW
drop view v1;
drop table t1;
create table t1 (col1 char(5),col2 char(5));
......@@ -3563,11 +3563,11 @@ CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1 USE KEY(non_existant);
ERROR HY000: Incorrect usage of USE INDEX and VIEW
ERROR HY000: Incorrect usage of index hints and VIEW
SELECT * FROM v1 FORCE KEY(non_existant);
ERROR HY000: Incorrect usage of FORCE INDEX and VIEW
ERROR HY000: Incorrect usage of index hints and VIEW
SELECT * FROM v1 IGNORE KEY(non_existant);
ERROR HY000: Incorrect usage of IGNORE INDEX and VIEW
ERROR HY000: Incorrect usage of index hints and VIEW
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests.
......
......@@ -953,12 +953,9 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
DBUG_RETURN(0);
}
if (table->use_index || table->ignore_index)
if (table->index_hints && table->index_hints->elements)
{
my_error(ER_WRONG_USAGE, MYF(0),
table->ignore_index ? "IGNORE INDEX" :
(table->force_index ? "FORCE INDEX" : "USE INDEX"),
"VIEW");
my_error(ER_WRONG_USAGE, MYF(0), "index hints", "VIEW");
DBUG_RETURN(TRUE);
}
......
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