Skip to content

Commit 0f69c54

Browse files
committed
[ODBC-120] Fix of performance issue. We did redundant calls of
mysql_stmt_data_seek. They are neede for different type of cursors, positioned operation, array fetch etc. But in general forward_only cursor it only significantly slows down execution.
1 parent 553bc88 commit 0f69c54

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

ma_statement.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,15 +4113,23 @@ SQLRETURN MADB_RefreshDynamicCursor(MADB_Stmt *Stmt)
41134113
Stmt->LastRowFetched= LastRowFetched;
41144114
Stmt->AffectedRows= AffectedRows;
41154115

4116-
MADB_StmtDataSeek(Stmt, Stmt->Cursor.Position);
4117-
if (SQL_SUCCEEDED(ret))
4116+
if (Stmt->Cursor.Position > 0)
41184117
{
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);
41234126
4124-
MADB_StmtDataSeek(Stmt, Stmt->Cursor.Position);
4127+
MADB_StmtDataSeek(Stmt, Stmt->Cursor.Position);
4128+
}*/
4129+
}
4130+
else
4131+
{
4132+
Stmt->Cursor.Position= 0;
41254133
}
41264134
return ret;
41274135
}
@@ -4492,7 +4500,7 @@ SQLRETURN MADB_StmtSetPos(MADB_Stmt *Stmt, SQLSETPOSIROW RowNumber, SQLUSMALLINT
44924500
SQLRETURN MADB_StmtFetchScroll(MADB_Stmt *Stmt, SQLSMALLINT FetchOrientation,
44934501
SQLLEN FetchOffset)
44944502
{
4495-
SQLRETURN ret;
4503+
SQLRETURN ret= SQL_SUCCESS;
44964504
SQLLEN Position;
44974505
SQLLEN RowsProcessed;
44984506

@@ -4587,10 +4595,20 @@ SQLRETURN MADB_StmtFetchScroll(MADB_Stmt *Stmt, SQLSMALLINT FetchOrientation,
45874595
}
45884596
if (Position < 0 || (my_ulonglong)Position > mysql_stmt_num_rows(Stmt->stmt) - 1)
45894597
{
4598+
/* We need to put cursor before RS start, not only return error */
4599+
if (Position < 0)
4600+
{
4601+
MADB_StmtDataSeek(Stmt, 0);
4602+
}
45904603
return SQL_NO_DATA;
45914604
}
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+
}
45924610

4593-
ret= MADB_StmtDataSeek(Stmt, Stmt->Cursor.Position);
4611+
/* Assuming, that ret before previous "if" was SQL_SUCCESS */
45944612
if (ret == SQL_SUCCESS)
45954613
{
45964614
ret= Stmt->Methods->Fetch(Stmt);

0 commit comments

Comments
 (0)