diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /libmysqld/emb_qcache.h | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libmysqld/emb_qcache.h')
-rw-r--r-- | libmysqld/emb_qcache.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h new file mode 100644 index 00000000..e3b6339b --- /dev/null +++ b/libmysqld/emb_qcache.h @@ -0,0 +1,83 @@ +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include "sql_cache.h" /* Query_cache_block */ + +class Querycache_stream +{ + uchar *cur_data; + uchar *data_end; + Query_cache_block *block; + uint headers_len; +public: +#ifdef DBUG_ASSERT_EXISTS + Query_cache_block *first_block; + uint stored_size; +#endif + Querycache_stream(Query_cache_block *ini_block, uint ini_headers_len) : + block(ini_block), headers_len(ini_headers_len) + { + cur_data= ((uchar*)block)+headers_len; + data_end= cur_data + (block->used-headers_len); +#ifdef DBUG_ASSERT_EXISTS + first_block= ini_block; + stored_size= 0; +#endif + } + void use_next_block(bool writing) + { + /* + This shouldn't be called if there is only one block, or to loop + around to the first block again. That means we're trying to write + more data than we allocated space for. + */ + DBUG_ASSERT(block->next != block); + DBUG_ASSERT(block->next != first_block); + + block= block->next; + /* + While writing, update the type of each block as we write to it. + While reading, make sure that the block is of the expected type. + */ + if (writing) + block->type= Query_cache_block::RES_CONT; + else + DBUG_ASSERT(block->type == Query_cache_block::RES_CONT); + + cur_data= ((uchar*)block)+headers_len; + data_end= cur_data + (block->used-headers_len); + } + + void store_uchar(uchar c); + void store_short(ushort s); + void store_int(uint i); + void store_ll(ulonglong ll); + void store_str_only(const char *str, uint str_len); + void store_str(const char *str, uint str_len); + void store_safe_str(const char *str, uint str_len); + + uchar load_uchar(); + ushort load_short(); + uint load_int(); + ulonglong load_ll(); + void load_str_only(char *buffer, uint str_len); + char *load_str(MEM_ROOT *alloc, uint *str_len); + int load_safe_str(MEM_ROOT *alloc, char **str, uint *str_len); + int load_column(MEM_ROOT *alloc, char **column); +}; + +uint emb_count_querycache_size(THD *thd); +int emb_load_querycache_result(THD *thd, Querycache_stream *src); +void emb_store_querycache_result(Querycache_stream *dst, THD* thd); |