Bug #17619
closedINSERT-Error on table "index_words" on ORACLE and PostgreSQL
0%
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