From: Date: August 12 2008 12:45am Subject: bzr commit into mysql-5.1 branch (marc.alff:2691) Bug#37302 Bug#38296 List-Archive: http://lists.mysql.com/commits/51358 X-Bug: 37302,38296 Message-Id: <20080811224501.F17F32D875@lambda.WEBLAB> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/malff/BZR-TREE/mysql-5.1-bt-merge/ 2691 Marc Alff 2008-08-11 [merge] Manual merge of mysql-5.0-bugteam -> mysql-5.1-bugteam Note: NULL merge of sql/sql_yacc.yy, the fix for bug#38296 will be provided separately for 5.1 modified: sql/field.h sql/item.h sql/sp_head.cc sql/sql_cursor.cc sql/sql_lex.h sql/sql_list.h sql/sql_string.h tests/mysql_client_test.c === modified file 'sql/field.h' --- a/sql/field.h 2008-07-24 20:38:44 +0000 +++ b/sql/field.h 2008-08-11 22:44:13 +0000 @@ -50,7 +50,8 @@ class Field Field(const Item &); /* Prevent use of these */ void operator=(Field &); public: - static void *operator new(size_t size) {return sql_alloc(size); } + static void *operator new(size_t size) throw () + { return sql_alloc(size); } static void operator delete(void *ptr_arg, size_t size) { TRASH(ptr_arg, size); } uchar *ptr; // Position to field in record === modified file 'sql/item.h' --- a/sql/item.h 2008-04-08 16:01:20 +0000 +++ b/sql/item.h 2008-08-11 22:44:13 +0000 @@ -467,9 +467,9 @@ class Item { Item(const Item &); /* Prevent use of these */ void operator=(Item &); public: - static void *operator new(size_t size) + static void *operator new(size_t size) throw () { return sql_alloc(size); } - static void *operator new(size_t size, MEM_ROOT *mem_root) + static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} === modified file 'sql/sp_head.cc' --- a/sql/sp_head.cc 2008-07-15 01:43:12 +0000 +++ b/sql/sp_head.cc 2008-08-11 22:44:13 +0000 @@ -475,7 +475,7 @@ sp_head::operator new(size_t size) throw init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); sp= (sp_head *) alloc_root(&own_root, size); if (sp == NULL) - return NULL; + DBUG_RETURN(NULL); sp->main_mem_root= own_root; DBUG_PRINT("info", ("mem_root 0x%lx", (ulong) &sp->mem_root)); DBUG_RETURN(sp); === modified file 'sql/sql_cursor.cc' --- a/sql/sql_cursor.cc 2008-08-11 11:06:16 +0000 +++ b/sql/sql_cursor.cc 2008-08-11 22:44:13 +0000 @@ -155,6 +155,7 @@ int mysql_open_cursor(THD *thd, uint fla if (! (sensitive_cursor= new (thd->mem_root) Sensitive_cursor(thd, result))) { delete result_materialize; + result_materialize= NULL; return 1; } @@ -212,6 +213,7 @@ int mysql_open_cursor(THD *thd, uint fla if ((rc= materialized_cursor->open(0))) { delete materialized_cursor; + materialized_cursor= NULL; goto err_open; } === modified file 'sql/sql_lex.h' --- a/sql/sql_lex.h 2008-07-15 01:43:12 +0000 +++ b/sql/sql_lex.h 2008-08-11 22:44:13 +0000 @@ -417,11 +417,11 @@ public: bool no_table_names_allowed; /* used for global order by */ bool no_error; /* suppress error message (convert it to warnings) */ - static void *operator new(size_t size) + static void *operator new(size_t size) throw () { return sql_alloc(size); } - static void *operator new(size_t size, MEM_ROOT *mem_root) + static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} === modified file 'sql/sql_list.h' --- a/sql/sql_list.h 2007-06-01 08:12:06 +0000 +++ b/sql/sql_list.h 2008-08-11 22:44:13 +0000 @@ -29,7 +29,7 @@ public: { return sql_alloc(size); } - static void *operator new[](size_t size) + static void *operator new[](size_t size) throw () { return sql_alloc(size); } @@ -450,7 +450,7 @@ public: struct ilink { struct ilink **prev,*next; - static void *operator new(size_t size) + static void *operator new(size_t size) throw () { return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE)); } === modified file 'sql/sql_string.h' --- a/sql/sql_string.h 2008-02-29 13:56:50 +0000 +++ b/sql/sql_string.h 2008-08-11 22:44:13 +0000 @@ -79,7 +79,7 @@ public: Alloced_length=str.Alloced_length; alloced=0; str_charset=str.str_charset; } - static void *operator new(size_t size, MEM_ROOT *mem_root) + static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr_arg,size_t size) { TRASH(ptr_arg, size); } === modified file 'tests/mysql_client_test.c' --- a/tests/mysql_client_test.c 2008-08-11 11:06:16 +0000 +++ b/tests/mysql_client_test.c 2008-08-11 22:44:13 +0000 @@ -17594,6 +17594,33 @@ static void test_wl4166_2() } +/** + Bug#38486 Crash when using cursor protocol +*/ + +static void test_bug38486(void) +{ + myheader("test_bug38486"); + + MYSQL_STMT *stmt; + stmt= mysql_stmt_init(mysql); + unsigned long type= CURSOR_TYPE_READ_ONLY; + mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*)&type); + const char *sql= "CREATE TABLE t1 (a INT)"; + mysql_stmt_prepare(stmt,sql,strlen(sql)); + + mysql_stmt_execute(stmt); + mysql_stmt_close(stmt); + + stmt= mysql_stmt_init(mysql); + mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*)&type); + const char *sql2= "INSERT INTO t1 VALUES (1)"; + mysql_stmt_prepare(stmt,sql2,strlen(sql2)); + mysql_stmt_execute(stmt); + + mysql_stmt_close(stmt); +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -17902,6 +17929,7 @@ static struct my_tests_st my_tests[]= { { "test_bug28386", test_bug28386 }, { "test_wl4166_1", test_wl4166_1 }, { "test_wl4166_2", test_wl4166_2 }, + { "test_bug38486", test_bug38486 }, { 0, 0 } };