aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/db/pgsqltools.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/db/pgsqltools.php')
-rw-r--r--lib/private/db/pgsqltools.php70
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/private/db/pgsqltools.php b/lib/private/db/pgsqltools.php
deleted file mode 100644
index e9e507551e6..00000000000
--- a/lib/private/db/pgsqltools.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * @author Andreas Fischer <bantu@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author tbelau666 <thomas.belau@gmx.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @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/>
- *
- */
-
-namespace OC\DB;
-use OCP\IConfig;
-
-/**
-* Various PostgreSQL specific helper functions.
-*/
-class PgSqlTools {
-
- /** @var \OCP\IConfig */
- private $config;
-
- /**
- * @param \OCP\IConfig $config
- */
- public function __construct(IConfig $config) {
- $this->config = $config;
- }
-
- /**
- * @brief Resynchronizes all sequences of a database after using INSERTs
- * without leaving out the auto-incremented column.
- * @param \OC\DB\Connection $conn
- * @return null
- */
- public function resynchronizeDatabaseSequences(Connection $conn) {
- $filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
- $databaseName = $conn->getDatabase();
- $conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
-
- foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
- $sequenceName = $sequence->getName();
- $sqlInfo = 'SELECT table_schema, table_name, column_name
- FROM information_schema.columns
- WHERE column_default = ? AND table_catalog = ?';
- $sequenceInfo = $conn->fetchAssoc($sqlInfo, array(
- "nextval('$sequenceName'::regclass)",
- $databaseName
- ));
- $tableName = $sequenceInfo['table_name'];
- $columnName = $sequenceInfo['column_name'];
- $sqlMaxId = "SELECT MAX($columnName) FROM $tableName";
- $sqlSetval = "SELECT setval('$sequenceName', ($sqlMaxId))";
- $conn->executeQuery($sqlSetval);
- }
- }
-}
f='#n203'>203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298