1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws

an error

Even after the fix for bug 28701 visible behaviors of
SELECT FROM a view and SELECT FROM a regular table are
little bit different:

1. "SELECT FROM regular table USE/FORCE/IGNORE(non
   existent index)" fails with a "ERROR 1176 (HY000):
   Key '...' doesn't exist in table '...'"

2. "SELECT FROM view USING/FORCE/IGNORE(any index)" fails
   with a "ERROR 1221 (HY000): Incorrect usage of
   USE/IGNORE INDEX and VIEW".  OTOH "SHOW INDEX FROM
   view" always returns empty result set, so from the point
   of same behaviour view we trying to use/ignore non
   existent index.

To harmonize the behaviour of USE/FORCE/IGNORE(index)
clauses in SELECT from a view and from a regular table the
"ERROR 1221 (HY000): Incorrect usage of USE/IGNORE INDEX
and VIEW" message has been replaced with the "ERROR 1176
(HY000): Key '...' doesn't exist in table '...'" message
like for tables and non existent keys.
This commit is contained in:
Gleb Shchepa
2008-11-28 20:13:12 +04:00
parent ccc3404f1b
commit 228c913ee5
3 changed files with 66 additions and 14 deletions

View File

@ -980,13 +980,14 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
DBUG_RETURN(0);
}
if (table->use_index || table->ignore_index)
List<String> *index_list= table->use_index ? table->use_index
: table->ignore_index;
if (index_list)
{
my_error(ER_WRONG_USAGE, MYF(0),
table->ignore_index ? "IGNORE INDEX" :
(table->force_index ? "FORCE INDEX" : "USE INDEX"),
"VIEW");
DBUG_RETURN(TRUE);
DBUG_ASSERT(index_list->head()); // should never fail
my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), index_list->head()->c_ptr_safe(),
table->table_name);
DBUG_RETURN(TRUE);
}
/* check loop via view definition */