}
/**
- * Returns true if this database requires that SELECT DISTINCT queries require that all
+ * Returns true if this database requires that SELECT DISTINCT queries require that all
ORDER BY expressions occur in the SELECT list per the SQL92 standard
*/
function standardSelectDistinct() {
* - DBO_TRX: automatically start transactions
* - DBO_DEFAULT: automatically sets DBO_TRX if not in command line mode
* and removes it in command line mode
- * - DBO_PERSISTENT: use persistant database connection
+ * - DBO_PERSISTENT: use persistant database connection
*/
function setFlag( $flag ) {
$this->mFlags |= $flag;
* Usually aborts on failure. If errors are explicitly ignored, returns success.
*
* @param $sql String: SQL query
- * @param $fname String: Name of the calling function, for profiling/SHOW PROCESSLIST
+ * @param $fname String: Name of the calling function, for profiling/SHOW PROCESSLIST
* comment (you can use __METHOD__ or add some extra info)
- * @param $tempIgnore Boolean: Whether to avoid throwing an exception on errors...
+ * @param $tempIgnore Boolean: Whether to avoid throwing an exception on errors...
* maybe best to catch the exception instead?
- * @return true for a successful write query, ResultWrapper object for a successful read query,
+ * @return true for a successful write query, ResultWrapper object for a successful read query,
* or false on failure if $tempIgnore set
* @throws DBQueryError Thrown when the database returns an error of any kind
*/
#}
# If DBO_TRX is set, start a transaction
- if ( ( $this->mFlags & DBO_TRX ) && !$this->trxLevel() &&
+ if ( ( $this->mFlags & DBO_TRX ) && !$this->trxLevel() &&
$sql != 'BEGIN' && $sql != 'COMMIT' && $sql != 'ROLLBACK') {
// avoid establishing transactions for SHOW and SET statements too -
- // that would delay transaction initializations to once connection
+ // that would delay transaction initializations to once connection
// is really used by application
$sqlstart = substr($sql,0,10); // very much worth it, benchmark certified(tm)
- if (strpos($sqlstart,"SHOW ")!==0 and strpos($sqlstart,"SET ")!==0)
- $this->begin();
+ if (strpos($sqlstart,"SHOW ")!==0 and strpos($sqlstart,"SET ")!==0)
+ $this->begin();
}
if ( $this->debug() ) {
if ( isset( $options['GROUP BY'] ) ) $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
if ( isset( $options['HAVING'] ) ) $preLimitTail .= " HAVING {$options['HAVING']}";
if ( isset( $options['ORDER BY'] ) ) $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
-
+
//if (isset($options['LIMIT'])) {
// $tailOpts .= $this->limitResult('', $options['LIMIT'],
- // isset($options['OFFSET']) ? $options['OFFSET']
+ // isset($options['OFFSET']) ? $options['OFFSET']
// : false);
//}
} else {
$useIndex = '';
}
-
+
return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail );
}
$sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds );
return $this->query( $sql, $fname );
}
-
+
/**
* SELECT wrapper
*
$sql = $this->limitResult($sql, $options['LIMIT'],
isset($options['OFFSET']) ? $options['OFFSET'] : false);
$sql = "$sql $postLimitTail";
-
+
if (isset($options['EXPLAIN'])) {
$sql = 'EXPLAIN ' . $sql;
}
return $obj;
}
-
+
/**
* Estimate rows in dataset
* Returns estimated count - not necessarily an accurate estimate across different databases,
}
}
$this->freeResult($res);
-
+
return empty($result) ? false : $result;
}
# use of `database`.table. But won't break things if someone wants
# to query a database table with a dot in the name.
if ( $name[0] == '`' && substr( $name, -1, 1 ) == '`' ) return $name;
-
+
# Lets test for any bits of text that should never show up in a table
# name. Basically anything like JOIN or ON which are actually part of
# SQL queries, but may end up inside of the table value to combine
# any remote case where a word like on may be inside of a table name
# surrounded by symbols which may be considered word breaks.
if( preg_match( '/(^|\s)(DISTINCT|JOIN|ON|AS)(\s|$)/i', $name ) !== 0 ) return $name;
-
+
# Split database and table into proper variables.
# We reverse the explode so that database.table and table both output
# the correct table.
if( isset( $dbDetails[1] ) ) @list( $table, $database ) = $dbDetails;
else @list( $table ) = $dbDetails;
$prefix = $this->mTablePrefix; # Default prefix
-
+
# A database name has been specified in input. Quote the table name
# because we don't want any prefixes added.
if( isset($database) ) $table = ( $table[0] == '`' ? $table : "`{$table}`" );
-
+
# Note that we use the long format because php will complain in in_array if
# the input is not an array, and will complain in is_array if it is not set.
if( !isset( $database ) # Don't use shared database if pre selected.
$database = $wgSharedDB;
$prefix = isset( $wgSharedPrefix ) ? $wgSharedPrefix : $prefix;
}
-
+
# Quote the $database and $table and apply the prefix if not quoted.
if( isset($database) ) $database = ( $database[0] == '`' ? $database : "`{$database}`" );
$table = ( $table[0] == '`' ? $table : "`{$prefix}{$table}`" );
-
+
# Merge our database and table into our final table name.
$tableName = ( isset($database) ? "{$database}.{$table}" : "{$table}" );
-
+
# We're finished, return.
return $tableName;
}
}
return $retVal;
}
-
+
/**
* Fetch a number of table names into an zero-indexed numerical array
* This is handy when you need to construct SQL for joins
* LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match
* containing either string literals that will be escaped or tokens returned by anyChar() or anyString().
* Alternatively, the function could be provided with an array of aforementioned parameters.
- *
+ *
* Example: $dbr->buildLike( 'My_page_title/', $dbr->anyString() ) returns a LIKE clause that searches
* for subpages of 'My page title'.
* Alternatively: $pattern = array( 'My_page_title/', $dbr->anyString() ); $query .= $dbr->buildLike( $pattern );
}
/**
- * Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries
+ * Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries
* within the UNION construct.
* @return Boolean
*/
}
/**
- * Determines if the last query error was something that should be dealt
+ * Determines if the last query error was something that should be dealt
* with by pinging the connection and reissuing the query.
* STUB
*/
/**
* A string describing the current software version, like from
* mysql_get_server_info(). Will be listed on Special:Version, etc.
- *
+ *
* @return String: Version information from the database
*/
abstract function getServerVersion();
$res = $this->query( 'SHOW PROCESSLIST', __METHOD__ );
# Find slave SQL thread
while ( $row = $this->fetchObject( $res ) ) {
- /* This should work for most situations - when default db
- * for thread is not specified, it had no events executed,
+ /* This should work for most situations - when default db
+ * for thread is not specified, it had no events executed,
* and therefore it doesn't know yet how lagged it is.
*
* Relay log I/O thread does not select databases.
*/
- if ( $row->User == 'system user' &&
+ if ( $row->User == 'system user' &&
$row->State != 'Waiting for master to send event' &&
- $row->State != 'Connecting to master' &&
+ $row->State != 'Connecting to master' &&
$row->State != 'Queueing master event to the relay log' &&
$row->State != 'Waiting for master update' &&
- $row->State != 'Requesting binlog dump' &&
+ $row->State != 'Requesting binlog dump' &&
$row->State != 'Waiting to reconnect after a failed master event read' &&
$row->State != 'Reconnecting after a failed master event read' &&
$row->State != 'Registering slave on master'
/**
* Get the full path of a patch file. Originally based on archive()
- * from updaters.inc. Keep in mind this always returns a patch, as
+ * from updaters.inc. Keep in mind this always returns a patch, as
* it fails back to MySQL if no DB-specific patch can be found
*
* @param $patch String The name of the patch, like patch-something.sql
array( $this, 'tableNameCallback' ), $ins );
// Index names
- $ins = preg_replace_callback( '!/\*i\*/([a-zA-Z_0-9]*)!',
+ $ins = preg_replace_callback( '!/\*i\*/([a-zA-Z_0-9]*)!',
array( $this, 'indexNameCallback' ), $ins );
return $ins;
}
function buildConcat( $stringList ) {
return 'CONCAT(' . implode( ',', $stringList ) . ')';
}
-
+
/**
* Acquire a named lock
- *
+ *
* Abstracted from Filestore::lock() so child classes can implement for
* their own needs.
- *
+ *
* @param $lockName String: Name of lock to aquire
* @param $method String: Name of method calling us
* @return bool
/**
* Release a lock.
- *
+ *
* @param $lockName String: Name of lock to release
* @param $method String: Name of method calling us
*
* FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
* @return Returns 1 if the lock was released, 0 if the lock was not established
- * by this thread (in which case the lock is not released), and NULL if the named
+ * by this thread (in which case the lock is not released), and NULL if the named
* lock did not exist
*/
public function unlock( $lockName, $method ) {
public function lockTables( $read, $write, $method, $lowPriority = true ) {
return true;
}
-
+
/**
* Unlock specific tables
*
public function unlockTables( $method ) {
return true;
}
-
+
/**
* Get search engine class. All subclasses of this
* need to implement this if they wish to use searching.
- *
+ *
* @return String
*/
public function getSearchEngine() {
}
/**
- * Allow or deny "big selects" for this session only. This is done by setting
+ * 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.
+ * This is a MySQL-specific feature.
*
* @param mixed $value true for allow, false for deny, or "default" to restore the initial value
*/
*/
class DBConnectionError extends DBError {
public $error;
-
+
function __construct( DatabaseBase &$db, $error = 'unknown error' ) {
$msg = 'DB connection error';
if ( trim( $error ) != '' ) {
// Not likely to work
return false;
}
-
+
function getLogMessage() {
# Don't send to the exception log
return false;
if ( $wgLang instanceof Language ) {
$header = htmlspecialchars( $wgLang->getMessage( 'dberr-header' ) );
}
-
+
return $header;
}
return '';
}
}
-
+
function htmlBodyOnly() {
return true;
}
*/
class DBQueryError extends DBError {
public $error, $errno, $sql, $fname;
-
+
function __construct( DatabaseBase &$db, $error, $errno, $sql, $fname ) {
$message = "A database error has occurred\n" .
"Query: $sql\n" .
return parent::getText();
}
}
-
+
function getSQL() {
global $wgShowSQLErrors;
if( !$wgShowSQLErrors ) {
return $this->sql;
}
}
-
+
function getLogMessage() {
# Don't send to the exception log
return false;