Bug 498431 - Some SQL queries with the SQL plugin are not processed
Summary: Some SQL queries with the SQL plugin are not processed
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (show other bugs)
Version: 24.08.3
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-09 15:09 UTC by isaac.o.braham
Modified: 2025-01-28 05:36 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description isaac.o.braham 2025-01-09 15:09:37 UTC
SUMMARY
Connecting to a PostgreSQL database I can run  SELECT queries without any issue, but trying to run ALTER TABLE queries fails with error
```
ERROR:  syntax error at or near "ALTER"
LINE 1: PREPARE qpsqlpstmt_7 AS ALTER TABLE ...
                                ^
(42601) QPSQL: Unable to prepare statement
```
I looked the issue up on Qt and some are reporting that when using QPSQL Alter Table statements need to be run without preparing them first (hence, I suppose, the 'Unable to prepare statement' bit). 

The action within Kate of preparing the statement seems to be inbuilt, but it limits the types of statements that can be run.

STEPS TO REPRODUCE
1. Ensure SQL Plugin is enabled
2. Connect to a PostgreSQL database using QPSQL
3. Run a normal SELECT statement to ensure the connection is working
4. Run an ALTER TABLE statement

OBSERVED RESULT
(see error message above)

EXPECTED RESULT
It should run the SQL as is.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.1

ADDITIONAL INFORMATION
Comment 1 Christoph Cullmann 2025-01-10 21:46:07 UTC
At the moment nobody really takes care of the SQL plugin, a patch to solve this would be welcome.
Comment 2 Bug Janitor Service 2025-01-13 11:36:51 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1691
Comment 3 Christoph Cullmann 2025-01-16 20:49:36 UTC
Git commit 686aa9225378f3317f887f1e7b7f9f108ab8d416 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 16/01/2025 at 20:38.
Pushed by cullmann into branch 'master'.

Allow ignoring QSqlQuery prepare failure

M  +15   -5    addons/katesql/sqlmanager.cpp

https://invent.kde.org/utilities/kate/-/commit/686aa9225378f3317f887f1e7b7f9f108ab8d416
Comment 4 Waqar Ahmed 2025-01-28 05:36:50 UTC
Git commit 30bac820cb1bfa435f0419039a914caecdcdfe95 by Waqar Ahmed.
Committed on 28/01/2025 at 05:34.
Pushed by waqar into branch 'release/24.12'.

Allow ignoring QSqlQuery prepare failure

M  +15   -5    addons/katesql/sqlmanager.cpp

https://invent.kde.org/utilities/kate/-/commit/30bac820cb1bfa435f0419039a914caecdcdfe95