summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-11-23 19:32:14 +0200
committerMichael Widenius <monty@askmonty.org>2011-11-23 19:32:14 +0200
commit7b368e3810feda53fc0dbdf5bfe8863f82f0bbcc (patch)
treebab573449ec11585c1b5149c7cbf477178caa469 /sql/sp_head.cc
parentc8768a091ac2d876216582813aaab7d9663008f7 (diff)
parentf28e7bd0645d478d33d7ae3b974931c7991cd0bd (diff)
downloadmariadb-git-7b368e3810feda53fc0dbdf5bfe8863f82f0bbcc.tar.gz
Merge with MySQL 5.1.60
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 7d3bd52ffe2..67ec830d902 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1029,12 +1029,22 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
/*
Allocate additional space at the end of the new query string for the
query_cache_send_result_to_client function.
+
+ The query buffer layout is:
+ buffer :==
+ <statement> The input statement(s)
+ '\0' Terminating null char
+ <length> Length of following current database name (size_t)
+ <db_name> Name of current database
+ <flags> Flags struct
*/
- buf_len= qbuf.length() + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE + 1;
+ buf_len= qbuf.length() + 1 + sizeof(size_t) + thd->db_length +
+ QUERY_CACHE_FLAGS_SIZE + 1;
if ((pbuf= (char *) alloc_root(thd->mem_root, buf_len)))
{
memcpy(pbuf, qbuf.ptr(), qbuf.length());
pbuf[qbuf.length()]= 0;
+ memcpy(pbuf+qbuf.length()+1, (char *) &thd->db_length, sizeof(size_t));
}
else
DBUG_RETURN(TRUE);