r113838 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113837‎ | r113838 | r113839 >
Date:20:20, 14 March 2012
Author:saper
Status:reverted
Tags:1.19, gerritmigration 
Comment:
Follow-up to r15791: Rename "user" and "text" when upgrading on PostgreSQL

You can lie to me, but not to your installer.

Make DatabasePostgres::tableExists to check
for real table names, not faked ones.

DatabasePostgres is currently lying to the rest
of the MediaWiki that "mwuser" table is actually
called "user" and that "pagecontents" is called
"text". While MediaWiki does not care, the
installer (and updater do).

This allows us to overcome first hurdle
in getting MediaWiki 1.7.3 to update to trunk
on PostgreSQL and uncover further bugs.

For this commit to actually do something,
we rename those tables when upgrading to match
what we have in maintenance/postgres/tables.sql

And by the way, tell installer not to check
for "user" table, since most PostgreSQL users
will have "mwuser" instead. Picking "archive"
instead.
Modified paths:
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresUpdater.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -708,14 +708,19 @@
709709 # Replace reserved words with better ones
710710 switch( $name ) {
711711 case 'user':
712 - return 'mwuser';
 712+ return $this->realTableName( 'mwuser', $format );
713713 case 'text':
714 - return 'pagecontent';
 714+ return $this->realTableName( 'pagecontent', $format );
715715 default:
716 - return parent::tableName( $name, $format );
 716+ return $this->realTableName( $name, $format );
717717 }
718718 }
719719
 720+ /* Don't cheat on installer */
 721+ function realTableName( $name, $format = 'quoted' ) {
 722+ return parent::tableName( $name, $format );
 723+ }
 724+
720725 /**
721726 * Return the next in a sequence, save the value for retrieval via insertId()
722727 * @return null
@@ -990,7 +995,7 @@
991996 if ( !$schema ) {
992997 $schema = $this->getCoreSchema();
993998 }
994 - $table = $this->tableName( $table, 'raw' );
 999+ $table = $this->realTableName( $table, 'raw' );
9951000 $etable = $this->addQuotes( $table );
9961001 $eschema = $this->addQuotes( $schema );
9971002 $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n "
Index: trunk/phase3/includes/installer/PostgresUpdater.php
@@ -27,6 +27,11 @@
2828 */
2929 protected function getCoreUpdateList() {
3030 return array(
 31+ # rename tables 1.7.3
 32+ # r15791 Change reserved word table names "user" and "text"
 33+ array( 'renameTable', 'user', 'mwuser'),
 34+ array( 'renameTable', 'text', 'pagecontent'),
 35+
3136 # new sequences
3237 array( 'addSequence', 'logging_log_id_seq' ),
3338 array( 'addSequence', 'page_restrictions_pr_id_seq' ),
@@ -406,7 +411,8 @@
407412 protected function renameTable( $old, $new ) {
408413 if ( $this->db->tableExists( $old ) ) {
409414 $this->output( "Renaming table $old to $new\n" );
410 - $old = $this->db->addQuotes( $old );
 415+ $old = $this->db->realTableName( $old, "quoted" );
 416+ $new = $this->db->realTableName( $new, "quoted" );
411417 $this->db->query( "ALTER TABLE $old RENAME TO $new" );
412418 }
413419 }
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -158,7 +158,7 @@
159159 }
160160 $this->db->selectDB( $this->getVar( 'wgDBname' ) );
161161
162 - if( $this->db->tableExists( 'user', __METHOD__ ) ) {
 162+ if( $this->db->tableExists( 'archive', __METHOD__ ) ) {
163163 $status->warning( 'config-install-tables-exist' );
164164 $this->enableLB();
165165 return $status;

Follow-up revisions

RevisionCommit summaryAuthorDate
r114335Revert r107309, r113601, r113704, r113742, r113792, r113838, r113859, r113893......catrope00:16, 21 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r15791Change reserved word table names "user" and "text"greg02:04, 23 July 2006

Status & tagging log