@@ -13,7 +13,7 @@ import Foundation
13
13
/// The virtual table module for the FTS5 full-text engine.
14
14
///
15
15
/// To create FTS5 tables, use the ``Database`` method
16
- /// ``Database/create(virtualTable:ifNotExists :using:_:)``:
16
+ /// ``Database/create(virtualTable:options :using:_:)``:
17
17
///
18
18
/// ```swift
19
19
/// // CREATE VIRTUAL TABLE document USING fts5(content)
@@ -85,7 +85,7 @@ public struct FTS5 {
85
85
/// }
86
86
/// ```
87
87
///
88
- /// See ``Database/create(virtualTable:ifNotExists :using:_:)``
88
+ /// See ``Database/create(virtualTable:options :using:_:)``
89
89
public init ( ) { }
90
90
91
91
// Support for FTS5Pattern initializers. Don't make public. Users tokenize
@@ -143,7 +143,7 @@ extension FTS5: VirtualTableModule {
143
143
144
144
/// Reserved; part of the VirtualTableModule protocol.
145
145
///
146
- /// See Database.create(virtualTable:using:)
146
+ /// See Database.create(virtualTable:options: using:_ :)
147
147
public func makeTableDefinition( configuration: VirtualTableConfiguration ) -> FTS5TableDefinition {
148
148
FTS5TableDefinition ( configuration: configuration)
149
149
}
@@ -219,14 +219,24 @@ extension FTS5: VirtualTableModule {
219
219
220
220
/// Reserved; part of the VirtualTableModule protocol.
221
221
///
222
- /// See Database.create(virtualTable:using:)
222
+ /// See Database.create(virtualTable:options: using:_ :)
223
223
public func database( _ db: Database , didCreate tableName: String , using definition: FTS5TableDefinition ) throws {
224
224
switch definition. contentMode {
225
225
case . raw:
226
226
break
227
227
case . synchronized( let contentTable) :
228
228
// https://sqlite.org/fts5.html#external_content_tables
229
229
230
+ if definition. configuration. temporary {
231
+ // SQLite can't rebuild the index of temporary tables:
232
+ //
233
+ // sqlite> CREATE TABLE t(id INTEGER PRIMARY KEY, a, b, c);
234
+ // sqlite> CREATE VIRTUAL TABLE temp.ft USING fts5(content="t",content_rowid="a",b,c);
235
+ // sqlite> INSERT INTO ft(ft) VALUES('rebuild');
236
+ // Runtime error: SQL logic error
237
+ fatalError ( " Temporary external content FTS5 tables are not supported. " )
238
+ }
239
+
230
240
let rowIDColumn = try db. primaryKey ( contentTable) . rowIDColumn ?? Column . rowID. name
231
241
let ftsTable = tableName. quotedDatabaseIdentifier
232
242
let content = contentTable. quotedDatabaseIdentifier
@@ -274,7 +284,7 @@ extension FTS5: VirtualTableModule {
274
284
/// virtual table.
275
285
///
276
286
/// You don't create instances of this class. Instead, you use the `Database`
277
- /// ``Database/create(virtualTable:ifNotExists :using:_:)`` method:
287
+ /// ``Database/create(virtualTable:options :using:_:)`` method:
278
288
///
279
289
/// ```swift
280
290
/// try db.create(virtualTable: "document", using: FTS5()) { t in // t is FTS5TableDefinition
0 commit comments