Skip to content

Commit

Permalink
Some more fixes around "WHERE COUNT OF"
Browse files Browse the repository at this point in the history
Fixed params allocation and work in conjunction with DAE
  • Loading branch information
lawrinn committed Dec 1, 2016
1 parent 81d5e44 commit d777bf8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions ma_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ SQLRETURN MADB_EDPrepare(MADB_Stmt *Stmt)
{
if (Stmt->params)
MADB_FREE(Stmt->params);
Stmt->params= (MYSQL_BIND *)MADB_CALLOC(sizeof(MYSQL_BIND) * Stmt->ParamCount);
/* If we have "WHERE CURRENT OF", we will need bind additionaly parameters for each field in the index */
Stmt->params= (MYSQL_BIND *)MADB_CALLOC(sizeof(MYSQL_BIND) * (Stmt->ParamCount +
(MADB_POSITIONED_COMMAND(Stmt) ? MADB_POS_COMM_IDX_FIELD_COUNT(Stmt) : 0)));
}
return SQL_SUCCESS;
}
Expand Down Expand Up @@ -785,8 +787,7 @@ SQLRETURN MADB_ExecutePositionedUpdate(MADB_Stmt *Stmt, BOOL ExecDirect)

MADB_InitDynamicArray(&DynData, sizeof(char *), 8, 8);

/*So far we always use all fields for index. Once that is changed, this should be changed as well*/
for (j= Stmt->ParamCount; j < Stmt->ParamCount + MADB_STMT_COLUMN_COUNT(Stmt->PositionedCursor); j++)
for (j= Stmt->ParamCount; j < Stmt->ParamCount + MADB_POS_COMM_IDX_FIELD_COUNT(Stmt); j++)
{
SQLLEN Length;
MADB_DescRecord *Rec= MADB_DescGetInternalRecord(Stmt->PositionedCursor->Ard, (SQLSMALLINT)(j - Stmt->ParamCount + 1), MADB_DESC_READ);
Expand All @@ -805,7 +806,17 @@ SQLRETURN MADB_ExecutePositionedUpdate(MADB_Stmt *Stmt, BOOL ExecDirect)

SaveCursor= Stmt->PositionedCursor;
Stmt->PositionedCursor= NULL;
Stmt->ParamCount= Stmt->Apd->Header.Count;

if (DAE_DONE(Stmt))
{
/* Re-marking DAE as done */
Stmt->ParamCount= Stmt->Apd->Header.Count;
MARK_DAE_DONE(Stmt);
}
else
{
Stmt->ParamCount= Stmt->Apd->Header.Count;
}

ret= Stmt->Methods->Execute(Stmt, ExecDirect);

Expand Down
2 changes: 2 additions & 0 deletions ma_statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ MYSQL_RES* FetchMetadata (MADB_Stmt *Stmt);
#define MADB_STMT_COLUMN_COUNT(aStmt) (aStmt)->Ird->Header.Count
#define MADB_STMT_PARAM_COUNT(aStmt) (aStmt)->ParamCount
#define MADB_POSITIONED_COMMAND(aStmt) ((aStmt)->PositionedCommand && (aStmt)->PositionedCursor)
/* So far we always use all fields for index. Once that is changed, this should be changed as well */
#define MADB_POS_COMM_IDX_FIELD_COUNT(aStmt) MADB_STMT_COLUMN_COUNT((aStmt)->PositionedCursor)

#define MADB_TRANSFER_OCTET_LENGTH\
"CAST(CASE @dt"\
Expand Down
1 change: 0 additions & 1 deletion test/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ ODBC_TEST(t_bug5853)
SQL_C_CHAR, SQL_VARCHAR, 0, 0, NULL,
0, &nLen));

;
while ((rc= SQLFetchScroll(Stmt, SQL_FETCH_NEXT, 0)) != SQL_NO_DATA_FOUND)
{
char data[2][3] = { "uvw", "xyz" };
Expand Down

0 comments on commit d777bf8

Please sign in to comment.