Follow-up to r15791.
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.
Patchset2: wrapped commit message at 72 chars
Change-Id: Ic874e92bb1adda3430d3292423d4f3617c25456c
# Replace reserved words with better ones
switch( $name ) {
case 'user':
- return 'mwuser';
+ return $this->realTableName( 'mwuser', $format );
case 'text':
- return 'pagecontent';
+ return $this->realTableName( 'pagecontent', $format );
default:
- return parent::tableName( $name, $format );
+ return $this->realTableName( $name, $format );
}
}
+ /* Don't cheat on installer */
+ function realTableName( $name, $format = 'quoted' ) {
+ return parent::tableName( $name, $format );
+ }
+
/**
* Return the next in a sequence, save the value for retrieval via insertId()
* @return null
if ( !$schema ) {
$schema = $this->getCoreSchema();
}
- $table = $this->tableName( $table, 'raw' );
+ $table = $this->realTableName( $table, 'raw' );
$etable = $this->addQuotes( $table );
$eschema = $this->addQuotes( $schema );
$SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n "
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
- if( $this->db->tableExists( 'user', __METHOD__ ) ) {
+ if( $this->db->tableExists( 'archive', __METHOD__ ) ) {
$status->warning( 'config-install-tables-exist' );
$this->enableLB();
return $status;
*/
protected function getCoreUpdateList() {
return array(
+ # rename tables 1.7.3
+ # r15791 Change reserved word table names "user" and "text"
+ array( 'renameTable', 'user', 'mwuser'),
+ array( 'renameTable', 'text', 'pagecontent'),
+
# new sequences
array( 'addSequence', 'logging_log_id_seq' ),
array( 'addSequence', 'page_restrictions_pr_id_seq' ),
protected function renameTable( $old, $new ) {
if ( $this->db->tableExists( $old ) ) {
$this->output( "Renaming table $old to $new\n" );
- $old = $this->db->addQuotes( $old );
+ $old = $this->db->realTableName( $old, "quoted" );
+ $new = $this->db->realTableName( $new, "quoted" );
$this->db->query( "ALTER TABLE $old RENAME TO $new" );
}
}