- SQL parser test: also test second call to parser->query(), it should return nullptr
GIT_SILENT use scoped pointer for owned query
- SQL parser test: use the cached query, parser->query() is nullptr by then
- Setup query in connection: parsing failure can delete the query object so do not try to access it
Query schema: fix possible crashes - explicitly/properly remove query from connection's cache when needed
- SQL parser: add Q_REQUIRED_RESULT flags when table or query objects are returned with ownership
+remove overload that makes no sense (because object with ownership passed should not be const)
- Naming in KDbQuerySchemaFieldsExpanded: ownedVisibleColumns -> ownedVisibleFields
- Query schema: fix memory leaks - remove internal expressions
- Correct result set retrieved from the backend when internal JOINs are in use, also fix possible crash
Example user's query (e.g. for the Simple_Database.kexi): "SELECT *, ownership.owner FROM ownership"
Assumption: the "ownership" table is related to persons table via ownership.owner=persons.id
Assumption: this relationship is used to obtain person's surname for display
Before the fix generated query was like this:
SELECT *, ownership.owner, persons.surname, ownership.OID
FROM ownership LEFT OUTER JOIN persons
ON ownership.owner=persons.id
This means the result set also included persons.* what is not what we expect:
- for performance reasons
- we have not allocated space for it --> crash
The fix is based on enumerating all explicitly used tables
(T1.*, T2.*, ... Tn.*) in the SELECT in place of the "*".
After the fix generated query is like this:
SELECT ownership.*, ownership.owner, persons.surname, ownership.OID
FROM ownership LEFT OUTER JOIN persons ON ownership.owner=persons.id
This means the result set includes columns that we need.
(redundancy in columns would be fixed elsewhere)
Affected drivers: any, crashes were confirmed in SQLite.
For other example see the Northwind tables mentioned in the patch.
FIXED-IN:3.1.0