Created attachment 84844 [details] Backtrace When using the same table in different "joins" (In SQL mode, since it's not possible in DESIGN mode) Kexi crashes when switching to either DATA or DESIGN modes. Please look at the attached testcase. The query I've tried is: SELECT tb3.id_t3 T3ID, tb3.id_t2 T2ID, tb3.id_t1 T1ID_REFIN_T3, tb2.id_t1 T1ID_REFIN_T2 from t3 tb3, t2 tb2, t1 tb1_2, t1 tb1_3 where tb3.id_t2 = tb2.id_t2 and tb3.id_t1 = tb1_3.id_t1 and tb2.id_t1 = tb1_2.id_t1
Created attachment 84845 [details] Testcase
Noticed that it actually happens whenever the "lookup" table in the join is aliased in the query.
Created attachment 85036 [details] Linux (2014-02-07 master) backtrace
If we reduce the query to "SELECT tb2.id_t1 AS a FROM t2 tb2", Kexi tries to execute: SELECT tb2.id_t1 AS a, __kexidb_t1_0.id_t1, t2.OID FROM t2 AS tb2 LEFT OUTER JOIN t1 AS __kexidb_t1_0 ON t2.id_t1=__kexidb_t1_0.id_t1 This does not crash but fails with message from server: no such column: t2.OID. it looks like the engine should not attempt to traverse via the lookups for queries. Here tb2.id_t1 should be handled in low-level, as normal integer column.
And on the resulting data table view tb2.id_t1 should be replaced with the referenced values. This is also how MSA behaves.
https://bugs.kde.org/show_bug.cgi?id=330410#c4 depends on #330910, which is was fixed for 2.8.0. The crash needs to be fixed still.
Fixed, hopefully will be part of 2.9.5.
Git commit fd3942a3c5228acc224ac3afd4f0a4e83a56c16f by Jaroslaw Staniek. Committed on 30/05/2015 at 19:30. Pushed by staniek into branch 'calligra/2.9'. Keep pointer to related Connection object in query, so it can be used to find related tables To do this, add a QuerySchema ctor and allow to call it internally by the parser. We had to move QuerySchemaPrivate to separate files. REVIEW:123942 FIXED-IN:2.9.5 M +1 -0 libs/db/CMakeLists.txt M +190 -189 libs/db/parser/sqlparser.cpp M +1 -1 libs/db/parser/sqlparser.h M +2 -1 libs/db/parser/sqlparser.y M +18 -333 libs/db/queryschema.cpp M +3 -0 libs/db/queryschema.h A +251 -0 libs/db/queryschema_p.cpp [License: LGPL (v2+)] A +201 -0 libs/db/queryschema_p.h [License: LGPL (v2+)] http://commits.kde.org/calligra/fd3942a3c5228acc224ac3afd4f0a4e83a56c16f
Git commit 77bd5dc71385871290873a528f034e203d45854d by Jaroslaw Staniek. Committed on 24/06/2015 at 10:14. Pushed by staniek into branch 'master'. Keep pointer to related Connection object in queries so it can be used to find related tables To do this, add a QuerySchema ctor. from Calligra 2.9.5 fd3942a3c5228acc M +25 -3 src/KDbQuerySchema.cpp M +3 -0 src/KDbQuerySchema.h http://commits.kde.org/kdb/77bd5dc71385871290873a528f034e203d45854d
Git commit 48ca098ea695f020134895288194717f531d60bc by Jaroslaw Staniek. Committed on 24/06/2015 at 10:46. Pushed by staniek into branch 'master'. Make parser pass its Connection object when creating query schemas To do that we had to move KDbQuerySchema::Private to separate files and add an internal function createQuery() accessible to the parser based on Calligra 2.9.5 fd3942a3c5228acc M +1 -0 src/CMakeLists.txt M +2 -339 src/KDbQuerySchema.cpp M +2 -1 src/KDbQuerySchema.h A +198 -0 src/KDbQuerySchema_p.cpp [License: LGPL (v2+)] A +210 -0 src/KDbQuerySchema_p.h [License: LGPL (v2+)] M +2 -1 src/parser/KDbSqlParser.y M +197 -196 src/parser/generated/sqlparser.cpp M +1 -1 src/parser/generated/sqlparser.h http://commits.kde.org/kdb/48ca098ea695f020134895288194717f531d60bc