• Gleb Shchepa's avatar
    Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws · 41ccbefc
    Gleb Shchepa authored
                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.
    
    
    mysql-test/r/view.result:
      Added test case for bug #33461.
      Updated test case for bug 28701.
    mysql-test/t/view.test:
      Added test case for bug #33461.
      Updated test case for bug 28701.
    sql/sql_view.cc:
      Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws
                  an error
      
      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.
    41ccbefc
view.result 108 KB