$options = [ $options ];
}
- $fh = null;
- if ( isset( $options['fileHandle'] ) ) {
- $fh = $options['fileHandle'];
- }
$options = $this->makeInsertOptions( $options );
if ( isset( $a[0] ) && is_array( $a[0] ) ) {
$sql .= '(' . $this->makeList( $a ) . ')';
}
- if ( $fh !== null && false === fwrite( $fh, $sql ) ) {
- return false;
- } elseif ( $fh !== null ) {
- return true;
- }
+ $this->query( $sql, $fname );
- return (bool)$this->query( $sql, $fname );
+ return true;
}
/**
$sql .= " WHERE " . $this->makeList( $conds, self::LIST_AND );
}
- return (bool)$this->query( $sql, $fname );
+ $this->query( $sql, $fname );
+
+ return true;
}
public function makeList( $a, $mode = self::LIST_COMMA ) {
* @param string $table Table name
* @param array|string $rows Row(s) to insert
* @param string $fname Caller function name
- *
- * @return ResultWrapper
*/
protected function nativeReplace( $table, $rows, $fname ) {
$table = $this->tableName( $table );
$sql .= '(' . $this->makeList( $row ) . ')';
}
- return $this->query( $sql, $fname );
+ $this->query( $sql, $fname );
}
public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
$this->startAtomic( $fname, self::ATOMIC_CANCELABLE );
# Update any existing conflicting row(s)
if ( $where !== false ) {
- $ok = $this->update( $table, $set, $where, $fname );
+ $this->update( $table, $set, $where, $fname );
$affectedRowCount += $this->affectedRows();
- } else {
- $ok = true;
}
# Now insert any non-conflicting row(s)
- $ok = $this->insert( $table, $rows, $fname, [ 'IGNORE' ] ) && $ok;
+ $this->insert( $table, $rows, $fname, [ 'IGNORE' ] );
$affectedRowCount += $this->affectedRows();
$this->endAtomic( $fname );
$this->affectedRowCount = $affectedRowCount;
throw $e;
}
- return $ok;
+ return true;
}
public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
$sql .= ' WHERE ' . $conds;
}
- return $this->query( $sql, $fname );
+ $this->query( $sql, $fname );
+
+ return true;
}
final public function insertSelect(
if ( $this->cliMode && $this->isInsertSelectSafe( $insertOptions, $selectOptions ) ) {
// For massive migrations with downtime, we don't want to select everything
// into memory and OOM, so do all this native on the server side if possible.
- return $this->nativeInsertSelect(
+ $this->nativeInsertSelect(
+ $destTable,
+ $srcTable,
+ $varMap,
+ $conds,
+ $fname,
+ array_diff( $insertOptions, $hints ),
+ $selectOptions,
+ $selectJoinConds
+ );
+ } else {
+ $this->nonNativeInsertSelect(
$destTable,
$srcTable,
$varMap,
);
}
- return $this->nonNativeInsertSelect(
- $destTable,
- $srcTable,
- $varMap,
- $conds,
- $fname,
- array_diff( $insertOptions, $hints ),
- $selectOptions,
- $selectJoinConds
- );
+ return true;
}
/**
* @param array $insertOptions
* @param array $selectOptions
* @param array $selectJoinConds
- * @return bool
*/
protected function nonNativeInsertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = __METHOD__,
$srcTable, implode( ',', $fields ), $conds, $fname, $selectOptions, $selectJoinConds
);
if ( !$res ) {
- return false;
+ return;
}
try {
} else {
$this->cancelAtomic( $fname );
}
- return $ok;
} catch ( Exception $e ) {
$this->cancelAtomic( $fname );
throw $e;
* @param array $insertOptions
* @param array $selectOptions
* @param array $selectJoinConds
- * @return bool
*/
protected function nativeInsertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = __METHOD__,
" INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ') ' .
$selectSql;
- return $this->query( $sql, $fname );
+ $this->query( $sql, $fname );
}
/**
}
}
if ( $pos < 0 ) {
- throw new DBUnexpectedError( "Atomic section not found (for $fname)" );
+ throw new DBUnexpectedError( $this, "Atomic section not found (for $fname)" );
}
// Remove all descendant sections and re-index the array
$excisedIds = [];