Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -476,7 +476,8 @@ |
477 | 477 | |
478 | 478 | $stmt = oci_parse( $this->mConn, $sql ); |
479 | 479 | foreach ( $row as $col => &$val ) { |
480 | | - $col_type = $this->fieldInfo( $this->tableName( $table ), $col )->type(); |
| 480 | + $col_info = $this->fieldInfo( $this->tableName( $table ), $col ); |
| 481 | + $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; |
481 | 482 | |
482 | 483 | if ( $val === null ) { |
483 | 484 | // do nothing ... null was inserted in statement creation |
— | — | @@ -837,11 +838,16 @@ |
838 | 839 | * based on prebuilt table to simulate MySQL field info and keep query speed minimal |
839 | 840 | */ |
840 | 841 | function fieldExists( $table, $field, $fname = 'DatabaseOracle::fieldExists' ) { |
| 842 | + return (bool)$this->fieldInfo( $table, $field, $fname ); |
| 843 | + } |
| 844 | + |
| 845 | + function fieldInfo( $table, $field ) { |
841 | 846 | $tableWhere = ''; |
| 847 | + $field = strtoupper($field); |
842 | 848 | if (is_array($table)) { |
843 | 849 | $tableWhere = 'IN ('; |
844 | 850 | foreach($table as &$singleTable) { |
845 | | - $singleTable = trim( $singleTable, '"' ); |
| 851 | + $singleTable = strtoupper(trim( $singleTable, '"' )); |
846 | 852 | if (isset($this->mFieldInfoCache["$singleTable.$field"])) { |
847 | 853 | return $this->mFieldInfoCache["$singleTable.$field"]; |
848 | 854 | } |
— | — | @@ -849,65 +855,36 @@ |
850 | 856 | } |
851 | 857 | $tableWhere = rtrim($tableWhere, ',').')'; |
852 | 858 | } else { |
853 | | - $table = trim( $table, '"' ); |
| 859 | + $table = strtoupper(trim( $table, '"' )); |
854 | 860 | if (isset($this->mFieldInfoCache["$table.$field"])) { |
855 | 861 | return $this->mFieldInfoCache["$table.$field"]; |
856 | 862 | } |
857 | | - $tableWhere = '= upper(\''.$table.'\')'; |
| 863 | + $tableWhere = '= \''.$table.'\''; |
858 | 864 | } |
859 | | - |
860 | | - $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = UPPER(\''.$field.'\')' ); |
861 | 865 | |
| 866 | + $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = \''.$field.'\'' ); |
862 | 867 | if ( oci_execute( $fieldInfoStmt, OCI_DEFAULT ) === false ) { |
863 | 868 | $e = oci_error( $fieldInfoStmt ); |
864 | 869 | $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ ); |
865 | 870 | return false; |
866 | 871 | } |
867 | 872 | $res = new ORAResult( $this, $fieldInfoStmt ); |
868 | | - if ($res->numRows() != 0) { |
| 873 | + if ($res->numRows() == 0 ) { |
| 874 | + if (is_array($table)) { |
| 875 | + foreach($table as &$singleTable) { |
| 876 | + $this->mFieldInfoCache["$singleTable.$field"] = false; |
| 877 | + } |
| 878 | + } else { |
| 879 | + $this->mFieldInfoCache["$table.$field"] = false; |
| 880 | + } |
| 881 | + } else { |
869 | 882 | $fieldInfoTemp = new ORAField( $res->fetchRow() ); |
870 | 883 | $table = $fieldInfoTemp->tableName(); |
871 | 884 | $this->mFieldInfoCache["$table.$field"] = $fieldInfoTemp; |
872 | | - return true; |
873 | | - } else { |
874 | | - return false; |
| 885 | + return $fieldInfoTemp; |
875 | 886 | } |
876 | 887 | } |
877 | 888 | |
878 | | - function fieldInfo( $table, $field ) { |
879 | | - $tableWhere = ''; |
880 | | - if (is_array($table)) { |
881 | | - $tableWhere = 'IN ('; |
882 | | - foreach($table as &$singleTable) { |
883 | | - $singleTable = trim( $singleTable, '"' ); |
884 | | - if (isset($this->mFieldInfoCache["$singleTable.$field"])) { |
885 | | - return $this->mFieldInfoCache["$singleTable.$field"]; |
886 | | - } |
887 | | - $tableWhere .= '\''.$singleTable.'\','; |
888 | | - } |
889 | | - $tableWhere = rtrim($tableWhere, ',').')'; |
890 | | - } else { |
891 | | - $table = trim( $table, '"' ); |
892 | | - if (isset($this->mFieldInfoCache["$table.$field"])) { |
893 | | - return $this->mFieldInfoCache["$table.$field"]; |
894 | | - } |
895 | | - $tableWhere = '= upper(\''.$table.'\')'; |
896 | | - } |
897 | | - |
898 | | - $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = UPPER(\''.$field.'\')' ); |
899 | | - |
900 | | - if ( oci_execute( $fieldInfoStmt, OCI_DEFAULT ) === false ) { |
901 | | - $e = oci_error( $fieldInfoStmt ); |
902 | | - $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ ); |
903 | | - return false; |
904 | | - } |
905 | | - $res = new ORAResult( $this, $fieldInfoStmt ); |
906 | | - $fieldInfoTemp = new ORAField( $res->fetchRow() ); |
907 | | - $table = $fieldInfoTemp->tableName(); |
908 | | - $this->mFieldInfoCache["$table.$field"] = $fieldInfoTemp; |
909 | | - return $fieldInfoTemp; |
910 | | - } |
911 | | - |
912 | 889 | function begin( $fname = '' ) { |
913 | 890 | $this->mTrxLevel = 1; |
914 | 891 | } |
— | — | @@ -1047,7 +1024,8 @@ |
1048 | 1025 | $conds2 = array(); |
1049 | 1026 | $conds = ($conds != null && !is_array($conds)) ? array($conds) : $conds; |
1050 | 1027 | foreach ( $conds as $col => $val ) { |
1051 | | - $col_type = $this->fieldInfo( $this->tableName( $table ), $col )->type(); |
| 1028 | + $col_info = $this->fieldInfo( $this->tableName( $table ), $col ); |
| 1029 | + $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; |
1052 | 1030 | if ( $col_type == 'CLOB' ) { |
1053 | 1031 | $conds2['TO_CHAR(' . $col . ')'] = $wgLang->checkTitleEncoding( $val ); |
1054 | 1032 | } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) { |
— | — | @@ -1118,7 +1096,8 @@ |
1119 | 1097 | $conds2 = array(); |
1120 | 1098 | $conds = ($conds != null && !is_array($conds)) ? array($conds) : $conds; |
1121 | 1099 | foreach ( $conds as $col => $val ) { |
1122 | | - $col_type = $this->fieldInfo( $this->tableName( $table ), $col )->type(); |
| 1100 | + $col_info = $this->fieldInfo( $this->tableName( $table ), $col ); |
| 1101 | + $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; |
1123 | 1102 | if ( $col_type == 'CLOB' ) { |
1124 | 1103 | $conds2['TO_CHAR(' . $col . ')'] = $wgLang->checkTitleEncoding( $val ); |
1125 | 1104 | } else { |