Recent

Author Topic: IB Database Buffers Bug  (Read 724 times)

gorepj

  • Newbie
  • Posts: 4
IB Database Buffers Bug
« on: May 27, 2026, 10:07:50 am »
Hello, I have identified a bug in the IBDatabase unit. When I compile a win64 application, at run time, I get the following exception raised when connecting to a FB5 database using TCP protocol.

"Engine code 335544325
bad parameters on attach or create database
-Attempt to temporarily set number of buffers less tan 25."

I have diagnosed the reason to be as follows:
 
TIBDataBase.GenerateDPB function handles the isc_dpb_num_buffers case at approx line 2403 as a Byte.  This causes the exception above.  It should be handled as an integer.  Changing the code accordingly fixes the problem.
...
isc_dpb_num_buffers: DPBItem.SetAsInteger(StrToInt(ParamValue));
...
regards
Peter

tonyw

  • Sr. Member
  • ****
  • Posts: 366
    • MWA Software
Re: IB Database Buffers Bug
« Reply #1 on: May 27, 2026, 11:00:37 am »
Thank you for the proposed fix. I'll verify it and get back.

maurog

  • Jr. Member
  • **
  • Posts: 97
Re: IB Database Buffers Bug
« Reply #2 on: May 27, 2026, 06:29:39 pm »
Hi,

just FYI: TurboBird (which is based on IBX4Lazarus) has been tested on several Windows and Linux systems without this isc_dpb_num_buffers issue. Peter is the first to report it.

Maybe it's related to a specific Windows version or Firebird build. ?

Here is a link to the German Firebird forum where TurboBird was also tested:
https://www.firebirdforum.de/viewtopic.php?t=387

Thanks!
maurog.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

gorepj

  • Newbie
  • Posts: 4
Re: IB Database Buffers Bug
« Reply #3 on: May 27, 2026, 06:44:46 pm »
It was indeed using Turbobird that I discovered this issue! I first experienced the issue trying to run the downloaded github Turbobird exe for the first time. I reported the issue to the owner, Mustaffa, who encouraged me to diagnose the problem on a win platform. Mustaffa, solely uses Linux. I installed Lazarus using the Windows installer, compiled the project, and reproduced the problem.   Do I have an old IBDatabase unit for some reason? Why does no one  else seem to have this problem? Is it because I'm compiling /running a 64 bit windows exe? I've reproduced this problem connecting to both Firebird 3 and Firebird 5 databases. My platform is 64bit Windows 11 latest release.
regards
Peter

maurog

  • Jr. Member
  • **
  • Posts: 97
Re: IB Database Buffers Bug
« Reply #4 on: May 27, 2026, 07:25:51 pm »
Hi Peter,

Mustafa is me (maurog). Sorry that I didn't mention it before.

And thank you very much for your work on TurboBird!

Best regards,
Mustafa.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

tonyw

  • Sr. Member
  • ****
  • Posts: 366
    • MWA Software
Re: IB Database Buffers Bug
« Reply #5 on: May 28, 2026, 11:35:54 am »
TIBDataBase.GenerateDPB function handles the isc_dpb_num_buffers case at approx line 2403 as a Byte.  This causes the exception above.  It should be handled as an integer.  Changing the code accordingly fixes the problem.
...
isc_dpb_num_buffers: DPBItem.SetAsInteger(StrToInt(ParamValue));
I have now had a change to review the issue and check back to the Firebird code.

This is more a hangover from the past than a bug as such. The original InterBase 6 API Guide identifies this field as a single byte value. However, the current InterBase docs and the Firebird 2.5 code (checking back) allow it to be from one to four bytes. IBX has not yet caught up with a very old change. Probably because it is a rarely used feature and works long as you don't request more than 255 buffers. Probably also why Turbobird hasn't had a problem.

The only issue I have with the proposed fix is that I prefer StrToUInt in order to raise an error on an attempt to set a negative value. Otherwise, I shall roll it out on github in the next few days and on OPM - but only once I am happy that an outstanding issue with TField.OldValue has been fixed (see github issues).

maurog

  • Jr. Member
  • **
  • Posts: 97
Re: IB Database Buffers Bug
« Reply #6 on: May 28, 2026, 07:37:45 pm »
@Tony,

thank you very much for your detailed explanation.

Best regards,
Mustafa.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

gorepj

  • Newbie
  • Posts: 4
Re: IB Database Buffers Bug
« Reply #7 on: May 29, 2026, 06:17:47 am »
Hello, Proposed fix looks great.

The thing is, regarding Turbobird, it does set the buffers to 1024 and in 3 places

ui\main\main.pas
Line 9968 IBDatabase.Params.Add('isc_dpb_num_buffers=1024');

ui\transaction_config\main\main.pas
ui\createuser\main\main.pas
Line 9130 IBDatabase.Params.Add('isc_dpb_num_buffers=1024');

This is how I identified the problem in the first place.

regards
Peter


maurog

  • Jr. Member
  • **
  • Posts: 97
Re: IB Database Buffers Bug
« Reply #8 on: May 29, 2026, 05:07:45 pm »
@Peter

Thank you for your hint.

I have added a new section to the INI file:

[Database]
NumBuffers=254

So you can set a working buffer size yourself until the bug is fixed.

Regards,
Mustafa.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

gorepj

  • Newbie
  • Posts: 4
Re: IB Database Buffers Bug
« Reply #9 on: May 30, 2026, 07:47:57 am »
Thanks Mustafa.
regards
Peter

tonyw

  • Sr. Member
  • ****
  • Posts: 366
    • MWA Software
Re: IB Database Buffers Bug
« Reply #10 on: May 31, 2026, 04:29:31 pm »
I have now release the update fixing this issue as part of IBX4Lazarus release 2.7.10.

It is now available on github https://github.com/MWASoftware/ibx4lazarus

I have also asked for it to be made available on OPM.

Regards

Tony

maurog

  • Jr. Member
  • **
  • Posts: 97
Re: IB Database Buffers Bug
« Reply #11 on: May 31, 2026, 10:36:28 pm »
Hi Tony,

thank you for the quick fix!

Best regards,
Mustafa.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

 

TinyPortal © 2005-2018