[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gb.db2 Connection problem & Fix


courtesy of ChatGPT.

----------
Connection.Timeout is ignored by gb.db2.sqlite3 in 3.20.4. The same code path is present in 3.22.0. With Connection.Timeout = -1 set before Open(), a locked write still retries for about 120 seconds because the driver's timeout stays at 0.

In gambas-3.22.0/main/comp/gb.db2/.src/Connection.class, add the middle line in Open()

  _Driver = hDriver
  hDriver.Timeout = Me.Timeout  '<--- add
  $pHandle = hDriver.Open(Me)


and add this setter so changes also take effect on an open connection:

Private Sub Timeout_Write(Value As Integer)

  $iTimeout = Value
  If $pHandle And If _Driver Then _Driver.Timeout = Value

End
----------

Found by testing a program write with the db being locked by a cli "sqlite> BEGIN IMMEDIATE;"

I wanted an immediate error, never happened.

nb: I have a working temp fix but I haven't tested this Gambas level fix yet.

--
Regards
Denis


Follow-Ups:
Re: gb.db2 Connection problem & FixBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>