[yunqa.de] Re: DISQLite3 rollback/commit failure after failed INSERT INTO

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Tue, 22 Dec 2009 11:40:22 +0100

At 03:35 22.12.2009, Sérgio Trindade wrote:

>I'm using DISQLite3 v2.1.2 personal edition on Delphi 7 and have the following 
>issue: after a floating point exception was generated while executing a 
>malformed "INSERT INTO" statement, both rollback and commit fail with message 
>"SQL statements in progress".

In a nutshell: Unlike Delphi, C does not like exceptions. It does not know how 
to handle them. SQLite is written in C, so any exception throws it off track.

The critical part in your SQL is the overlong argument to the datetime() 
function. This short SQL triggers the "Invalid floating point operation" 
exception:

  SELECT datetime('0001020000000100000000000000000000');

Of course you are right in saying that this should nevertheless work, and 
indeed it does. It only requires to turn off the offending FPU exception. 

FPU exceptions can be switched off easily be calling Set8087CW(), defined in 
System.pas:

  Set8087CW($133F); { Disable all FPU exceptions. }

Only a single call is necessary, but it must be placed before any FPU-critical 
DISQLite3 operation. Application setup or unit initialization are good places 
to do so.

With FPU exceptions disabled, you will see that your "incorrect" INSERT 
statement succeeds. However, it will store an incorrect value to the "EvtTime" 
column. But this is not due to DISQLite3. Instead it results from the incorrect 
timestring you are passing to datetime().

Ralf  

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: