From 42b52c6f5153b45a5b1998aca54ca48480ef7514 Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Thu, 23 Oct 2014 21:03:58 +0300 Subject: [PATCH] Fix to bug #587, http://bugs.mariadb.com/show_bug.cgi?id=587 buffer.c:gwbuf_make_contiguous: hint wasn't duplicated to new GWBUF struct. As a result hints were lost if query rewriting resulted in longer query than the original. --- server/core/buffer.c | 4 ++-- server/core/hint.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/core/buffer.c b/server/core/buffer.c index c8ffdba69..81d7bd629 100644 --- a/server/core/buffer.c +++ b/server/core/buffer.c @@ -569,7 +569,8 @@ int len; if ((newbuf = gwbuf_alloc(gwbuf_length(orig))) != NULL) { - gwbuf_type_t buftype = orig->gwbuf_type; + newbuf->gwbuf_type = orig->gwbuf_type; + newbuf->hint = hint_dup(orig->hint); ptr = GWBUF_DATA(newbuf); while (orig) @@ -579,7 +580,6 @@ int len; ptr += len; orig = gwbuf_consume(orig, len); } - newbuf->gwbuf_type = buftype; } return newbuf; } diff --git a/server/core/hint.c b/server/core/hint.c index 0564625a4..65a3816c9 100644 --- a/server/core/hint.c +++ b/server/core/hint.c @@ -38,6 +38,8 @@ * * @param hint The hint list to duplicate * @return A duplicate of the list + * + * Note : Optimize this to use version numbering instead of copying memory */ HINT * hint_dup(HINT *hint)