mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
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
This commit is contained in:
@ -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 */
|
||||
|
Reference in New Issue
Block a user