Merge "rdbms: add getDomainChangeException() call to DBConnRef::dbSchema()"

This commit is contained in:
jenkins-bot 2022-08-10 04:14:36 +00:00 committed by Gerrit Code Review
commit 5538b4c0ac
3 changed files with 16 additions and 18 deletions

View file

@ -158,16 +158,21 @@ class DBConnRef implements IMaintainableDatabase {
}
public function dbSchema( $schema = null ) {
if ( $this->conn === null && $schema === null ) {
$domain = DatabaseDomain::newFromId( $this->params[self::FLD_DOMAIN] );
// Avoid triggering a database connection
return $domain->getSchema();
} elseif ( $this->conn !== null && $schema === null ) {
// This will just return the schema
return $this->__call( __FUNCTION__, func_get_args() );
if ( $schema !== null ) {
// Disallow things that might confuse the LoadBalancer tracking
throw $this->getDomainChangeException();
}
// Disallow things that might confuse the LoadBalancer tracking
throw $this->getDomainChangeException();
if ( $this->conn === null ) {
// Avoid triggering a database connection
$domain = DatabaseDomain::newFromId( $this->params[self::FLD_DOMAIN] );
$schema = (string)$domain->getSchema();
} else {
// This will just return the schema
$schema = $this->__call( __FUNCTION__, func_get_args() );
}
return $schema;
}
public function getLBInfo( $name = null ) {

View file

@ -318,7 +318,7 @@ interface ILoadBalancer {
/**
* @internal Only to be used by DBConnRef
* @param int $i Specific or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param string[]|string $groups Query group(s) in preference order; [] for the default group
* @param string|false $domain DB domain ID or false for the local domain
* @param int $flags Bitfield of CONN_* class constants (e.g. CONN_TRX_AUTOCOMMIT)

View file

@ -931,14 +931,6 @@ class LoadBalancer implements ILoadBalancerForOwner {
return $this->getConnectionRef( $i, $groups, $domain, $flags );
}
/**
* @internal
* @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
* @param string[]|string $groups Query group(s) in preference order; [] for the default group
* @param string|false $domain DB domain ID or false for the local domain
* @param int $flags Bitfield of CONN_* class constants
* @return IDatabase
*/
public function getConnectionInternal( $i, $groups = [], $domain = false, $flags = 0 ): IDatabase {
$domain = $this->resolveDomainID( $domain );
$groups = $this->resolveGroups( $groups, $i );
@ -963,6 +955,7 @@ class LoadBalancer implements ILoadBalancerForOwner {
: 'The database is read-only until replica database servers becomes reachable.';
$conn->setLBInfo( $conn::LB_READ_ONLY_REASON, $reason );
}
return $conn;
}