[patch_done] Interbase bug w/createNewDatabase in D2009
Posted: 02.03.2009, 19:32
A typecast is needed in TZInterbase6Connection.CreateNewDatabase to convert the SQL parameter to an AnsiString. The sc_dsql_execute_immediate call expects and PAnsiChar and is getting a pointer to the UnicodeString (see modified version below).
procedure TZInterbase6Connection.CreateNewDatabase(const SQL: String);
var
DbHandle: PISC_DB_HANDLE;
TrHandle: PISC_TR_HANDLE;
begin
Close;
DbHandle := nil;
TrHandle := nil;
FPlainDriver.isc_dsql_execute_immediate(@FStatusVector, @DbHandle, @TrHandle,
0, PAnsiChar(AnsiString(sql)), FDialect, nil); <-- This line
CheckInterbase6Error(FPlainDriver, FStatusVector, lcExecute, SQL);
FPlainDriver.isc_detach_database(@FStatusVector, @DbHandle);
CheckInterbase6Error(FPlainDriver, FStatusVector, lcExecute, SQL);
end;
procedure TZInterbase6Connection.CreateNewDatabase(const SQL: String);
var
DbHandle: PISC_DB_HANDLE;
TrHandle: PISC_TR_HANDLE;
begin
Close;
DbHandle := nil;
TrHandle := nil;
FPlainDriver.isc_dsql_execute_immediate(@FStatusVector, @DbHandle, @TrHandle,
0, PAnsiChar(AnsiString(sql)), FDialect, nil); <-- This line
CheckInterbase6Error(FPlainDriver, FStatusVector, lcExecute, SQL);
FPlainDriver.isc_detach_database(@FStatusVector, @DbHandle);
CheckInterbase6Error(FPlainDriver, FStatusVector, lcExecute, SQL);
end;