Skip to content

Commit

Permalink
Check for mysql error in FetchRowCsps (#24)
Browse files Browse the repository at this point in the history
* Check for mysql error in FetchRowCsps

---------

Co-authored-by: Pavlo Mishchenko <[email protected]>
  • Loading branch information
pmishchenko-ua and Pavlo Mishchenko authored Nov 13, 2024
1 parent e69a19d commit 084e85d
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions ma_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -3073,11 +3073,19 @@ MYSQL_ROW FetchRowCsps(MADB_Stmt* Stmt, unsigned long **field_lengths)
if (row == NULL)
{
Stmt->stmt->state= MYSQL_STMT_FETCH_DONE;
} else
}
else
{
Stmt->stmt->state= MYSQL_STMT_USER_FETCHING;
}

if (mysql_errno(Stmt->stmt->mysql))
{
MADB_SetError(&Stmt->Error, MADB_ERR_HY000, mysql_error(Stmt->stmt->mysql),
mysql_errno(Stmt->stmt->mysql));
return NULL;
}

*field_lengths = mysql_fetch_lengths(Stmt->CspsResult);
return row;
}
Expand Down Expand Up @@ -3117,7 +3125,14 @@ SQLRETURN MADB_FetchCsps(MADB_Stmt *Stmt)
row = FetchRowCsps(Stmt, &field_lengths);
if (row == NULL)
{
if (SQL_SUCCEEDED(Stmt->Error.ReturnValue))
{
return MYSQL_NO_DATA;
}
else
{
return 1;
}
}

for (i = 0; i < Stmt->stmt->field_count; ++i)
Expand Down Expand Up @@ -3183,10 +3198,10 @@ else if (_cur_row_rc != _accumulated_rc) _accumulated_rc= SQL_SUCCESS_WITH_INFO
/* {{{ MADB_StmtFetch */
SQLRETURN MADB_StmtFetch(MADB_Stmt *Stmt)
{
unsigned int RowNum, j, rc;
unsigned int RowNum, j;
SQLULEN Rows2Fetch= Stmt->Ard->Header.ArraySize, Processed, *ProcessedPtr= &Processed;
MYSQL_ROW_OFFSET SaveCursor= NULL;
SQLRETURN Result= SQL_SUCCESS, RowResult;
SQLRETURN Result= SQL_SUCCESS, RowResult, rc;

MADB_CLEAR_ERROR(&Stmt->Error);

Expand Down Expand Up @@ -3306,6 +3321,16 @@ SQLRETURN MADB_StmtFetch(MADB_Stmt *Stmt)

switch(rc) {
case 1:
if (MADB_SSPS_DISABLED(Stmt))
{
if (Stmt->Ird->Header.ArrayStatusPtr)
{
Stmt->Ird->Header.ArrayStatusPtr[RowNum]= SQL_ROW_ERROR;
}
return SQL_ERROR;
}
else
{
RowResult= MADB_SetNativeError(&Stmt->Error, SQL_HANDLE_STMT, Stmt->stmt);
/* If mysql_stmt_fetch returned error, there is no sense to continue */
if (Stmt->Ird->Header.ArrayStatusPtr)
Expand All @@ -3314,7 +3339,7 @@ SQLRETURN MADB_StmtFetch(MADB_Stmt *Stmt)
}
CALC_ALL_ROWS_RC(Result, RowResult, RowNum);
return Result;

}
case MYSQL_DATA_TRUNCATED:
{
/* We will not report truncation if a dummy buffer was bound */
Expand Down

0 comments on commit 084e85d

Please sign in to comment.