From 785ad24aa7ba7c3f50758831e761b4c8bd0dd2df Mon Sep 17 00:00:00 2001 From: Jure Kajzer Date: Wed, 28 Oct 2009 16:17:16 +0000 Subject: [PATCH] Changed sequence names to a standard __seq form. Updated all nextSequenceValue calls with new sequence names. OverlordQ stated he'll handle changes to Postgres scripts. Need someone to change DB2 scripts. --- includes/Article.php | 2 +- includes/Block.php | 2 +- includes/Category.php | 2 +- includes/Import.php | 2 +- includes/LogPage.php | 2 +- includes/RecentChange.php | 2 +- includes/Revision.php | 4 ++-- includes/db/DatabaseOracle.php | 6 ++++++ maintenance/ora/patch_seq_names_pre1.16.sql | 8 ++++++++ maintenance/ora/tables.sql | 14 +++++++------- 10 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 maintenance/ora/patch_seq_names_pre1.16.sql diff --git a/includes/Article.php b/includes/Article.php index e1f172ad62..9e6545a18c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -4097,7 +4097,7 @@ class Article { } $insertRows = array(); foreach( $insertCats as $cat ) { - $insertRows[] = array( 'cat_id' => $dbw->nextSequenceValue( 'category_id_seq' ), + $insertRows[] = array( 'cat_id' => $dbw->nextSequenceValue( 'category_cat_id_seq' ), 'cat_title' => $cat ); } $dbw->insert( 'category', $insertRows, __METHOD__, 'IGNORE' ); diff --git a/includes/Block.php b/includes/Block.php index 02469080cf..8e96e0903d 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -377,7 +377,7 @@ class Block { # Don't collide with expired blocks Block::purgeExpired(); - $ipb_id = $dbw->nextSequenceValue('ipblocks_ipb_id_val'); + $ipb_id = $dbw->nextSequenceValue('ipblocks_ipb_id_seq'); $dbw->insert( 'ipblocks', array( 'ipb_id' => $ipb_id, diff --git a/includes/Category.php b/includes/Category.php index ba52b9444d..e0a356350b 100644 --- a/includes/Category.php +++ b/includes/Category.php @@ -246,7 +246,7 @@ class Category { } else { # Let's be sure that the row exists in the table. We don't need to # do this if we got the row from the table in initialization! - $seqVal = $dbw->nextSequenceValue( 'category_id_seq' ); + $seqVal = $dbw->nextSequenceValue( 'category_cat_id_seq' ); $dbw->insert( 'category', array( 'cat_id' => $seqVal, diff --git a/includes/Import.php b/includes/Import.php index 367361cd12..ecd686606b 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -265,7 +265,7 @@ class WikiRevision { $this->timestamp . "\n" ); return false; } - $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' ); + $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' ); $data = array( 'log_id' => $log_id, 'log_type' => $this->type, diff --git a/includes/LogPage.php b/includes/LogPage.php index 68e8c8ec45..6beb094a44 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -60,7 +60,7 @@ class LogPage { global $wgLogRestrictions; $dbw = wfGetDB( DB_MASTER ); - $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' ); + $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' ); $this->timestamp = $now = wfTimestampNow(); $data = array( diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 386ae72465..64ab5abdd0 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -156,7 +156,7 @@ class RecentChange # Fixup database timestamps $this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']); $this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']); - $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'rc_rc_id_seq' ); + $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' ); ## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL if( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id']==0 ) { diff --git a/includes/Revision.php b/includes/Revision.php index afa273c7cc..93c1120338 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -826,7 +826,7 @@ class Revision { # Record the text (or external storage URL) to the text table if( !isset( $this->mTextId ) ) { - $old_id = $dbw->nextSequenceValue( 'text_old_id_val' ); + $old_id = $dbw->nextSequenceValue( 'text_old_id_seq' ); $dbw->insert( 'text', array( 'old_id' => $old_id, @@ -840,7 +840,7 @@ class Revision { # Record the edit in revisions $rev_id = isset( $this->mId ) ? $this->mId - : $dbw->nextSequenceValue( 'rev_rev_id_val' ); + : $dbw->nextSequenceValue( 'revision_rev_id_seq' ); $dbw->insert( 'revision', array( 'rev_id' => $rev_id, diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index dfbc769c93..8e37a26dea 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -512,6 +512,12 @@ class DatabaseOracle extends DatabaseBase { } else { $srcTable = $this->tableName( $srcTable ); } + + // count-alias subselect fields to avoid abigious definition errors + $i=0; + foreach($varMap as $key=>&$val) + $val=$val.' field'.($i++); + $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . " SELECT $startOpts " . implode( ',', $varMap ) . " FROM $srcTable $useIndex "; diff --git a/maintenance/ora/patch_seq_names_pre1.16.sql b/maintenance/ora/patch_seq_names_pre1.16.sql new file mode 100644 index 0000000000..5346b1418a --- /dev/null +++ b/maintenance/ora/patch_seq_names_pre1.16.sql @@ -0,0 +1,8 @@ +-- script for renameing sequence names to conform with
__seq format +RENAME rev_rev_id_val TO revision_rev_id_seq; +RENAME text_old_id_val TO text_old_id_seq; +RENAME category_id_seq TO category_cat_id_seq; +RENAME ipblocks_ipb_id_val TO ipblocks_ipb_id_seq; +RENAME rc_rc_id_seq TO recentchanges_rc_id_seq; +RENAME log_log_id_seq TO logging_log_id_seq; +RENAME pr_id_val TO page_restrictions_pr_id_seq; \ No newline at end of file diff --git a/maintenance/ora/tables.sql b/maintenance/ora/tables.sql index 1e0289356f..2ddadfe7f3 100644 --- a/maintenance/ora/tables.sql +++ b/maintenance/ora/tables.sql @@ -79,7 +79,7 @@ BEGIN END; /*$mw$*/ -CREATE SEQUENCE rev_rev_id_val; +CREATE SEQUENCE revision_rev_id_seq; CREATE TABLE &mw_prefix.revision ( rev_id NUMBER NOT NULL, rev_page NUMBER NULL REFERENCES &mw_prefix.page (page_id) ON DELETE CASCADE, @@ -100,7 +100,7 @@ CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timest CREATE INDEX &mw_prefix.revision_i03 ON &mw_prefix.revision (rev_user,rev_timestamp); CREATE INDEX &mw_prefix.revision_i04 ON &mw_prefix.revision (rev_user_text,rev_timestamp); -CREATE SEQUENCE text_old_id_val; +CREATE SEQUENCE text_old_id_seq; CREATE TABLE &mw_prefix.pagecontent ( -- replaces reserved word 'text' old_id NUMBER NOT NULL, old_text CLOB, @@ -163,7 +163,7 @@ CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_sortkey,cl_from); CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp); -CREATE SEQUENCE category_id_seq; +CREATE SEQUENCE category_cat_id_seq; CREATE TABLE &mw_prefix.category ( cat_id NUMBER NOT NULL, cat_title VARCHAR2(255) NOT NULL, @@ -210,7 +210,7 @@ CREATE TABLE &mw_prefix.hitcounter ( hc_id NUMBER NOT NULL ); -CREATE SEQUENCE ipblocks_ipb_id_val; +CREATE SEQUENCE ipblocks_ipb_id_seq; CREATE TABLE &mw_prefix.ipblocks ( ipb_id NUMBER NOT NULL, ipb_address VARCHAR2(255) NULL, @@ -314,7 +314,7 @@ CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_gr CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp); CREATE INDEX &mw_prefix.filearchive_i04 ON &mw_prefix.filearchive (fa_user_text,fa_timestamp); -CREATE SEQUENCE rc_rc_id_seq; +CREATE SEQUENCE recentchanges_rc_id_seq; CREATE TABLE &mw_prefix.recentchanges ( rc_id NUMBER NOT NULL, rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, @@ -409,7 +409,7 @@ CREATE TABLE &mw_prefix.transcache ( CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url); -CREATE SEQUENCE log_log_id_seq; +CREATE SEQUENCE logging_log_id_seq; CREATE TABLE &mw_prefix.logging ( log_id NUMBER NOT NULL, log_type VARCHAR2(10) NOT NULL, @@ -488,7 +488,7 @@ CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type, CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title); CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo); -CREATE SEQUENCE pr_id_val; +CREATE SEQUENCE page_restrictions_pr_id_seq; CREATE TABLE &mw_prefix.page_restrictions ( pr_id NUMBER NOT NULL, pr_page NUMBER NULL REFERENCES &mw_prefix.page (page_id) ON DELETE CASCADE, -- 2.20.1