Bug 80084 - sort out ownership of resultset returned by "X(Prepared)?Statement::execute(Query|Update)?"
Summary: sort out ownership of resultset returned by "X(Prepared)?Statement::execute(Q...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
4.3.0.0.alpha0+ Master
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:4.4.0 target:4.3.0.2
Keywords:
Depends on:
Blocks: Database-Connectivity
  Show dependency treegraph
 
Reported: 2014-06-16 08:22 UTC by Lionel Elie Mamane
Modified: 2024-08-15 03:15 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 Lionel Elie Mamane 2014-06-16 08:22:18 UTC
The sdbc file driver was fixed in:

commit d87c2c59c9c1d5f5825f355c9eb941fdf95b42f6
Author: Lionel Elie Mamane <lionel@mamane.lu>
Date:   Fri Dec 13 13:10:49 2013 +0100

    sdbc file driver (Prepared)Statement: created ResultSet owned by *caller*

Need to do the same with *all* drivers.

For implementers of getMoreResults, we should probably keep references to all resultsets, and free the reference (not dispose the object!) when getMoreResults is called.
Comment 1 Lionel Elie Mamane 2014-06-17 16:06:24 UTC
The difficulty is (from XStatement documentation):

  All statement execute methods implicitly close a statement's
  current ResultSet if an open one exists.

To do that, we need to keep (at least a *weak*) reference. Which is what many drivers actually do...

Also (from service ResultSet documentation):

  A ResultSet is automatically closed (disposed) by the Statement
  that generated it when that Statement is closed, re-executed,
  or used to retrieve the next result from a sequence of multiple results.

So actually, contrary to the assumption in commit d87c2c59c9c1d5f5825f355c9eb941fdf95b42f6, the resulset is not allowed to survive the statement that generated it. That commit needs to be partially reverted, but partially only: it still needs to "abandon" close ownership of the generated resultset and generate a *fresh* one each time it is asked for one by execute() (but not necessarily in the case of repeated calls to getResultSet()).
Comment 2 Julien Nabet 2014-06-18 11:41:58 UTC
Just for information, trying to understand a crash concerning closing LO after having opened queries (Firebird DB) on MacOs with master sources + debug, I noticed that resultset didn't use WeakRef but just a ref (see http://opengrok.libreoffice.org/xref/core/connectivity/source/drivers/firebird/StatementCommonBase.hxx#58)
I tried to use WeakRef but got errors I didn't know how to deal with, trying to change all the dependencies.

Also it seems too that multiple resultsets isn't implemented on Firebird LO driver (see opengrok.libreoffice.org/xref/core/connectivity/source/drivers/firebird/PreparedStatement.cxx#295)
Comment 3 Commit Notification 2014-06-18 14:23:09 UTC
Lionel Elie Mamane committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2504ffccd02f42211dcbc92a5aa6addb04a4b717

fdo#80084 file driver PreparedStatement: close previous ResultSet on reexec



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 4 Commit Notification 2014-06-20 16:21:03 UTC
Lionel Elie Mamane committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f6b9cc2c5b2133b5a44f54ed307bbe9e1e02e5fc&h=libreoffice-4-3

fdo#80084 file driver PreparedStatement: close previous ResultSet on reexec


It will be available in LibreOffice 4.3.

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 5 Alex Thurgood 2015-01-03 17:40:56 UTC Comment hidden (no-value)
Comment 6 QA Administrators 2016-01-17 20:04:18 UTC Comment hidden (obsolete)
Comment 7 Gerhard Schaber 2016-08-09 07:25:06 UTC Comment hidden (obsolete)
Comment 8 Gerhard Schaber 2016-08-09 07:29:43 UTC Comment hidden (obsolete)
Comment 9 Xisco Faulí 2016-09-15 22:49:49 UTC
Hello,
Is this bug fixed?
If so, could you please close it as RESOLVED FIXED?
Comment 10 Xisco Faulí 2017-09-29 08:52:02 UTC Comment hidden (obsolete)
Comment 11 QA Administrators 2019-12-03 14:16:31 UTC Comment hidden (obsolete)
Comment 12 QA Administrators 2022-08-15 03:44:43 UTC Comment hidden (obsolete)
Comment 13 QA Administrators 2024-08-15 03:15:04 UTC
Dear Lionel Elie Mamane,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug