Project

General

Profile

Actions

Bug #46271

closed

DB-error with postgreSQL

Added by Gerald Buttinger about 11 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-03-14
Due date:
% Done:

100%

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

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


Related issues 2 (0 open2 closed)

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

Actions
Related to TYPO3 Core - Bug #67155: Invalid SQL Query for sys_categoriesClosed2015-05-26

Actions
Actions #1

Updated by Georg Ringer about 11 years ago

  • Status changed from New to Accepted
Actions #2

Updated by Xavier Perseguers about 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

Actions #3

Updated by Gerald Buttinger about 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.

Actions #4

Updated by Gerald Buttinger about 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?

Actions #5

Updated by Georg Ringer about 11 years ago

  • Project changed from 1486 to 534
Actions #6

Updated by Anja Leichsenring about 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.

Actions #7

Updated by Mathias Schreiber over 9 years ago

  • Status changed from Accepted to Resolved
  • Is Regression set to No

Check out sysext/dbal/res/postpresql/ to supply the functions necessary

Actions #8

Updated by alexis nicolas almost 9 years ago

Fix issue #67172. Thank you very much Gerald!

Actions #9

Updated by Mathias Schreiber almost 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

Actions #10

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 #11

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 #12

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 #13

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 #14

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 #15

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 #16

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 #17

Updated by Morton Jonuschat almost 9 years ago

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

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 #19

Updated by Morton Jonuschat almost 9 years ago

  • Status changed from Under Review to Resolved
Actions #20

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF