composer update
This commit is contained in:
@@ -1,32 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding;
|
||||
|
||||
use Doctrine\Common\EventManager;
|
||||
use Doctrine\DBAL\Configuration;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
||||
use Doctrine\DBAL\Events;
|
||||
use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
|
||||
use InvalidArgumentException;
|
||||
use function array_merge;
|
||||
use function is_numeric;
|
||||
use function is_string;
|
||||
@@ -63,65 +47,54 @@ use function is_string;
|
||||
* $shardManager = $conn->getShardManager();
|
||||
* $shardManager->selectGlobal();
|
||||
* $shardManager->selectShard($value);
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class PoolingShardConnection extends Connection
|
||||
{
|
||||
/**
|
||||
* @var DriverConnection[]
|
||||
*/
|
||||
/** @var DriverConnection[] */
|
||||
private $activeConnections = [];
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
/** @var int|null */
|
||||
private $activeShardId;
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $connectionParameters = [];
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param \Doctrine\DBAL\Driver $driver
|
||||
* @param \Doctrine\DBAL\Configuration $config
|
||||
* @param \Doctrine\Common\EventManager $eventManager
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
|
||||
public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
|
||||
{
|
||||
if (! isset($params['global'], $params['shards'])) {
|
||||
throw new \InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations.");
|
||||
throw new InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations.");
|
||||
}
|
||||
|
||||
if (! isset($params['shardChoser'])) {
|
||||
throw new \InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'");
|
||||
throw new InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'");
|
||||
}
|
||||
|
||||
if (is_string($params['shardChoser'])) {
|
||||
$params['shardChoser'] = new $params['shardChoser'];
|
||||
$params['shardChoser'] = new $params['shardChoser']();
|
||||
}
|
||||
|
||||
if ( ! ($params['shardChoser'] instanceof ShardChoser)) {
|
||||
throw new \InvalidArgumentException("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser");
|
||||
if (! ($params['shardChoser'] instanceof ShardChoser)) {
|
||||
throw new InvalidArgumentException("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser");
|
||||
}
|
||||
|
||||
$this->connectionParameters[0] = array_merge($params, $params['global']);
|
||||
|
||||
foreach ($params['shards'] as $shard) {
|
||||
if ( ! isset($shard['id'])) {
|
||||
throw new \InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id.");
|
||||
if (! isset($shard['id'])) {
|
||||
throw new InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id.");
|
||||
}
|
||||
|
||||
if ( !is_numeric($shard['id']) || $shard['id'] < 1) {
|
||||
throw new \InvalidArgumentException("Shard Id has to be a non-negative number.");
|
||||
if (! is_numeric($shard['id']) || $shard['id'] < 1) {
|
||||
throw new InvalidArgumentException('Shard Id has to be a non-negative number.');
|
||||
}
|
||||
|
||||
if (isset($this->connectionParameters[$shard['id']])) {
|
||||
throw new \InvalidArgumentException("Shard " . $shard['id'] . " is duplicated in the configuration.");
|
||||
throw new InvalidArgumentException('Shard ' . $shard['id'] . ' is duplicated in the configuration.');
|
||||
}
|
||||
|
||||
$this->connectionParameters[$shard['id']] = array_merge($params, $shard);
|
||||
@@ -195,7 +168,7 @@ class PoolingShardConnection extends Connection
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Sharding\ShardingException
|
||||
* @throws ShardingException
|
||||
*/
|
||||
public function connect($shardId = null)
|
||||
{
|
||||
@@ -208,7 +181,7 @@ class PoolingShardConnection extends Connection
|
||||
}
|
||||
|
||||
if ($this->getTransactionNestingLevel() > 0) {
|
||||
throw new ShardingException("Cannot switch shard when transaction is active.");
|
||||
throw new ShardingException('Cannot switch shard when transaction is active.');
|
||||
}
|
||||
|
||||
$this->activeShardId = (int) $shardId;
|
||||
@@ -244,7 +217,7 @@ class PoolingShardConnection extends Connection
|
||||
|
||||
$connectionParams = $this->connectionParameters[$shardId];
|
||||
|
||||
$user = $connectionParams['user'] ?? null;
|
||||
$user = $connectionParams['user'] ?? null;
|
||||
$password = $connectionParams['password'] ?? null;
|
||||
|
||||
return $this->_driver->connect($connectionParams, $user, $password, $driverOptions);
|
||||
|
||||
@@ -1,51 +1,24 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding;
|
||||
|
||||
use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Shard Manager for the Connection Pooling Shard Strategy
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class PoolingShardManager implements ShardManager
|
||||
{
|
||||
/**
|
||||
* @var PoolingShardConnection
|
||||
*/
|
||||
/** @var PoolingShardConnection */
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @var ShardChoser
|
||||
*/
|
||||
/** @var ShardChoser */
|
||||
private $choser;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
/** @var string|null */
|
||||
private $currentDistributionValue;
|
||||
|
||||
/**
|
||||
* @param PoolingShardConnection $conn
|
||||
*/
|
||||
public function __construct(PoolingShardConnection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
@@ -96,22 +69,18 @@ class PoolingShardManager implements ShardManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sql
|
||||
* @param array $params
|
||||
* @param array $types
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function queryAll($sql, array $params, array $types)
|
||||
{
|
||||
$shards = $this->getShards();
|
||||
if (!$shards) {
|
||||
throw new \RuntimeException("No shards found.");
|
||||
if (! $shards) {
|
||||
throw new RuntimeException('No shards found.');
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$result = [];
|
||||
$oldDistribution = $this->getCurrentDistributionValue();
|
||||
|
||||
foreach ($shards as $shard) {
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding\SQLAzure;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Synchronizer\AbstractSchemaSynchronizer;
|
||||
use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
|
||||
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
|
||||
use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use RuntimeException;
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
@@ -35,30 +19,19 @@ use function array_merge;
|
||||
* by partitioning the passed schema into subschemas for the federation and the
|
||||
* global database and then applying the operations step by step using the
|
||||
* {@see \Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer}.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
{
|
||||
const FEDERATION_TABLE_FEDERATED = 'azure.federated';
|
||||
const FEDERATION_DISTRIBUTION_NAME = 'azure.federatedOnDistributionName';
|
||||
public const FEDERATION_TABLE_FEDERATED = 'azure.federated';
|
||||
public const FEDERATION_DISTRIBUTION_NAME = 'azure.federatedOnDistributionName';
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager
|
||||
*/
|
||||
/** @var SQLAzureShardManager */
|
||||
private $shardManager;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer
|
||||
*/
|
||||
/** @var SchemaSynchronizer */
|
||||
private $synchronizer;
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Connection $conn
|
||||
* @param \Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager $shardManager
|
||||
* @param \Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer|null $sync
|
||||
*/
|
||||
public function __construct(Connection $conn, SQLAzureShardManager $shardManager, SchemaSynchronizer $sync = null)
|
||||
public function __construct(Connection $conn, SQLAzureShardManager $shardManager, ?SchemaSynchronizer $sync = null)
|
||||
{
|
||||
parent::__construct($conn);
|
||||
$this->shardManager = $shardManager;
|
||||
@@ -72,13 +45,13 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
{
|
||||
$sql = [];
|
||||
|
||||
list($global, $federation) = $this->partitionSchema($createSchema);
|
||||
[$global, $federation] = $this->partitionSchema($createSchema);
|
||||
|
||||
$globalSql = $this->synchronizer->getCreateSchema($global);
|
||||
if ($globalSql) {
|
||||
$sql[] = "-- Create Root Federation\n" .
|
||||
"USE FEDERATION ROOT WITH RESET;";
|
||||
$sql = array_merge($sql, $globalSql);
|
||||
'USE FEDERATION ROOT WITH RESET;';
|
||||
$sql = array_merge($sql, $globalSql);
|
||||
}
|
||||
|
||||
$federationSql = $this->synchronizer->getCreateSchema($federation);
|
||||
@@ -87,8 +60,8 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
$defaultValue = $this->getFederationTypeDefaultValue();
|
||||
|
||||
$sql[] = $this->getCreateFederationStatement();
|
||||
$sql[] = "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $defaultValue . ") WITH RESET, FILTERING = OFF;";
|
||||
$sql = array_merge($sql, $federationSql);
|
||||
$sql[] = 'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $defaultValue . ') WITH RESET, FILTERING = OFF;';
|
||||
$sql = array_merge($sql, $federationSql);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
@@ -99,7 +72,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
*/
|
||||
public function getUpdateSchema(Schema $toSchema, $noDrops = false)
|
||||
{
|
||||
return $this->work($toSchema, function ($synchronizer, $schema) use ($noDrops) {
|
||||
return $this->work($toSchema, static function ($synchronizer, $schema) use ($noDrops) {
|
||||
return $synchronizer->getUpdateSchema($schema, $noDrops);
|
||||
});
|
||||
}
|
||||
@@ -109,7 +82,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
*/
|
||||
public function getDropSchema(Schema $dropSchema)
|
||||
{
|
||||
return $this->work($dropSchema, function ($synchronizer, $schema) {
|
||||
return $this->work($dropSchema, static function ($synchronizer, $schema) {
|
||||
return $synchronizer->getDropSchema($schema);
|
||||
});
|
||||
}
|
||||
@@ -148,7 +121,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
|
||||
if ($globalSql) {
|
||||
$sql[] = "-- Work on Root Federation\nUSE FEDERATION ROOT WITH RESET;";
|
||||
$sql = array_merge($sql, $globalSql);
|
||||
$sql = array_merge($sql, $globalSql);
|
||||
}
|
||||
|
||||
$shards = $this->shardManager->getShards();
|
||||
@@ -156,15 +129,17 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
$this->shardManager->selectShard($shard['rangeLow']);
|
||||
|
||||
$federationSql = $this->synchronizer->getDropAllSchema();
|
||||
if ($federationSql) {
|
||||
$sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" .
|
||||
"USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;";
|
||||
$sql = array_merge($sql, $federationSql);
|
||||
if (! $federationSql) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql[] = '-- Work on Federation ID ' . $shard['id'] . "\n" .
|
||||
'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ') WITH RESET, FILTERING = OFF;';
|
||||
$sql = array_merge($sql, $federationSql);
|
||||
}
|
||||
|
||||
$sql[] = "USE FEDERATION ROOT WITH RESET;";
|
||||
$sql[] = "DROP FEDERATION " . $this->shardManager->getFederationName();
|
||||
$sql[] = 'USE FEDERATION ROOT WITH RESET;';
|
||||
$sql[] = 'DROP FEDERATION ' . $this->shardManager->getFederationName();
|
||||
|
||||
return $sql;
|
||||
}
|
||||
@@ -178,9 +153,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Schema $schema
|
||||
*
|
||||
* @return array
|
||||
* @return Schema[]
|
||||
*/
|
||||
private function partitionSchema(Schema $schema)
|
||||
{
|
||||
@@ -191,12 +164,11 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Schema $schema
|
||||
* @param bool $isFederation
|
||||
* @param bool $isFederation
|
||||
*
|
||||
* @return \Doctrine\DBAL\Schema\Schema
|
||||
* @return Schema
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function extractSchemaFederation(Schema $schema, $isFederation)
|
||||
{
|
||||
@@ -213,7 +185,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
foreach ($table->getForeignKeys() as $fk) {
|
||||
$foreignTable = $schema->getTable($fk->getForeignTableName());
|
||||
if ($foreignTable->hasOption(self::FEDERATION_TABLE_FEDERATED) !== $isFederation) {
|
||||
throw new \RuntimeException("Cannot have foreign key between global/federation.");
|
||||
throw new RuntimeException('Cannot have foreign key between global/federation.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,15 +199,12 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
* perform the given operation on the underlying schema synchronizer given
|
||||
* the different partitioned schema instances.
|
||||
*
|
||||
* @param \Doctrine\DBAL\Schema\Schema $schema
|
||||
* @param \Closure $operation
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
private function work(Schema $schema, \Closure $operation)
|
||||
private function work(Schema $schema, Closure $operation)
|
||||
{
|
||||
list($global, $federation) = $this->partitionSchema($schema);
|
||||
$sql = [];
|
||||
[$global, $federation] = $this->partitionSchema($schema);
|
||||
$sql = [];
|
||||
|
||||
$this->shardManager->selectGlobal();
|
||||
$globalSql = $operation($this->synchronizer, $global);
|
||||
@@ -251,11 +220,13 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
$this->shardManager->selectShard($shard['rangeLow']);
|
||||
|
||||
$federationSql = $operation($this->synchronizer, $federation);
|
||||
if ($federationSql) {
|
||||
$sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" .
|
||||
"USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'].") WITH RESET, FILTERING = OFF;";
|
||||
$sql = array_merge($sql, $federationSql);
|
||||
if (! $federationSql) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql[] = '-- Work on Federation ID ' . $shard['id'] . "\n" .
|
||||
'USE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' = ' . $shard['rangeLow'] . ') WITH RESET, FILTERING = OFF;';
|
||||
$sql = array_merge($sql, $federationSql);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
@@ -290,10 +261,10 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer
|
||||
*/
|
||||
private function getCreateFederationStatement()
|
||||
{
|
||||
$federationType = Type::getType($this->shardManager->getDistributionType());
|
||||
$federationType = Type::getType($this->shardManager->getDistributionType());
|
||||
$federationTypeSql = $federationType->getSQLDeclaration([], $this->conn->getDatabasePlatform());
|
||||
|
||||
return "--Create Federation\n" .
|
||||
"CREATE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " " . $federationTypeSql ." RANGE)";
|
||||
'CREATE FEDERATION ' . $this->shardManager->getFederationName() . ' (' . $this->shardManager->getDistributionKey() . ' ' . $federationTypeSql . ' RANGE)';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding\SQLAzure;
|
||||
|
||||
@@ -23,71 +6,56 @@ use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Sharding\ShardingException;
|
||||
use Doctrine\DBAL\Sharding\ShardManager;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use RuntimeException;
|
||||
use function is_bool;
|
||||
use function is_scalar;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Sharding using the SQL Azure Federations support.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class SQLAzureShardManager implements ShardManager
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $federationName;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
/** @var bool */
|
||||
private $filteringEnabled;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $distributionKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $distributionType;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Connection
|
||||
*/
|
||||
/** @var Connection */
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
/** @var string|null */
|
||||
private $currentDistributionValue;
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Connection $conn
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Sharding\ShardingException
|
||||
* @throws ShardingException
|
||||
*/
|
||||
public function __construct(Connection $conn)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
$params = $conn->getParams();
|
||||
$params = $conn->getParams();
|
||||
|
||||
if ( ! isset($params['sharding']['federationName'])) {
|
||||
if (! isset($params['sharding']['federationName'])) {
|
||||
throw ShardingException::missingDefaultFederationName();
|
||||
}
|
||||
|
||||
if ( ! isset($params['sharding']['distributionKey'])) {
|
||||
if (! isset($params['sharding']['distributionKey'])) {
|
||||
throw ShardingException::missingDefaultDistributionKey();
|
||||
}
|
||||
|
||||
if ( ! isset($params['sharding']['distributionType'])) {
|
||||
if (! isset($params['sharding']['distributionType'])) {
|
||||
throw ShardingException::missingDistributionType();
|
||||
}
|
||||
|
||||
$this->federationName = $params['sharding']['federationName'];
|
||||
$this->distributionKey = $params['sharding']['distributionKey'];
|
||||
$this->federationName = $params['sharding']['federationName'];
|
||||
$this->distributionKey = $params['sharding']['distributionKey'];
|
||||
$this->distributionType = $params['sharding']['distributionType'];
|
||||
$this->filteringEnabled = (bool) ($params['sharding']['filteringEnabled'] ?? false);
|
||||
}
|
||||
@@ -143,7 +111,7 @@ class SQLAzureShardManager implements ShardManager
|
||||
throw ShardingException::activeTransaction();
|
||||
}
|
||||
|
||||
$sql = "USE FEDERATION ROOT WITH RESET";
|
||||
$sql = 'USE FEDERATION ROOT WITH RESET';
|
||||
$this->conn->exec($sql);
|
||||
$this->currentDistributionValue = null;
|
||||
}
|
||||
@@ -157,13 +125,13 @@ class SQLAzureShardManager implements ShardManager
|
||||
throw ShardingException::activeTransaction();
|
||||
}
|
||||
|
||||
if ($distributionValue === null || is_bool($distributionValue) || !is_scalar($distributionValue)) {
|
||||
if ($distributionValue === null || is_bool($distributionValue) || ! is_scalar($distributionValue)) {
|
||||
throw ShardingException::noShardDistributionValue();
|
||||
}
|
||||
|
||||
$platform = $this->conn->getDatabasePlatform();
|
||||
$sql = sprintf(
|
||||
"USE FEDERATION %s (%s = %s) WITH RESET, FILTERING = %s;",
|
||||
$sql = sprintf(
|
||||
'USE FEDERATION %s (%s = %s) WITH RESET, FILTERING = %s;',
|
||||
$platform->quoteIdentifier($this->federationName),
|
||||
$platform->quoteIdentifier($this->distributionKey),
|
||||
$this->conn->quote($distributionValue),
|
||||
@@ -187,13 +155,13 @@ class SQLAzureShardManager implements ShardManager
|
||||
*/
|
||||
public function getShards()
|
||||
{
|
||||
$sql = "SELECT member_id as id,
|
||||
$sql = 'SELECT member_id as id,
|
||||
distribution_name as distribution_key,
|
||||
CAST(range_low AS CHAR) AS rangeLow,
|
||||
CAST(range_high AS CHAR) AS rangeHigh
|
||||
FROM sys.federation_member_distributions d
|
||||
INNER JOIN sys.federations f ON f.federation_id = d.federation_id
|
||||
WHERE f.name = " . $this->conn->quote($this->federationName);
|
||||
WHERE f.name = ' . $this->conn->quote($this->federationName);
|
||||
|
||||
return $this->conn->fetchAll($sql);
|
||||
}
|
||||
@@ -204,11 +172,11 @@ class SQLAzureShardManager implements ShardManager
|
||||
public function queryAll($sql, array $params = [], array $types = [])
|
||||
{
|
||||
$shards = $this->getShards();
|
||||
if (!$shards) {
|
||||
throw new \RuntimeException("No shards found for " . $this->federationName);
|
||||
if (! $shards) {
|
||||
throw new RuntimeException('No shards found for ' . $this->federationName);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$result = [];
|
||||
$oldDistribution = $this->getCurrentDistributionValue();
|
||||
|
||||
foreach ($shards as $shard) {
|
||||
@@ -238,9 +206,9 @@ class SQLAzureShardManager implements ShardManager
|
||||
{
|
||||
$type = Type::getType($this->distributionType);
|
||||
|
||||
$sql = "ALTER FEDERATION " . $this->getFederationName() . " " .
|
||||
"SPLIT AT (" . $this->getDistributionKey() . " = " .
|
||||
$this->conn->quote($splitDistributionValue, $type->getBindingType()) . ")";
|
||||
$sql = 'ALTER FEDERATION ' . $this->getFederationName() . ' ' .
|
||||
'SPLIT AT (' . $this->getDistributionKey() . ' = ' .
|
||||
$this->conn->quote($splitDistributionValue, $type->getBindingType()) . ')';
|
||||
$this->conn->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding\SQLAzure\Schema;
|
||||
|
||||
use Doctrine\DBAL\Schema\Visitor\Visitor;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Column;
|
||||
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
|
||||
use Doctrine\DBAL\Schema\Sequence;
|
||||
use Doctrine\DBAL\Schema\Index;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Sequence;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Schema\Visitor\Visitor;
|
||||
use RuntimeException;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
@@ -46,24 +30,16 @@ use function in_array;
|
||||
* (otherwise they will affect the same-id rows from other tenants as well).
|
||||
* SQLAzure throws errors when you try to create IDENTIY columns on federated
|
||||
* tables.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class MultiTenantVisitor implements Visitor
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var string[] */
|
||||
private $excludedTables = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $tenantColumnName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $tenantColumnType = 'integer';
|
||||
|
||||
/**
|
||||
@@ -75,13 +51,13 @@ class MultiTenantVisitor implements Visitor
|
||||
private $distributionName;
|
||||
|
||||
/**
|
||||
* @param array $excludedTables
|
||||
* @param string[] $excludedTables
|
||||
* @param string $tenantColumnName
|
||||
* @param string|null $distributionName
|
||||
*/
|
||||
public function __construct(array $excludedTables = [], $tenantColumnName = 'tenant_id', $distributionName = null)
|
||||
{
|
||||
$this->excludedTables = $excludedTables;
|
||||
$this->excludedTables = $excludedTables;
|
||||
$this->tenantColumnName = $tenantColumnName;
|
||||
$this->distributionName = $distributionName ?: $tenantColumnName;
|
||||
}
|
||||
@@ -96,12 +72,12 @@ class MultiTenantVisitor implements Visitor
|
||||
}
|
||||
|
||||
$table->addColumn($this->tenantColumnName, $this->tenantColumnType, [
|
||||
'default' => "federation_filtering_value('". $this->distributionName ."')",
|
||||
'default' => "federation_filtering_value('" . $this->distributionName . "')",
|
||||
]);
|
||||
|
||||
$clusteredIndex = $this->getClusteredIndex($table);
|
||||
|
||||
$indexColumns = $clusteredIndex->getColumns();
|
||||
$indexColumns = $clusteredIndex->getColumns();
|
||||
$indexColumns[] = $this->tenantColumnName;
|
||||
|
||||
if ($clusteredIndex->isPrimary()) {
|
||||
@@ -115,22 +91,24 @@ class MultiTenantVisitor implements Visitor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Table $table
|
||||
* @param Table $table
|
||||
*
|
||||
* @return \Doctrine\DBAL\Schema\Index
|
||||
* @return Index
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function getClusteredIndex($table)
|
||||
{
|
||||
foreach ($table->getIndexes() as $index) {
|
||||
if ($index->isPrimary() && ! $index->hasFlag('nonclustered')) {
|
||||
return $index;
|
||||
} elseif ($index->hasFlag('clustered')) {
|
||||
}
|
||||
|
||||
if ($index->hasFlag('clustered')) {
|
||||
return $index;
|
||||
}
|
||||
}
|
||||
throw new \RuntimeException("No clustered index found on table " . $table->getName());
|
||||
throw new RuntimeException('No clustered index found on table ' . $table->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding\ShardChoser;
|
||||
|
||||
@@ -24,8 +7,6 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection;
|
||||
/**
|
||||
* The MultiTenant Shard choser assumes that the distribution value directly
|
||||
* maps to the shard id.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class MultiTenantShardChoser implements ShardChoser
|
||||
{
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding\ShardChoser;
|
||||
|
||||
@@ -24,18 +7,15 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection;
|
||||
/**
|
||||
* Given a distribution value this shard-choser strategy will pick the shard to
|
||||
* connect to for retrieving rows with the distribution value.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
interface ShardChoser
|
||||
{
|
||||
/**
|
||||
* Picks a shard for the given distribution value.
|
||||
*
|
||||
* @param string|int $distributionValue
|
||||
* @param \Doctrine\DBAL\Sharding\PoolingShardConnection $conn
|
||||
* @param string|int $distributionValue
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function pickShard($distributionValue, PoolingShardConnection $conn);
|
||||
public function pickShard($distributionValue, PoolingShardConnection $conn);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding;
|
||||
|
||||
@@ -34,8 +17,6 @@ namespace Doctrine\DBAL\Sharding;
|
||||
* executed against the last shard that was selected. If a query is created for
|
||||
* a shard Y but then a shard X is selected when its actually executed you
|
||||
* will hit the wrong shard.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
interface ShardManager
|
||||
{
|
||||
@@ -47,7 +28,7 @@ interface ShardManager
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function selectGlobal();
|
||||
public function selectGlobal();
|
||||
|
||||
/**
|
||||
* Selects the shard against which the queries after this statement will be issued.
|
||||
@@ -56,16 +37,16 @@ interface ShardManager
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Sharding\ShardingException If no value is passed as shard identifier.
|
||||
* @throws ShardingException If no value is passed as shard identifier.
|
||||
*/
|
||||
function selectShard($distributionValue);
|
||||
public function selectShard($distributionValue);
|
||||
|
||||
/**
|
||||
* Gets the distribution value currently used for sharding.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getCurrentDistributionValue();
|
||||
public function getCurrentDistributionValue();
|
||||
|
||||
/**
|
||||
* Gets information about the amount of shards and other details.
|
||||
@@ -73,9 +54,9 @@ interface ShardManager
|
||||
* Format is implementation specific, each shard is one element and has an
|
||||
* 'id' attribute at least.
|
||||
*
|
||||
* @return array
|
||||
* @return mixed[][]
|
||||
*/
|
||||
function getShards();
|
||||
public function getShards();
|
||||
|
||||
/**
|
||||
* Queries all shards in undefined order and return the results appended to
|
||||
@@ -83,11 +64,11 @@ interface ShardManager
|
||||
*
|
||||
* Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param array $params
|
||||
* @param array $types
|
||||
* @param string $sql
|
||||
* @param mixed[] $params
|
||||
* @param int[]|string[] $types
|
||||
*
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
function queryAll($sql, array $params, array $types);
|
||||
public function queryAll($sql, array $params, array $types);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Sharding;
|
||||
|
||||
@@ -23,8 +6,6 @@ use Doctrine\DBAL\DBALException;
|
||||
|
||||
/**
|
||||
* Sharding related Exceptions
|
||||
*
|
||||
* @since 2.3
|
||||
*/
|
||||
class ShardingException extends DBALException
|
||||
{
|
||||
@@ -33,7 +14,7 @@ class ShardingException extends DBALException
|
||||
*/
|
||||
public static function notImplemented()
|
||||
{
|
||||
return new self("This functionality is not implemented with this sharding provider.", 1331557937);
|
||||
return new self('This functionality is not implemented with this sharding provider.', 1331557937);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +22,7 @@ class ShardingException extends DBALException
|
||||
*/
|
||||
public static function missingDefaultFederationName()
|
||||
{
|
||||
return new self("SQLAzure requires a federation name to be set during sharding configuration.", 1332141280);
|
||||
return new self('SQLAzure requires a federation name to be set during sharding configuration.', 1332141280);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +30,7 @@ class ShardingException extends DBALException
|
||||
*/
|
||||
public static function missingDefaultDistributionKey()
|
||||
{
|
||||
return new self("SQLAzure requires a distribution key to be set during sharding configuration.", 1332141329);
|
||||
return new self('SQLAzure requires a distribution key to be set during sharding configuration.', 1332141329);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +38,7 @@ class ShardingException extends DBALException
|
||||
*/
|
||||
public static function activeTransaction()
|
||||
{
|
||||
return new self("Cannot switch shard during an active transaction.", 1332141766);
|
||||
return new self('Cannot switch shard during an active transaction.', 1332141766);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +46,7 @@ class ShardingException extends DBALException
|
||||
*/
|
||||
public static function noShardDistributionValue()
|
||||
{
|
||||
return new self("You have to specify a string or integer as shard distribution value.", 1332142103);
|
||||
return new self('You have to specify a string or integer as shard distribution value.', 1332142103);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user