diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf2dd8ada..50339128e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,15 @@
Release Notes
=============
+## 0.75.2
+
+Released July 18, 2016
+
+**Fixed**
+
+- Fixed crashes that could happen when using virtual tables (fixes [#82](https://github.com/groue/GRDB.swift/issues/82))
+
+
## 0.75.1
Released July 8, 2016
diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec
index 81ecef495..35c1acafa 100644
--- a/GRDB.swift.podspec
+++ b/GRDB.swift.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
- s.version = '0.75.1'
+ s.version = '0.75.2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A versatile SQLite toolkit for Swift, with WAL mode support.'
s.homepage = 'https://github.com/groue/GRDB.swift'
diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift
index f998d77db..4d0e7efb5 100644
--- a/GRDB/Core/Database.swift
+++ b/GRDB/Core/Database.swift
@@ -1097,17 +1097,7 @@ final class StatementCompilationObserver {
observer.databaseEventKinds.append(.delete(tableName: String(cString: CString1!)))
case SQLITE_UPDATE:
let observer = unsafeBitCast(observerPointer, to: StatementCompilationObserver.self)
- let tableName = String(cString: CString1!)
-
- // Ignore all changes to sqlite_master.
- //
- // The schema changes are already processed by the SQLITE_DROP_TABLE, SQLITE_CREATE_INDEX, etc. (see above).
- //
- // Plus SQLite will sometimes announce that SELECT statements
- // perform changes to sqlite_master. See DatabasePoolConcurrencyTests.testIssue80()
- if tableName != "sqlite_master" {
- observer.insertUpdateEventKind(tableName: tableName, columnName: String(cString: CString2!))
- }
+ observer.insertUpdateEventKind(tableName: String(cString: CString1!), columnName: String(cString: CString2!))
case SQLITE_SAVEPOINT:
let observer = unsafeBitCast(observerPointer, to: StatementCompilationObserver.self)
let name = String(cString: CString2!)
@@ -1408,7 +1398,28 @@ extension Database {
static func preconditionValidSelectStatement(sql: String, observer: StatementCompilationObserver) {
GRDBPrecondition(observer.invalidatesDatabaseSchemaCache == false, "Invalid statement type for query \(String(reflecting: sql)): use UpdateStatement instead.")
GRDBPrecondition(observer.savepointAction == nil, "Invalid statement type for query \(String(reflecting: sql)): use UpdateStatement instead.")
- GRDBPrecondition(observer.databaseEventKinds.isEmpty, "Invalid statement type for query \(String(reflecting: sql)): use UpdateStatement instead.")
+
+ // Don't check for observer.databaseEventKinds.isEmpty
+ //
+ // When observer.databaseEventKinds.isEmpty is NOT empty, this means
+ // that the database is changed by the statement.
+ //
+ // It thus looks like the statement should be performed by an
+ // UpdateStatement, not a SelectStatement: transaction observers are not
+ // notified of database changes when they are executed by
+ // a SelectStatement.
+ //
+ // However https://github.com/groue/GRDB.swift/issues/80 and
+ // https://github.com/groue/GRDB.swift/issues/82 have shown that SELECT
+ // statements on virtual tables can generate database changes.
+ //
+ // :-(
+ //
+ // OK, this is getting very difficult to protect the user against
+ // himself: just give up, and allow SelectStatement to execute database
+ // changes. We'll cope with eventual troubles later, when they occur.
+ //
+ // GRDBPrecondition(observer.databaseEventKinds.isEmpty, "Invalid statement type for query \(String(reflecting: sql)): use UpdateStatement instead.")
}
func updateStatementWillExecute(_ statement: UpdateStatement) {
diff --git a/README.md b/README.md
index e7baff24c..6af5713e0 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ You should give it a try.
---
-The Swift3 branch has no version. It is currently synced with v0.75.1 of the Swift 2.2 [main branch](https://github.com/groue/GRDB.swift).
+The Swift3 branch has no version. It is currently synced with v0.75.2 of the Swift 2.2 [main branch](https://github.com/groue/GRDB.swift).
Follow [@groue](http://twitter.com/groue) on Twitter for release announcements and usage tips.
@@ -280,7 +280,7 @@ let dbQueue = try DatabaseQueue(
configuration: config)
```
-See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Structs/Configuration.html) for more details.
+See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Structs/Configuration.html) for more details.
## Database Pools
@@ -360,7 +360,7 @@ let dbPool = try DatabasePool(
configuration: config)
```
-See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Structs/Configuration.html) for more details.
+See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Structs/Configuration.html) for more details.
Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information.
@@ -1442,10 +1442,10 @@ for person in Person.fetch(db, sql, adapter: adapter) {
For more information about row adapters, see the documentation of:
-- [RowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Protocols/RowAdapter.html): the protocol that lets you define your custom row adapters
-- [ColumnMapping](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Structs/ColumnMapping.html): a row adapter that renames row columns
-- [SuffixRowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Structs/SuffixRowAdapter.html): a row adapter that hides the first columns of a row
-- [ScopeAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Structs/ScopeAdapter.html): the row adapter that groups several adapters together to define scopes
+- [RowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Protocols/RowAdapter.html): the protocol that lets you define your custom row adapters
+- [ColumnMapping](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Structs/ColumnMapping.html): a row adapter that renames row columns
+- [SuffixRowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Structs/SuffixRowAdapter.html): a row adapter that hides the first columns of a row
+- [ScopeAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Structs/ScopeAdapter.html): the row adapter that groups several adapters together to define scopes
## Raw SQLite Pointers
@@ -3340,7 +3340,7 @@ let count2 = dbQueue.inDatabase { db in
SQLite concurrency is a wiiide topic.
-First have a detailed look at the full API of [DatabaseQueue](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Classes/DatabaseQueue.html) and [DatabasePool](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Classes/DatabasePool.html). Both adopt the [DatabaseReader](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Protocols/DatabaseReader.html) and [DatabaseWriter](http://cocoadocs.org/docsets/GRDB.swift/0.75.1/Protocols/DatabaseWriter.html) protocols, so that you can write code that targets both classes.
+First have a detailed look at the full API of [DatabaseQueue](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Classes/DatabaseQueue.html) and [DatabasePool](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Classes/DatabasePool.html). Both adopt the [DatabaseReader](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Protocols/DatabaseReader.html) and [DatabaseWriter](http://cocoadocs.org/docsets/GRDB.swift/0.75.2/Protocols/DatabaseWriter.html) protocols, so that you can write code that targets both classes.
If the built-in queues and pools do not fit your needs, or if you can not guarantee that a single queue or pool is accessing your database file, you may have a look at:
diff --git a/Support/Info.plist b/Support/Info.plist
index eb90c95cc..dedd45df7 100644
--- a/Support/Info.plist
+++ b/Support/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 0.75.1
+ 0.75.2
CFBundleSignature
????
CFBundleVersion
diff --git a/TODO.md b/TODO.md
index b9af5ba3e..8f2ed09e2 100644
--- a/TODO.md
+++ b/TODO.md
@@ -22,6 +22,7 @@
Not sure
+- [ ] Issue 85: Consider Django ordering: "Each order_by() call will clear any previous ordering": https://docs.djangoproject.com/en/1.9/ref/models/querysets/#order-by
- [ ] Support for NSColor/UIColor. Beware UIColor components can go beyond [0, 1.0] in iOS10.