Index: ChangeLog =================================================================== --- ChangeLog (revision 956) +++ ChangeLog (working copy) @@ -3,6 +3,8 @@ Functionality added or changed: Bugs fixed: + * Adding a row using SQLSetPos() on a result set with aliased columns + would fail. (Bug #6157) ---- Index: driver/cursor.c =================================================================== --- driver/cursor.c (revision 953) +++ driver/cursor.c (working copy) @@ -1375,7 +1375,7 @@ for (nCol= 0; nCol < result->field_count; nCol++) { MYSQL_FIELD *field= mysql_fetch_field_direct(result, nCol); - dynstr_append_quoted_name(&dynQuery, field->name); + dynstr_append_quoted_name(&dynQuery, field->org_name); dynstr_append_mem(&dynQuery, ",", 1); } dynQuery.length--; /* Remove last ',' */ Index: test/my_cursor.c =================================================================== --- test/my_cursor.c (revision 953) +++ test/my_cursor.c (working copy) @@ -2758,6 +2758,45 @@ } +/** + Bug #6157: BUG in the alias use with ADO's Object +*/ +DECLARE_TEST(t_bug6157) +{ + SQLINTEGER data= 6157; + + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug6157"); + ok_sql(hstmt, "CREATE TABLE t_bug6157(a INT)"); + ok_sql(hstmt, "INSERT INTO t_bug6157 VALUES (1)"); + + ok_sql(hstmt, "SELECT a AS b FROM t_bug6157"); + + ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_LONG, &data, 0, NULL)); + + ok_stmt(hstmt, SQLSetPos(hstmt, 1, SQL_ADD, SQL_LOCK_NO_CHANGE)); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_sql(hstmt, "SELECT a FROM t_bug6157 ORDER BY a"); + + ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_LONG, &data, 0, NULL)); + + ok_stmt(hstmt, SQLFetch(hstmt)); + is_num(data, 1); + + ok_stmt(hstmt, SQLFetch(hstmt)); + is_num(data, 6157); + + expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug6157"); + + return OK; +} + + BEGIN_TESTS ADD_TEST(my_positioned_cursor) ADD_TEST(my_setpos_cursor) @@ -2801,6 +2840,7 @@ ADD_TEST(t_update_type) ADD_TEST(t_update_offsets) ADD_TEST(t_bug29765) + ADD_TEST(t_bug6157) END_TESTS