Bug #46271
closedDB-error with postgreSQL
100%
Description
using "news" with DBAL and postreSQL results in the following DB-error, when editing the news-plugin-content-element:
TYPO3\CMS\Core\Database\DatabaseConnection::exec_SELECTquery
ERROR ERROR: function find_in_set(unknown, bigint) does not exist
LINE 1: ...id" FROM "tx_news_domain_model_category" WHERE FIND_IN_SE...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
lastBuiltQuery:
SELECT "uid" FROM "tx_news_domain_model_category" WHERE FIND_IN_SET('0', "parentcategory") != 0 OR "parentcategory" = ''
debug_backtrace:
TYPO3\CMS\Backend\Controller\EditDocumentController->main#59 // TYPO3\CMS\Backend\Controller\EditDocumentController->makeEditForm#627 // TYPO3\CMS\Backend\Form\FormEngine->getMainFields#832 // TYPO3\CMS\Backend\Form\FormEngine->getSingleField#786 // TYPO3\CMS\Backend\Form\FormEngine->getSingleField_SW#1092 // TYPO3\CMS\Backend\Form\FormEngine->getSingleField_typeFlex#1207 // TYPO3\CMS\Backend\Form\FormEngine->getSingleField_typeFlex_draw#2682 // TYPO3\CMS\Backend\Form\FormEngine->getSingleField_SW#2964 // TYPO3\CMS\Backend\Form\FormEngine->getSingleField_typeSelect#1192 // TYPO3\CMS\Backend\Form\Element\TreeElement->renderField#1740 // TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider->initializeTreeData#87 // TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider->getChildrenOf#288 // TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider->getRelatedRecords#313 // TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider->getChildrenUidsFromParentRelation#340 // TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider->listFieldQuery#376 // TYPO3\CMS\Core\Database\DatabaseConnection->exec_SELECTgetRows#427 // TYPO3\CMS\Core\Database\DatabaseConnection->debug#284
Updated by Xavier Perseguers over 11 years ago
The error shows something interesting:
ERROR ERROR: function find_in_set(unknown, bigint) does not exist
So the find_in_set('0', "parentcategory") seems to tell us that column parentcategory is a bigint, is it true? If so, why are you using a find_in_set for a numerical column?
If not, or anyway, the find_in_set() is not part of PostgreSQL and has normally been created when you run the script EXT:dbal/res/postgresql/postgresql-compatibility.sql. You may have to have a look at its definition, adjust it or overload it for your environment with different types.
HTH
Updated by Gerald Buttinger over 11 years ago
the column "parentcategory" of table "tx_news_domain_model_category" is indeed "bigint" on postgres and "int(11)" on mysql. so i also don't understand, why "find_in_set" is used here. wouldn't "WHERE parentcategory != 0" have the same result here?
i have run the "postgresql-compatibility.sql" script, but it only creates a "find_in_set(text, text)" function, which wants a text and not bigint as second parameter. sure, one could create a "find_in_set(text, bigint)" variant, but imho that would not make sense.
also, i've just realized, that the second WHERE-part (OR "parentcategory" = '') also fails on postgres, since the field is bigint and not a string.
Updated by Gerald Buttinger over 11 years ago
i've dug a little deeper now. the culprit select statement is created in this function:
TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider->listFieldQuery
...which looks like this:
protected function listFieldQuery($fieldName, $queryId) { $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $this->getTableName(), $GLOBALS['TYPO3_DB']->listQuery($fieldName, intval($queryId), $this->getTableName()) . (intval($queryId) == 0 ? ' OR ' . $fieldName . ' = \'\'' : '')); $uidArray = array(); foreach ($records as $record) { $uidArray[] = $record['uid']; } return $uidArray; }
the function makes the select statement, even if the targetted field is not a string-field, and thus cannot contain a "list".
i've now modified the function to first check the field type, and it is "int", make a "int=int" where-clause:
protected function listFieldQuery($fieldName, $queryId) { $uidArray = array(); $arrFieldTypes = $GLOBALS['TYPO3_DB']->cache_fieldType; if ($arrFieldTypes[$this->getTableName()][$fieldName]['type'] == 'int') { $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $this->getTableName(), $fieldName . '=' . $queryId); } else { $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $this->getTableName(), $GLOBALS['TYPO3_DB']->listQuery($fieldName, intval($queryId), $this->getTableName()) . (intval($queryId) == 0 ? ' OR ' . $fieldName . ' = \'\'' : '')); } if (is_array($records)) { foreach ($records as $record) { $uidArray[] = $record['uid']; } } return $uidArray; }
this fixes the problem for me, but i don't know if it's the "right" solution.
also, since the problem seems to lie with the typo3-core, and not especially with the "news"-extension, maybe this bug should be assigned to the core-project.
what do you typo3-gurus think?
Updated by Anja Leichsenring over 11 years ago
- Project changed from 534 to TYPO3 Core
Sorry to tell you this, but this is not an Extbase issue, but for the Core or maybe dbal. So I move the ticket again.
Updated by Mathias Schreiber almost 10 years ago
- Status changed from Accepted to Resolved
- Is Regression set to No
Check out sysext/dbal/res/postpresql/ to supply the functions necessary
Updated by alexis nicolas over 9 years ago
Fix issue #67172. Thank you very much Gerald!
Updated by Mathias Schreiber over 9 years ago
- Status changed from Resolved to New
- TYPO3 Version changed from 6.0 to 7
re-opened because it was closed during the FIND_IN_SET on postgres madness
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 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.