summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <kaa@polly.local>2006-12-14 20:58:07 +0300
committerunknown <kaa@polly.local>2006-12-14 20:58:07 +0300
commit5b71281467c85dc705da30f0fe4ebc094f0ff983 (patch)
treeead3becc168cb944b0829362acb6113451102675 /include
parent66e49e3763c90cf169af6f8710786be6176ee5b6 (diff)
downloadmariadb-git-5b71281467c85dc705da30f0fe4ebc094f0ff983.tar.gz
Fix for bug #24117 "server crash on a FETCH with a cursor on a table which is not in the table cache"
Problem: When creating a temporary field for a temporary table in create_tmp_field_from_field(), a resulting field is created as an exact copy of an original one (in Field::new_field()). However, Field_enum and Field_set contain a pointer (typelib) to memory allocated in the parent table's MEM_ROOT, which under some circumstances may be deallocated later by the time a temporary table is used. Solution: Override the new_field() method for Field_enum and Field_set and create a separate copy of the typelib structure in there. include/typelib.h: Added copy_typelib() declaration mysql-test/r/sp.result: Added a testcase for bug #24117 "server crash on a FETCH with a cursor on a table which is not in the table cache" mysql-test/t/sp.test: Added a testcase for bug #24117 "server crash on a FETCH with a cursor on a table which is not in the table cache" mysys/typelib.c: Added copy_typelib() definition sql/field.cc: Create a copy of the internal 'typelib' structure when copying Field_enum of Field_set objects. sql/field.h: Override new_field method in Field_enum (and Field_set) to copy the typelib structure.
Diffstat (limited to 'include')
-rw-r--r--include/typelib.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/typelib.h b/include/typelib.h
index 4d6a90ad51e..fe19f1001d4 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -18,6 +18,8 @@
#ifndef _typelib_h
#define _typelib_h
+#include "my_alloc.h"
+
typedef struct st_typelib { /* Different types saved here */
unsigned int count; /* How many types */
const char *name; /* Name of typelib */
@@ -28,6 +30,7 @@ typedef struct st_typelib { /* Different types saved here */
extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
+extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
extern TYPELIB sql_protocol_typelib;