diff options
author | unknown <df@pippilotta.erinye.com> | 2007-08-23 17:43:47 +0200 |
---|---|---|
committer | unknown <df@pippilotta.erinye.com> | 2007-08-23 17:43:47 +0200 |
commit | 0ff829bb7162a12845ab25282b3e2677eac89ba1 (patch) | |
tree | 639c7e3e6dd6a4ca28c50d13b8772122ec22554f /sql/sql_cache.cc | |
parent | e4659ee132456837fda9c23d07788ba9b47b7781 (diff) | |
parent | 3dbffd24c84cf2011489063482f89cdeab54a0d7 (diff) | |
download | mariadb-git-0ff829bb7162a12845ab25282b3e2677eac89ba1.tar.gz |
Merge pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-marvel
into pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0.48
sql/sql_base.cc:
Auto merged
sql/sql_cache.cc:
Auto merged
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 0d8ef568550..e1df1ce8d9a 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -3000,14 +3000,42 @@ void Query_cache::double_linked_list_join(Query_cache_block *head_tail, >0 number of tables */ -static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used, - uint8 *tables_type) +TABLE_COUNTER_TYPE +Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, + uint8 *tables_type) { DBUG_ENTER("process_and_count_tables"); TABLE_COUNTER_TYPE table_count = 0; for (; tables_used; tables_used= tables_used->next_global) { table_count++; +#ifdef HAVE_QUERY_CACHE + /* + Disable any attempt to store this statement if there are + column level grants on any referenced tables. + The grant.want_privileges flag was set to 1 in the + check_grant() function earlier if the TABLE_LIST object + had any associated column privileges. + + We need to check that the TABLE_LIST object isn't part + of a VIEW definition because we want to be able to cache + views. + + TODO: Although it is possible to cache views, the privilege + check on view tables always fall back on column privileges + even if there are more generic table privileges. Thus it isn't + currently possible to retrieve cached view-tables unless the + client has the super user privileges. + */ + if (tables_used->grant.want_privilege && + tables_used->belong_to_view == NULL) + { + DBUG_PRINT("qcache", ("Don't cache statement as it refers to " + "tables with column privileges.")); + thd->lex->safe_to_cache_query= 0; + DBUG_RETURN(0); + } +#endif if (tables_used->view) { DBUG_PRINT("qcache", ("view: %s db: %s", @@ -3080,7 +3108,8 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex, (long) lex->select_lex.options, (int) thd->variables.query_cache_type)); - if (!(table_count= process_and_count_tables(tables_used, tables_type))) + if (!(table_count= process_and_count_tables(thd, tables_used, + tables_type))) DBUG_RETURN(0); if ((thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && |