Merge "database: Fix various scalar and null types"

This commit is contained in:
jenkins-bot 2022-03-10 05:56:31 +00:00 committed by Gerrit Code Review
commit 8d2e09d2bf
3 changed files with 14 additions and 14 deletions

View file

@ -105,7 +105,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
protected $flags; protected $flags;
/** @var array Current LoadBalancer tracking information */ /** @var array Current LoadBalancer tracking information */
protected $lbInfo = []; protected $lbInfo = [];
/** @var string Current SQL query delimiter */ /** @var string|false Current SQL query delimiter */
protected $delimiter = ';'; protected $delimiter = ';';
/** @var array[] Current map of (table => (dbname, schema, prefix) map) */ /** @var array[] Current map of (table => (dbname, schema, prefix) map) */
protected $tableAliases = []; protected $tableAliases = [];
@ -2456,7 +2456,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
$indexInfo = $this->indexInfo( $table, $index, $fname ); $indexInfo = $this->indexInfo( $table, $index, $fname );
if ( !$indexInfo ) { if ( !$indexInfo ) {
return null; return false;
} }
return !$indexInfo[0]->Non_unique; return !$indexInfo[0]->Non_unique;
@ -2830,7 +2830,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
) { ) {
$fld = "GROUP_CONCAT($field SEPARATOR " . $this->addQuotes( $delim ) . ')'; $fld = "GROUP_CONCAT($field SEPARATOR " . $this->addQuotes( $delim ) . ')';
return '(' . $this->selectSQLText( $table, $fld, $conds, null, [], $join_conds ) . ')'; return '(' . $this->selectSQLText( $table, $fld, $conds, __METHOD__, [], $join_conds ) . ')';
} }
/** /**
@ -3036,7 +3036,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
} }
public function getServerName() { public function getServerName() {
return $this->serverName ?? $this->getServer(); return $this->serverName ?? $this->getServer() ?? 'unknown';
} }
/** /**
@ -5105,7 +5105,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
} }
try { try {
$error = $this->sourceStream( return $this->sourceStream(
$fp, $fp,
$lineCallback, $lineCallback,
$resultCallback, $resultCallback,
@ -5115,8 +5115,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
} finally { } finally {
fclose( $fp ); fclose( $fp );
} }
return $error;
} }
public function setSchemaVars( $vars ) { public function setSchemaVars( $vars ) {

View file

@ -265,10 +265,12 @@ class DatabasePostgres extends Database {
public function lastErrno() { public function lastErrno() {
if ( $this->lastResultHandle ) { if ( $this->lastResultHandle ) {
return pg_result_error_field( $this->lastResultHandle, PGSQL_DIAG_SQLSTATE ); $lastErrno = pg_result_error_field( $this->lastResultHandle, PGSQL_DIAG_SQLSTATE );
} else { if ( $lastErrno !== false ) {
return false; return (int)$lastErrno;
}
} }
return 0;
} }
protected function fetchAffectedRowCount() { protected function fetchAffectedRowCount() {
@ -407,7 +409,7 @@ __INDEXATTR__;
")'"; ")'";
$res = $this->query( $sql, $fname, $flags ); $res = $this->query( $sql, $fname, $flags );
if ( !$res ) { if ( !$res ) {
return null; return false;
} }
return $res->numRows() > 0; return $res->numRows() > 0;

View file

@ -271,7 +271,7 @@ interface IDatabase {
* Keys matching the IDatabase::LB_* constants are also used internally by subclasses * Keys matching the IDatabase::LB_* constants are also used internally by subclasses
* *
* @param array|string $nameOrArray The new array or the name of a key to set * @param array|string $nameOrArray The new array or the name of a key to set
* @param array|null $value If $nameOrArray is a string, the new key value (null to unset) * @param array|mixed|null $value If $nameOrArray is a string, the new key value (null to unset)
*/ */
public function setLBInfo( $nameOrArray, $value = null ); public function setLBInfo( $nameOrArray, $value = null );
@ -293,7 +293,7 @@ interface IDatabase {
/** /**
* Get the last time the connection may have been used for a write query * Get the last time the connection may have been used for a write query
* *
* @return int|float UNIX timestamp or false * @return int|float|false UNIX timestamp or false
* @since 1.24 * @since 1.24
*/ */
public function lastDoneWrites(); public function lastDoneWrites();
@ -2206,7 +2206,7 @@ interface IDatabase {
* @param string $method Name of the calling method * @param string $method Name of the calling method
* @param int $timeout Acquisition timeout in seconds (0 means non-blocking) * @param int $timeout Acquisition timeout in seconds (0 means non-blocking)
* @param int $flags Bit field of IDatabase::LOCK_* constants * @param int $flags Bit field of IDatabase::LOCK_* constants
* @return bool Success * @return bool|float Success
* @throws DBError If an error occurs, {@see query} * @throws DBError If an error occurs, {@see query}
*/ */
public function lock( $lockName, $method, $timeout = 5, $flags = 0 ); public function lock( $lockName, $method, $timeout = 5, $flags = 0 );