Bug 144163 - LibreOffice 7.2 Firebird Embedded Base Error - field defined with 20 CHAR limit and containing more than 20 characters stored opens with 7.1, fails to open with 7.2
Summary: LibreOffice 7.2 Firebird Embedded Base Error - field defined with 20 CHAR lim...
Status: RESOLVED NOTOURBUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.2.0.4 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL: https://github.com/FirebirdSQL/firebi...
Whiteboard:
Keywords:
: 145899 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-08-29 17:19 UTC by putmann1013
Modified: 2022-01-26 20:52 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Buggy table created with version 7.1 (2.75 KB, application/vnd.sun.xml.base)
2021-10-05 07:32 UTC, Wolfgang Hördt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description putmann1013 2021-08-29 17:19:48 UTC
Description:
Pre-existing Base db with Firebird Embedded that worked well under LibreOffice 7.1. Can not open/edit queries or tables in the db.

"The connection to the data source "ACCOUNTS - Copy" could not be established.
firebird_sdbc error:
*arithmetic exception, numeric overflow, or string truncation
*string right truncation
*expected length 20, actual 25
*gds_$send failed
*Exiting before completion due to errors
caused by
'isc_service_query'

Steps to Reproduce:
1.Uninstalled 7.2
2.Re-installed 7.1.5.2
3.Reviewed Tables and Queries. Nothing found


Actual Results:
The connection to the data source "ACCOUNTS - Copy" could not be established.
firebird_sdbc error:
*arithmetic exception, numeric overflow, or string truncation
*string right truncation
*expected length 20, actual 25
*gds_$send failed
*Exiting before completion due to errors
caused by
'isc_service_query'

Expected Results:
Open useful database with no errors


Reproducible: Always


User Profile Reset: No



Additional Info:
No other information
Comment 1 m_a_riosv 2021-08-29 21:31:44 UTC
Please test with a clean profile, Menu/Help/Restart in Safe Mode
Comment 2 putmann1013 2021-08-29 21:53:26 UTC
(In reply to m.a.riosv from comment #1)
> Please test with a clean profile, Menu/Help/Restart in Safe Mode

Sorry. I should have added that I did test with a clean profile in Safe Mode. I received the same results.
Comment 3 QA Administrators 2021-08-30 03:57:27 UTC Comment hidden (obsolete)
Comment 4 Timur 2021-08-30 09:03:11 UTC
Seems duplicate of bug 144172 (that has more details).
Comment 5 putmann1013 2021-08-31 23:41:30 UTC
Found a table with 1 field set to a length 20 but the actual entries exceeded lengths of 20.
Comment 6 Alex Thurgood 2021-09-01 08:02:37 UTC
Surely, it is a bug if you have a field with a defined character limit of 20 and the software application nonetheless allows you to store more than 20 characters, and then subsequently screws up restituting that character string (or value) ?

I would argue that this is buggy behaviour.

Rings a bell though, as an already existing bug...
Comment 7 Alex Thurgood 2021-09-01 08:06:54 UTC
Inf act, it sounds very similar to, or is a DUPLICATE of, bug 104956
Comment 8 Robert Großkopf 2021-09-01 14:04:17 UTC
(In reply to Alex Thurgood from comment #7)
> Inf act, it sounds very similar to, or is a DUPLICATE of, bug 104956

Bug 104956 was reported for fields, which would save less tan the 20 characters, but length of 20 characters has been defined.

An example file would be helpful: database with one table - more than the allowed length saved in the table.
Comment 9 putmann1013 2021-09-19 17:01:15 UTC
(In reply to Alex Thurgood from comment #6)
> Surely, it is a bug if you have a field with a defined character limit of 20
> and the software application nonetheless allows you to store more than 20
> characters, and then subsequently screws up restituting that character
> string (or value) ?
> 
> I would argue that this is buggy behaviour.
> 
> Rings a bell though, as an already existing bug...

Surely, it is a bug that is still there in release 7.2.1.2
Comment 10 Wolfgang Hördt 2021-10-05 07:32:07 UTC
Created attachment 175526 [details]
Buggy table created with version 7.1
Comment 11 Wolfgang Hördt 2021-10-05 07:32:46 UTC
Obviously a bug is fixed in version 7.2
In 7.1 it is possible to enter more characters than defined (see example).
This buggy table can't be opened in version 7.2.
I have no suggestion, how to solve the problem by software.
A program should not change content.
It is annoying, but I would prefer to correct the column content manually with an older version.
Comment 12 Robert Großkopf 2021-10-06 15:29:02 UTC
Could confirm the buggy behavior with the attached database.
The file could be opened in LO 7.1.5.2 under OpenSUSE 15.2 64bit rpm Linux without any problems.
The table has been defined for filed "Column 1" with VARCHAR(5) and for "Column 2" with VARCHAR(10).
Having a look at the content, which could been saved in LO 7.1.5.2: "Column 1" has been added content with 9 characters, "Column 2" has been added content with 11 characters.

When trying to open this file in LO 7.2.2.1 on the same system it fails. There comes a warning the content for the field is too long.

The behavior in LO 7.1.5.2 had been wrong. So I don't know how there could be fixed anything …
Comment 13 Wolfgang Hördt 2021-10-06 18:42:06 UTC
To be compatible to version 7.1 version 7.2 should adapt the definition of the field length to the actual length.
Changing a definition automatically seems less critical to me than changing content.
Users can be informed about the issue with a dialog.
Then they can correct content or field length, whatever is more important individually.
The database could be used anyway.

And: No, I don't have time to implement this suggestion.
Comment 14 Robert Großkopf 2021-11-27 11:20:23 UTC
*** Bug 145899 has been marked as a duplicate of this bug. ***
Comment 15 Julien Nabet 2022-01-02 15:47:08 UTC
(In reply to Wolfgang Hördt from comment #13)
> To be compatible to version 7.1 version 7.2 should adapt the definition of
> the field length to the actual length.
> Changing a definition automatically seems less critical to me than changing
> content.
> Users can be informed about the issue with a dialog.
> Then they can correct content or field length, whatever is more important
> individually.
> The database could be used anyway.
> 
> And: No, I don't have time to implement this suggestion.

LO fails during connection to the database in Connection::construct, it detects it's an embedded Firebird which uses old fdb file so tries to run runBackupService.
This one fails and so LO doesn't even go to isc_attach_database in order to connect to the database.
See https://opengrok.libreoffice.org/xref/core/connectivity/source/drivers/firebird/Connection.cxx?r=4761e11a#302
The result is we can't even enter Tools/SQL to update system tables and so change definition of the table. 
In brief, I don't think it's possible to fix the file from recent LO.
Now perhaps, the file may be fixed in older LO (see Robert's comment 12 about the presence of too long values) then migrated in recent LO.

Have in mind that Firebird had been put as experimental feature because considered as not stable enough.

IMHO this one should be considered as WONTFIX but if someone disagrees, don't hesitate to explain why and provide some hints to fix this.
Comment 16 Robert Großkopf 2022-01-02 16:36:05 UTC
(In reply to Julien Nabet from comment #15)

> 
> IMHO this one should be considered as WONTFIX but if someone disagrees,
> don't hesitate to explain why and provide some hints to fix this.

Se it the same. We couldn't get back to a buggy behavior to get old created databases working. Installing an older version LO will solve this problem.
Comment 17 Julien Nabet 2022-01-02 17:05:43 UTC
Lionel: after Robert's feedback, ok too for WONTFIX here?
Comment 18 Lionel Elie Mamane 2022-01-02 17:17:24 UTC
(In reply to Robert Großkopf from comment #16)
> We couldn't get back to a buggy behavior to get old created
> databases working. Installing an older version LO will solve this problem.

In principle, I disagree, Ascending compatibility of user data is of cardinal importance. OTOH, if nobody is going to fix this bug, then WONTFIX is more honest than letting the bug rot :-(

Maybe "at least" document how to extract the fdb from the odb, fix it and put it back?

(In reply to Julien Nabet from comment #17)
> Lionel: after Robert's feedback, ok too for WONTFIX here?

Could you first try to fallback to isc_attach_database when runBackupService fails? If that works (along with a pop-up warning?) it at least gives the user a chance to fix the issue manually?

I guess the bug is more related to an upgrade of the Firebird version than LibreOffice code, so the "real fix" would be in Firebird; runBackupService should accept all data created by a past version of FireBird (!) Maybe we should open the subject of ascending data compatibility with the Firebird devs?
Comment 19 Julien Nabet 2022-01-02 17:33:36 UTC
(In reply to Lionel Elie Mamane from comment #18)
> ...
> Could you first try to fallback to isc_attach_database when runBackupService
> fails? If that works (along with a pop-up warning?) it at least gives the
> user a chance to fix the issue manually?

I commented the runBackupService in Connection::construct just to test and had this:
warn:connectivity.firebird:223594:223594:connectivity/source/drivers/firebird/Util.cxx:57: firebird_sdbc error:
*I/O error during "open" operation for file "/tmp/luiv08z.tmp/luiv092.tmp/firebird.fdb"
*Error while trying to open file
*No such file or directory
caused by
'isc_attach_database'
Comment 20 Robert Großkopf 2022-01-02 18:29:26 UTC
(In reply to Julien Nabet from comment #19)
> "/tmp/luiv08z.tmp/luiv092.tmp/firebird.fdb"
> *Error while trying to open file
> *No such file or directory

Did you have a look at this folder? Could be the file isn't unpacked right form LO.
Comment 21 Julien Nabet 2022-01-02 18:44:19 UTC
(In reply to Robert Großkopf from comment #20)
> (In reply to Julien Nabet from comment #19)
> > "/tmp/luiv08z.tmp/luiv092.tmp/firebird.fdb"
> > *Error while trying to open file
> > *No such file or directory
> 
> Did you have a look at this folder? Could be the file isn't unpacked right
> form LO.

Yes it contains firebird.fbk
but if I use:
const OString sFirebirdURL2 = OUStringToOString(m_sFBKPath, RTL_TEXTENCODING_UTF8);
and use for isc_attach_database, I got:
warn:connectivity.firebird:226371:226371:connectivity/source/drivers/firebird/Util.cxx:57: firebird_sdbc error:
*file /tmp/luln2ix.tmp/luln2j0.tmp/firebird.fbk is not a valid database
caused by
'isc_attach_database'
Comment 22 Robert Großkopf 2022-01-02 18:59:49 UTC
(In reply to Julien Nabet from comment #21)
> (In reply to Robert Großkopf from comment #20)
> > (In reply to Julien Nabet from comment #19)
> > > "/tmp/luiv08z.tmp/luiv092.tmp/firebird.fdb"
> > > *Error while trying to open file
> > > *No such file or directory
> > 
> > Did you have a look at this folder? Could be the file isn't unpacked right
> > form LO.
> 
> Yes it contains firebird.fbk

There has to be a firebird.fbk and a firebird.fdb in the same folder. The *.fbk is the file created by a backup, which is also the saved file inside the *.odb-file.
Comment 23 Julien Nabet 2022-01-02 19:10:27 UTC
(In reply to Robert Großkopf from comment #22)
> ...
> There has to be a firebird.fbk and a firebird.fdb in the same folder. The
> *.fbk is the file created by a backup, which is also the saved file inside
> the *.odb-file.

Sorry, I forgot to tell it contained only firebird.fbk file, no other file (standard or hidden).

To be even more precise, here's what I got in /tmp/luln2iz.tmp
./luln2ix.tmp
./luln2ix.tmp/luln2iz.tmp
./luln2ix.tmp/luln2iz.tmp/fb_init
./luln2ix.tmp/luln2iy.tmp
./luln2ix.tmp/luln2j1.tmp
./luln2ix.tmp/luln2j1.tmp/firebird.fbk
Comment 24 Lionel Elie Mamane 2022-01-03 08:16:09 UTC
Julien, you wrote in comment 15 that the odb bug reproduction file contains the "old way" fdb file, not the "new way" fbk file, or did I misunderstand? That is a key question, and the basis of my idea.

My hope is that runBackupService chokes on that file, but the firebird engine does not.

So you need to extract the .fdb file from the odb (like old LibreOffice was doing) and isc_attach_database to that.
Comment 25 Julien Nabet 2022-01-03 18:08:54 UTC
(In reply to Lionel Elie Mamane from comment #24)
> Julien, you wrote in comment 15 that the odb bug reproduction file contains
> the "old way" fdb file, not the "new way" fbk file, or did I misunderstand?
> That is a key question, and the basis of my idea.
> 
> My hope is that runBackupService chokes on that file, but the firebird
> engine does not.
> 
> So you need to extract the .fdb file from the odb (like old LibreOffice was
> doing) and isc_attach_database to that.

It seems I had to be really confused since I mixed fbk and fdb.

Here's the result of unzipping the odb file from Wolfgang's attachment (comment 10):
unzip Test-db.zip 
Archive:  Test-db.zip
 extracting: mimetype                
  inflating: content.xml             
  inflating: database/firebird.fbk   
   creating: forms/
   creating: Configurations2/
  inflating: settings.xml            
   creating: reports/
  inflating: META-INF/manifest.xml

So we got an fbk not an fdb.

Then, runBackupService is called in connectivity/source/drivers/firebird/Connection.cxx:
    300             if (m_bIsEmbedded && !bIsFdbStored) // We need to restore the .fbk first
    301             {
    302                 runBackupService(isc_action_svc_restore);
    303             }

m_bIsEmbedded is true since it's an embedded Firebird.
bIsFdbStored is false since there's no fdb in odb file (and so !bIsFdbStored is true and LO calls runBackupService)

Very sorry about the confusion I brought :-(
Comment 26 Lionel Elie Mamane 2022-01-03 18:32:00 UTC
(In reply to Julien Nabet from comment #25)
> (In reply to Lionel Elie Mamane from comment #24)
>> Julien, you wrote in comment 15 that the odb bug reproduction file contains
>> the "old way" fdb file, not the "new way" fbk file, or did I misunderstand?
>> That is a key question, and the basis of my idea.
> 
> It seems I had to be really confused since I mixed fbk and fdb.
> 
> Here's the result of unzipping the odb file from Wolfgang's attachment
> (comment 10):
> unzip Test-db.zip 
> Archive:  Test-db.zip
>   inflating: database/firebird.fbk   
 
> So we got an fbk not an fdb.

OK, then forget my idea.

However, if you feel up to it, there is a conversation to be had with the firebird devs about backwards compatibility. Ideally, we would write to them something along the lines of:

 * this fbk file (send them just the fbk file), created with Firebird version XXXX (the one in LibreOffice 7.1) is accepted by runBackupService(isc_action_svc_restore) in Firebird version XXX , although it contains non-conforming data in that a row contains in column XXXX a value of length YYYY chars, but the row is contstrained to maximum ZZZZZ chars.

 * However, in Firebird version QQQQQ (the one in LibreOffice 7.2), this error

 * This lead to users not being able to access their data anymore.

For reasons of backwards compatibility, would you consider making runBackupService(isc_action_svc_restore) more "be liberal in what it accepts", insofar as it will accept data produced by earlier versions of Firebird?
Comment 27 Julien Nabet 2022-01-03 19:12:59 UTC
(In reply to Lionel Elie Mamane from comment #26)
> ...
> OK, then forget my idea.
> 
> However, if you feel up to it, there is a conversation to be had with the
> firebird devs about backwards compatibility. Ideally, we would write to them
> something along the lines of:
> ...
Good idea! Done here:
https://github.com/FirebirdSQL/firebird/issues/7091

Should we then consider this one as NOTOURBUG or it's a bit too early to tell?
Comment 28 Julien Nabet 2022-01-26 20:52:55 UTC
Since we're dependent on upstream, let's put this one to NOTOURBUG.