From: Date: August 11 2008 1:07pm Subject: bzr push into mysql-5.0 branch (kpettersson:2655 to 2656) Bug#31605 List-Archive: http://lists.mysql.com/commits/51276 X-Bug: 31605 Message-Id: <20080811110730.AA5125300B9@Adventure> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 2656 Kristofer Pettersson 2008-08-11 [merge] Automerge modified: sql/sql_cursor.cc tests/mysql_client_test.c 2655 Chad MILLER 2008-08-07 Bug#31605: mysql_upgrade relies on Linux /proc filesystem when not \ running on Windows We used two OS-specific methods of looking up the executable name, which don't work outside of those two kinds of OSes (Linux+Solaris and Windows). We assume that if the user ran this program with a certain name, we can run the other sibling programs with a similar name. (re-patch in bzr) modified: client/mysql_upgrade.c === modified file 'sql/sql_cursor.cc' --- a/sql/sql_cursor.cc 2008-02-20 19:45:24 +0000 +++ b/sql/sql_cursor.cc 2008-08-11 09:40:54 +0000 @@ -111,7 +111,8 @@ class Select_materialize: public select_ select_result *result; /* the result object of the caller (PS or SP) */ public: Materialized_cursor *materialized_cursor; - Select_materialize(select_result *result_arg) :result(result_arg) {} + Select_materialize(select_result *result_arg) :result(result_arg), + materialized_cursor(0) {} virtual bool send_fields(List &list, uint flags); }; @@ -155,6 +156,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 +214,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 'tests/mysql_client_test.c' --- a/tests/mysql_client_test.c 2008-05-27 11:33:08 +0000 +++ b/tests/mysql_client_test.c 2008-08-11 09:40:54 +0000 @@ -16189,6 +16189,35 @@ static void test_bug32265() DBUG_VOID_RETURN; } + +/** + 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 */ @@ -16483,6 +16512,7 @@ static struct my_tests_st my_tests[]= { { "test_bug29306", test_bug29306 }, { "test_bug31669", test_bug31669 }, { "test_bug32265", test_bug32265 }, + { "test_bug38486", test_bug38486 }, { 0, 0 } };