Bug 167434 - SDBC method cancelRowUpdates caller on insert row
Summary: SDBC method cancelRowUpdates caller on insert row
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-09 10:37 UTC by prrvchr
Modified: 2025-07-14 19:58 UTC (History)
0 users

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 prrvchr 2025-07-09 10:37:43 UTC
Description:
In the libreoffice/dbaccess/source/core/api/RowSetCache.cxx file, line 110, the cancelRowUpdates method is called while the cursor is on the insert row. Normally, JDBC doesn't allow this, but I also see that SDBC shouldn't allow it, libreoffice/dbaccess/source/core/api/RowSet.cxx line 992.

Steps to Reproduce:
If you use a ResultSet in LibreOffice Base that supports the css.sdbcx.XRowLocate interface (bookmark support), it will be impossible to use that ResultSet in Base without moving the cursor before Base calls cancelRowUpdates().
What's certain is that if nothing is done, it won't work.


Actual Results:
Cant use the interface css.sdbcx.XRowLocate in ResultSet.

Expected Results:
Be able to use the interface css.sdbcx.XRowLocate in ResultSet.


Reproducible: Always


User Profile Reset: No

Additional Info:
No
Comment 1 Mike Kaganski 2025-07-09 11:26:28 UTC
Please provide a sample of what's broken, at least to create a unit test for that. Code reading is great; but it should be possible to construct an ODB with a code that does what you explain. Thanks.
Comment 2 prrvchr 2025-07-09 11:48:44 UTC
Hi Mike,

I don't see how to create an ODB file that could highlight this problem.

However, the SDBC layer specification should clearly specify whether or not it's possible to use the cancelRowUpdates() method when you're on the insert row.

Because if it doesn't allow it, then there's definitely a problem on line 111 in the RowSetCache.cxx file.

This problem can be resolved by modifying to obtain:
xUp->moveToInsertRow();
xUp->moveToCurrentRow();
xUp->cancelRowUpdates();

Furthermore, for me, this is a problem that prevents my jdbcDriverOOo driver from working, and I have to work around this problem from the beginning.

What do you think?
Comment 3 Mike Kaganski 2025-07-09 11:52:32 UTC
I think that you are welcome to create a patch. However, when later there appears a regression from that patch, then someone trying to understand how to fix it will find this bug report, which talks about something hypothetical, without a way to reproduce. Then, the natural solution will be just revert the patch.
Comment 4 prrvchr 2025-07-09 12:03:02 UTC
I wanted to add that the code line 111 is only there to ensure that the resultset is editable or not and that if this problem is not managed by the underlying driver then it is impossible to use ResultSets with the css.sdbcx.XRowLocate interface
Comment 5 prrvchr 2025-07-09 12:10:44 UTC
> when later there appears a regression from that patch

Anyway, I believe I'm the only one to present to Base a driver capable of providing ResultSets implementing the XRowLocate interface.

In any case, I've never found a driver providing the XRowLocate interface in the LibreOffice source code.

Maybe I didn't search properly?
Comment 6 Mike Kaganski 2025-07-09 12:33:31 UTC
As I wrote, you are welcome to create a fix. Furthermore, I would likely review it myself; and I am convinced by your analysis. However, I fail to see what is problematic in creating a sample that literally follows your description; with a dataset; a macro that creates a cursor on the insert row, and that calls cancelRowUpdates method. Which would make it easily observable for anyone.

But shrug.
Comment 7 prrvchr 2025-07-09 12:44:44 UTC
The problem is that, apart from jdbcDriverOOo, I don't know of any driver that uses XRowLocate, and jdbcDriverOOo has been working around this problem from the start with a Boolean field: onInsertRow that is tested before the cancelRowUpdates() method is executed.

So, to highlight this problem, I first need to produce a version of jdbcDriverOOo that no longer supports this workaround, and then I can effectively write a macro. Ouf...

To save time, I've proposed this fix: https://gerrit.libreoffice.org/c/core/+/187567
Comment 8 Mike Kaganski 2025-07-09 12:52:49 UTC
(In reply to prrvchr from comment #7)
> The problem is that, apart from jdbcDriverOOo, I don't know of any driver
> that uses XRowLocate

But why can't a *macro* use that? Explicitly calling its methods.
Comment 9 Commit Notification 2025-07-09 14:01:29 UTC
prrvchr committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/dc41bafaf5086bc59b9a2a6315ef5c59fa4a8016

tdf#167434 Don't call cancelRowUpdates when cursor is in insert row

It will be available in 26.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 10 prrvchr 2025-07-09 14:16:58 UTC
> But why can't a *macro* use that? Explicitly calling its methods

I'm probably having trouble explaining this properly.

The problem isn't calling the method, but providing Base with a ResultSet implementing the XRowLocate interface.
And I don't know of any driver implementing this interface other than jdbcDriverOOo, which makes any testing without jdbcDriverOOo impossible.


Anyway, thanks a lot for the merge...