• unknown's avatar
    Fix for BUG#27337: Privileges are not properly restored. · 7e08016a
    unknown authored
    The problem was that THD::db_access variable was not restored after
    database switch in stored-routine-execution code.
    
    The fix is to restore THD::db_access in this case.
    
    Unfortunately, this fix requires additional changes,
    because in prepare_schema_table(), called on the parsing stage, we checked
    privileges. That was wrong according to our design, but this flaw haven't
    struck so far, because it was masked. All privilege checkings must be
    done on the execution stage in order to be compatible with prepared statements
    and stored routines. So, this patch also contains patch for
    prepare_schema_table(), which moves the checkings to the execution phase.
    
    
    mysql-test/r/grant.result:
      Updated result file.
    mysql-test/t/grant.test:
      Added test case for BUG#27337.
    sql/mysql_priv.h:
      Added function declaration.
    sql/sql_db.cc:
      Fix for BUG#27337 -- set THD::db_access even if we're called
      from stored-routine-execution code.
    sql/sql_parse.cc:
      Split prepare_schema_table() into two functions:
        - prepare_schema_table(), which is called from the parser (parsing stage);
        - check_show_access(), which is called on the execution stage.
    sql/sql_show.cc:
      Ignore schema_select_lex member if its table is NULL.
    7e08016a
sql_db.cc 37.8 KB