From dc40da1ef29c045cb8ca2c4a7f05525836ffa75c Mon Sep 17 00:00:00 2001 From: Thaddeus Ternes Date: Mon, 19 Jul 2021 21:59:43 -0500 Subject: [PATCH] Improvements based on PR feedback --- GRDB/Core/DatabaseWriter.swift | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/GRDB/Core/DatabaseWriter.swift b/GRDB/Core/DatabaseWriter.swift index bcc2ce1be..de0859e74 100644 --- a/GRDB/Core/DatabaseWriter.swift +++ b/GRDB/Core/DatabaseWriter.swift @@ -320,16 +320,32 @@ extension DatabaseWriter { try writeWithoutTransaction { try $0.execute(sql: "VACUUM") } } - /// Creates a new database file at the specified file with a minimum + // VACUUM INTO was introduced in SQLite 3.27.0: + // https://www.sqlite.org/releaselog/3_27_0.html + #if GRDBCUSTOMSQLITE + /// Creates a new database file at the specified path with a minimum /// amount of disk space. - /// See https://www.sqlite.org/lang_vacuum.html for more information. + /// See https://www.sqlite.org/lang_vacuum.html#vacuuminto for more information. /// - /// - Parameter into: filename for new database - public func vacuum(into: String) throws { + /// - Parameter filePath: file path for new database + public func vacuum(into filePath: String) throws { try writeWithoutTransaction { - try $0.execute(sql: "VACUUM INTO ?", arguments: [into]) + try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath]) } } + #elseif !GRDBCIPHER + /// Creates a new database file at the specified path with a minimum + /// amount of disk space. + /// See https://www.sqlite.org/lang_vacuum.html#vacuuminto for more information. + /// + /// - Parameter filePath: file path for new database + @available(OSX 10.16, iOS 14, tvOS 14, watchOS 7, *) + public func vacuum(into filePath: String) throws { + try writeWithoutTransaction { + try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath]) + } + } + #endif // MARK: - Database Observation