#At file:///home/thek/Development/cpp/mysqlbzr/mysql-6.0-bugteam/ based on
revid:bernt.johnsen@stripped
3105 Kristofer Pettersson 2009-03-05 [merge]
merge 5.1->6.0
modified:
sql/sql_cache.cc
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc 2009-02-20 12:37:37 +0000
+++ b/sql/sql_cache.cc 2009-03-05 11:44:37 +0000
@@ -419,6 +419,43 @@ TYPELIB query_cache_type_typelib=
array_elements(query_cache_type_names)-1,"", query_cache_type_names, NULL
};
+
+/**
+ Helper function for determine if a SELECT statement has a SQL_NO_CACHE
+ directive.
+
+ @param sql A pointer to the first white space character after SELECT
+
+ @return
+ @retval TRUE The character string contains SQL_NO_CACHE
+ @retval FALSE No directive found.
+*/
+
+static bool has_no_cache_directive(char *sql)
+{
+ int i=0;
+ while (sql[i] == ' ')
+ ++i;
+
+ if (my_toupper(system_charset_info, sql[i]) == 'S' &&
+ my_toupper(system_charset_info, sql[i+1]) == 'Q' &&
+ my_toupper(system_charset_info, sql[i+2]) == 'L' &&
+ my_toupper(system_charset_info, sql[i+3]) == '_' &&
+ my_toupper(system_charset_info, sql[i+4]) == 'N' &&
+ my_toupper(system_charset_info, sql[i+5]) == 'O' &&
+ my_toupper(system_charset_info, sql[i+6]) == '_' &&
+ my_toupper(system_charset_info, sql[i+7]) == 'C' &&
+ my_toupper(system_charset_info, sql[i+8]) == 'A' &&
+ my_toupper(system_charset_info, sql[i+9]) == 'C' &&
+ my_toupper(system_charset_info, sql[i+10]) == 'H' &&
+ my_toupper(system_charset_info, sql[i+11]) == 'E' &&
+ my_toupper(system_charset_info, sql[i+12]) == ' ')
+ return TRUE;
+
+ return FALSE;
+}
+
+
/*****************************************************************************
Query_cache_block_table method(s)
*****************************************************************************/
@@ -1254,6 +1291,16 @@ Query_cache::send_result_to_client(THD *
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
goto err;
}
+
+ if (query_length > 20 && has_no_cache_directive(&sql[i+6]))
+ {
+ /*
+ We do not increase 'refused' statistics here since it will be done
+ later when the query is parsed.
+ */
+ DBUG_PRINT("qcache", ("The statement has a SQL_NO_CACHE directive"));
+ goto err;
+ }
}
STRUCT_LOCK(&structure_guard_mutex);
Attachment: [text/bzr-bundle] bzr/kristofer.pettersson@sun.com-20090305114437-zyg77t9ba009f4kp.bundle
| Thread |
|---|
| • bzr commit into mysql-6.0-bugteam branch (kristofer.pettersson:3105) | Kristofer Pettersson | 5 Mar 2009 |