Subject Re: [firebird-support] Re: Firebird crashing
Author Helen Borrie
At 07:07 PM 4/09/2003 +0000, you wrote:
>I have done the OldParameterOrdering procedure, but it seems not to
>solve the problem. I have re-analized the code, where the sequence
>of operations is the following:
>TIB_Query.Open <----------- A
>assign SQL
>TIBQuery.Active := true <------- B
>GoTop function <--------------------------NO IDEA WHAT THIS IS
> GoTop function
> StartTransaction
> TIBQuery.Active := true <-------D
> TIBQuery.First <-------- E
> TIBQuery.RecordCount <------ F
> Commit Transaction <------
>TIBQuery.First <------
>I did replace the GoTop call, keeping just the last TIBQuery.First,
>and it seems to work. I guess that the doubt here is if by making
>two .Active:=True to the same object would cause Firebird to crash,
>and not just leave the problem to the application keeping Firebird

A, B and D all do the same thing - that is, setting Active calls Open.
Do this *once* and do it at the right time. It will raise exceptions of
various sorts if there is no transaction or if its transaction is started
and it has an unhandled exception pending.

Are you using TIB_Query (IB Objects) or TIBQuery (IBXpress)? They are not

Your flow above is trying to assign SQL to an open query. This is
wrong. The sequence of events is:

if transaction not started then start transaction
if query not prepared then try to prepare query
if exception occurs then
roll back transaction
fix errors
start again
if parameters are needed then supply values to parameters
open query (== submit select request)
do stuff (recordcount and first won't work on a closed dataset)
if no DML pending
try to post work
if no exception
commit work
roll back work

Your application medium should be handling exceptions thrown by the
server. If you are using IBO or IBX (one or the other, not both
simultaneously) then exceptions being caused by bad application logic
should *not* be able to cause a GPF on an operation between fbclient.dll
and fbserver.exe, such as you report.

Something is missing from your problem description, I think.