@@ -4113,15 +4113,23 @@ SQLRETURN MADB_RefreshDynamicCursor(MADB_Stmt *Stmt)
4113
4113
Stmt -> LastRowFetched = LastRowFetched ;
4114
4114
Stmt -> AffectedRows = AffectedRows ;
4115
4115
4116
- MADB_StmtDataSeek (Stmt , Stmt -> Cursor .Position );
4117
- if (SQL_SUCCEEDED (ret ))
4116
+ if (Stmt -> Cursor .Position > 0 )
4118
4117
{
4119
- /* We need to prevent that bound variables will be overwritten
4120
- by fetching data again: For subsequent GetData we need to update
4121
- bind->row_ptr */
4122
- Stmt -> Methods -> RefreshRowPtrs (Stmt );
4118
+ /* Looks likt this is not needed altogether. Leaving it commented out, so far */
4119
+ /*MADB_StmtDataSeek(Stmt, Stmt->Cursor.Position);
4120
+ if (SQL_SUCCEEDED(ret))
4121
+ {*/
4122
+ /* We need to prevent that bound variables will be overwritten
4123
+ by fetching data again: For subsequent GetData we need to update
4124
+ bind->row_ptr */
4125
+ /*Stmt->Methods->RefreshRowPtrs(Stmt);
4123
4126
4124
- MADB_StmtDataSeek (Stmt , Stmt -> Cursor .Position );
4127
+ MADB_StmtDataSeek(Stmt, Stmt->Cursor.Position);
4128
+ }*/
4129
+ }
4130
+ else
4131
+ {
4132
+ Stmt -> Cursor .Position = 0 ;
4125
4133
}
4126
4134
return ret ;
4127
4135
}
@@ -4492,7 +4500,7 @@ SQLRETURN MADB_StmtSetPos(MADB_Stmt *Stmt, SQLSETPOSIROW RowNumber, SQLUSMALLINT
4492
4500
SQLRETURN MADB_StmtFetchScroll (MADB_Stmt * Stmt , SQLSMALLINT FetchOrientation ,
4493
4501
SQLLEN FetchOffset )
4494
4502
{
4495
- SQLRETURN ret ;
4503
+ SQLRETURN ret = SQL_SUCCESS ;
4496
4504
SQLLEN Position ;
4497
4505
SQLLEN RowsProcessed ;
4498
4506
@@ -4587,10 +4595,20 @@ SQLRETURN MADB_StmtFetchScroll(MADB_Stmt *Stmt, SQLSMALLINT FetchOrientation,
4587
4595
}
4588
4596
if (Position < 0 || (my_ulonglong )Position > mysql_stmt_num_rows (Stmt -> stmt ) - 1 )
4589
4597
{
4598
+ /* We need to put cursor before RS start, not only return error */
4599
+ if (Position < 0 )
4600
+ {
4601
+ MADB_StmtDataSeek (Stmt , 0 );
4602
+ }
4590
4603
return SQL_NO_DATA ;
4591
4604
}
4605
+
4606
+ if (FetchOrientation != SQL_FETCH_NEXT || RowsProcessed > 1 || Stmt -> Options .CursorType == SQL_CURSOR_DYNAMIC )
4607
+ {
4608
+ ret = MADB_StmtDataSeek (Stmt , Stmt -> Cursor .Position );
4609
+ }
4592
4610
4593
- ret = MADB_StmtDataSeek ( Stmt , Stmt -> Cursor . Position );
4611
+ /* Assuming, that ret before previous "if" was SQL_SUCCESS */
4594
4612
if (ret == SQL_SUCCESS )
4595
4613
{
4596
4614
ret = Stmt -> Methods -> Fetch (Stmt );
0 commit comments