diff --git a/include/mysql.h b/include/mysql.h index fc306db6..5a48bc41 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -590,6 +590,7 @@ int STDCALL mysql_next_result_start(int *ret, MYSQL *mysql); int STDCALL mysql_next_result_cont(int *ret, MYSQL *mysql, int status); int STDCALL mysql_select_db_start(int *ret, MYSQL *mysql, const char *db); int STDCALL mysql_select_db_cont(int *ret, MYSQL *mysql, int ready_status); +int STDCALL mysql_stmt_warning_count(MYSQL_STMT *stmt); int STDCALL mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt); int STDCALL mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status); diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt index 4b59c36e..a29baec6 100644 --- a/libmariadb/CMakeLists.txt +++ b/libmariadb/CMakeLists.txt @@ -130,6 +130,7 @@ SET(MARIADB_LIB_SYMBOLS mysql_stmt_send_long_data mysql_stmt_sqlstate mysql_stmt_store_result + mysql_stmt_warning_count mysql_store_result mysql_thread_end mysql_thread_id diff --git a/libmariadb/mariadb_stmt.c b/libmariadb/mariadb_stmt.c index 3f09b725..3942ae7e 100644 --- a/libmariadb/mariadb_stmt.c +++ b/libmariadb/mariadb_stmt.c @@ -1183,11 +1183,12 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) stmt->field_count= uint2korr(p); p+= 2; stmt->param_count= uint2korr(p); + p+= 2; /* filler */ p++; - stmt->upsert_status.warning_count= uint2korr(p); - + /* for backward compatibility we also update mysql->warning_count */ + stmt->mysql->warning_count= stmt->upsert_status.warning_count= uint2korr(p); return(0); } @@ -1216,6 +1217,11 @@ my_bool mthd_stmt_get_result_metadata(MYSQL_STMT *stmt) return(0); } +int STDCALL mysql_stmt_warning_count(MYSQL_STMT *stmt) +{ + return stmt->upsert_status.warning_count; +} + int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t length) { MYSQL *mysql= stmt->mysql; diff --git a/unittest/libmariadb/ps_bugs.c b/unittest/libmariadb/ps_bugs.c index 5addadab..afbe03b8 100644 --- a/unittest/libmariadb/ps_bugs.c +++ b/unittest/libmariadb/ps_bugs.c @@ -4191,7 +4191,32 @@ static int test_conc177(MYSQL *mysql) return OK; } +static int test_conc179(MYSQL *mysql) +{ + MYSQL_STMT *stmt; + int rc; + char *stmtstr= "CREATE TABLE t1 (`blurb_id` int NOT NULL DEFAULT 0, `blurb` text default '', PRIMARY KEY (blurb_id)) ENGINE='FEDERATED' DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'"; + + rc= mysql_query(mysql, "set sql_mode=''"); + check_mysql_rc(rc, mysql); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + check_mysql_rc(rc, mysql); + + stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr)); + check_stmt_rc(rc, stmt); + + FAIL_IF(mysql_warning_count(mysql) != 3, "expected 3 warnings"); + FAIL_IF(mysql_stmt_warning_count(stmt) != 3, "expected 3 warnings"); + + mysql_stmt_close(stmt); + + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc179", test_conc179, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc177", test_conc177, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc167", test_conc167, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc168", test_conc168, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},