Bug 393705 - Exporting query with ORDER BY crashes KEXI
Summary: Exporting query with ORDER BY crashes KEXI
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: Queries (show other bugs)
Version: 3.1.0
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: 3.2
Assignee: Jarosław Staniek
URL:
Keywords:
: 395268 402716 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-04-30 23:16 UTC by Barrie Backhurst
Modified: 2019-01-06 21:47 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barrie Backhurst 2018-04-30 23:16:41 UTC
Having created a query and being able to view data, design or sql right clicking and choosing an export option causes KEXI to crash. I have not installed with debugging support but running from the command line displays the following message

QString::arg: Argument missing: SELECT o_id, o_type, o_name, o_caption, o_desc FROM kexi__objects WHERE o_type=1 AND o_id=1, 187
KCrash: Application 'kexi-3.1' crashing...

An example of sql that I am using is as follows

SELECT p11n.* FROM p11n WHERE p11n.EmpID > 4 AND p11n.Prd < 9 ORDER BY EmpID, Prd

When opening the same file in KEXI-2.9.11(on a diferent pc) the export works perfectly
Comment 1 Jarosław Staniek 2018-05-01 21:19:39 UTC
Thanks Barrie. 
The "QString::arg: Argument missing" bug will be fixed in 3.1.1. I am not sure it will fix the case you mention though. If you could attach or send me example file that crashes KEXI it could be clear.
Comment 2 Jarosław Staniek 2018-05-01 21:29:46 UTC
Git commit a00f37b024e1a0888de3266af9acff99e6f21aa2 by Jaroslaw Staniek.
Committed on 01/05/2018 at 21:29.
Pushed by staniek into branch '3.1'.

Fix loading object data for given type and ID

FIXED-IN:3.1.1

M  +1    -1    src/KDbConnection.cpp

https://commits.kde.org/kdb/a00f37b024e1a0888de3266af9acff99e6f21aa2
Comment 3 Barrie Backhurst 2018-05-02 05:47:25 UTC
(In reply to Jarosław Staniek from comment #1)
> Thanks Barrie. 
> The "QString::arg: Argument missing" bug will be fixed in 3.1.1. I am not
> sure it will fix the case you mention though. If you could attach or send me
> example file that crashes KEXI it could be clear.

I did not want to send the whole file as is and deleted all unrelated tables(188 tables), now with the file trimmed to a minimum it no longer crashes when attempting the export, though it fails with an error message "could not open data for exporting" The command line out put is as follows

QString::arg: Argument missing: SELECT o_id, o_type, o_name, o_caption, o_desc FROM kexi__objects WHERE o_type=1 AND o_id=1, 187
QString::arg: Argument missing: SELECT o_id, o_type, o_name, o_caption, o_desc FROM kexi__objects WHERE o_type=2 AND o_id=2, 187
org.kde.kdb.core: no table or query found for id== 187
Comment 4 Barrie Backhurst 2018-05-02 06:08:29 UTC
I have sent you the trimmed copy via email
Comment 5 Barrie Backhurst 2018-05-02 07:59:01 UTC
(In reply to Jarosław Staniek from comment #2)
> Git commit a00f37b024e1a0888de3266af9acff99e6f21aa2 by Jaroslaw Staniek.
> Committed on 01/05/2018 at 21:29.
> Pushed by staniek into branch '3.1'.
> 
> Fix loading object data for given type and ID
> 
> FIXED-IN:3.1.1
> 
> M  +1    -1    src/KDbConnection.cpp
> 
> https://commits.kde.org/kdb/a00f37b024e1a0888de3266af9acff99e6f21aa2


I have rebuilt kdb with the patch and the export works fine now

Thankyou
Comment 6 Jarosław Staniek 2018-05-16 08:16:36 UTC
Git commit 3414fbddffa433b23d43376b44fef5421b734250 by Jaroslaw Staniek.
Committed on 16/05/2018 at 08:15.
Pushed by staniek into branch 'master'.

Fix handling ORDER BY part of queries

Summary:
- new APIs
- maintain relations between connections, queries and column infos
- fix cloning queries with ORDER BY
- update and add autotests

FIXED-IN:3.2
Related: bug 392753

Test Plan:
Required: KEXI & KDb 3.2 (current master)

Test 1: Open report and query from https://bugs.kde.org/show_bug.cgi?id=392753#c0 in design and data views.
Expected: works, no crashes

Test 2: Try these on a standard Persons and Cars test:
select id from cars order by owner;
select id from cars order by owner, model, id;
select id, model from cars order by 2, 1;

Expected: works, no crash

Reviewers: piggz

Reviewed By: piggz

Subscribers: Kexi-Devel-list

Tags: #kdb

Differential Revision: https://phabricator.kde.org/D12873

M  +1    -1    CMakeLists.txt
M  +3    -0    autotests/CMakeLists.txt
A  +212  -0    autotests/OrderByColumnTest.cpp     [License: LGPL (v2+)]
A  +46   -0    autotests/OrderByColumnTest.h     [License: LGPL (v2+)]
M  +2    -2    src/KDbNativeStatementBuilder.cpp
M  +87   -28   src/KDbOrderByColumn.cpp
M  +40   -13   src/KDbOrderByColumn.h
M  +17   -28   src/KDbQueryColumnInfo.cpp
M  +25   -1    src/KDbQueryColumnInfo.h
M  +18   -4    src/KDbQuerySchema.cpp
M  +29   -1    src/KDbQuerySchema_p.h

https://commits.kde.org/kdb/3414fbddffa433b23d43376b44fef5421b734250
Comment 7 Jarosław Staniek 2018-05-16 13:01:07 UTC
Feel free to test the git version.
Comment 8 Jarosław Staniek 2018-06-13 11:42:30 UTC
*** Bug 395268 has been marked as a duplicate of this bug. ***
Comment 9 Jarosław Staniek 2018-12-30 22:48:38 UTC
*** Bug 402716 has been marked as a duplicate of this bug. ***
Comment 10 Jarosław Staniek 2019-01-06 21:47:02 UTC
Git commit d1b31bd8a6fc6632f8eeab70b5e9a0f1c8630c8f by Jaroslaw Staniek.
Committed on 06/01/2019 at 21:16.
Pushed by staniek into branch '3.2'.

Fix handling ORDER BY part of queries

Summary:
- new APIs
- maintain relations between connections, queries and column infos
- fix cloning queries with ORDER BY
- update and add autotests

FIXED-IN:3.2
Related: bug 392753

Test Plan:
Required: KEXI & KDb 3.2 (current master)

Test 1: Open report and query from https://bugs.kde.org/show_bug.cgi?id=392753#c0 in design and data views.
Expected: works, no crashes

Test 2: Try these on a standard Persons and Cars test:
select id from cars order by owner;
select id from cars order by owner, model, id;
select id, model from cars order by 2, 1;

Expected: works, no crash

Reviewers: piggz

Reviewed By: piggz

Subscribers: Kexi-Devel-list

Tags: #kdb

Differential Revision: https://phabricator.kde.org/D12873

M  +3    -0    autotests/CMakeLists.txt
A  +212  -0    autotests/OrderByColumnTest.cpp     [License: LGPL (v2+)]
A  +46   -0    autotests/OrderByColumnTest.h     [License: LGPL (v2+)]
M  +2    -2    src/KDbNativeStatementBuilder.cpp
M  +87   -28   src/KDbOrderByColumn.cpp
M  +40   -13   src/KDbOrderByColumn.h
M  +17   -28   src/KDbQueryColumnInfo.cpp
M  +25   -1    src/KDbQueryColumnInfo.h
M  +18   -4    src/KDbQuerySchema.cpp
M  +29   -1    src/KDbQuerySchema_p.h

https://commits.kde.org/kdb/d1b31bd8a6fc6632f8eeab70b5e9a0f1c8630c8f