Implemented save/restore logic for sql_big_selects, per CR comments on r50168.
This commit is contained in:
parent
b02dd9c492
commit
cb3bbe1809
7 changed files with 43 additions and 9 deletions
|
|
@ -745,14 +745,10 @@ class LogPager extends ReverseChronologicalPager {
|
|||
}
|
||||
|
||||
public function doQuery() {
|
||||
// Work around MySQL optimizer bug
|
||||
if ( in_array( get_class( $this->mDb ), array( 'Database', 'DatabaseMysql' ) ) ) {
|
||||
$this->mDb->query( 'SET SQL_BIG_SELECTS=1' );
|
||||
parent::doQuery();
|
||||
$this->mDb->query( 'SET SQL_BIG_SELECTS=0' );
|
||||
} else {
|
||||
parent::doQuery();
|
||||
}
|
||||
// Workaround MySQL optimizer bug
|
||||
$this->mDb->setBigSelects();
|
||||
parent::doQuery();
|
||||
$this->mDb->setBigSelects( 'default' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class Database {
|
|||
protected $mErrorCount = 0;
|
||||
protected $mLBInfo = array();
|
||||
protected $mFakeSlaveLag = null, $mFakeMaster = false;
|
||||
protected $mDefaultBigSelects = null;
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Accessors
|
||||
|
|
@ -2393,6 +2394,29 @@ class Database {
|
|||
public function getSearchEngine() {
|
||||
return "SearchMySQL";
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow or deny "big selects" for this session only. This is done by setting
|
||||
* the sql_big_selects session variable.
|
||||
*
|
||||
* This is a MySQL-specific feature.
|
||||
*
|
||||
* @param mixed $value true for allow, false for deny, or "default" to restore the initial value
|
||||
*/
|
||||
public function setBigSelects( $value = true ) {
|
||||
if ( $value === 'default' ) {
|
||||
if ( $this->mDefaultBigSelects === null ) {
|
||||
# Function hasn't been called before so it must already be set to the default
|
||||
return;
|
||||
} else {
|
||||
$value = $this->mDefaultBigSelects;
|
||||
}
|
||||
} elseif ( $this->mDefaultBigSelects === null ) {
|
||||
$this->mDefaultBigSelects = (bool)$this->selectField( false, '@@sql_big_selects' );
|
||||
}
|
||||
$encValue = $value ? '1' : '0';
|
||||
$this->query( "SET sql_big_selects=$encValue", __METHOD__ );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1792,5 +1792,8 @@ SQL;
|
|||
// TODO
|
||||
// see SpecialAncientpages
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
public function setBigSelects( $value = true ) {}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1015,6 +1015,8 @@ class DatabaseMssql extends Database {
|
|||
return "SearchEngineDummy";
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
public function setBigSelects( $value = true ) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -721,4 +721,7 @@ echo "error!\n";
|
|||
return "SearchOracle";
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
public function setBigSelects( $value = true ) {}
|
||||
|
||||
} // end DatabaseOracle class
|
||||
|
|
|
|||
|
|
@ -1438,4 +1438,7 @@ END;
|
|||
return "SearchPostgres";
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
public function setBigSelects( $value = true ) {}
|
||||
|
||||
} // end DatabasePostgres class
|
||||
|
|
|
|||
|
|
@ -497,6 +497,9 @@ class DatabaseSqlite extends Database {
|
|||
return $s;
|
||||
}
|
||||
|
||||
/** No-op */
|
||||
public function setBigSelects( $value = true ) {}
|
||||
|
||||
} // end DatabaseSqlite class
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue