Fix for SQLite's TZUpdateSQL binding bug on v6.6.1 - beta

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Howe
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 13.05.2007, 06:46

Fix for SQLite's TZUpdateSQL binding bug on v6.6.1 - beta

Post by Howe »

Hello,

Here is a quick fix for a bug in the TZSQLiteStatement.Execute() routine. If an empty SQL string is passed into the function it will raise a cryptic error message:

"library routine called out of sequence"

Replace this:

CheckSQLiteError(FPlainDriver, ErrorCode, ErrorMessage, lcExecute, SQL);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
try
ErrorCode := FPlainDriver.Step(StmtHandle, ColumnCount,

with this:

CheckSQLiteError(FPlainDriver, ErrorCode, ErrorMessage, lcExecute, SQL);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
ColumnCount := 0;
if SQL <> '' then
try
ErrorCode := FPlainDriver.Step(StmtHandle, ColumnCount,

... in the referred routine.

Can anyone else please confirm this works ?

Thanks,
Howe
aducom
Zeos Dev Team
Zeos Dev Team
Posts: 67
Joined: 30.08.2005, 13:21

Post by aducom »

I'll check it out.

albert
aducom
Zeos Dev Team
Zeos Dev Team
Posts: 67
Joined: 30.08.2005, 13:21

Post by aducom »

The real reason why it is not working is because it is a general bug. It can be (temporarely) solved by:

Code: Select all

{**
  Checks the correct SQL query.
}
procedure TZAbstractRODataset.CheckSQLQuery;
begin
  if Trim(FSQL.Text)='' then                              // 20070529 Aducom
    raise EZSQLException.Create(SQueryIsEmpty);   // 20070529 Aducom
  if FSQL.StatementCount < 1 then
    raise EZDatabaseError.Create(SQueryIsEmpty);
  if FSQL.StatementCount > 1 then
    raise EZDatabaseError.Create(SCanNotExecuteMoreQueries);
end;
You'll find it in ZAbstractRODataset

albert
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I just committed a more correct solution (SVN rev. 256). Now FSQL.statementcount correctly returns 0 when the query string is empty. This had some implications on other components too. So the patch was a little more complicated. It will be in next 'Testing' snapshot. Meanwhile you can solve it as above.

Mark
Post Reply