aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/IDBConnection.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/IDBConnection.php')
-rw-r--r--lib/public/IDBConnection.php52
1 files changed, 48 insertions, 4 deletions
diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php
index a5df85896e2..ea9b71d8958 100644
--- a/lib/public/IDBConnection.php
+++ b/lib/public/IDBConnection.php
@@ -11,6 +11,8 @@
namespace OCP;
use Doctrine\DBAL\Schema\Schema;
+use OC\DB\QueryBuilder\Sharded\CrossShardMoveHelper;
+use OC\DB\QueryBuilder\Sharded\ShardDefinition;
use OCP\DB\Exception;
use OCP\DB\IPreparedStatement;
use OCP\DB\IResult;
@@ -43,6 +45,11 @@ interface IDBConnection {
public const PLATFORM_SQLITE = 'sqlite';
/**
+ * @since 32.0.0
+ */
+ public const PLATFORM_MARIADB = 'mariadb';
+
+ /**
* Gets the QueryBuilder for the connection.
*
* @return \OCP\DB\QueryBuilder\IQueryBuilder
@@ -134,8 +141,8 @@ interface IDBConnection {
* @param string $table The table name (will replace *PREFIX* with the actual prefix)
* @param array $input data that should be inserted into the table (column name => value)
* @param array|null $compare List of values that should be checked for "if not exists"
- * If this is null or an empty array, all keys of $input will be compared
- * Please note: text fields (clob) must not be used in the compare array
+ * If this is null or an empty array, all keys of $input will be compared
+ * Please note: text fields (clob) must not be used in the compare array
* @return int number of inserted rows
* @throws Exception used to be the removed dbal exception, since 21.0.0 it's \OCP\DB\Exception
* @since 6.0.0 - parameter $compare was added in 8.1.0, return type changed from boolean in 8.1.0
@@ -278,6 +285,7 @@ interface IDBConnection {
*
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
* @since 8.0.0
+ * @deprecated 30.0.0 Please use {@see self::getDatabaseProvider()} and compare to self::PLATFORM_* constants
*/
public function getDatabasePlatform();
@@ -293,6 +301,21 @@ interface IDBConnection {
public function dropTable(string $table): void;
/**
+ * Truncate a table data if it exists
+ *
+ * Cascade is not supported on many platforms but would optionally cascade the truncate by
+ * following the foreign keys.
+ *
+ * @param string $table table name without the prefix
+ * @param bool $cascade whether to truncate cascading
+ * @throws Exception
+ * @since 32.0.0
+ *
+ * @psalm-taint-sink sql $table
+ */
+ public function truncateTable(string $table, bool $cascade): void;
+
+ /**
* Check if a table exists
*
* @param string $table table name without the prefix
@@ -339,9 +362,30 @@ interface IDBConnection {
/**
* Returns the database provider name
+ *
* @link https://github.com/nextcloud/server/issues/30877
+ *
+ * @param bool $strict differentiate between database flavors, e.g. MySQL vs MariaDB
+ * @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE|self::PLATFORM_MARIADB
+ * @since 32.0.0 Optional parameter $strict was added
* @since 28.0.0
- * @return IDBConnection::PLATFORM_*
*/
- public function getDatabaseProvider(): string;
+ public function getDatabaseProvider(bool $strict = false): string;
+
+ /**
+ * Get the shard definition by name, if configured
+ *
+ * @param string $name
+ * @return ShardDefinition|null
+ * @since 30.0.0
+ */
+ public function getShardDefinition(string $name): ?ShardDefinition;
+
+ /**
+ * Get a helper class for implementing cross-shard moves
+ *
+ * @return CrossShardMoveHelper
+ * @since 30.0.0
+ */
+ public function getCrossShardMoveHelper(): CrossShardMoveHelper;
}