Index: driver/cursor.c =================================================================== --- driver/cursor.c (revision 959) +++ driver/cursor.c (working copy) @@ -1328,7 +1328,8 @@ sqlRet = setpos_delete( stmt, irow, &dynQuery ); dynstr_free(&dynQuery); /* since we've deleted the current row, cursor pos gets fixed */ - stmt->current_row--; + if (stmt->current_row > 0) + stmt->current_row--; break; } Index: test/my_cursor.c =================================================================== --- test/my_cursor.c (revision 959) +++ test/my_cursor.c (working copy) @@ -2758,6 +2758,42 @@ } +/* + Bug#33388 + Bug caused by the fix for bug#29765. Cursor position isn't + advanced after SQL_DELETE of the *first* row on a static cursor. +*/ +DECLARE_TEST(t_bug33388) +{ + SQLINTEGER x; + + ok_sql(hstmt, "drop table if exists t_bug33388"); + ok_sql(hstmt, "create table t_bug33388 (x int)"); + ok_sql(hstmt, "insert into t_bug33388 values (1),(2),(3),(4)"); + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_stmt(hstmt, SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, + (SQLPOINTER)SQL_CURSOR_STATIC, 0)); + + ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_LONG, &x, 0, NULL)); + ok_sql(hstmt, "select x from t_bug33388 order by 1"); + + ok_stmt(hstmt, SQLFetch(hstmt)); + + /* delete x = 1 */ + ok_stmt(hstmt, SQLSetPos(hstmt, 1, SQL_DELETE, SQL_LOCK_NO_CHANGE)); + + /* next row should be 2 */ + ok_stmt(hstmt, SQLFetch(hstmt)); + is_num(x, 2); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_sql(hstmt, "drop table if exists t_bug33388"); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_positioned_cursor) ADD_TEST(my_setpos_cursor) @@ -2801,6 +2837,7 @@ ADD_TEST(t_update_type) ADD_TEST(t_update_offsets) ADD_TEST(t_bug29765) + ADD_TEST(t_bug33388) END_TESTS Index: ChangeLog =================================================================== --- ChangeLog (revision 959) +++ ChangeLog (working copy) @@ -52,6 +52,8 @@ * Recordset Update() fails in 5.1 ODBC connector when using adUseClient cursor. (Bug #26985) * MyODBC 5/ ADO Not possible to update a client side cursor. (Bug #27961) + * SQLSetPos w/SQL_DELETE didn't advance when deleting the first row on + a static cursor. (Bug #33388) Includes changes from Connector/ODBC 3.51.21 and 3.51.22.