Bug 165458 - Database queries suddenly show SQL error after update from 24.7.2 to 24.8.5
Summary: Database queries suddenly show SQL error after update from 24.7.2 to 24.8.5
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
24.8.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:25.8.0 target:25.2.2 target:24...
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2025-02-26 11:38 UTC by ernstfritsch6
Modified: 2025-02-27 21:28 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
The database in question (11.90 MB, application/vnd.sun.xml.base)
2025-02-26 12:50 UTC, ernstfritsch6
Details
Minimal test database (3.25 KB, application/vnd.sun.xml.base)
2025-02-27 21:28 UTC, jcsanz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ernstfritsch6 2025-02-26 11:38:13 UTC
Description:
From a quick examination it seems that the COLLATE "UNICODE" statements in an order by clause is suddenly producing an error.
It worked fine in 24.7.2 and striking that from the statements removes the SQL error but of course gives crappy sorting results.
And it gets even sillier:
I have forms using the very queries that are throwing an error when called as a query ... and these forms are working fine showing the desired query results with correct sorting!
What is going on here?????

Steps to Reproduce:
1. Make a query using COLLATE "UNICODE" in an order by statement.
2. Try to save query and get an error.
3. If you already have such a query and it is used in a form however, it works fine.

Actual Results:
Query as query is not running at all due to an (imagined?) error.

Expected Results:
The query should simply run and produce the correctly sorted results.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 24.8.5.2 (X86_64) / LibreOffice Community
Build ID: fddf2685c70b461e7832239a0162a77216259f22
CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL threaded
Comment 1 Xisco Faulí 2025-02-26 12:06:31 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 2 ernstfritsch6 2025-02-26 12:22:48 UTC
I need Info what I can do to make LibreOffice NOT report "errors" it doesn't see itself when calling queries from a form.
The person asking for the data is myself. And while I can get to the data by some workaround that is not exactly what I would call "expected baviour" (being a software developer myself). It is time consuming and if I had not made the mistake of throwing away the install file for 24.7.2 I would have reverted to that in an instant.
Comment 3 ernstfritsch6 2025-02-26 12:28:57 UTC
The only thing I could do is send you the complete database. Everthing else is clearly written here.
SELECT "Artist"."Name" || ' - ' || "Herkunft"."Kuerzel" || ' - ' || "Artist"."Laendercounter", "Artist"."ID", "Artist"."Name", "Herkunft"."Kuerzel", "Artist"."Laendercounter", "Artist"."Gruppenkennzeichen", "Artist"."Ordner" FROM "Artist", "Herkunft" WHERE "Artist"."Herkunft" = "Herkunft"."ID" ORDER BY UPPER ( "Artist"."Name" ) COLLATE "UNICODE" ASC, "Herkunft"."Kuerzel" ASC

saved as "artist_for_selection" in the previous version 24.7.2 shows "SQL syntax error" when opened for editing or called for running.
A form using "artist_for_selection" runs just fin with the correct sorting.

SELECT "Artist"."Name" || ' - ' || "Herkunft"."Kuerzel" || ' - ' || "Artist"."Laendercounter", "Artist"."ID", "Artist"."Name", "Herkunft"."Kuerzel", "Artist"."Laendercounter", "Artist"."Gruppenkennzeichen", "Artist"."Ordner" FROM "Artist", "Herkunft" WHERE "Artist"."Herkunft" = "Herkunft"."ID" ORDER BY UPPER ( "Artist"."Name" ) ASC, "Herkunft"."Kuerzel" ASC
also works fine and does not throw an sql error but of course has crappy sorting.
No idea, what else you need.
Comment 4 ernstfritsch6 2025-02-26 12:50:22 UTC
Created attachment 199467 [details]
The database in question

query's exact name is "_Artist-for-Auswahl" (although every other that has an order by with text shows the same behaviour)
Form using that without problem is "Song"
Comment 5 jcsanz 2025-02-26 13:15:38 UTC
The SQL command (In reply to ernstfritsch6 from comment #3)
> The only thing I could do is send you the complete database. Everthing else
> is clearly written here.
> SELECT "Artist"."Name" || ' - ' || "Herkunft"."Kuerzel" || ' - ' ||
> "Artist"."Laendercounter", "Artist"."ID", "Artist"."Name",
> "Herkunft"."Kuerzel", "Artist"."Laendercounter",
> "Artist"."Gruppenkennzeichen", "Artist"."Ordner" FROM "Artist", "Herkunft"
> WHERE "Artist"."Herkunft" = "Herkunft"."ID" ORDER BY UPPER ( "Artist"."Name"
> ) COLLATE "UNICODE" ASC, "Herkunft"."Kuerzel" ASC
> 

This command works for me just using the option "Run SQL command directly"

Version: 25.2.0.3 (X86_64) / LibreOffice Community
Build ID: e1cf4a87eb02d755bce1a01209907ea5ddc8f069
CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: es-ES
Calc: CL threaded
Comment 6 ernstfritsch6 2025-02-26 13:32:23 UTC
Yes, that works here as well. But I cannot see the results in a meaningful way here. (it runs quickly if I don't look at the results of the select but if I do, it takes forever. Longer than I would expect a 9,500 records resultset to take).
But starting the query _Artist-for-Auswahl which contains this exact SQL statement reults in an SQL-error that can be removed by removing the COLLATE "UNICODE".
By the way (nothing to do with this problem but it has been reported ages ago and I would need that feature)
Extras-> SQL still only takes a single command. Adding a ";" to separate several commands results in an error.
I knew @filename.sql to simply execute an sql file with several commands from Oracle but I have not fouund anything like that here (if that worked, it wouldn't matter that I can only execute single commands under that menue item)
Comment 7 m_a_riosv 2025-02-26 22:41:18 UTC
Works with
Version: 24.2.0.3 (X86_64) / LibreOffice Community
Build ID: da48488a73ddd66ea24cf16bbc4f7b9c08e9bea1
CPU threads: 16; OS: Windows 10.0 Build 26100; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL threaded

But fails with
Version: 24.8.5.2 (X86_64) / LibreOffice Community
Build ID: fddf2685c70b461e7832239a0162a77216259f22

Version: 25.2.1.2 (X86_64) / LibreOffice Community
Build ID: d3abf4aee5fd705e4a92bba33a32f40bc4e56f49

Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 1fc03eaed2899ac041f660f54cb1facb71390ccf
CPU threads: 16; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Raster; VCL: win
Locale: en-US (es_ES); UI: en-GB
Calc: CL threaded
Comment 8 Xisco Faulí 2025-02-27 09:43:56 UTC
Regression introduced by:

commit 9530664d07f400f4d8dcbe54d0e82d69168844de	[log]
author	Julien Nabet <serval2412@yahoo.fr>	Wed Feb 07 18:40:38 2024 +0100
committer	Julien Nabet <serval2412@yahoo.fr>	Sat Feb 10 12:50:46 2024 +0100
tree 78e1390aff829106d9a1d0375cdfd410742a74f1
parent b370357b40b55cece8407eea2dc0014a5aec0d17 [diff]

tdf#159588: Query-GUI: LOWER isnt supported in Query-GUI if condition is LIKE

Bisected with: linux64-24.8
Comment 9 ernstfritsch6 2025-02-27 14:03:20 UTC
@ m_a_riosv 
It worked until 24.7.2 (that was the version I had before upgrading) so whatever changed in 25.x is responsible.

@Xisco Faulí 
You sure you are in the right bug thread? ;-)
Comment 10 ernstfritsch6 2025-02-27 14:06:56 UTC
Sorry, I meant 24.2.7 instead of 7.2
Comment 11 Xisco Faulí 2025-02-27 14:38:25 UTC
(In reply to ernstfritsch6 from comment #9)
> @Xisco Faulí 
> You sure you are in the right bug thread? ;-)

yes, if the mentioned commit is reverted, then it works...
Comment 12 ernstfritsch6 2025-02-27 14:55:34 UTC
Sorry, I had just seen that in MY SQL there wasn't a lower or upper.
I didn't know that you were talking about the inner workings of this. But I understand now.
Comment 13 ernstfritsch6 2025-02-27 14:57:16 UTC
Crap, I wish I could edit comments here.
I mean I knew I didn't have a LIKE in my statement. There was of course an upper in there.
Comment 14 Julien Nabet 2025-02-27 15:48:15 UTC
Revert submitted here:
https://gerrit.libreoffice.org/c/core/+/182314
Comment 15 Julien Nabet 2025-02-27 15:56:42 UTC
Revert for 25.2 waiting for review here:
https://gerrit.libreoffice.org/c/core/+/182315


and for 24.8 branch:
https://gerrit.libreoffice.org/c/core/+/182316
Comment 16 Xisco Faulí 2025-02-27 19:32:11 UTC
if someone could create a minimal reproducer file with the issue, I might be able to create a unittest for it. Unfortunately Base is a complete stranger to me
Comment 17 jcsanz 2025-02-27 21:28:04 UTC
Created attachment 199523 [details]
Minimal test database