Author Topic: IBX for Lazarus 2.7.11 and 2.7.12 released  (Read 1778 times)

mariuz

  • New Member
  • *
  • Posts: 46
    • http://flamerobin.org
IBX for Lazarus 2.7.11 and 2.7.12 released
« on: August 01, 2026, 10:49:34 am »
MWA Software has published two bug-fix releases of IBX for Lazarus, the Lazarus components for accessing Firebird databases.

2.7.11 (2 June) fixes field-to-column mapping when a SELECT uses aggregate or concatenation functions without an explicit alias. Firebird reports the same alias name for each function of a given type, and IBX's disambiguation could previously associate fields with the wrong column.

2.7.12 (21 June, Build 1676) ensures that ApplyUpdates respects "OLD_" parameter values in custom update SQL — typically when updating a key field and the WHERE clause refers to the old key value (WHERE MYKEY = :OLD_MYKEY). Regression tests 4, 18 and 20 were extended to cover key updates.

Downloads are available from the GitHub release pages above or via the Lazarus Online Package Manager.

dsiders

  • Hero Member
  • *****
  • Posts: 1740

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #2 on: August 19, 2026, 12:13:11 pm »
Hi everyone,

I wanted to share some feedback regarding the IBX component for Lazarus. It is truly an excellent component and works flawlessly in both Windows and Linux environments.

However, I've encountered a specific limitation when using it on macOS 26. Currently, the component does not recognize the installation of Firebird SQL 5. Since Firebird SQL 5 is quite different from Firebird SQL 3 architecturally, the detection seems to fail. The component still works perfectly fine on macOS with older versions, up to Firebird SQL 3, but it completely misses the version 5 setup.

Has anyone else encountered this issue, or is there a planned update to improve Firebird 5 detection on macOS? Any guidance, patches, or workarounds would be highly appreciated.

Thanks for the great work on this component!

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #3 on: August 20, 2026, 10:50:28 am »
Quick Update / Follow-up:

As an update to my previous message: by making several compromises, I actually managed to get TurboBird IBX working on macOS 26.

However, I am now facing a new issue. After successfully registering both the server and the database using Firebird SQL 3, I get the following error message whenever I click on a table:

    Exception: Invalid type cast

Does anyone have an idea what might be causing this or how to resolve it? Any help is appreciated!

maurog

  • Full Member
  • ***
  • Posts: 119
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #4 on: August 23, 2026, 01:54:48 pm »
@laguna,

were you able to fix the exception?

The latest version of TurboBird also includes the SQLMonitor! Maybe you can see something there?

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

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #5 on: August 26, 2026, 05:12:26 pm »
Hi,
I resolved the exception; it works fine on macOS with Firebird SQL version 3.

 I haven't yet been able to verify copying the Firebird SQL 5 `fbclient` library for macOS into the IBX component folder for Firebird SQL 5.

 
« Last Edit: August 26, 2026, 07:03:38 pm by laguna »

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #6 on: August 26, 2026, 07:44:43 pm »
I used the version I had compiled with lazarus 4.8 and installed firebird sql 5, removed firebird sql 3, installed firebird sql 5, started turbobird but from this error.
« Last Edit: August 26, 2026, 07:59:03 pm by laguna »

maurog

  • Full Member
  • ***
  • Posts: 119
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #7 on: August 26, 2026, 08:33:19 pm »
Thank you for your wonderful work!

Developing is like a relay race – you give your best and then wait for someone to take over the baton. Thank you for taking over the baton now! You are doing a fantastic job, and your dedication is truly impressive.

Please let me and the community know if you need help – we all stand behind you.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #8 on: August 26, 2026, 09:25:00 pm »
I copied the firebird sql client library to all the folders of ibx and lazarus but it is not recognized when starting lazarus

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #9 on: August 27, 2026, 09:37:31 am »
Hi everyone,

I am encountering an issue trying to use Firebird 5 on macOS (iMac Studio) with Lazarus 4.8.
I have tested both the IBX components and the standard IBConnection (SQLdb), and neither of them is able to load or connect using the Firebird 5 libfbclient.dylib.

The Firebird 5 installation itself is perfect. I can successfully connect to my databases (e.g., employee.fdb) directly from the terminal using the isql tool, which means the server is running and the library is functioning at the system level.

To troubleshoot this dynamic linking issue with Lazarus, I ran the following commands in the macOS Terminal, but none of them solved the problem:

1. Removed Gatekeeper quarantine from the Firebird 5 libraries:

Bash
Code: Pascal  [Select][+][-]
  1. sudo xattr -d com.apple.quarantine /Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/*.dylib
2. Created a symlink in /usr/local/lib (since IBX usually looks there for the client):

Bash
Code: Pascal  [Select][+][-]
  1. sudo mkdir -p /usr/local/lib
  2. sudo ln -s /Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/libfbclient.dylib /usr/local/lib/libfbclient.dylib
Even after forcing the path and removing macOS security restrictions, Lazarus simply refuses to see or load the Firebird 5 client library.

Because I could not get this to work, I had to completely uninstall Firebird 5 and downgrade to Firebird 3. With Firebird 3, both IBX and IBConnection work perfectly out of the box without any of these workarounds.

Furthermore, while analyzing the source code and structure of the IBX components, I noticed there is a unit written specifically for Firebird 3. I think it would be appropriate at this point to propose an update, perhaps by creating a new dedicated unit for Firebird versions above 3 (personally I have never used version 4, so I jumped straight to 5). By working on a specific unit for FB5, it would be possible to do some targeted debugging to understand exactly at which step the library fails to load, even though the file is present and accessible by the system.

Has anyone successfully connected to Firebird 5 using IBX or IBConnection on macOS? Could this be an architecture (Apple Silicon/ARM64) mismatch related to how the FB5 .dylib is compiled, or is it strictly a matter of needing to update the internal IBX units?

It would be worth investigating what goes on inside the uloadlibrary.inc file (located in the DBIntF package, under Client / Include).

Udpate with bab result view images:
I'll try this this afternoon:
Code: Pascal  [Select][+][-]
  1. {$IFDEF DARWIN}
  2.   if FIBLibrary = NilHandle then
  3.   begin
  4.     { Percorso legacy 1 }
  5.     LibName := '/Library/Frameworks/Firebird.framework/Firebird';
  6.     FIBLibrary := LoadLibrary(LibName);
  7.    
  8.     { Percorso legacy 2 }
  9.     if FIBLibrary = NilHandle then
  10.     begin
  11.       LibName := '/Library/Frameworks/Firebird.framework/Libraries/libfbclient.dylib';
  12.       FIBLibrary := LoadLibrary(LibName);
  13.     end;
  14.    
  15.     { NUOVO PERCORSO PER FIREBIRD 5 }
  16.     if FIBLibrary = NilHandle then
  17.     begin
  18.       LibName := '/Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/libfbclient.dylib';
  19.       FIBLibrary := LoadLibrary(LibName);
  20.     end;
  21.  
  22.     if FIBLibrary <> NilHandle then
  23.        FFBLibraryName := ExtractFileName(LibName);
  24.   end;
  25.   {$ENDIF}

Update IB.pas:
Code: Pascal  [Select][+][-]
  1. function LoadFBLibrary(aLibPathName: string): IFirebirdLibrary;
  2. var fblib: IFirebirdLibrary;
  3. begin
  4.   Writeln('DEBUG: Inizio LoadFBLibrary. Percorso richiesto: ', aLibPathName);
  5.  
  6.   if trim(aLibPathName) = '' then
  7.   begin
  8.     Writeln('DEBUG: Percorso vuoto, chiamo CheckIBLoaded');
  9.     CheckIBLoaded;
  10.     Result := FDefaultFBLibrary;
  11.   end
  12.   else
  13.   begin
  14.     Writeln('DEBUG: Tento di caricare la libreria...');
  15.     fblib := TFBLibraryImpl.GetFBLibrary(aLibPathName);
  16.    
  17.     if fblib = nil then
  18.     begin
  19.       Writeln('DEBUG: ERRORE CRITICO! fblib è NIL. La libreria non si è caricata (problema di sistema o dipendenze).');
  20.       IBError(ibxeInterBaseMissing, [nil]);
  21.     end
  22.     else
  23.     begin
  24.       Writeln('DEBUG: Libreria caricata. Tento di estrarre le API di Firebird...');
  25.       if fblib.GetFirebirdAPI = nil then
  26.       begin
  27.         Writeln('DEBUG: ERRORE CRITICO! GetFirebirdAPI è NIL. IBX non riconosce la struttura di Firebird 5.');
  28.         IBError(ibxeInterBaseMissing, [nil]);
  29.       end;
  30.     end;
  31.    
  32.     Writeln('DEBUG: Libreria e API caricate con successo!');
  33.     Result := fblib;
  34.   end;
  35. end;

Thanks in advance for any help or insights!
Laguna
« Last Edit: August 27, 2026, 01:49:47 pm by laguna »

laguna

  • Sr. Member
  • ****
  • Posts: 348
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #10 on: August 27, 2026, 02:14:32 pm »
Work with previous updates and these:
 
Code: Pascal  [Select][+][-]
  1. function TFB30ClientAPI.LoadInterface: boolean;
  2. var
  3.   fb_get_master_interface: Tfb_get_master_interface;
  4.   legacy_result: boolean;
  5. begin
  6.   Writeln('DEBUG FB30: Entro in TFB30ClientAPI.LoadInterface');
  7.  
  8.   { 1. Testiamo il blocco legacy }
  9.   legacy_result := inherited LoadInterface;
  10.   Writeln('DEBUG FB30: inherited LoadInterface ha restituito: ', legacy_result);
  11.  
  12.   { 2. Estrazione della Master Interface di Firebird 5 }
  13.   if (FMaster = nil) and (GetFBLibrary <> nil) then
  14.   begin
  15.     Writeln('DEBUG FB30: Cerco l''esportazione ''fb_get_master_interface'' nella dylib...');
  16.     fb_get_master_interface := GetProcAddress(GetFBLibrary.GetHandle, 'fb_get_master_interface');
  17.    
  18.     if assigned(fb_get_master_interface) then
  19.     begin
  20.       Writeln('DEBUG FB30: fb_get_master_interface TROVATA con successo!');
  21.       FMaster := fb_get_master_interface;
  22.     end
  23.     else
  24.       Writeln('DEBUG FB30: FALLIMENTO! GetProcAddress non ha trovato fb_get_master_interface!');
  25.   end;
  26.  
  27.   { 3. Caricamento delle sotto-interfacce }
  28.   if FMaster <> nil then
  29.   begin
  30.     Writeln('DEBUG FB30: FMaster assegnato, recupero le sotto-interfacce...');
  31.     FUtil := FMaster.getUtilInterface;
  32.     if FUtil = nil then Writeln('DEBUG FB30: ATTENZIONE - FUtil e'' NIL');
  33.    
  34.     FProvider := FMaster.getDispatcher;
  35.     if FProvider = nil then Writeln('DEBUG FB30: ATTENZIONE - FProvider e'' NIL');
  36.    
  37.     FConfigManager := FMaster.getConfigManager;
  38.     if FConfigManager = nil then Writeln('DEBUG FB30: ATTENZIONE - FConfigManager e'' NIL');
  39.    
  40.     CheckPlugins;
  41.   end
  42.   else
  43.     Writeln('DEBUG FB30: FMaster e'' NIL, impossibile proseguire.');
  44.  
  45.   Result := HasMasterIntf;
  46.   Writeln('DEBUG FB30: Esco da LoadInterface. Result = ', Result);
  47. end;

The issue was caused by macOS blocking the LoadLibrary call due to missing secondary dependencies in the new Firebird 5 path. To fix this, you need to tell macOS where to find those dependencies by setting an environment variable directly in Lazarus.

Here are the steps that made it work:

    In Lazarus, go to the menu Run -> Run Parameters...

    Switch to the Environment tab.

    Click on the Add button and enter the following details:

        Name: DYLD_LIBRARY_PATH

        Value: /Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/

    Click OK and run/debug the project again.

After doing this, IBX successfully loads the Firebird 5 libfbclient.dylib without any SIGABRT errors.

The definitive solution for now without modifying the component sources, even if the improvement works I posted above are interesting, is to follow these commands in the terminal before starting Lazarus:
Code: Pascal  [Select][+][-]
  1. echo 'export DYLD_LIBRARY_PATH="/Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/"' >> ~/.zshrc

Code: Pascal  [Select][+][-]
  1. Create text file in ~/Desktop/AvviaLazarus.command
  2.  
  3. #!/bin/bash
  4. export DYLD_LIBRARY_PATH="/Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/"
  5. /Users/scozzaro/lazarus_src/lazarus.app/Contents/MacOS/lazarus --no-splash-screen

Run:
Code: Pascal  [Select][+][-]
  1. chmod +x ~/Desktop/AvviaLazarus.command



Setting a global DYLD_LIBRARY_PATH on macOS requires updating both the terminal environment and the graphical interface layer. This ensures locally compiled applications like Lazarus or TurboBird can seamlessly locate Firebird 5 dynamic libraries regardless of how they are launched.

For the Terminal (All Users)
macOS uses Zsh as the default shell. To make the variable available globally across all terminal sessions, you must modify the system-wide environment file.

    Open your terminal and execute:
Code: Pascal  [Select][+][-]
  1.     sudo nano /etc/zshenv
  2.  
  3.     Add the following export path at the very bottom of the file:
  4.     export DYLD_LIBRARY_PATH="/Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/"

    Save and exit the editor (Press Ctrl + O, Enter, and then Ctrl + X).

For GUI Applications (Finder/Dock - All Users)
macOS strictly isolates graphical applications from terminal configurations. To inject the environment variable into the GUI layer at login, you need to create a system LaunchAgent.

    Create a new configuration file:
Code: Pascal  [Select][+][-]
  1.     sudo nano /Library/LaunchAgents/com.firebird.env.plist

    Paste this XML configuration block to instruct macOS to set the variable upon loading:
    XML

   
Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.     <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3.     <plist version="1.0">
  4.     <dict>
  5.         <key>Label</key>
  6.         <string>com.firebird.env</string>
  7.         <key>ProgramArguments</key>
  8.         <array>
  9.             <string>launchctl</string>
  10.             <string>setenv</string>
  11.             <string>DYLD_LIBRARY_PATH</string>
  12.             <string>/Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/</string>
  13.         </array>
  14.         <key>RunAtLoad</key>
  15.         <true/>
  16.     </dict>
  17.     </plist>
  18.  
    Save and exit the editor.

    Apply the mandatory system permissions to the file to ensure macOS trusts it:
Code: Pascal  [Select][+][-]
  1.     sudo chown root:wheel /Library/LaunchAgents/com.firebird.env.plist
  2.     sudo chmod 644 /Library/LaunchAgents/com.firebird.env.plist

    Load the service immediately (a system reboot achieves the same result):
    launchctl load /Library/LaunchAgents/com.firebird.env.plist

A Note on macOS System Integrity Protection (SIP)
Due to macOS SIP protocols, the operating system intentionally strips or ignores environment variables starting with DYLD_ when launching protected system binaries. This security restriction does not affect locally compiled executables like your Lazarus IDE or custom projects, which will continue to inherit the path perfectly to hook into Firebird 5.

« Last Edit: August 28, 2026, 11:04:30 am by laguna »

tonyw

  • Sr. Member
  • ****
  • Posts: 374
    • MWA Software
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #11 on: September 13, 2026, 08:26:54 pm »
I missed this thread being largely away for August. Are there any changes needed for the IBX source code? I have no access to a MacOS testbed so an totally reliant on contributions for MACOS  support.

tonyw

  • Sr. Member
  • ****
  • Posts: 374
    • MWA Software
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #12 on: September 15, 2026, 05:55:41 pm »
In advance of any reply to my last post. fbintf release 1.4.10 is almost ready (see changelog for details) and I have included in this an updated DARWIN search path for dynamic load of Firebird to include

   '/Library/Frameworks/Firebird.framework/Versions/A/Resources/lib/libfbclient.dylib'
   as an additional location.

I have not been able to test this as I have no access to MACOS. it would be useful if someone could confirm that this fixes the issue for MACOS.

See https://github.com/MWASoftware/fbintf main branch

maurog

  • Full Member
  • ***
  • Posts: 119
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #13 on: September 25, 2026, 09:16:20 am »
Hi Tony,

I have extended TurboBird to support the complete range of Firebird
versions from 1.5 to 6.0. The main reason for this is the porting
and rescue of older Firebird databases.

During this work I came across a compatibility problem with IBX
under Firebird 1.5 (ODS 10) and would like to propose a small patch.

The Problem:

When opening a table under Firebird 1.5, TFieldDefsMaker.Create
fails with:

  Engine Code: 335544569
  Dynamic SQL Error
  -SQL error code = -104
  -Token unknown - line 1, column 191
  -Select

The problematic SQL is in IBCustomDataSet.pas, in the constant
"DefaultSQL", and uses a derived table:

  Left Outer Join (Select C.RDB$RELATION_NAME, ...) X

Firebird 1.5 does not support derived tables (subqueries in FROM),
so this fails with a syntax error. The ODS version check in
TFieldDefsMaker.Create only distinguishes between ODS >= 12
(DefaultSQLODS12) and ODS < 12 (DefaultSQL) — it does not account
for ODS 10 (Firebird 1.5).

The Fix:

I have added a third constant "DefaultSQLODS10" that rewrites the
derived table into two plain LEFT JOINs, and extended the ODS
check accordingly:

1) New constant in IBCustomDataSet.pas, inserted before "DefaultSQL":

  {FB 1.5 / ODS 10 — without derived tables}
  DefaultSQLODS10 =
    'Select F.RDB$COMPUTED_BLR,F.RDB$DEFAULT_VALUE, R.RDB$FIELD_NAME, ' +
    'C.RDB$CONSTRAINT_TYPE ' +
    'from RDB$RELATION_FIELDS R ' +
    'JOIN RDB$FIELDS F on R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME ' +
    'LEFT JOIN RDB$RELATION_CONSTRAINTS C ' +
    '  ON C.RDB$RELATION_NAME = R.RDB$RELATION_NAME ' +
    '  AND C.RDB$CONSTRAINT_TYPE = ''PRIMARY KEY'' ' +
    'LEFT JOIN RDB$INDEX_SEGMENTS S ' +
    '  ON S.RDB$INDEX_NAME = C.RDB$INDEX_NAME ' +
    '  AND S.RDB$FIELD_NAME = R.RDB$FIELD_NAME ' +
    'where R.RDB$RELATION_NAME = :RELATION and ' +
    '  (F.RDB$COMPUTED_BLR is not NULL or ' +
    '   F.RDB$DEFAULT_VALUE is not NULL or ' +
    '   C.RDB$CONSTRAINT_TYPE is not null)';

2) Modified ODS check in TFieldDefsMaker.Create:

  if Dataset.FDatabaseInfo.ODSMajorVersion >= 12 then
    FQuery.SQL.Text := DefaultSQLODS12
  else if Dataset.FDatabaseInfo.ODSMajorVersion >= 11 then
    FQuery.SQL.Text := DefaultSQL
  else
    FQuery.SQL.Text := DefaultSQLODS10;


I have tested the new SQL directly against:

  - Firebird 1.5.6 (ODS 10)  — works
  - Firebird 6.0.0  (ODS 14) — works


Would you consider incorporating this change into IBX4Lazarus?

The patch is minimal (one new constant + a two-line modification
to the ODS check) and does not affect Firebird 2.0+ users at all —
it only adds the missing ODS 10 branch that is currently not
covered.


Thanks again for your work on IBX!

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: 374
    • MWA Software
Re: IBX for Lazarus 2.7.11 and 2.7.12 released
« Reply #14 on: September 30, 2026, 12:05:25 pm »
I can probably do this without impacting current users - although I am mystified as to why anyone would still want to use Firebird 1.5. If you want to upgrade an existing FB1.5 database then gbak can always be used to upgrade the DB to a more recent version.

 

TinyPortal © 2005-2018