| 6137 | */ |
| 6138 | |
| 6139 | bool check_column_grant_in_table_ref(THD *thd, TABLE_LIST * table_ref, |
| 6140 | const char *name, uint length) |
| 6141 | { |
| 6142 | GRANT_INFO *grant; |
| 6143 | const char *db_name; |
| 6144 | const char *table_name; |
| 6145 | Security_context *sctx= MY_TEST(table_ref->security_ctx) ? |
| 6146 | table_ref->security_ctx : thd->security_ctx; |
| 6147 | |
| 6148 | if (table_ref->view || table_ref->field_translation) |
| 6149 | { |
| 6150 | /* View or derived information schema table. */ |
| 6151 | ulong view_privs; |
| 6152 | grant= &(table_ref->grant); |
| 6153 | db_name= table_ref->view_db.str; |
| 6154 | table_name= table_ref->view_name.str; |
| 6155 | if (table_ref->belong_to_view && |
| 6156 | thd->lex->sql_command == SQLCOM_SHOW_FIELDS) |
| 6157 | { |
| 6158 | view_privs= get_column_grant(thd, grant, db_name, table_name, name); |
| 6159 | if (view_privs & VIEW_ANY_ACL) |
| 6160 | { |
| 6161 | table_ref->belong_to_view->allowed_show= TRUE; |
| 6162 | return FALSE; |
| 6163 | } |
| 6164 | table_ref->belong_to_view->allowed_show= FALSE; |
| 6165 | my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0)); |
| 6166 | return TRUE; |
| 6167 | } |
| 6168 | } |
| 6169 | else |
| 6170 | { |
| 6171 | /* Normal or temporary table. */ |
| 6172 | TABLE *table= table_ref->table; |
| 6173 | grant= &(table->grant); |
| 6174 | db_name= table->s->db.str; |
| 6175 | table_name= table->s->table_name.str; |
| 6176 | } |
| 6177 | |
| 6178 | if (grant->want_privilege) |
| 6179 | return check_grant_column(thd, grant, db_name, table_name, name, |
| 6180 | length, sctx); |
| 6181 | else |
| 6182 | return FALSE; |
| 6183 | |
| 6184 | } |
| 6185 | |
| 6186 | |
| 6187 | /** |
nothing calls this directly
no test coverage detected