r58356 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58355‎ | r58356 | r58357 >
Date:09:44, 30 October 2009
Author:freakolowsky
Status:ok (Comments)
Tags:
Comment:
overloaded makeList in DatabaseOracle to handle CLOBs in WHERE clauses
Modified paths:
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -1012,39 +1012,22 @@
10131013 return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail );
10141014 }
10151015
1016 - /* redundand ... will remove after confirming bitwise operations functionality
10171016 public function makeList( $a, $mode = LIST_COMMA ) {
1018 - if ( !is_array( $a ) ) {
 1017+ if ( !is_array( $a ) ) {
10191018 throw new DBUnexpectedError( $this, 'DatabaseOracle::makeList called with incorrect parameters' );
10201019 }
 1020+
10211021 $a2 = array();
1022 - foreach ($a as $key => $value) {
1023 - if (strpos($key, ' & ') !== FALSE)
1024 - $a2[preg_replace('/(.*)\s&\s(.*)/', 'BITAND($1, $2)', $key)] = $value;
1025 - elseif (strpos($key, ' | ') !== FALSE)
1026 - $a2[preg_replace('/(.*)\s|\s(.*)/', 'BITOR($1, $2)', $key)] = $value;
1027 - elseif (!is_array($value)) {
1028 - if (strpos($value, ' = ') !== FALSE) {
1029 - if (strpos($value, ' & ') !== FALSE)
1030 - $a2[$key] = preg_replace('/(.*)\s&\s(.*?)\s=\s(.*)/', 'BITAND($1, $2) = $3', $value);
1031 - elseif (strpos($value, ' | ') !== FALSE)
1032 - $a2[$key] = preg_replace('/(.*)\s|\s(.*?)\s=\s(.*)/', 'BITOR($1, $2) = $3', $value);
1033 - else $a2[$key] = $value;
1034 - }
1035 - elseif (strpos($value, ' & ') !== FALSE)
1036 - $a2[$key] = preg_replace('/(.*)\s&\s(.*)/', 'BITAND($1, $2)', $value);
1037 - elseif (strpos($value, ' | ') !== FALSE)
1038 - $a2[$key] = preg_replace('/(.*)\s|\s(.*)/', 'BITOR($1, $2)', $value);
1039 - else
1040 - $a2[$key] = $value;
1041 - }
 1022+ foreach($a as $col=>$val) {
 1023+ $col_type=$this->fieldInfo($this->tableName($table), $col)->type();
 1024+ if ($col_type == 'CLOB')
 1025+ $a2['TO_CHAR('.$col.')'] = $val;
10421026 else
1043 - $a2[$key] = $value;
 1027+ $a2[$col] = $val;
10441028 }
1045 -
 1029+
10461030 return parent::makeList($a2, $mode);
10471031 }
1048 - */
10491032
10501033 function bitNot($field) {
10511034 //expecting bit-fields smaller than 4bytes

Follow-up revisions

RevisionCommit summaryAuthorDate
r60665fixme for r58356freakolowsky13:35, 5 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   03:52, 5 January 2010

fieldInfo() needs to cache its results if you're going to use it in a tight loop like this.

#Comment by Freakolowsky (talk | contribs)   13:41, 5 January 2010

preliminary fixed in r60665.

Usually SGA and oci driver perform quite well with their own internal query cacheing, but i guess more cache of statics is always better. I will look into using a filecache system for this one ...

Status & tagging log