Bug 115828 - SQL: SHUTDOWN COMPACT fails in internal HSQLDB
Summary: SQL: SHUTDOWN COMPACT fails in internal HSQLDB
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
5.4.5.1 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.1.0 target:6.0.2
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2018-02-18 15:41 UTC by robert
Modified: 2018-02-24 15:09 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description robert 2018-02-18 15:41:34 UTC
1. Open an internal HSQL-DB-database-file. Could try it with every database, which is attached to a bug-description, for example this one:
https://bugs.documentfoundation.org/attachment.cgi?id=56592
 
2. Go to Tools > SQL
3. Write the command
SHUTDOWN COMPACT
4. Press "Enter"

This Status is shown:
1: error in script file line: 3 File input/output errorerror java.io.IOException: S1000 invalid storage class: java.lang.NullPointerException opening file - file /home/user/Database/DateAdd.odb.data in statement [CREATE CACHED TABLE "Tabelle"] in statement [SHUTDOWN COMPACT]

If execute the command again this Status is shown:
2: Access is denied: Session is closed

So it seems the command has been executed, but a java-error appears, because LO tries to create a cached table. Has never done this before.

Works till LO 5.4.4.2, fails first with LO 5.4.5.1 on OpenSUSE 42.3 64bit rpm Linux. Also reported in German forum for Windows ...
Comment 1 Julien Nabet 2018-02-19 20:56:08 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 2 Xisco Faulí 2018-02-20 12:09:17 UTC
Regression introduced by:

author	Lionel Elie Mamane <lionel@mamane.lu>	2017-12-28 06:16:30 +0100
committer	Julien Nabet <serval2412@yahoo.fr>	2017-12-28 09:36:46 +0100
commit	66d7540bcf3f82de906a588f01d1fbedc3d2928c (patch)
tree	88041254578e03a3905e4196e5e9f89c9e574a7b
parent	aa1bfa6d18e73265f486ed1f9673ac8f0a4e6de5 (diff)
dbaccess OStatementBase: correctly check database metadata
the previous test didn't make any sense:
 * if xMeta.is(), then the test evaluated to false
 * if !xMeta.is(), then it called supportsMultipleResultSets
   (or supportsBatchUpdates, respectively) on a NULL pointer,
   which guaranteed a segfault / assert.


Bisected with: bibisect-linux64-6.1

Adding Cc: to Lionel Elie Mamane
Comment 3 Julien Nabet 2018-02-20 13:19:41 UTC
Thank you Xisco! I'll try to investigate from this.
Comment 4 Julien Nabet 2018-02-20 20:56:38 UTC
I reverted the patch locally and gave a new try, I could still reproduce this.
Comment 5 Xisco Faulí 2018-02-21 09:57:52 UTC
Hi Julien,

Ok, it seems at 66d7540bcf3f82de906a588f01d1fbedc3d2928c, there is no java error, but '1: Function sequence error.'.

The java error started after

author	Lionel Elie Mamane <lionel@mamane.lu>	2017-12-27 10:17:24 +0100
committer	Julien Nabet <serval2412@yahoo.fr>	2017-12-28 09:40:51 +0100
commit	3c567e55e6aed9e0da892d8b9fc09f8a0c784fcc (patch)
tree	6dc0c6004665ded8c1f23f01df0a9231fc5512d3
parent	8375ab7b5024bad1bcf8bbb0c734ba1e5416445f (diff)
tdf#114702 don't use XMultipleResultset unless DatabaseMetaData says we can

@Julien, I hope it helps now
Comment 6 Lionel Elie Mamane 2018-02-21 10:29:21 UTC
(In reply to Xisco Faulí from comment #5)

> Ok, it seems at 66d7540bcf3f82de906a588f01d1fbedc3d2928c, there is no java
> error, but '1: Function sequence error.'.

The change in 66d7540bcf3f82de906a588f01d1fbedc3d2928c is to throw "function sequence error" when one of the following methods is called when it is not supported (by the underlying SDBC driver):
 - getResultSet
 - getUpdateCount
 - getMoreResults
(also addBatch, clearBatch and executeBatch, but I guess the problematic one is one of the above)

So it seems there is code somewhere that calls one of these functions unconditionally, without checking they are supported, and this patch just exposes that.

> The java error started after
> 
> author	Lionel Elie Mamane <lionel@mamane.lu>	2017-12-27 10:17:24 +0100
> committer	Julien Nabet <serval2412@yahoo.fr>	2017-12-28 09:40:51 +0100
> commit	3c567e55e6aed9e0da892d8b9fc09f8a0c784fcc (patch)
> tree	6dc0c6004665ded8c1f23f01df0a9231fc5512d3
> parent	8375ab7b5024bad1bcf8bbb0c734ba1e5416445f (diff)
> tdf#114702 don't use XMultipleResultset unless DatabaseMetaData says we can

That patch fixes one of the places where getResultSet/getUpdateCount was called without proper checking beforehand. From reading the code, I cannot find a clear idea of the link with the HSQLDB error this bug report is about... It seems to suggest that HSQLDB reacts badly to:
 executeUpdate("SHUTDOWN COMPACT")
but OK to
 execute("SHUTDOWN COMPACT")

Anyway, HSQLDB claims not to support
 - getResultSet
 - getUpdateCount
 - getMoreResults
but seems to implement them (cf class jdbcStatement in workdir/UnpackedTarball/hsqldb/src/org/hsqldb/jdbc/jdbcStatement.java

I would try to just change in workdir/UnpackedTarball/hsqldb/src/org/hsqldb/jdbc/jdbcDatabaseMetaData.java
    public boolean supportsMultipleResultSets() throws SQLException {
        return false;
    }
to
    public boolean supportsMultipleResultSets() throws SQLException {
        return true;
    }

Julien, you want to try that and report back?
Comment 7 Julien Nabet 2018-02-21 10:36:24 UTC
Thank you for your new feedback Xisco, I'll take a look after my day time job.
Comment 8 Julien Nabet 2018-02-21 10:38:29 UTC
(In reply to Lionel Elie Mamane from comment #6)
> ...
> Julien, you want to try that and report back?

Ok, I'll just have to retrieve the LO wiki page explaining how to patch external module and be able to test this.
Comment 9 Julien Nabet 2018-02-21 19:16:36 UTC
(In reply to Lionel Elie Mamane from comment #6)
> ...
> Julien, you want to try that and report back?
I gave it a try and it indeed worked.
Comment 10 Julien Nabet 2018-02-21 19:27:46 UTC
I still fail to understand how to generate a patch even with https://wiki.documentfoundation.org/Development/Patching_External_Libraries.
Indeed, I don't have same paths, everything is different and the patch can't be applied.
Comment 11 Julien Nabet 2018-02-22 20:44:04 UTC
I submitted a patch on gerrit to review here:
https://gerrit.libreoffice.org/#/c/50202/
Comment 12 Commit Notification 2018-02-23 22:55:42 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=856159b3913976c68c8a04b7e939a6cc64477f6a

tdf#115828: hsqldb supports multiple resultSets

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Julien Nabet 2018-02-23 22:56:53 UTC
backport for 6.0 waiting for review here: https://gerrit.libreoffice.org/#/c/50267/
Comment 14 Commit Notification 2018-02-24 15:09:04 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=46980ee24a04f6bcc9ace4217f6b6c929adb0625&h=libreoffice-6-0

tdf#115828: hsqldb supports multiple resultSets

It will be available in 6.0.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.