# r15791 Change reserved word table names "user" and "text"
array( 'renameTable', 'user', 'mwuser' ),
array( 'renameTable', 'text', 'pagecontent' ),
- array( 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey'),
+ array( 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey' ),
array( 'renameIndex', 'mwuser', 'user_user_name_key', 'mwuser_user_name_key' ),
- array( 'renameIndex', 'pagecontent','text_pkey', 'pagecontent_pkey' ),
+ array( 'renameIndex', 'pagecontent', 'text_pkey', 'pagecontent_pkey' ),
# renamed sequences
array( 'renameSequence', 'ipblocks_ipb_id_val', 'ipblocks_ipb_id_seq' ),
array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
array( 'addTable', 'user_former_groups','patch-user_former_groups.sql' ),
- array( 'addTable', 'external_user', 'patch-external_user.sql' ),
array( 'addTable', 'sites', 'patch-sites.sql' ),
# Needed before new field
array( 'changeField', 'templatelinks', 'tl_namespace', 'smallint', 'tl_namespace::smallint' ),
array( 'changeField', 'user_newtalk', 'user_ip', 'text', 'host(user_ip)' ),
array( 'changeField', 'uploadstash', 'us_image_bits', 'smallint', '' ),
+ array( 'changeField', 'profiling', 'pf_time', 'float', '' ),
+ array( 'changeField', 'profiling', 'pf_memory', 'float', '' ),
# null changes
array( 'changeNullableField', 'oldimage', 'oi_bits', 'NULL' ),
array( 'addPgIndex', 'watchlist', 'wl_user', '(wl_user)' ),
array( 'addPgIndex', 'logging', 'logging_user_type_time', '(log_user, log_type, log_timestamp)' ),
array( 'addPgIndex', 'logging', 'logging_page_id_time', '(log_page,log_timestamp)' ),
+ array( 'addPgIndex', 'iwlinks', 'iwl_prefix_from_title', '(iwl_prefix, iwl_from, iwl_title)' ),
array( 'addPgIndex', 'iwlinks', 'iwl_prefix_title_from', '(iwl_prefix, iwl_title, iwl_from)' ),
array( 'addPgIndex', 'job', 'job_timestamp_idx', '(job_timestamp)' ),
array( 'addPgIndex', 'job', 'job_sha1', '(job_sha1)' ),
array( 'cl_from', 'int4_ops', 'btree', 0 ),
),
'CREATE INDEX cl_sortkey ON "categorylinks" USING "btree" ("cl_to", "cl_sortkey", "cl_from")' ),
+ array( 'checkIndex', 'iwl_prefix_title_from', array(
+ array( 'iwl_prefix', 'text_ops', 'btree', 0 ),
+ array( 'iwl_title', 'text_ops', 'btree', 0 ),
+ array( 'iwl_from', 'int4_ops', 'btree', 0 ),
+ ),
+ 'CREATE INDEX iwl_prefix_title_from ON "iwlinks" USING "btree" ("iwl_prefix", "iwl_title", "iwl_from")' ),
array( 'checkIndex', 'logging_times', array(
array( 'log_timestamp', 'timestamptz_ops', 'btree', 0 ),
),
array( 'checkOiNameConstraint' ),
array( 'checkPageDeletedTrigger' ),
array( 'checkRevUserFkey' ),
- array( 'dropIndex', 'ipblocks', 'ipb_address'),
+ array( 'dropIndex', 'ipblocks', 'ipb_address' ),
array( 'checkIndex', 'ipb_address_unique', array(
array( 'ipb_address', 'text_ops', 'btree', 0 ),
- array( 'ipb_user', 'int4_ops', 'btree', 0 ),
- array( 'ipb_auto', 'int2_ops', 'btree', 0 ),
+ array( 'ipb_user', 'int4_ops', 'btree', 0 ),
+ array( 'ipb_auto', 'int2_ops', 'btree', 0 ),
array( 'ipb_anon_only', 'int2_ops', 'btree', 0 ),
),
'CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only)' ),
# Add missing extension fields
foreach ( $wgExtPGNewFields as $fieldRecord ) {
$updates[] = array(
- 'addPgField', $fieldRecord[0], $fieldRecord[1],
- $fieldRecord[2]
- );
+ 'addPgField', $fieldRecord[0], $fieldRecord[1],
+ $fieldRecord[2]
+ );
}
# Change altered columns
foreach ( $wgExtPGAlteredFields as $fieldRecord ) {
$updates[] = array(
- 'changeField', $fieldRecord[0], $fieldRecord[1],
- $fieldRecord[2]
- );
+ 'changeField', $fieldRecord[0], $fieldRecord[1],
+ $fieldRecord[2]
+ );
}
# Add missing extension indexes
foreach ( $wgExtNewIndexes as $fieldRecord ) {
$updates[] = array(
- 'addPgExtIndex', $fieldRecord[0], $fieldRecord[1],
- $fieldRecord[2]
- );
+ 'addPgExtIndex', $fieldRecord[0], $fieldRecord[1],
+ $fieldRecord[2]
+ );
}
return $updates;
AND relname=%s AND nspname=%s
END;
$res = $this->db->query( sprintf( $q,
- $this->db->addQuotes( $table ),
- $this->db->addQuotes( $this->db->getCoreSchema() ) ) );
+ $this->db->addQuotes( $table ),
+ $this->db->addQuotes( $this->db->getCoreSchema() ) ) );
if ( !$res ) {
return null;
}
$cols = array();
foreach ( $res as $r ) {
$cols[] = array(
- "name" => $r[0],
- "ord" => $r[1],
- );
+ "name" => $r[0],
+ "ord" => $r[1],
+ );
}
+
return $cols;
}
if ( !( $row = $this->db->fetchRow( $r ) ) ) {
return null;
}
+
return $row[0];
}
function ruleDef( $table, $rule ) {
- $q = <<<END
+ $q = <<<END
SELECT definition FROM pg_rules
WHERE schemaname = %s
AND tablename = %s
return null;
}
$d = $row[0];
+
return $d;
}
if ( !$this->db->sequenceExists( $ns ) ) {
$this->output( "Creating sequence $ns\n" );
$this->db->query( "CREATE SEQUENCE $ns" );
- if( $pkey !== false ) {
+ if ( $pkey !== false ) {
$this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' );
}
}
protected function renameSequence( $old, $new ) {
if ( $this->db->sequenceExists( $new ) ) {
$this->output( "...sequence $new already exists.\n" );
+
return;
}
if ( $this->db->sequenceExists( $old ) ) {
$old = $this->db->realTableName( $old, "quoted" );
$new = $this->db->realTableName( $new, "quoted" );
$this->db->query( "ALTER TABLE $old RENAME TO $new" );
- if( $patch !== false ) {
+ if ( $patch !== false ) {
$this->applyPatch( $patch );
}
}
// First requirement: the table must exist
if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
$this->output( "...skipping: '$table' table doesn't exist yet.\n" );
+
return;
}
if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) {
$this->output( "...index $new already set on $table table.\n" );
if ( !$skipBothIndexExistWarning
- && $this->db->indexExists( $table, $old, __METHOD__ ) )
- {
+ && $this->db->indexExists( $table, $old, __METHOD__ )
+ ) {
$this->output( "...WARNING: $old still exists, despite it has been renamed into $new (which also exists).\n" .
" $old should be manually removed if not needed anymore.\n" );
}
+
return;
}
// Third requirement: the old index must exist
if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) {
$this->output( "...skipping: index $old doesn't exist.\n" );
+
return;
}
$fi = $this->db->fieldInfo( $table, $field );
if ( !is_null( $fi ) ) {
$this->output( "...column '$table.$field' already exists\n" );
+
return;
} else {
$this->output( "Adding column '$table.$field'\n" );
exit( 1 );
}
- if ( $fi->type() === $newtype )
+ if ( $fi->type() === $newtype ) {
$this->output( "...column '$table.$field' is already of type '$newtype'\n" );
- else {
+ } else {
$this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
$sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
if ( strlen( $default ) ) {
}
}
- protected function changeNullableField( $table, $field, $null) {
+ protected function changeNullableField( $table, $field, $null ) {
$fi = $this->db->fieldInfo( $table, $field );
if ( is_null( $fi ) ) {
$this->output( "...ERROR: expected column $table.$field to exist\n" );
if ( 'NULL' === $null ) {
$this->output( "Changing '$table.$field' to allow NULLs\n" );
$this->db->query( "ALTER TABLE $table ALTER $field DROP NOT NULL" );
- }
- else {
+ } else {
$this->output( "...column '$table.$field' is already set as NOT NULL\n" );
}
}
$fi = $this->db->fieldInfo( $table, $field );
if ( is_null( $fi ) ) {
$this->output( "WARNING! Column '$table.$field' does not exist but it should! Please report this.\n" );
+
return;
}
if ( $fi->is_deferred() && $fi->is_deferrable() ) {
protected function dropIndex( $table, $index, $patch = '', $fullpath = false ) {
if ( $this->db->indexExists( $table, $index ) ) {
$this->output( "Dropping obsolete index '$index'\n" );
- $this->db->query( "DROP INDEX \"". $index ."\"" );
+ $this->db->query( "DROP INDEX \"" . $index . "\"" );
}
}
$pu = $this->db->indexAttributes( $index );
if ( !empty( $pu ) && $pu != $should_be ) {
$this->output( "Dropping obsolete version of index '$index'\n" );
- $this->db->query( "DROP INDEX \"". $index ."\"" );
+ $this->db->query( "DROP INDEX \"" . $index . "\"" );
$pu = array();
} else {
$this->output( "...no need to drop index '$index'\n" );
protected function checkIwlPrefix() {
if ( $this->db->indexExists( 'iwlinks', 'iwl_prefix' ) ) {
- $this->applyPatch( 'patch-rename-iwl_prefix.sql', false, "Replacing index 'iwl_prefix' with 'iwl_prefix_from_title'" );
+ $this->applyPatch( 'patch-rename-iwl_prefix.sql', false, "Replacing index 'iwl_prefix' with 'iwl_prefix_title_from'" );
}
}