$isWriteQuery = $this->isWriteQuery( $sql );
if ( $isWriteQuery ) {
- if ( !$this->mDoneWrites ) {
- wfDebug( __METHOD__ . ': Writes done: ' .
- DatabaseBase::generalizeSQL( $sql ) . "\n" );
+ $reason = $this->getLBInfo( 'readOnlyReason' );
+ if ( is_string( $reason ) ) {
+ throw new DBReadOnlyError( $this, "Database is read-only: $reason" );
}
# Set a flag indicating that writes have been done
$this->mDoneWrites = microtime( true );
*
* Takes the same arguments as DatabaseBase::select().
*
- * @param string $table Table name
+ * @since 1.27 Added $join_conds parameter
+ *
+ * @param array|string $tables Table names
* @param string $vars Unused
* @param array|string $conds Filters on the table
* @param string $fname Function name for profiling
* @param array $options Options for select
+ * @param array $join_conds Join conditions (since 1.27)
* @return int Row count
- * @since 1.24
*/
public function selectRowCount(
- $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array()
+ $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array()
) {
$rows = 0;
- $sql = $this->selectSQLText( $table, '1', $conds, $fname, $options );
+ $sql = $this->selectSQLText( $tables, '1', $conds, $fname, $options, $join_conds );
$res = $this->query( "SELECT COUNT(*) AS rowcount FROM ($sql) tmp_count", $fname );
if ( $res ) {
if ( $this->mTrxAtomicLevels ) {
// If the current transaction was an automatic atomic one, then we definitely have
// a problem. Same if there is any unclosed atomic level.
- throw new DBUnexpectedError( $this,
- "Attempted to start explicit transaction when atomic levels are still open."
+ $levels = implode( ', ', $this->mTrxAtomicLevels );
+ throw new DBUnexpectedError(
+ $this,
+ "Got explicit BEGIN while atomic sections $levels are still open."
);
} elseif ( !$this->mTrxAutomatic ) {
// We want to warn about inadvertently nested begin/commit pairs, but not about
final public function commit( $fname = __METHOD__, $flush = '' ) {
if ( $this->mTrxLevel && $this->mTrxAtomicLevels ) {
// There are still atomic sections open. This cannot be ignored
+ $levels = implode( ', ', $this->mTrxAtomicLevels );
throw new DBUnexpectedError(
$this,
- "Attempted to commit transaction while atomic sections are still open"
+ "Got COMMIT while atomic sections $levels are still open"
);
}
}
}
}
+
+/**
+ * @since 1.27
+ */
+abstract class Database extends DatabaseBase {
+ // B/C until nothing type hints for DatabaseBase
+ // @TODO: finish renaming DatabaseBase => Database
+}