return (int)$rows;
}
+ function tableExists( $table, $fname = __METHOD__ ) {
+ $table = $this->tableName( $table, 'raw' );
+ if ( isset( $this->mSessionTempTables[$table] ) ) {
+ return true; // already known to exist and won't show in SHOW TABLES anyway
+ }
+
+ $encLike = $this->buildLike( $table );
+
+ return $this->query( "SHOW TABLES $encLike", $fname )->numRows() > 0;
+ }
+
/**
* @param string $table
* @param string $field
* @see https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html
*/
protected function getHeartbeatData( array $conds ) {
- $whereSQL = $this->makeList( $conds, LIST_AND );
+ $whereSQL = $this->makeList( $conds, self::LIST_AND );
// Use ORDER BY for channel based queries since that field might not be UNIQUE.
// Note: this would use "TIMESTAMPDIFF(MICROSECOND,ts,UTC_TIMESTAMP(6))" but the
// percision field is not supported in MySQL <= 5.5.
* @since 1.20
*/
public function lockIsFree( $lockName, $method ) {
- $lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
- $result = $this->query( "SELECT IS_FREE_LOCK($lockName) AS lockstatus", $method );
+ $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
+ $result = $this->query( "SELECT IS_FREE_LOCK($encName) AS lockstatus", $method );
$row = $this->fetchObject( $result );
return ( $row->lockstatus == 1 );
* @return bool
*/
public function lock( $lockName, $method, $timeout = 5 ) {
- $lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
- $result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method );
+ $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
+ $result = $this->query( "SELECT GET_LOCK($encName, $timeout) AS lockstatus", $method );
$row = $this->fetchObject( $result );
if ( $row->lockstatus == 1 ) {
return true;
}
- $this->queryLogger->debug( __METHOD__ . " failed to acquire lock\n" );
+ $this->queryLogger->warning( __METHOD__ . " failed to acquire lock '$lockName'\n" );
return false;
}
* @return bool
*/
public function unlock( $lockName, $method ) {
- $lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
- $result = $this->query( "SELECT RELEASE_LOCK($lockName) as lockstatus", $method );
+ $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
+ $result = $this->query( "SELECT RELEASE_LOCK($encName) as lockstatus", $method );
$row = $this->fetchObject( $result );
if ( $row->lockstatus == 1 ) {
return true;
}
- $this->queryLogger->debug( __METHOD__ . " failed to release lock\n" );
+ $this->queryLogger->warning( __METHOD__ . " failed to release lock '$lockName'\n" );
return false;
}
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() {
- return 'SearchMySQL';
- }
-
/**
* @param bool $value
*/
$sql = "DELETE $delTable FROM $delTable, $joinTable WHERE $delVar=$joinVar ";
if ( $conds != '*' ) {
- $sql .= ' AND ' . $this->makeList( $conds, LIST_AND );
+ $sql .= ' AND ' . $this->makeList( $conds, self::LIST_AND );
}
return $this->query( $sql, $fname );
$rowTuples[] = '(' . $this->makeList( $row ) . ')';
}
$sql .= implode( ',', $rowTuples );
- $sql .= " ON DUPLICATE KEY UPDATE " . $this->makeList( $set, LIST_SET );
+ $sql .= " ON DUPLICATE KEY UPDATE " . $this->makeList( $set, self::LIST_SET );
return (bool)$this->query( $sql, $fname );
}
return $this->query( "DROP TABLE IF EXISTS " . $this->tableName( $tableName ), $fName );
}
- /**
- * @return array
- */
- protected function getDefaultSchemaVars() {
- $vars = parent::getDefaultSchemaVars();
- $vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', $GLOBALS['wgDBTableOptions'] );
- $vars['wgDBTableOptions'] = str_replace(
- 'CHARSET=mysql4',
- 'CHARSET=binary',
- $vars['wgDBTableOptions']
- );
-
- return $vars;
- }
-
/**
* Get status information from SHOW STATUS in an associative array
*