Index: trunk/phase3/maintenance/oracle/archives/patch_rebuild_dupfunc.sql |
— | — | @@ -6,6 +6,7 @@ |
7 | 7 | e_table_not_exist EXCEPTION; |
8 | 8 | PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942); |
9 | 9 | l_temp_ei_sql VARCHAR2(2000); |
| 10 | + l_temporary BOOLEAN := p_temporary; |
10 | 11 | BEGIN |
11 | 12 | BEGIN |
12 | 13 | EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname || |
— | — | @@ -14,7 +15,10 @@ |
15 | 16 | WHEN e_table_not_exist THEN |
16 | 17 | NULL; |
17 | 18 | END; |
18 | | - IF (p_temporary) THEN |
| 19 | + IF (p_tabname = 'SEARCHINDEX') THEN |
| 20 | + l_temporary := FALSE; |
| 21 | + END IF; |
| 22 | + IF (l_temporary) THEN |
19 | 23 | EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix || |
20 | 24 | p_tabname || ' AS SELECT * FROM ' || p_oldprefix || |
21 | 25 | p_tabname || ' WHERE ROWNUM = 0'; |
— | — | @@ -53,7 +57,7 @@ |
54 | 58 | EXECUTE IMMEDIATE l_temp_ei_sql; |
55 | 59 | END IF; |
56 | 60 | END LOOP; |
57 | | - IF (NOT p_temporary) THEN |
| 61 | + IF (NOT l_temporary) THEN |
58 | 62 | FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT', |
59 | 63 | constraint_name), |
60 | 64 | 32767, |
— | — | @@ -98,6 +102,29 @@ |
99 | 103 | EXECUTE IMMEDIATE l_temp_ei_sql; |
100 | 104 | END IF; |
101 | 105 | END LOOP; |
| 106 | + FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX', |
| 107 | + index_name), |
| 108 | + 32767, |
| 109 | + 1), |
| 110 | + USER || '"."' || p_oldprefix, |
| 111 | + USER || '"."' || p_newprefix), |
| 112 | + '"' || index_name || '"', |
| 113 | + '"' || p_newprefix || index_name || '"') DDLVC2, |
| 114 | + index_name, |
| 115 | + index_type |
| 116 | + FROM user_indexes ui |
| 117 | + WHERE table_name = p_oldprefix || p_tabname |
| 118 | + AND index_type = 'DOMAIN' |
| 119 | + AND NOT EXISTS |
| 120 | + (SELECT NULL |
| 121 | + FROM user_constraints |
| 122 | + WHERE table_name = ui.table_name |
| 123 | + AND constraint_name = ui.index_name)) LOOP |
| 124 | + l_temp_ei_sql := rc.ddlvc2; |
| 125 | + IF nvl(length(l_temp_ei_sql), 0) > 0 THEN |
| 126 | + EXECUTE IMMEDIATE l_temp_ei_sql; |
| 127 | + END IF; |
| 128 | + END LOOP; |
102 | 129 | FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER', |
103 | 130 | trigger_name), |
104 | 131 | 32767, |
Index: trunk/phase3/maintenance/oracle/tables.sql |
— | — | @@ -718,6 +718,7 @@ |
719 | 719 | e_table_not_exist EXCEPTION; |
720 | 720 | PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942); |
721 | 721 | l_temp_ei_sql VARCHAR2(2000); |
| 722 | + l_temporary BOOLEAN := p_temporary; |
722 | 723 | BEGIN |
723 | 724 | BEGIN |
724 | 725 | EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname || |
— | — | @@ -726,7 +727,10 @@ |
727 | 728 | WHEN e_table_not_exist THEN |
728 | 729 | NULL; |
729 | 730 | END; |
730 | | - IF (p_temporary) THEN |
| 731 | + IF (p_tabname = 'SEARCHINDEX') THEN |
| 732 | + l_temporary := FALSE; |
| 733 | + END IF; |
| 734 | + IF (l_temporary) THEN |
731 | 735 | EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix || |
732 | 736 | p_tabname || ' AS SELECT * FROM ' || p_oldprefix || |
733 | 737 | p_tabname || ' WHERE ROWNUM = 0'; |
— | — | @@ -765,7 +769,7 @@ |
766 | 770 | EXECUTE IMMEDIATE l_temp_ei_sql; |
767 | 771 | END IF; |
768 | 772 | END LOOP; |
769 | | - IF (NOT p_temporary) THEN |
| 773 | + IF (NOT l_temporary) THEN |
770 | 774 | FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT', |
771 | 775 | constraint_name), |
772 | 776 | 32767, |
— | — | @@ -810,6 +814,29 @@ |
811 | 815 | EXECUTE IMMEDIATE l_temp_ei_sql; |
812 | 816 | END IF; |
813 | 817 | END LOOP; |
| 818 | + FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX', |
| 819 | + index_name), |
| 820 | + 32767, |
| 821 | + 1), |
| 822 | + USER || '"."' || p_oldprefix, |
| 823 | + USER || '"."' || p_newprefix), |
| 824 | + '"' || index_name || '"', |
| 825 | + '"' || p_newprefix || index_name || '"') DDLVC2, |
| 826 | + index_name, |
| 827 | + index_type |
| 828 | + FROM user_indexes ui |
| 829 | + WHERE table_name = p_oldprefix || p_tabname |
| 830 | + AND index_type = 'DOMAIN' |
| 831 | + AND NOT EXISTS |
| 832 | + (SELECT NULL |
| 833 | + FROM user_constraints |
| 834 | + WHERE table_name = ui.table_name |
| 835 | + AND constraint_name = ui.index_name)) LOOP |
| 836 | + l_temp_ei_sql := rc.ddlvc2; |
| 837 | + IF nvl(length(l_temp_ei_sql), 0) > 0 THEN |
| 838 | + EXECUTE IMMEDIATE l_temp_ei_sql; |
| 839 | + END IF; |
| 840 | + END LOOP; |
814 | 841 | FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER', |
815 | 842 | trigger_name), |
816 | 843 | 32767, |
— | — | @@ -827,6 +854,7 @@ |
828 | 855 | END IF; |
829 | 856 | END LOOP; |
830 | 857 | END; |
| 858 | + |
831 | 859 | /*$mw$*/ |
832 | 860 | |
833 | 861 | /*$mw$*/ |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -278,6 +278,7 @@ |
279 | 279 | # removed putenv calls because they interfere with the system globaly |
280 | 280 | $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' ); |
281 | 281 | $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' ); |
| 282 | + $this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' ); |
282 | 283 | return $this->mConn; |
283 | 284 | } |
284 | 285 | |
— | — | @@ -298,7 +299,7 @@ |
299 | 300 | } |
300 | 301 | |
301 | 302 | function execFlags() { |
302 | | - return $this->mTrxLevel ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS; |
| 303 | + return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS; |
303 | 304 | } |
304 | 305 | |
305 | 306 | function doQuery( $sql ) { |
— | — | @@ -548,7 +549,7 @@ |
549 | 550 | } |
550 | 551 | |
551 | 552 | $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val; |
552 | | - if ( oci_bind_by_name( $stmt, ":$col", $val ) === false ) { |
| 553 | + if ( oci_bind_by_name( $stmt, ":$col", $val, -1, SQLT_CHR ) === false ) { |
553 | 554 | $e = oci_error( $stmt ); |
554 | 555 | $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ ); |
555 | 556 | return false; |
— | — | @@ -686,7 +687,14 @@ |
687 | 688 | */ |
688 | 689 | private function getSequenceData( $table ) { |
689 | 690 | if ( $this->sequenceData == null ) { |
690 | | - $result = $this->doQuery( 'SELECT lower(us.sequence_name), lower(utc.table_name), lower(utc.column_name) from user_sequences us, user_tab_columns utc where us.sequence_name = utc.table_name||\'_\'||utc.column_name||\'_SEQ\'' ); |
| 691 | + $result = $this->doQuery( "SELECT lower(asq.sequence_name), |
| 692 | + lower(atc.table_name), |
| 693 | + lower(atc.column_name) |
| 694 | + FROM all_sequences asq, all_tab_columns atc |
| 695 | + WHERE decode(atc.table_name, '{$this->mTablePrefix}MWUSER', '{$this->mTablePrefix}USER', atc.table_name) || '_' || |
| 696 | + atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name |
| 697 | + AND asq.sequence_owner = '{$this->mDBname}' |
| 698 | + AND atc.owner = '{$this->mDBname}'" ); |
691 | 699 | |
692 | 700 | while ( ( $row = $result->fetchRow() ) !== false ) { |
693 | 701 | $this->sequenceData[$this->tableName( $row[1] )] = array( |
— | — | @@ -695,7 +703,7 @@ |
696 | 704 | ); |
697 | 705 | } |
698 | 706 | } |
699 | | - |
| 707 | + $table = strtolower( $this->removeIdentifierQuotes( $this->tableName( $table ) ) ); |
700 | 708 | return ( isset( $this->sequenceData[$table] ) ) ? $this->sequenceData[$table] : false; |
701 | 709 | } |
702 | 710 | |
— | — | @@ -810,19 +818,15 @@ |
811 | 819 | } |
812 | 820 | |
813 | 821 | function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseOracle::duplicateTableStructure' ) { |
814 | | - global $wgDBprefix; |
815 | | - $this->setFlag( DBO_DDLMODE ); |
816 | | - |
817 | 822 | $temporary = $temporary ? 'TRUE' : 'FALSE'; |
818 | 823 | |
819 | 824 | $newName = strtoupper( $newName ); |
820 | 825 | $oldName = strtoupper( $oldName ); |
821 | 826 | |
822 | | - $tabName = substr( $newName, strlen( $wgDBprefix ) ); |
| 827 | + $tabName = substr( $newName, strlen( $this->mTablePrefix ) ); |
823 | 828 | $oldPrefix = substr( $oldName, 0, strlen( $oldName ) - strlen( $tabName ) ); |
824 | | - $newPrefix = strtoupper( $wgDBprefix ); |
| 829 | + $newPrefix = strtoupper( $this->mTablePrefix ); |
825 | 830 | |
826 | | - $this->clearFlag( DBO_DDLMODE ); |
827 | 831 | return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', '$oldPrefix', '$newPrefix', $temporary ); END;" ); |
828 | 832 | } |
829 | 833 | |
— | — | @@ -936,7 +940,7 @@ |
937 | 941 | } else { |
938 | 942 | $count = 0; |
939 | 943 | } |
940 | | - return $count != 0; |
| 944 | + return $count; |
941 | 945 | } |
942 | 946 | |
943 | 947 | /** |
— | — | @@ -1010,12 +1014,17 @@ |
1011 | 1015 | |
1012 | 1016 | function begin( $fname = 'DatabaseOracle::begin' ) { |
1013 | 1017 | $this->mTrxLevel = 1; |
| 1018 | + $this->doQuery( 'SET CONSTRAINTS ALL DEFERRED' ); |
1014 | 1019 | } |
1015 | 1020 | |
1016 | 1021 | function commit( $fname = 'DatabaseOracle::commit' ) { |
1017 | 1022 | if ( $this->mTrxLevel ) { |
1018 | | - oci_commit( $this->mConn ); |
| 1023 | + $ret = oci_commit( $this->mConn ); |
| 1024 | + if ( !$ret ) { |
| 1025 | + throw new DBUnexpectedError( $this, $this->lastError() ); |
| 1026 | + } |
1019 | 1027 | $this->mTrxLevel = 0; |
| 1028 | + $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' ); |
1020 | 1029 | } |
1021 | 1030 | } |
1022 | 1031 | |
— | — | @@ -1023,6 +1032,7 @@ |
1024 | 1033 | if ( $this->mTrxLevel ) { |
1025 | 1034 | oci_rollback( $this->mConn ); |
1026 | 1035 | $this->mTrxLevel = 0; |
| 1036 | + $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' ); |
1027 | 1037 | } |
1028 | 1038 | } |
1029 | 1039 | |