Bug 142091 - Queries like "SELECT 1 + 1;" won't run on Libreoffice Base with the MySQL backend.
Summary: Queries like "SELECT 1 + 1;" won't run on Libreoffice Base with the MySQL bac...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.1.2.2 release
Hardware: All Linux (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-05 06:37 UTC by Fajkolan
Modified: 2021-12-19 20:13 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Direct SQL execution from Query GUI (67.24 KB, image/png)
2021-06-07 07:51 UTC, Alex Thurgood
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fajkolan 2021-05-05 06:37:44 UTC
Description:
Queries like "SELECT 1 + 1;" refuse to run in Libreoffice Base with the MySQL backend, even tough they run perfectly from the MySQL command line. Not sure if this affects other backends too.
The example I provided might not seem very useful, but similar queries are useful for getting ratios such as the percentage of men in a dataset:

SELECT (SELECT COUNT(*) FROM members WHERE gender = 'm') / (SELECT COUNT(*) FROM members);

This query runs fine from the MySQL command line, but Libreoffice refuses to run it for some reason.


Steps to Reproduce:
1. Create database with MySQL as backend.
2. Try running a query like "SELECT 1 + 1;"

Actual Results:
SQL Status: HY000
Error code: 1000

syntax error /build/libreoffice-fresh/src/libreoffice-7.1.2.2/dbaccess/source/core/api/SingleSelectQueryComposer.cxx:

SQL Status: HY000
Error code: 1000

/build/libreoffice-fresh/src/libreoffice-7.1.2.2/dbaccess/source/core/api/SingleSelectQueryComposer.cxx:108

SQL Status: HY000
Error code: 1000

Syntax error in SQL statement /build/libreoffice-fresh/src/libreoffice-7.1.2.2/dbaccess/source/core/api/SingleSelectQueryComposer.cxx:109

Expected Results:
It should return the number 2


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.1.2.2 / LibreOffice Community
Build ID: 10(Build:2)
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: hu-HU (en_US.utf8); UI: en-US
7.1.2-3
Calc: threaded

I am using Manjaro Linux.
Comment 1 Robert Großkopf 2021-05-17 18:50:30 UTC
No problem here with LO 7.1.3.2 on OpenSUSE 15.2 64bit rpm Linux.
Note: You have to choose "Run SQL command directly". The GUI of Base doesn't accept queries without 'FROM "Tablename"'.
Comment 2 Alex Thurgood 2021-06-07 07:50:19 UTC
Works for me too on

Version: 7.1.2.2 / LibreOffice Community
Build ID: 8a45595d069ef5570103caea1b71cc9d82b2aae4
CPU threads: 8; OS: Mac OS X 10.16; UI render: default; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded

cf. enclosed screenshot

As Robert has mentioned, you need to run the query in Direct SQL mode, i.e. bypassing the LO SQL parser.
Comment 3 Alex Thurgood 2021-06-07 07:51:22 UTC
Created attachment 172668 [details]
Direct SQL execution from Query GUI
Comment 4 Julien Nabet 2021-12-19 20:13:56 UTC
Following comments from Robert and Alex, let's put this one to WFM.

Fakjolan: don't hesitate to reopen this tracker if you still reproduce this after having applied advice from them.