aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/ConnectionAdapter.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/ConnectionAdapter.php')
-rw-r--r--lib/private/DB/ConnectionAdapter.php58
1 files changed, 38 insertions, 20 deletions
diff --git a/lib/private/DB/ConnectionAdapter.php b/lib/private/DB/ConnectionAdapter.php
index 86a901a7de3..d9ccb3c54f2 100644
--- a/lib/private/DB/ConnectionAdapter.php
+++ b/lib/private/DB/ConnectionAdapter.php
@@ -10,12 +10,10 @@ namespace OC\DB;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use OC\DB\Exceptions\DbalException;
+use OC\DB\QueryBuilder\Sharded\CrossShardMoveHelper;
+use OC\DB\QueryBuilder\Sharded\ShardDefinition;
use OCP\DB\IPreparedStatement;
use OCP\DB\IResult;
use OCP\DB\QueryBuilder\IQueryBuilder;
@@ -52,7 +50,7 @@ class ConnectionAdapter implements IDBConnection {
$this->inner->executeQuery($sql, $params, $types)
);
} catch (Exception $e) {
- throw DbalException::wrap($e);
+ throw DbalException::wrap($e, '', $sql);
}
}
@@ -60,7 +58,7 @@ class ConnectionAdapter implements IDBConnection {
try {
return $this->inner->executeUpdate($sql, $params, $types);
} catch (Exception $e) {
- throw DbalException::wrap($e);
+ throw DbalException::wrap($e, '', $sql);
}
}
@@ -68,7 +66,7 @@ class ConnectionAdapter implements IDBConnection {
try {
return $this->inner->executeStatement($sql, $params, $types);
} catch (Exception $e) {
- throw DbalException::wrap($e);
+ throw DbalException::wrap($e, '', $sql);
}
}
@@ -191,6 +189,14 @@ class ConnectionAdapter implements IDBConnection {
}
}
+ public function truncateTable(string $table, bool $cascade): void {
+ try {
+ $this->inner->truncateTable($table, $cascade);
+ } catch (Exception $e) {
+ throw DbalException::wrap($e);
+ }
+ }
+
public function tableExists(string $table): bool {
try {
return $this->inner->tableExists($table);
@@ -230,18 +236,30 @@ class ConnectionAdapter implements IDBConnection {
return $this->inner;
}
- public function getDatabaseProvider(): string {
- $platform = $this->inner->getDatabasePlatform();
- if ($platform instanceof MySQLPlatform) {
- return IDBConnection::PLATFORM_MYSQL;
- } elseif ($platform instanceof OraclePlatform) {
- return IDBConnection::PLATFORM_ORACLE;
- } elseif ($platform instanceof PostgreSQLPlatform) {
- return IDBConnection::PLATFORM_POSTGRES;
- } elseif ($platform instanceof SqlitePlatform) {
- return IDBConnection::PLATFORM_SQLITE;
- } else {
- throw new \Exception('Database ' . $platform::class . ' not supported');
- }
+ /**
+ * @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE|self::PLATFORM_MARIADB
+ */
+ public function getDatabaseProvider(bool $strict = false): string {
+ return $this->inner->getDatabaseProvider($strict);
+ }
+
+ /**
+ * @internal Should only be used inside the QueryBuilder, ExpressionBuilder and FunctionBuilder
+ * All apps and API code should not need this and instead use provided functionality from the above.
+ */
+ public function getServerVersion(): string {
+ return $this->inner->getServerVersion();
+ }
+
+ public function logDatabaseException(\Exception $exception) {
+ $this->inner->logDatabaseException($exception);
+ }
+
+ public function getShardDefinition(string $name): ?ShardDefinition {
+ return $this->inner->getShardDefinition($name);
+ }
+
+ public function getCrossShardMoveHelper(): CrossShardMoveHelper {
+ return $this->inner->getCrossShardMoveHelper();
}
}