Bug #67155
closedInvalid SQL Query for sys_categories
100%
Description
DBAL/AdoDB Error message:
#1421053336: ADOdb could not run this query: SELECT "uid" FROM "sys_category" WHERE FIND_IN_SET('0', "parent") != 0 OR "parent" = ''
Environment: TYPO3 7.3-dev, PostgreSQL 9.4
How to reproduce: Open the „Backend User Listing” and try to add a new account.
Updated by Morton Jonuschat over 9 years ago
Additional information:
PostgreSQL fails the query with the error message:
ERROR: function find_in_set(unknown, bigint) does not exist
The function is defined with arguments find_in_set(unknown, bigint)
A find_in_set() on an integer column doesn't make any sense, even on MySQL.
Updated by Morton Jonuschat over 9 years ago
The query originates at \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::getChildrenUidsFromParentRelation, line #382 where a query for a child with possibly multiple parents is being created
Updated by alexis nicolas over 9 years ago
The problem seems to be in \TYPO3\CMS\Core\Database\DatabaseConnection:exec_SELECTgetRows().
There, a query is performed but sql_fetch_assoc() returns a 'false' on it.
Updated by Gerrit Code Review over 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Morton Jonuschat over 9 years ago
Background information for the Patch under review:
The impact of the explicit cast on MySQL seems very low according to the query profile. The dataset used for the set was a tree consisting of 100.000 nodes, 100 of which were on the top level,
the rest randomly distributed on varying levels of depth.
mysql> SHOW PROFILES; +----------+------------+-----------------------------------------------------------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+-----------------------------------------------------------------------------------------------+ | 1 | 0.03615300 | SELECT uid FROM sys_category WHERE FIND_IN_SET('0', parent) != 0 OR CAST(parent AS CHAR) = '' | | 2 | 0.03553800 | SELECT uid FROM sys_category WHERE FIND_IN_SET('0', parent) != 0 OR parent = '' | +----------+------------+-----------------------------------------------------------------------------------------------+ 2 rows in set (0,00 sec)
Using FIND_IN_SET() make indexes unusable so there is no difference according to EXPLAIN for a statement:
mysql> EXPLAIN SELECT uid FROM sys_category WHERE FIND_IN_SET('0', parent) != 0 OR parent = ''; +----+-------------+--------------+-------+-----------------+-----------------+---------+------+--------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+--------------+-------+-----------------+-----------------+---------+------+--------+--------------------------+ | 1 | SIMPLE | sys_category | index | category_parent | category_parent | 4 | NULL | 100479 | Using where; Using index | +----+-------------+--------------+-------+-----------------+-----------------+---------+------+--------+--------------------------+ 1 row in set (0,00 sec) mysql> EXPLAIN SELECT uid FROM sys_category WHERE FIND_IN_SET('0', parent) != 0 OR CAST(parent AS CHAR) = ''; +----+-------------+--------------+-------+---------------+-----------------+---------+------+--------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+--------------+-------+---------------+-----------------+---------+------+--------+--------------------------+ | 1 | SIMPLE | sys_category | index | NULL | category_parent | 4 | NULL | 100479 | Using where; Using index | +----+-------------+--------------+-------+---------------+-----------------+---------+------+--------+--------------------------+ 1 row in set (0,01 sec)
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Gerrit Code Review over 9 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Gerrit Code Review over 9 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Gerrit Code Review over 9 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Gerrit Code Review over 9 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Gerrit Code Review over 9 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39779
Updated by Morton Jonuschat over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 14f04a6a526ce654c86e7e62bcf4cb09cfca6eb2.
Updated by Gerrit Code Review over 9 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/41842
Updated by Morton Jonuschat over 9 years ago
- Status changed from Under Review to Resolved
Applied in changeset a780e46ad709bcf5df9253182c620cec8c748bc4.