diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6ae5ac96..cf4270541 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
#### 6.x Releases
-- `6.24.x` Releases - [6.24.0](#6240)
+- `6.24.x` Releases - [6.24.0](#6240) - [6.24.1](#6241)
- `6.23.x` Releases - [6.23.0](#6230)
- `6.22.x` Releases - [6.22.0](#6220)
- `6.21.x` Releases - [6.21.0](#6210)
@@ -122,6 +122,12 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
---
+## 6.24.1
+
+Released January 6, 2024
+
+- **New**: [#1477](https://github.com/groue/GRDB.swift/pull/1477): Remove shadow tables from database dump
+
## 6.24.0
Released January 6, 2024
diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec
index afb5040f5..466b8cf16 100644
--- a/GRDB.swift.podspec
+++ b/GRDB.swift.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
- s.version = '6.24.0'
+ s.version = '6.24.1'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
diff --git a/GRDB/Dump/Database+Dump.swift b/GRDB/Dump/Database+Dump.swift
index 146efed16..e98716edc 100644
--- a/GRDB/Dump/Database+Dump.swift
+++ b/GRDB/Dump/Database+Dump.swift
@@ -129,6 +129,9 @@ extension Database {
///
/// > Note: Internal SQLite and GRDB schema objects are not recorded
/// > (those with a name that starts with "sqlite_" or "grdb_").
+ /// >
+ /// > [Shadow tables](https://www.sqlite.org/vtab.html#xshadowname) are
+ /// > not recorded, starting SQLite 3.37+.
///
/// - Parameters:
/// - format: The output format.
@@ -252,7 +255,7 @@ extension Database {
""")
for row in sqlRows {
let name: String = row[1]
- if Database.isSQLiteInternalTable(name) || Database.isGRDBInternalTable(name) {
+ if try ignoresObject(named: name) {
continue
}
stream.writeln(row[0])
@@ -266,12 +269,42 @@ extension Database {
ORDER BY name COLLATE NOCASE
""")
.filter {
- !(Database.isSQLiteInternalTable($0) || Database.isGRDBInternalTable($0))
+ try !ignoresObject(named: $0)
}
if tables.isEmpty { return }
stream.write("\n")
try _dumpTables(tables, format: format, tableHeader: .always, stableOrder: true, to: &stream)
}
+
+ private func ignoresObject(named name: String) throws -> Bool {
+ if Database.isSQLiteInternalTable(name) { return true }
+ if Database.isGRDBInternalTable(name) { return true }
+ if try isShadowTable(name) { return true }
+ return false
+ }
+
+ private func isShadowTable(_ tableName: String) throws -> Bool {
+#if GRDBCUSTOMSQLITE || GRDBCIPHER
+ // Maybe SQLCipher is too old: check actual version
+ if sqlite3_libversion_number() >= 3037000 {
+ guard let table = try table(tableName) else {
+ // Not a table
+ return false
+ }
+ return table.kind == .shadow
+ }
+#else
+ if #available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) { // SQLite 3.37+
+ guard let table = try table(tableName) else {
+ // Not a table
+ return false
+ }
+ return table.kind == .shadow
+ }
+#endif
+ // Don't know
+ return false
+ }
}
/// Options for printing table names.
diff --git a/GRDB/Dump/DatabaseReader+dump.swift b/GRDB/Dump/DatabaseReader+dump.swift
index e18807d05..cd3649cae 100644
--- a/GRDB/Dump/DatabaseReader+dump.swift
+++ b/GRDB/Dump/DatabaseReader+dump.swift
@@ -120,6 +120,9 @@ extension DatabaseReader {
///
/// > Note: Internal SQLite and GRDB schema objects are not recorded
/// > (those with a name that starts with "sqlite_" or "grdb_").
+ /// >
+ /// > [Shadow tables](https://www.sqlite.org/vtab.html#xshadowname) are
+ /// > not recorded, starting SQLite 3.37+.
///
/// - Parameters:
/// - format: The output format.
diff --git a/README.md b/README.md
index a908cf6ab..e7c052d6e 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@