This saves trouble in a number of places where we can now do joins with the link tables to get other info (such as cur_is_redirect!) as well as the name, and fewer bits need to be juggled on page renaming, as outgoing links no longer have to be changed (cur_id remains the same when a page is renamed).
rebuildLinks.inc and some of the tools in the 'maintenance page' still need to be updated to work with the new setup. (Special:Maintenance needs a *lot* of cleanup in general. It's kind of a catch-all of vaguely defined features which suck performance like a hydroelectric dam.)
Also I've slipped in some extra debug code. And, I think 'indexes.sql' is a big waste of time and should all be moved into tables.sql. Building indexes separately doesn't help on InnoDB and won't do anything on MyISAM either if you're just going to replace the table after it's built with an imported one from a dump which creates it with indexes.
wfPurgeSquidServers($urlArr);
/* prepare the list of urls to purge */
- $sql = "SELECT l_from FROM links WHERE l_to={$id}" ;
+ $sql = "SELECT cur_namespace,cur_title FROM links,cur WHERE l_to={$id} and l_from=cur_id" ;
$res = wfQuery ( $sql, DB_READ ) ;
while ( $BL = wfFetchObject ( $res ) )
{
- $tobj = Title::newFromDBkey( $BL->l_from) ;
+ $tobj = Title::MakeTitle( $BL->cur_namespace, $BL->cur_title ) ;
$blurlArr[] = $tobj->getInternalURL();
}
wfFreeResult ( $res ) ;
$res = wfQuery( $sql, DB_READ, $fname );
$sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
- $now = wfTimestampNow();
+ $now = wfTimestampNow();
$sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN (";
$first = true;
while ( $s = wfFetchObject( $res ) ) {
- $nt = Title::newFromDBkey( $s->l_from );
- $lid = $nt->getArticleID();
-
if ( ! $first ) { $sql .= ","; $sql2 .= ","; }
$first = false;
- $sql .= "({$lid},'{$t}')";
- $sql2 .= "{$lid}";
+ $sql .= "({$s->l_from},'{$t}')";
+ $sql2 .= "{$s->l_from}";
}
$sql2 .= ")";
if ( ! $first ) {
$sql = "DELETE FROM links WHERE l_to={$id}";
wfQuery( $sql, DB_WRITE, $fname );
- $sql = "DELETE FROM links WHERE l_from='{$t}'";
+ $sql = "DELETE FROM links WHERE l_from={$id}";
wfQuery( $sql, DB_WRITE, $fname );
- $sql = "DELETE FROM imagelinks WHERE il_from='{$t}'";
+ $sql = "DELETE FROM imagelinks WHERE il_from={$d}";
wfQuery( $sql, DB_WRITE, $fname );
$sql = "DELETE FROM brokenlinks WHERE bl_from={$id}";
}
function freeResult( $res ) { mysql_free_result( $res ); }
- function fetchObject( $res ) { return mysql_fetch_object( $res ); }
- function numRows( $res ) { return mysql_num_rows( $res ); }
+ function fetchObject( $res ) {
+ @$row = mysql_fetch_object( $res );
+ # FIXME: HACK HACK HACK HACK debug
+ if( mysql_errno() ) {
+ wfDebugDieBacktrace( "SQL error: " . htmlspecialchars( mysql_error() ) );
+ }
+ return $row;
+ }
+ function numRows( $res ) {
+ @$n = mysql_num_rows( $res );
+ if( mysql_errno() ) {
+ wfDebugDieBacktrace( "SQL error: " . htmlspecialchars( mysql_error() ) );
+ }
+ return $n;
+ }
function numFields( $res ) { return mysql_num_fields( $res ); }
function fieldName( $res, $n ) { return mysql_field_name( $res, $n ); }
function insertId() { return mysql_insert_id( $this->mConn ); }
$wgOut->addHTML( "<h2>" . wfMsg( "imagelinks" ) . "</h2>\n" );
- $sql = "SELECT il_from FROM imagelinks WHERE il_to='" .
- wfStrencode( $this->mTitle->getDBkey() ) . "'";
+ $sql = "SELECT cur_namespace,cur_title FROM imagelinks,cur WHERE il_to='" .
+ wfStrencode( $this->mTitle->getDBkey() ) . "' AND il_from=cur_id";
$res = wfQuery( $sql, DB_READ, "Article::imageLinks" );
if ( 0 == wfNumRows( $res ) ) {
$sk = $wgUser->getSkin();
while ( $s = wfFetchObject( $res ) ) {
- $name = $s->il_from;
- $link = $sk->makeKnownLink( $name, "" );
+ $name = Title::MakeTitle( $s->cur_namespace, $s->cur_title );
+ $link = $sk->makeKnownLinkObj( $name, "" );
$wgOut->addHTML( "<li>{$link}</li>\n" );
}
$wgOut->addHTML( "</ul>\n" );
$fname = "LinkCache::preFill";
wfProfileIn( $fname );
# Note -- $fromtitle is a Title *object*
- $dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
+ $this->suspend();
+ $id = $fromtitle->getArticleID();
+ $this->resume();
+
+ if( $id == 0 ) {
+ wfDebug( "$fname - got id 0 for title '" . $fromtitle->getPrefixedDBkey() . "'\n" );
+ wfProfileOut( $fname );
+ return;
+ }
+
if ( $wgEnablePersistentLC ) {
- if( $this->fillFromLinkscc( $dbkeyfrom ) ){
+ if( $this->fillFromLinkscc( $id ) ){
return;
}
}
$sql = "SELECT cur_id,cur_namespace,cur_title
FROM cur,links
- WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'";
+ WHERE cur_id=l_to AND l_from=$id";
$res = wfQuery( $sql, DB_READ, $fname );
while( $s = wfFetchObject( $res ) ) {
$this->addGoodLink( $s->cur_id,
);
}
- $this->suspend();
- $id = $fromtitle->getArticleID();
- $this->resume();
-
- if( $id == 0 ) {
- wfDebug( "$fname - got id 0 for title '" . $fromtitle->getPrefixedDBkey() . "'\n" );
- wfProfileOut( $fname );
- return;
- }
-
$sql = "SELECT bl_to
FROM brokenlinks
WHERE bl_from='{$id}'";
$this->mImageLinks = array();
}
- /* private */ function fillFromLinkscc( $dbkeyfrom ){
- $res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_title = '{$dbkeyfrom}'",
+ /* private */ function fillFromLinkscc( $id ){
+ $id = IntVal( $id );
+ $res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_pageid = $id",
DB_READ);
$row = wfFetchObject( $res );
if( $row == FALSE)
} else {
$ser = wfStrencode( serialize( $this ) );
}
- wfQuery("REPLACE INTO linkscc(lcc_pageid,lcc_title,lcc_cacheobj) " .
- "VALUES({$pid}, '{$dbkeyfrom}', '{$ser}')", DB_WRITE);
+ wfQuery("REPLACE INTO linkscc(lcc_pageid,lcc_cacheobj) " .
+ "VALUES({$pid}, '{$ser}')", DB_WRITE);
}
# $pid is a page id
/* static */ function linksccClearLinksTo( $pid ){
$pid = intval( $pid );
wfQuery("DELETE linkscc FROM linkscc,links ".
- "WHERE lcc_title=links.l_from AND l_to={$pid}", DB_WRITE);
+ "WHERE lcc_pageid=links.l_from AND l_to={$pid}", DB_WRITE);
wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE);
}
if ( $wgLinkCache->incrementalSetup( LINKCACHE_GOOD, $del, $add ) ) {
# Delete where necessary
if ( count( $del ) ) {
- $sql = "DELETE FROM links WHERE l_from='{$this->mTitleEnc}' AND l_to IN(".
+ $sql = "DELETE FROM links WHERE l_from={$this->mId} AND l_to IN(".
implode( ",", $del ) . ")";
wfQuery( $sql, DB_WRITE, $fname );
}
} else {
# Delete everything
- $sql = "DELETE FROM links WHERE l_from='{$this->mTitleEnc}'";
+ $sql = "DELETE FROM links WHERE l_from={$this->mId}";
wfQuery( $sql, DB_WRITE, $fname );
# Get the addition list
if ( ! $first ) { $sql .= ","; }
$first = false;
- $sql .= "('{$this->mTitleEnc}',{$lid})";
+ $sql .= "({$this->mId},{$lid})";
}
}
if ( "" != $sql ) {
#------------------------------------------------------------------------------
# Image links
- $sql = "DELETE FROM imagelinks WHERE il_from='{$this->mTitleEnc}'";
+ $sql = "DELETE FROM imagelinks WHERE il_from='{$this->mId}'";
wfQuery( $sql, DB_WRITE, $fname );
# Get addition list
if ( ! $first ) { $sql .= ","; }
$first = false;
- $sql .= "('{$this->mTitleEnc}','{$iname}')";
+ $sql .= "({$this->mId},'{$iname}')";
}
}
if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); }
wfQuery( $sql, DB_WRITE, $fname );
}
- $sql = "DELETE FROM links WHERE l_from='{$this->mTitleEnc}'";
+ $sql = "DELETE FROM links WHERE l_from={$this->mId}";
wfQuery( $sql, DB_WRITE, $fname );
$a = $wgLinkCache->getGoodLinks();
if ( ! $first ) { $sql .= ","; }
$first = false;
- $sql .= "('{$this->mTitleEnc}',{$lid})";
+ $sql .= "({$this->mId},{$lid})";
}
}
if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); }
}
if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); }
- $sql = "DELETE FROM imagelinks WHERE il_from='{$this->mTitleEnc}'";
+ $sql = "DELETE FROM imagelinks WHERE il_from={$this->mId}";
wfQuery( $sql, DB_WRITE, $fname );
$a = $wgLinkCache->getImageLinks();
if ( ! $first ) { $sql .= ","; }
$first = false;
- $sql .= "('{$this->mTitleEnc}','{$iname}')";
+ $sql .= "({$this->mId},'{$iname}')";
}
}
if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); }
while ( $row = wfFetchObject( $res ) ) {
if ( ! $first ) { $sql .= ","; $sql2 .= ","; }
$first = false;
- $nl = wfStrencode( Title::nameOf( $row->bl_from ) );
- $sql .= "('{$nl}',{$this->mId})";
+ $sql .= "({$row->bl_from},{$this->mId})";
$sql2 .= $row->bl_from;
}
$sql2 .= ")";
$doesexist = false ;
if ( $doesexist ) {
- $sql = "SELECT l_from FROM links WHERE l_to={$id}" ;
+ $sql = "SELECT cur_title,cur_namespace FROM cur,links WHERE l_to={$id} AND l_from=cur_id";
} else {
$sql = "SELECT cur_title,cur_namespace FROM cur,brokenlinks WHERE bl_to={$id} AND bl_from=cur_id" ;
}
# $t = new Title ;
# $t->newFromDBkey ( $x->l_from ) ;
# $t = $t->getText() ;
- if ( $doesexist ) {
- $t = $x->l_from ;
- } else {
- $t = $wgLang->getNsText ( $x->cur_namespace ) ;
- if ( $t != "" ) $t .= ":" ;
- $t .= $x->cur_title ;
- }
+ $t = $wgLang->getNsText ( $x->cur_namespace ) ;
+ if ( $t != "" ) $t .= ":" ;
+ $t .= $x->cur_title ;
$y = explode ( ":" , $t , 2 ) ;
if ( count ( $y ) == 2 && $y[0] == $cat ) {
function clearLinksTo( $pid ){
$pid = intval( $pid );
wfQuery("DELETE parsercache FROM parsercache,links ".
- "WHERE pc_title=links.l_from AND l_to={$pid}", DB_WRITE);
+ "WHERE pc_pageid=links.l_from AND l_to={$pid}", DB_WRITE);
wfQuery("DELETE FROM parsercache WHERE pc_pageid='{$pid}'", DB_WRITE);
}
function getSQL( $offset, $limit ) {
return "SELECT cur_title " .
- "FROM cur LEFT JOIN links ON cur_title = l_from " .
+ "FROM cur LEFT JOIN links ON cur_id = l_from " .
"WHERE l_from IS NULL " .
"AND cur_namespace = 0 " .
"ORDER BY cur_title " .
list( $limit, $offset ) = wfCheckLimits();
$dp = wfStrencode( wfMsg("disambiguationspage") );
-
+
+ die( "wfSpecialDisambiguation is broken. Link tables have changed...\n" );
+
$sql = "SELECT la.l_from,la.l_to,"
. " lb.l_from AS source,lb.l_to AS dest,"
. " c.cur_id, c.cur_title AS dt"
list( $limit, $offset ) = wfCheckLimits();
+ die( "wfSpecialDoubleRedirects() is broken for now; link tables are changed." );
$sql = "SELECT l_from,l_to,cb.cur_text AS rt,cb.cur_title AS ti FROM links,cur AS ca, cur AS cb WHERE ca.cur_is_redirect=1 AND cb.cur_is_redirect=1 AND l_to=cb.cur_id AND l_from=ca.cur_title AND ca.cur_namespace=0 LIMIT {$offset}, {$limit}" ;
$res = wfQuery( $sql, DB_READ, $fname );
RecentChange::notifyMove( $now, $this->ot, $this->nt, $wgUser, $mt );
- # The only link from here should be the old redirect
-
- $sql = "DELETE FROM links WHERE l_from='{$this->nft}'";
- wfQuery( $sql, DB_WRITE, $fname );
-
- $sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'";
- wfQuery( $sql, DB_WRITE, $fname );
-
# Swap links. Using MAXINT as a temp; if there's ever an article
# with id 4294967295, this will fail, but I think that's pretty safe
+ # FIXME: LOCK TABLE
+ # Reassign links to the old title to LIMBO
$sql = "UPDATE links SET l_to=4294967295 WHERE l_to={$this->oldid}";
wfQuery( $sql, DB_WRITE, $fname );
+ # Reassign links to the new title to the old title
$sql = "UPDATE links SET l_to={$this->oldid} WHERE l_to={$this->newid}";
wfQuery( $sql, DB_WRITE, $fname );
+ # Reassign links from LIMBO to the new title. Ah, clear as mud!
$sql = "UPDATE links SET l_to={$this->newid} WHERE l_to=4294967295";
wfQuery( $sql, DB_WRITE, $fname );
# Note: the insert below must be after the updates above!
- $sql = "INSERT INTO links (l_from,l_to) VALUES ('{$this->oft}',{$this->oldid})";
+ # Now, we record the link from the redirect to the new title.
+ # It should have no other outgoing links...
+ $sql = "DELETE FROM links WHERE l_from={$this->newid}";
wfQuery( $sql, DB_WRITE, $fname );
-
- $sql = "UPDATE imagelinks SET il_from='{$this->nft}' WHERE il_from='{$this->oft}'";
+ $sql = "INSERT INTO links (l_from,l_to) VALUES ({$this->newid},{$this->oldid})";
wfQuery( $sql, DB_WRITE, $fname );
}
RecentChange::notifyMove( $now, $this->ot, $this->nt, $wgUser, $comment );
Article::onArticleCreate( $this->nt );
- $sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'";
- wfQuery( $sql, DB_WRITE, $fname );
-
+ # Any text links to the old title must be reassigned to the redirect
$sql = "UPDATE links SET l_to={$this->newid} WHERE l_to={$this->oldid}";
wfQuery( $sql, DB_WRITE, $fname );
- $sql = "INSERT INTO links (l_from,l_to) VALUES ('{$this->oft}',{$this->oldid})";
+ # Record the just-created redirect's linking to the page
+ $sql = "INSERT INTO links (l_from,l_to) VALUES ({$this->newid},{$this->oldid})";
wfQuery( $sql, DB_WRITE, $fname );
# Non-existent target may have had broken links to it; these must
# now be removed and made into good links.
$update = new LinksUpdate( $this->oldid, $this->nft );
$update->fixBrokenLinks();
-
- $sql = "UPDATE imagelinks SET il_from='{$this->nft}' WHERE il_from='{$this->oft}'";
- wfQuery( $sql, DB_WRITE, $fname );
}
function updateWatchlists()
return;
}
$nt = Title::newFromURL( $target );
+ if( !$nt ) {
+ $wgOut->errorpage( "notargettitle", "notargettext" );
+ return;
+ }
+ $id = $nt->getArticleId();
+
$wgOut->setSubtitle( wfMsg( "rclsub", $nt->getPrefixedText() ) );
if ( ! $days ) {
$sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
"cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
- "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
- wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
- "ORDER BY inverse_timestamp LIMIT {$limit}";
+ "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
+ "GROUP BY cur_id ORDER BY inverse_timestamp LIMIT {$limit}";
$res = wfQuery( $sql, DB_READ, $fname );
$note = wfMsg( "rcnote", $limit, $days );
$isredir = " (" . wfMsg( "isredirect" ) . ")\n";
if ( 0 == $id ) {
- $sql = "SELECT bl_from FROM brokenlinks WHERE bl_to='" .
- wfStrencode( $nt->getPrefixedDBkey() ) . "' LIMIT 500";
+ $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM brokenlinks,cur WHERE bl_to='" .
+ wfStrencode( $nt->getPrefixedDBkey() ) . "' AND bl_from=cur_id LIMIT 500";
$res = wfQuery( $sql, DB_READ, $fname );
if ( 0 == wfNumRows( $res ) ) {
$wgOut->addHTML( "\n<ul>" );
while ( $row = wfFetchObject( $res ) ) {
- $lid = $row->bl_from;
- $sql = "SELECT cur_namespace,cur_title,cur_is_redirect " .
- "FROM cur WHERE cur_id={$lid}";
- $res2 = wfQuery( $sql, DB_READ, $fname );
- $s = wfFetchObject( $res2 );
-
- $n = Title::makeName( $s->cur_namespace, $s->cur_title );
- $link = $sk->makeKnownLink( $n, "", "redirect=no" );
+ $nt = Title::makeTitle( $row->cur_namespace, $row->cur_title );
+ if( !$nt ) {
+ continue;
+ }
+ $link = $sk->makeKnownLinkObj( $nt, "", "redirect=no" );
$wgOut->addHTML( "<li>{$link}" );
- if ( 1 == $s->cur_is_redirect ) {
+ if ( $row->cur_is_redirect ) {
$wgOut->addHTML( $isredir );
- wfShowIndirectLinks( 1, $lid );
+ wfShowIndirectLinks( 1, $row->cur_id );
}
$wgOut->addHTML( "</li>\n" );
}
global $wgOut, $wgUser;
$fname = "wfShowIndirectLinks";
- $sql = "SELECT l_from FROM links WHERE l_to={$lid} LIMIT 500";
+ $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM links,cur WHERE l_to={$lid} AND l_from=cur_id LIMIT 500";
$res = wfQuery( $sql, DB_READ, $fname );
if ( 0 == wfNumRows( $res ) ) {
$wgOut->addHTML( "<ul>" );
while ( $row = wfFetchObject( $res ) ) {
- $nt = Title::newFromDBkey( $row->l_from );
+ $nt = Title::makeTitle( $row->cur_namespace, $row->cur_title );
if( !$nt ) {
$wgOut->addHTML( "<!-- bad backlink: " . htmlspecialchars( $row->l_from ) . " -->\n" );
continue;
}
- $ns = $nt->getNamespace();
- $t = wfStrencode( $nt->getDBkey() );
-
- # FIXME: this should be in a join above, or cached in the links table
- $sql = "SELECT cur_id,cur_is_redirect FROM cur " .
- "WHERE cur_namespace={$ns} AND cur_title='{$t}'";
- $res2 = wfQuery( $sql, DB_READ, $fname );
- $s = wfFetchObject( $res2 );
-
- if ( 1 == $s->cur_is_redirect ) {
+ if ( $row->cur_is_redirect ) {
$extra = "redirect=no";
} else {
$extra = "";
}
- $link = $sk->makeKnownLink( $row->l_from, "", $extra );
+ $link = $sk->makeKnownLinkObj( $nt, "", $extra );
$wgOut->addHTML( "<li>{$link}" );
- if ( 1 == $s->cur_is_redirect ) {
+ if ( $row->cur_is_redirect ) {
$wgOut->addHTML( $isredir );
if ( $level < 2 ) {
- wfShowIndirectLinks( $level + 1, $s->cur_id );
+ wfShowIndirectLinks( $level + 1, $row->cur_id );
}
}
$wgOut->addHTML( "</li>\n" );
# See deferred.doc
class SquidUpdate {
-
- function SquidUpdate( $title, $urlArr = Array() )
- {
+ var $title, $urlArr;
+
+ function SquidUpdate( $title, $urlArr = Array() ) {
$this->title = $title;
$this->urlArr = $urlArr;
}
- function doUpdate()
- {
- if (count( $this->urlArr ) == 0) { // newly created Article
- /* prepare the list of urls to purge */
+ function doUpdate() {
+ if( count( $this->urlArr ) == 0) {
+ # newly created Article
+ # prepare the list of urls to purge
$id= $this->title->getArticleID();
- $sql = "SELECT l_from FROM links WHERE l_to={$id}" ;
- $res = wfQuery ( $sql, DB_READ ) ;
- while ( $BL = wfFetchObject ( $res ) )
- {
- $t = Title::newFromDBkey( $BL->l_from) ;
- $this->urlArr[] = $t->getInternalURL() ;
+ $sql = "SELECT cur_namespace,cur_title FROM links,cur WHERE l_to={$id} AND l_from=cur_id" ;
+ $res = wfQuery( $sql, DB_READ );
+ while( $row = wfFetchObject ( $res ) ) {
+ $t = Title::MakeTitle( $row->cur_namespace, $row->cur_title );
+ $this->urlArr[] = $t->getInternalURL();
}
- wfFreeResult ( $res ) ;
-
+ wfFreeResult( $res );
}
- wfPurgeSquidServers($this->urlArr);
+ wfPurgeSquidServers( $this->urlArr );
}
}
--- /dev/null
+--
+-- Track links that do exist
+-- l_from and l_to key to cur_id
+--
+DROP TABLE IF EXISTS links;
+CREATE TABLE links (
+ l_from int(8) unsigned NOT NULL default '0',
+ l_to int(8) unsigned NOT NULL default '0',
+ UNIQUE KEY l_from(l_from,l_to),
+ KEY (l_to)
+);
+
+--
+-- Track links to pages that don't yet exist.
+-- bl_from keys to cur_id
+-- bl_to is a text link (namespace:title)
+--
+DROP TABLE IF EXISTS brokenlinks;
+CREATE TABLE brokenlinks (
+ bl_from int(8) unsigned NOT NULL default '0',
+ bl_to varchar(255) binary NOT NULL default '',
+ UNIQUE KEY bl_from(bl_from,bl_to),
+ KEY (bl_to)
+);
+
+--
+-- Track links to images *used inline*
+-- il_from keys to cur_id, il_to keys to image_name.
+-- We don't distinguish live from broken links.
+--
+DROP TABLE IF EXISTS imagelinks;
+CREATE TABLE imagelinks (
+ il_from int(8) unsigned NOT NULL default '0',
+ il_to varchar(255) binary NOT NULL default '',
+ UNIQUE KEY il_from(il_from,il_to),
+ KEY (il_to)
+);
+
+--
+-- Stores (possibly gzipped) serialized objects with
+-- cache arrays to reduce database load slurping up
+-- from links and brokenlinks.
+--
+DROP TABLE IF EXISTS linkscc;
+CREATE TABLE linkscc (
+ lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
+ lcc_cacheobj MEDIUMBLOB NOT NULL
+);
* 2004-02-14: Adds the ipb_expiry field to ipblocks
patch-ipb_expiry.sql
+
+* 2004-03-11: Recreate links tables to avoid duplicating titles
+everywhere. **Rebuild your links after this with refreshLinks.php**
+
+patch-linktables.sql
+-- This file should be phased out.
+-- It's useless importing dumps that already have indexes in their definitions.
+--
+
-- SQL to add non-unique indexes to Wikipedia database tables.
-- This is read and executed by the install script; you should
-- never have to run it by itself.
ADD INDEX user_timestamp (old_user,inverse_timestamp),
ADD INDEX usertext_timestamp (old_user_text,inverse_timestamp);
-ALTER TABLE links
- ADD INDEX l_from (l_from),
- ADD INDEX l_to (l_to);
-
-ALTER TABLE brokenlinks
- ADD INDEX bl_from (bl_from),
- ADD INDEX bl_to (bl_to);
-
-ALTER TABLE imagelinks
- ADD INDEX il_from (il_from(10)),
- ADD INDEX il_to (il_to(10));
-
ALTER TABLE ipblocks
ADD INDEX ipb_address (ipb_address),
ADD INDEX ipb_user (ipb_user);
<?php
+die( "rebuildLinks.inc needs to be updated for the new schema\n" );
+
# Functions for rebuilding the link tracking tables; must
# be included within a script that also includes the Setup.
# See rebuildlinks.php, for example.
-- This is read and executed by the install script; you should
-- never have to run it by itself.
--
--- Only UNIQUE keys are defined here; the rest are added by
--- indexes.sql.
---
--- If you change the main development branch version of this
--- file, please add an appropriate ALTER TABLE to update.php,
--- and increment the version number in Version.php.
+-- Indexes should be defined here; please import the rest from indexes.sql.
DROP TABLE IF EXISTS user;
CREATE TABLE user (
user_options blob NOT NULL default '',
user_touched char(14) binary NOT NULL default '',
UNIQUE KEY user_id (user_id)
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS user_newtalk;
CREATE TABLE user_newtalk (
user_id int(5) NOT NULL default '0',
user_ip varchar(40) NOT NULL default ''
-) TYPE=MyISAM;
+);
DROP TABLE IF EXISTS cur;
CREATE TABLE cur (
cur_touched char(14) binary NOT NULL default '',
inverse_timestamp char(14) binary NOT NULL default '',
UNIQUE KEY cur_id (cur_id)
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS old;
CREATE TABLE old (
old_flags tinyblob NOT NULL default '',
inverse_timestamp char(14) binary NOT NULL default '',
UNIQUE KEY old_id (old_id)
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS archive;
CREATE TABLE archive (
ar_timestamp char(14) binary NOT NULL default '',
ar_minor_edit tinyint(1) NOT NULL default '0',
ar_flags tinyblob NOT NULL default ''
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
+--
+-- Track links that do exist
+-- l_from and l_to key to cur_id
+--
DROP TABLE IF EXISTS links;
CREATE TABLE links (
- l_from varchar(255) binary NOT NULL default '',
- l_to int(8) unsigned NOT NULL default '0'
-) TYPE=MyISAM;
+ l_from int(8) unsigned NOT NULL default '0',
+ l_to int(8) unsigned NOT NULL default '0',
+ UNIQUE KEY l_from(l_from,l_to),
+ KEY (l_to)
+);
+--
+-- Track links to pages that don't yet exist.
+-- bl_from keys to cur_id
+-- bl_to is a text link (namespace:title)
+--
DROP TABLE IF EXISTS brokenlinks;
CREATE TABLE brokenlinks (
bl_from int(8) unsigned NOT NULL default '0',
- bl_to varchar(255) binary NOT NULL default ''
-) TYPE=MyISAM;
+ bl_to varchar(255) binary NOT NULL default '',
+ UNIQUE KEY bl_from(bl_from,bl_to),
+ KEY (bl_to)
+);
+
+--
+-- Track links to images *used inline*
+-- il_from keys to cur_id, il_to keys to image_name.
+-- We don't distinguish live from broken links.
+--
+DROP TABLE IF EXISTS imagelinks;
+CREATE TABLE imagelinks (
+ il_from int(8) unsigned NOT NULL default '0',
+ il_to varchar(255) binary NOT NULL default '',
+ UNIQUE KEY il_from(il_from,il_to),
+ KEY (il_to)
+);
+--
+-- Stores (possibly gzipped) serialized objects with
+-- cache arrays to reduce database load slurping up
+-- from links and brokenlinks.
+--
DROP TABLE IF EXISTS linkscc;
CREATE TABLE linkscc (
lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
- lcc_title VARCHAR(255) binary NOT NULL UNIQUE KEY,
lcc_cacheobj MEDIUMBLOB NOT NULL
-) TYPE=MyISAM;
-
-DROP TABLE IF EXISTS imagelinks;
-CREATE TABLE imagelinks (
- il_from varchar(255) binary NOT NULL default '',
- il_to varchar(255) binary NOT NULL default ''
-) TYPE=MyISAM;
+);
DROP TABLE IF EXISTS site_stats;
CREATE TABLE site_stats (
ss_total_edits bigint(20) unsigned default '0',
ss_good_articles bigint(20) unsigned default '0',
UNIQUE KEY ss_row_id (ss_row_id)
-) TYPE=MyISAM;
+);
DROP TABLE IF EXISTS hitcounter;
CREATE TABLE hitcounter (
ipb_auto tinyint(1) NOT NULL default '0',
ipb_expiry char(14) binary NOT NULL default '',
UNIQUE KEY ipb_id (ipb_id)
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS image;
CREATE TABLE image (
img_user int(5) unsigned NOT NULL default '0',
img_user_text varchar(255) binary NOT NULL default '',
img_timestamp char(14) binary NOT NULL default ''
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS oldimage;
CREATE TABLE oldimage (
oi_user int(5) unsigned NOT NULL default '0',
oi_user_text varchar(255) binary NOT NULL default '',
oi_timestamp char(14) binary NOT NULL default ''
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS recentchanges;
CREATE TABLE recentchanges (
rc_type tinyint(3) unsigned NOT NULL default '0',
rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
rc_moved_to_title varchar(255) binary NOT NULL default ''
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS watchlist;
CREATE TABLE watchlist (
wl_namespace tinyint(2) unsigned NOT NULL default '0',
wl_title varchar(255) binary NOT NULL default '',
UNIQUE KEY (wl_user, wl_namespace, wl_title)
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS math;
CREATE TABLE math (
math_html text,
math_mathml text,
UNIQUE KEY math_inputhash (math_inputhash)
-) TYPE=MyISAM;
+);
-- Table searchindex must be MyISAM for fulltext support
si_title varchar(255) NOT NULL default '',
si_text mediumtext NOT NULL default '',
UNIQUE KEY (si_page)
-) TYPE=MyISAM PACK_KEYS=1;
+) PACK_KEYS=1;
DROP TABLE IF EXISTS interwiki;
CREATE TABLE interwiki (