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.php85
1 files changed, 53 insertions, 32 deletions
diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php
index b3e7d697017..ea9b71d8958 100644
--- a/lib/public/IDBConnection.php
+++ b/lib/public/IDBConnection.php
@@ -1,39 +1,18 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Ole Ostergaard <ole.c.ostergaard@gmail.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
// use OCP namespace for all classes that are considered public.
-// This means that they should be used by apps instead of the internal ownCloud classes
+// This means that they should be used by apps instead of the internal Nextcloud classes
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;
@@ -66,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
@@ -157,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
@@ -301,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();
@@ -316,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
@@ -362,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;
}