Project

General

Profile

Actions

Bug #17619

closed

INSERT-Error on table "index_words" on ORACLE and PostgreSQL

Added by Moreno Feltscher over 16 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Indexed Search
Target version:
-
Start date:
2007-09-19
Due date:
% Done:

0%

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

Description

An error occurs when I try to index external documents like PDF:
Warning: ociexecute() [function.ociexecute]: ORA-00001: unique constraint (INTRANET.SYS_C0090792) violated in ...\typo3\sysext\adodb\adodb\drivers\adodb-oci8.inc.php on line 1017

In the dbal-Log I see this (example):
sqlError ORA-00001: unique constraint (*.SYS_C0090792) violated

INSERT INTO "index_words" ( "wid", "baseword", "metaphone" ) VALUES ( '88728859', 'schalter', '212743736' )

This error means there is already one record with this "wid" ("wid" is the key).

So I tried to fix this bug and found something interesting on typo3\sysext\indexed_search\class.indexer.php on line 1843: "// A duplicate-key error will occur here if a word is NOT unset in the unset() line. However as long as the words in $wl are NOT longer as 60 chars (the baseword varchar is 60 characters...) this is not a problem."
This may be true on MySQL, but with Oracle it failes.

So I fixed the function like this:
function checkWordList($wl) {
reset($wl);
$phashArr = array();
while(list($key,) = each($wl)) {
$phashArr[] = $wl[$key]['hash'];
}
if (count($phashArr)) {
$cwl = implode(',',$phashArr);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('baseword', 'index_words', 'wid IN ('.$cwl.')');

if($GLOBALS['TYPO3_DB']->sql_num_rows($res)!=count($wl)) {
$this->log_setTSlogMessage('Inserting words: '.(count($wl)-$GLOBALS['TYPO3_DB']->sql_num_rows($res)),1);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
unset($wl[$row['baseword']]);
}
reset($wl);
while(list($key,$val)=each($wl)) {
$insertFields = array(
'wid' => $val['hash'],
'baseword' => $key,
'metaphone' => $val['metaphone']
);
/* NEW: FIX /
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('
', 'index_words', 'wid = \''.$val['hash'].'\'');
if($GLOBALS['TYPO3_DB']->sql_num_rows($res)==0) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('index_words', $insertFields);
}
/* END FIX */
}
}
}
}

Now it works.
Can please anyone check the fix and give me feedback?

Indexed Search Engine version is 2.10.0
(issue imported from #M6369)


Files

0006369.diff (1.29 KB) 0006369.diff Administrator Admin, 2008-01-15 12:39

Related issues 1 (0 open1 closed)

Has duplicate TYPO3 Core - Bug #84541: Uncaught TYPO3 Exception in indexed_search: duplicate key (hash) errorResolved2018-03-27

Actions
Actions

Also available in: Atom PDF