Commit 1bda3aaa authored by joreland@mysql.com's avatar joreland@mysql.com

Merge mysql.com:/home/jonas/src/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0-ndb
parents 1d171c87 3a65f15d
...@@ -1809,6 +1809,18 @@ static my_bool my_realloc_str(NET *net, ulong length) ...@@ -1809,6 +1809,18 @@ static my_bool my_realloc_str(NET *net, ulong length)
} }
/* Clear possible error statee of struct NET */
static void net_clear_error(NET *net)
{
if (net->last_errno)
{
net->last_errno= 0;
net->last_error[0]= '\0';
strmov(net->sqlstate, not_error_sqlstate);
}
}
/* /*
Set statement error code, sqlstate, and error message Set statement error code, sqlstate, and error message
from given errcode and sqlstate. from given errcode and sqlstate.
...@@ -2499,6 +2511,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt) ...@@ -2499,6 +2511,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate); set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (stmt->mysql->status != MYSQL_STATUS_READY)
{
set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
DBUG_RETURN(1);
}
net_clear(net); /* Sets net->write_pos */ net_clear(net); /* Sets net->write_pos */
/* Reserve place for null-marker bytes */ /* Reserve place for null-marker bytes */
...@@ -4858,6 +4875,11 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) ...@@ -4858,6 +4875,11 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
if (mysql) if (mysql)
{ {
mysql->stmts= list_delete(mysql->stmts, &stmt->list); mysql->stmts= list_delete(mysql->stmts, &stmt->list);
/*
Clear NET error state: if the following commands come through
successfully, connection will still be usable for other commands.
*/
net_clear_error(&mysql->net);
if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE) if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE)
{ {
char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */ char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */
......
...@@ -194,8 +194,8 @@ MY_LOG_DIR="$MYSQL_TEST_DIR/var/log" ...@@ -194,8 +194,8 @@ MY_LOG_DIR="$MYSQL_TEST_DIR/var/log"
# #
# Set LD_LIBRARY_PATH if we are using shared libraries # Set LD_LIBRARY_PATH if we are using shared libraries
# #
LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$LD_LIBRARY_PATH" LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$LD_LIBRARY_PATH"
DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$DYLD_LIBRARY_PATH" DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$DYLD_LIBRARY_PATH"
export LD_LIBRARY_PATH DYLD_LIBRARY_PATH export LD_LIBRARY_PATH DYLD_LIBRARY_PATH
# #
......
...@@ -101,7 +101,7 @@ extern "C" { ...@@ -101,7 +101,7 @@ extern "C" {
typedef struct { typedef struct {
struct Ndb_cluster_connection* pNCC; struct Ndb_cluster_connection* pNCC;
struct Ndb * pNDB; struct Ndb * pNDB;
struct NdbConnection * pCurrTrans; struct NdbTransaction * pCurrTrans;
} UserHandle; } UserHandle;
/*************************************************************** /***************************************************************
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <my_global.h> #include <my_global.h>
#include <my_sys.h> #include <my_sys.h>
#include <mysql.h> #include <mysql.h>
#include <errmsg.h>
#include <my_getopt.h> #include <my_getopt.h>
#include <m_string.h> #include <m_string.h>
...@@ -12512,6 +12513,77 @@ static void test_bug6761(void) ...@@ -12512,6 +12513,77 @@ static void test_bug6761(void)
} }
/* Bug#8330 - mysql_stmt_execute crashes (libmysql) */
static void test_bug8330()
{
const char *stmt_text;
MYSQL_STMT *stmt[2];
int i, rc;
char *query= "select a,b from t1 where a=?";
MYSQL_BIND bind[2];
long lval[2];
myheader("test_bug8330");
stmt_text= "drop table if exists t1";
/* in case some previos test failed */
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt_text= "create table t1 (a int, b int)";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
bzero(bind, sizeof(bind));
for (i=0; i < 2; i++)
{
stmt[i]= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt[i], query, strlen(query));
check_execute(stmt[i], rc);
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (void*) &lval[i];
bind[i].is_null= 0;
mysql_stmt_bind_param(stmt[i], &bind[i]);
}
rc= mysql_stmt_execute(stmt[0]);
check_execute(stmt[0], rc);
rc= mysql_stmt_execute(stmt[1]);
DIE_UNLESS(rc && mysql_stmt_errno(stmt[1]) == CR_COMMANDS_OUT_OF_SYNC);
rc= mysql_stmt_execute(stmt[0]);
check_execute(stmt[0], rc);
mysql_stmt_close(stmt[0]);
mysql_stmt_close(stmt[1]);
stmt_text= "drop table t1";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
}
/* Bug#7990 - mysql_stmt_close doesn't reset mysql->net.last_error */
static void test_bug7990()
{
MYSQL_STMT *stmt;
int rc;
myheader("test_bug7990");
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, "foo", 3);
/*
XXX: the fact that we store errno both in STMT and in
MYSQL is not documented and is subject to change in 5.0
*/
DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql));
mysql_stmt_close(stmt);
DIE_UNLESS(!mysql_errno(mysql));
}
/* /*
Read and parse arguments and MySQL options from my.cnf Read and parse arguments and MySQL options from my.cnf
*/ */
...@@ -12730,6 +12802,8 @@ static struct my_tests_st my_tests[]= { ...@@ -12730,6 +12802,8 @@ static struct my_tests_st my_tests[]= {
{ "test_cursors_with_union", test_cursors_with_union }, { "test_cursors_with_union", test_cursors_with_union },
{ "test_truncation", test_truncation }, { "test_truncation", test_truncation },
{ "test_truncation_option", test_truncation_option }, { "test_truncation_option", test_truncation_option },
{ "test_bug8330", test_bug8330 },
{ "test_bug7990", test_bug7990 },
{ 0, 0 } { 0, 0 }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment