Project

General

Profile

Actions

Bug #67155

closed

Invalid SQL Query for sys_categories

Added by Morton Jonuschat almost 9 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2015-05-26
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Epic #64459: Make TYPO3 run on PostgreSQLClosed2015-05-21

Actions
Related to TYPO3 Core - Bug #67172: AdoDB error on editing a pageClosed2015-05-27

Actions
Related to TYPO3 Core - Bug #46271: DB-error with postgreSQLClosed2013-03-14

Actions
Actions #1

Updated by Morton Jonuschat almost 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.

Actions #2

Updated by Morton Jonuschat almost 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

Actions #3

Updated by alexis nicolas almost 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.

Actions #4

Updated by Gerrit Code Review almost 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

Actions #5

Updated by Morton Jonuschat almost 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)
Actions #6

Updated by Gerrit Code Review almost 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

Actions #7

Updated by Gerrit Code Review almost 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

Actions #8

Updated by Gerrit Code Review almost 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

Actions #9

Updated by Gerrit Code Review almost 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

Actions #10

Updated by Gerrit Code Review almost 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

Actions #11

Updated by Gerrit Code Review almost 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

Actions #12

Updated by Morton Jonuschat almost 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #13

Updated by Gerrit Code Review almost 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

Actions #14

Updated by Morton Jonuschat almost 9 years ago

  • Status changed from Under Review to Resolved
Actions #15

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF