diff options
author | Georgi Kodinov <joro@sun.com> | 2009-08-19 15:14:57 +0300 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-08-19 15:14:57 +0300 |
commit | 0665536995fa1afe4ac71e13451dd8258063ff36 (patch) | |
tree | ec3d6929232f89d5951fb478830ddf37d9aa403b /sql/table.h | |
parent | 40defb1d53e6978bdfcd4fc67f638cb56fa58ebb (diff) | |
download | mariadb-git-0665536995fa1afe4ac71e13451dd8258063ff36.tar.gz |
Bug #46019: ERROR 1356 When selecting from within another
view that has Group By
Table access rights checking function check_grant() assumed
that no view is opened when it's called.
This is not true with nested views where the inner view
needs materialization. In this case the view is already
materialized when check_grant() is called for it.
This caused check_grant() to not look for table level
grants on the materialized view table.
Fixed by checking if a view is already materialized and if
it is check table level grants using the original table name
(not the ones of the materialized temp table).
Diffstat (limited to 'sql/table.h')
-rw-r--r-- | sql/table.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/table.h b/sql/table.h index db996d45320..ce9364fad4d 100644 --- a/sql/table.h +++ b/sql/table.h @@ -771,6 +771,29 @@ struct TABLE_LIST void reinit_before_use(THD *thd); Item_subselect *containing_subselect(); + /** + @brief True if this TABLE_LIST represents an not yet materialized + derived table, i.e. the result of a subquery or view execution. + */ + bool is_non_materialized_derived_table() const + { + return derived && !derived_result; + } + + /** + @brief Returns the name of the database that the referenced table belongs + to. + */ + char *get_db_name() { return view != NULL ? view_db.str : db; } + + /** + @brief Returns the name of the table that this TABLE_LIST represents. + + @details The unqualified table name or view name for a table or view, + respectively. + */ + char *get_table_name() { return view != NULL ? view_name.str : table_name; } + private: bool prep_check_option(THD *thd, uint8 check_opt_type); bool prep_where(THD *thd, Item **conds, bool no_where_clause); |