summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-03-31 09:49:09 +0300
committerunknown <bell@sanja.is.com.ua>2003-03-31 09:49:09 +0300
commita424d01173d0b6d446f752a220c827d28358831a (patch)
treea1014229ed839c48e488a253ba1fcc4b017ddfff /sql/sql_cache.cc
parent280a1e4ad3475c7e367cd31c20ec32d09f0623d5 (diff)
downloadmariadb-git-a424d01173d0b6d446f752a220c827d28358831a.tar.gz
fixed bug 209 (SQL_SELECT_LIMIT and query cache incompatibility)
mysql-test/r/query_cache.result: test of SET OPTION SQL_SELECT_LIMIT mysql-test/t/query_cache.test: test of SET OPTION SQL_SELECT_LIMIT sql/sql_cache.cc: layout fixed SQL_SELECT_LIMIT stored in query cache now sql/sql_parse.cc: room for SQL_SELECT_LAYOUT storing added
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index ee62d7b16ed..59430d6a486 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -743,11 +743,11 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
if (query_cache_size == 0)
DBUG_VOID_RETURN;
- if ((local_tables = is_cacheable(thd, thd->query_length,
+ if ((local_tables= is_cacheable(thd, thd->query_length,
thd->query, &thd->lex, tables_used)))
{
- NET *net = &thd->net;
- byte flags = (thd->client_capabilities & CLIENT_LONG_FLAG ? 0x80 : 0);
+ NET *net= &thd->net;
+ byte flags= (thd->client_capabilities & CLIENT_LONG_FLAG ? 0x80 : 0);
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size == 0)
@@ -775,8 +775,10 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
flags|= (byte) thd->variables.convert_set->number();
DBUG_ASSERT(thd->variables.convert_set->number() < 128);
}
- tot_length=thd->query_length+thd->db_length+2;
- thd->query[tot_length-1] = (char) flags;
+ tot_length= thd->query_length+thd->db_length+2+sizeof(ha_rows);
+ thd->query[tot_length-1]= (char) flags;
+ memcpy((void *)(thd->query + (tot_length-sizeof(ha_rows)-1)),
+ (const void *)&thd->variables.select_limit, sizeof(ha_rows));
/* Check if another thread is processing the same query? */
Query_cache_block *competitor = (Query_cache_block *)
@@ -910,7 +912,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
}
Query_cache_block *query_block;
- tot_length=query_length+thd->db_length+2;
+ tot_length= query_length+thd->db_length+2+sizeof(ha_rows);
if (thd->db_length)
{
memcpy(sql+query_length+1, thd->db, thd->db_length);
@@ -926,15 +928,18 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
Most significant bit - CLIENT_LONG_FLAG,
Other - charset number (0 no charset convertion)
*/
- flags = (thd->client_capabilities & CLIENT_LONG_FLAG ? 0x80 : 0);
+ flags= (thd->client_capabilities & CLIENT_LONG_FLAG ? 0x80 : 0);
if (thd->variables.convert_set != 0)
{
- flags |= (byte) thd->variables.convert_set->number();
+ flags|= (byte) thd->variables.convert_set->number();
DBUG_ASSERT(thd->variables.convert_set->number() < 128);
}
- sql[tot_length-1] = (char) flags;
- query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql,
+ sql[tot_length-1]= (char) flags;
+ memcpy((void *)(sql + (tot_length-sizeof(ha_rows)-1)),
+ (const void *)&thd->variables.select_limit, sizeof(ha_rows));
+ query_block= (Query_cache_block *) hash_search(&queries, (byte*) sql,
tot_length);
+
/* Quick abort on unlocked data */
if (query_block == 0 ||
query_block->query()->result() == 0 ||