Index: driver/results.c =================================================================== --- driver/results.c (revision 993) +++ driver/results.c (working copy) @@ -869,29 +869,19 @@ my_bool set_dynamic_result(STMT FAR *stmt) { - if ( odbc_stmt(stmt->dbc, stmt->query) != SQL_SUCCESS ) - return 1; + SQLRETURN rc; + long row= stmt->current_row; + uint rows= stmt->rows_found_in_set; - pthread_mutex_lock(&stmt->dbc->lock); - if (!stmt->fake_result) - mysql_free_result(stmt->result); - else - x_free(stmt->result); - stmt->result= 0; - stmt->fake_result= 0; - stmt->cursor_row= 0; - stmt->result= mysql_store_result(&stmt->dbc->mysql); - if ( !stmt->result ) - { - set_error(stmt,MYERR_S1000,mysql_error(&stmt->dbc->mysql), - mysql_errno(&stmt->dbc->mysql)); - pthread_mutex_unlock(&stmt->dbc->lock); - return 1; - } - fix_result_types(stmt); + rc= my_SQLExecute(stmt); + + stmt->current_row= row; + stmt->rows_found_in_set= rows; + + if (SQL_SUCCEEDED(rc)) set_current_cursor_data(stmt,0); - pthread_mutex_unlock(&stmt->dbc->lock); - return 0; + + return rc; } Index: test/my_cursor.c =================================================================== --- test/my_cursor.c (revision 993) +++ test/my_cursor.c (working copy) @@ -2753,6 +2753,7 @@ ok_stmt(hstmt1, SQLFreeStmt(hstmt1, SQL_CLOSE)); ok_sql(hstmt1, "drop table if exists t_bug29765"); + free_basic_handles(&henv1, &hdbc1, &hstmt1); SET_DSN_OPTION(0); return OK; } @@ -2803,6 +2804,34 @@ } +/* + Bug#11846 - DIAG [S1T00] Driver Failed to set the internal dynamic result + Dynamic cursors on statements with parameters wasn't supported. +*/ +DECLARE_TEST(t_bug11846) +{ + SQLINTEGER val_in= 4, val_out= 99; + SQLHANDLE henv1, hdbc1, hstmt1; + SET_DSN_OPTION(32); + alloc_basic_handles(&henv1, &hdbc1, &hstmt1); + + ok_stmt(hstmt1, SQLSetStmtAttr(hstmt1, SQL_ATTR_CURSOR_TYPE, + (SQLPOINTER)SQL_CURSOR_DYNAMIC,0)); + ok_stmt(hstmt1, SQLBindParameter(hstmt1, 1, SQL_PARAM_INPUT, SQL_C_LONG, + SQL_INTEGER, 0, 0, &val_in, 0, NULL)); + ok_sql(hstmt1, "select ?"); + + ok_stmt(hstmt1, SQLFetch(hstmt1)); + + ok_stmt(hstmt1, SQLGetData(hstmt1, 1, SQL_C_LONG, &val_out, 0, NULL)); + is_num(val_out, val_in); + + free_basic_handles(&henv1, &hdbc1, &hstmt1); + SET_DSN_OPTION(0); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_positioned_cursor) ADD_TEST(my_setpos_cursor) @@ -2847,6 +2876,7 @@ ADD_TEST(t_update_offsets) ADD_TEST(t_bug29765) ADD_TEST(t_bug6157) + ADD_TEST(t_bug11846) END_TESTS