diff options
author | konstantin@mysql.com <> | 2005-09-22 02:11:21 +0400 |
---|---|---|
committer | konstantin@mysql.com <> | 2005-09-22 02:11:21 +0400 |
commit | 6f8d3c4844e7f7dd760f09a5ab8ad309d1d690d6 (patch) | |
tree | c670884265eea87654bb764c095e254eff48128d /mysys | |
parent | e89c5220b54fe74d1afc1361f91e18b164e90e33 (diff) | |
download | mariadb-git-6f8d3c4844e7f7dd760f09a5ab8ad309d1d690d6.tar.gz |
A fix and a test case for Bug#6513 "Test Suite: Values inserted by using
cursor is interpreted latin1 character and Bug#9819 "Cursors: Mysql Server
Crash while fetching from table with 5 million records."
A fix for a possible memory leak when fetching into an SP cursor
in a long loop.
The patch uses a common implementation of cursors in the binary protocol and
in stored procedures and implements materialized cursors.
For implementation details, see comments in sql_cursor.cc
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_alloc.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index fd5a4908572..d5346d530c3 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -221,6 +221,57 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) #endif } + +/* + Allocate many pointers at the same time. + + DESCRIPTION + ptr1, ptr2, etc all point into big allocated memory area. + + SYNOPSIS + multi_alloc_root() + root Memory root + ptr1, length1 Multiple arguments terminated by a NULL pointer + ptr2, length2 ... + ... + NULL + + RETURN VALUE + A pointer to the beginning of the allocated memory block + in case of success or NULL if out of memory. +*/ + +gptr multi_alloc_root(MEM_ROOT *root, ...) +{ + va_list args; + char **ptr, *start, *res; + uint tot_length, length; + DBUG_ENTER("multi_alloc_root"); + + va_start(args, root); + tot_length= 0; + while ((ptr= va_arg(args, char **))) + { + length= va_arg(args, uint); + tot_length+= ALIGN_SIZE(length); + } + va_end(args); + + if (!(start= (char*) alloc_root(root, tot_length))) + DBUG_RETURN(0); /* purecov: inspected */ + + va_start(args, root); + res= start; + while ((ptr= va_arg(args, char **))) + { + *ptr= res; + length= va_arg(args, uint); + res+= ALIGN_SIZE(length); + } + va_end(args); + DBUG_RETURN((gptr) start); +} + #define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left) /* Mark all data in blocks free for reusage */ |