Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug23383
into moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-bug23383
This commit is contained in:
commit
1f699a4422
@ -2472,6 +2472,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
|
|||||||
NET *net= &mysql->net;
|
NET *net= &mysql->net;
|
||||||
char buff[4 /* size of stmt id */ +
|
char buff[4 /* size of stmt id */ +
|
||||||
5 /* execution flags */];
|
5 /* execution flags */];
|
||||||
|
my_bool res;
|
||||||
|
|
||||||
DBUG_ENTER("execute");
|
DBUG_ENTER("execute");
|
||||||
DBUG_DUMP("packet", packet, length);
|
DBUG_DUMP("packet", packet, length);
|
||||||
|
|
||||||
@ -2479,16 +2481,18 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
|
|||||||
int4store(buff, stmt->stmt_id); /* Send stmt id to server */
|
int4store(buff, stmt->stmt_id); /* Send stmt id to server */
|
||||||
buff[4]= (char) stmt->flags;
|
buff[4]= (char) stmt->flags;
|
||||||
int4store(buff+5, 1); /* iteration count */
|
int4store(buff+5, 1); /* iteration count */
|
||||||
if (cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
|
|
||||||
packet, length, 1, NULL) ||
|
res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
|
||||||
(*mysql->methods->read_query_result)(mysql))
|
packet, length, 1, NULL) ||
|
||||||
|
(*mysql->methods->read_query_result)(mysql));
|
||||||
|
stmt->affected_rows= mysql->affected_rows;
|
||||||
|
stmt->server_status= mysql->server_status;
|
||||||
|
stmt->insert_id= mysql->insert_id;
|
||||||
|
if (res)
|
||||||
{
|
{
|
||||||
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
|
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
stmt->affected_rows= mysql->affected_rows;
|
|
||||||
stmt->server_status= mysql->server_status;
|
|
||||||
stmt->insert_id= mysql->insert_id;
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,24 +278,26 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
|
|||||||
DBUG_ENTER("emb_stmt_execute");
|
DBUG_ENTER("emb_stmt_execute");
|
||||||
char header[5];
|
char header[5];
|
||||||
THD *thd;
|
THD *thd;
|
||||||
|
my_bool res;
|
||||||
|
|
||||||
int4store(header, stmt->stmt_id);
|
int4store(header, stmt->stmt_id);
|
||||||
header[4]= stmt->flags;
|
header[4]= stmt->flags;
|
||||||
thd= (THD*)stmt->mysql->thd;
|
thd= (THD*)stmt->mysql->thd;
|
||||||
thd->client_param_count= stmt->param_count;
|
thd->client_param_count= stmt->param_count;
|
||||||
thd->client_params= stmt->params;
|
thd->client_params= stmt->params;
|
||||||
if (emb_advanced_command(stmt->mysql, COM_STMT_EXECUTE,0,0,
|
|
||||||
header, sizeof(header), 1, stmt) ||
|
res= test(emb_advanced_command(stmt->mysql, COM_STMT_EXECUTE, 0, 0,
|
||||||
emb_read_query_result(stmt->mysql))
|
header, sizeof(header), 1, stmt) ||
|
||||||
|
emb_read_query_result(stmt->mysql));
|
||||||
|
stmt->affected_rows= stmt->mysql->affected_rows;
|
||||||
|
stmt->insert_id= stmt->mysql->insert_id;
|
||||||
|
stmt->server_status= stmt->mysql->server_status;
|
||||||
|
if (res)
|
||||||
{
|
{
|
||||||
NET *net= &stmt->mysql->net;
|
NET *net= &stmt->mysql->net;
|
||||||
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
|
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
stmt->affected_rows= stmt->mysql->affected_rows;
|
|
||||||
stmt->insert_id= stmt->mysql->insert_id;
|
|
||||||
stmt->server_status= stmt->mysql->server_status;
|
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15508,6 +15508,83 @@ static void test_bug21726()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
BUG#23383: mysql_affected_rows() returns different values than
|
||||||
|
mysql_stmt_affected_rows()
|
||||||
|
|
||||||
|
Test that both mysql_affected_rows() and mysql_stmt_affected_rows()
|
||||||
|
return -1 on error, 0 when no rows were affected, and (positive) row
|
||||||
|
count when some rows were affected.
|
||||||
|
*/
|
||||||
|
static void test_bug23383()
|
||||||
|
{
|
||||||
|
const char *insert_query= "INSERT INTO t1 VALUES (1), (2)";
|
||||||
|
const char *update_query= "UPDATE t1 SET i= 4 WHERE i = 3";
|
||||||
|
MYSQL_STMT *stmt;
|
||||||
|
my_ulonglong row_count;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
DBUG_ENTER("test_bug23383");
|
||||||
|
myheader("test_bug23383");
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||||
|
myquery(rc);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE t1 (i INT UNIQUE)");
|
||||||
|
myquery(rc);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, insert_query);
|
||||||
|
myquery(rc);
|
||||||
|
row_count= mysql_affected_rows(mysql);
|
||||||
|
DIE_UNLESS(row_count == 2);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, insert_query);
|
||||||
|
DIE_UNLESS(rc != 0);
|
||||||
|
row_count= mysql_affected_rows(mysql);
|
||||||
|
DIE_UNLESS(row_count == (my_ulonglong)-1);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, update_query);
|
||||||
|
myquery(rc);
|
||||||
|
row_count= mysql_affected_rows(mysql);
|
||||||
|
DIE_UNLESS(row_count == 0);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DELETE FROM t1");
|
||||||
|
myquery(rc);
|
||||||
|
|
||||||
|
stmt= mysql_stmt_init(mysql);
|
||||||
|
DIE_UNLESS(stmt != 0);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, insert_query, strlen(insert_query));
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
row_count= mysql_stmt_affected_rows(stmt);
|
||||||
|
DIE_UNLESS(row_count == 2);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
DIE_UNLESS(rc != 0);
|
||||||
|
row_count= mysql_stmt_affected_rows(stmt);
|
||||||
|
DIE_UNLESS(row_count == (my_ulonglong)-1);
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, update_query, strlen(update_query));
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
row_count= mysql_stmt_affected_rows(stmt);
|
||||||
|
DIE_UNLESS(row_count == 0);
|
||||||
|
|
||||||
|
rc= mysql_stmt_close(stmt);
|
||||||
|
check_execute(stmt, rc);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE t1");
|
||||||
|
myquery(rc);
|
||||||
|
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read and parse arguments and MySQL options from my.cnf
|
Read and parse arguments and MySQL options from my.cnf
|
||||||
*/
|
*/
|
||||||
@ -15786,6 +15863,7 @@ static struct my_tests_st my_tests[]= {
|
|||||||
{ "test_bug19671", test_bug19671 },
|
{ "test_bug19671", test_bug19671 },
|
||||||
{ "test_bug21206", test_bug21206 },
|
{ "test_bug21206", test_bug21206 },
|
||||||
{ "test_bug21726", test_bug21726 },
|
{ "test_bug21726", test_bug21726 },
|
||||||
|
{ "test_bug23383", test_bug23383 },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user