Skip to content

Commit a66d0fa

Browse files
authored
Merge pull request #472 from stephencelis/revert-451-connection-pool
Revert "Implement connection pool."
2 parents 0997f34 + 20fa6ca commit a66d0fa

File tree

8 files changed

+58
-578
lines changed

8 files changed

+58
-578
lines changed

Documentation/Index.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
- [Read-Only Databases](#read-only-databases)
1212
- [In-Memory Databases](#in-memory-databases)
1313
- [Thread-Safety](#thread-safety)
14-
- [Connection Pools](#connection-pools)
1514
- [Building Type-Safe SQL](#building-type-safe-sql)
1615
- [Expressions](#expressions)
1716
- [Compound Expressions](#compound-expressions)
@@ -252,7 +251,7 @@ Every Connection comes equipped with its own serial queue for statement executio
252251

253252
If you maintain multiple connections for a single database, consider setting a timeout (in seconds) and/or a busy handler:
254253

255-
``` swift
254+
```swift
256255
db.busyTimeout = 5
257256

258257
db.busyHandler({ tries in
@@ -266,33 +265,6 @@ db.busyHandler({ tries in
266265
> _Note:_ The default timeout is 0, so if you see `database is locked` errors, you may be trying to access the same database simultaneously from multiple connections.
267266

268267

269-
### Connection Pools
270-
271-
Connection pools use SQLite WAL mode to allow concurrent reads and writes, which can increase performance. Connection pools are created similar to connections:
272-
273-
``` swift
274-
let pool = try ConnectionPool("path/to/db.sqlite3")
275-
```
276-
277-
Writes are done inside of a readWrite block:
278-
279-
``` swift
280-
pool.readWrite { connection in
281-
try connection.run(users.insert(email <- "[email protected]", name <- "Alice"))
282-
}
283-
```
284-
285-
Reads are done inside of a read block:
286-
287-
``` swift
288-
pool.read { connection in
289-
for user in try connection.prepare(users) {
290-
print("id: \(user[id]), email: \(user[email]), name: \(user[name])")
291-
}
292-
}
293-
```
294-
295-
296268
## Building Type-Safe SQL
297269

298270
SQLite.swift comes with a typed expression layer that directly maps [Swift types](https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/SwiftStandardLibraryReference/) to their [SQLite counterparts](https://www.sqlite.org/datatype3.html).

SQLite.xcodeproj/project.pbxproj

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,6 @@
4646
03A65E941C6BB3030062603F /* ValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE247B331C3F142E00AE3E12 /* ValueTests.swift */; };
4747
03A65E951C6BB3030062603F /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE247B161C3F127200AE3E12 /* TestHelpers.swift */; };
4848
03A65E971C6BB3210062603F /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 03A65E961C6BB3210062603F /* libsqlite3.tbd */; };
49-
AA780B3D1CC201A700E0E95E /* ConnectionPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3B1CC201A700E0E95E /* ConnectionPool.swift */; };
50-
AA780B3E1CC201A700E0E95E /* Dispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3C1CC201A700E0E95E /* Dispatcher.swift */; };
51-
AA780B411CC202C800E0E95E /* ConnectionPoolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3F1CC202B000E0E95E /* ConnectionPoolTests.swift */; };
52-
AA780B421CC202C900E0E95E /* ConnectionPoolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3F1CC202B000E0E95E /* ConnectionPoolTests.swift */; };
53-
AA780B431CC202CA00E0E95E /* ConnectionPoolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3F1CC202B000E0E95E /* ConnectionPoolTests.swift */; };
54-
AA780B441CC202F300E0E95E /* ConnectionPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3B1CC201A700E0E95E /* ConnectionPool.swift */; };
55-
AA780B451CC202F300E0E95E /* Dispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3C1CC201A700E0E95E /* Dispatcher.swift */; };
56-
AA780B461CC202F400E0E95E /* ConnectionPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3B1CC201A700E0E95E /* ConnectionPool.swift */; };
57-
AA780B471CC202F400E0E95E /* Dispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3C1CC201A700E0E95E /* Dispatcher.swift */; };
58-
AA780B481CC202F500E0E95E /* ConnectionPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3B1CC201A700E0E95E /* ConnectionPool.swift */; };
59-
AA780B491CC202F500E0E95E /* Dispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA780B3C1CC201A700E0E95E /* Dispatcher.swift */; };
6049
19A1717B10CC941ACB5533D6 /* FTS5.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1730E4390C775C25677D1 /* FTS5.swift */; };
6150
19A171E6FA242F72A308C594 /* FTS5Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1721B8984686B9963B45D /* FTS5Tests.swift */; };
6251
19A17254FBA7894891F7297B /* FTS5Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1721B8984686B9963B45D /* FTS5Tests.swift */; };
@@ -181,28 +170,25 @@
181170
39548A6D1CA63C740003E3B5 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
182171
39548A6F1CA63C740003E3B5 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
183172
A121AC451CA35C79005A31D1 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
184-
AA780B3B1CC201A700E0E95E /* ConnectionPool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ConnectionPool.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
185-
AA780B3C1CC201A700E0E95E /* Dispatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dispatcher.swift; sourceTree = "<group>"; };
186-
AA780B3F1CC202B000E0E95E /* ConnectionPoolTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionPoolTests.swift; sourceTree = "<group>"; };
187173
EE247AD31C3F04ED00AE3E12 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
188174
EE247AD61C3F04ED00AE3E12 /* SQLite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQLite.h; sourceTree = "<group>"; };
189175
EE247AD81C3F04ED00AE3E12 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
190176
EE247ADD1C3F04ED00AE3E12 /* SQLiteTests iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SQLiteTests iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
191177
EE247AE41C3F04ED00AE3E12 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
192178
EE247AEE1C3F06E900AE3E12 /* Blob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Blob.swift; sourceTree = "<group>"; };
193-
EE247AEF1C3F06E900AE3E12 /* Connection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Connection.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
179+
EE247AEF1C3F06E900AE3E12 /* Connection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Connection.swift; sourceTree = "<group>"; };
194180
EE247AF01C3F06E900AE3E12 /* fts3_tokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fts3_tokenizer.h; sourceTree = "<group>"; };
195181
EE247AF11C3F06E900AE3E12 /* SQLite-Bridging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SQLite-Bridging.m"; sourceTree = "<group>"; };
196-
EE247AF21C3F06E900AE3E12 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Statement.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
182+
EE247AF21C3F06E900AE3E12 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Statement.swift; sourceTree = "<group>"; };
197183
EE247AF31C3F06E900AE3E12 /* Value.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Value.swift; sourceTree = "<group>"; };
198-
EE247AF51C3F06E900AE3E12 /* FTS4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = FTS4.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
184+
EE247AF51C3F06E900AE3E12 /* FTS4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS4.swift; sourceTree = "<group>"; };
199185
EE247AF61C3F06E900AE3E12 /* R*Tree.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "R*Tree.swift"; sourceTree = "<group>"; };
200186
EE247AF71C3F06E900AE3E12 /* Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Foundation.swift; sourceTree = "<group>"; };
201187
EE247AF81C3F06E900AE3E12 /* Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
202188
EE247AFA1C3F06E900AE3E12 /* AggregateFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AggregateFunctions.swift; sourceTree = "<group>"; };
203189
EE247AFB1C3F06E900AE3E12 /* Collation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Collation.swift; sourceTree = "<group>"; };
204190
EE247AFC1C3F06E900AE3E12 /* CoreFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreFunctions.swift; sourceTree = "<group>"; };
205-
EE247AFD1C3F06E900AE3E12 /* CustomFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CustomFunctions.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
191+
EE247AFD1C3F06E900AE3E12 /* CustomFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomFunctions.swift; sourceTree = "<group>"; };
206192
EE247AFE1C3F06E900AE3E12 /* Expression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Expression.swift; sourceTree = "<group>"; };
207193
EE247AFF1C3F06E900AE3E12 /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
208194
EE247B001C3F06E900AE3E12 /* Query.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Query.swift; sourceTree = "<group>"; };
@@ -212,7 +198,7 @@
212198
EE247B181C3F134A00AE3E12 /* SetterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetterTests.swift; sourceTree = "<group>"; };
213199
EE247B1A1C3F137700AE3E12 /* AggregateFunctionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AggregateFunctionsTests.swift; sourceTree = "<group>"; };
214200
EE247B1B1C3F137700AE3E12 /* BlobTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlobTests.swift; sourceTree = "<group>"; };
215-
EE247B1D1C3F137700AE3E12 /* ConnectionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ConnectionTests.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
201+
EE247B1D1C3F137700AE3E12 /* ConnectionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionTests.swift; sourceTree = "<group>"; };
216202
EE247B1E1C3F137700AE3E12 /* CoreFunctionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreFunctionsTests.swift; sourceTree = "<group>"; };
217203
EE247B1F1C3F137700AE3E12 /* CustomFunctionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomFunctionsTests.swift; sourceTree = "<group>"; };
218204
EE247B201C3F137700AE3E12 /* ExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpressionTests.swift; sourceTree = "<group>"; };
@@ -412,7 +398,6 @@
412398
EE247AE11C3F04ED00AE3E12 /* SQLiteTests */ = {
413399
isa = PBXGroup;
414400
children = (
415-
AA780B3F1CC202B000E0E95E /* ConnectionPoolTests.swift */,
416401
EE247B1A1C3F137700AE3E12 /* AggregateFunctionsTests.swift */,
417402
EE247B1B1C3F137700AE3E12 /* BlobTests.swift */,
418403
EE247B1D1C3F137700AE3E12 /* ConnectionTests.swift */,
@@ -437,8 +422,6 @@
437422
EE247AED1C3F06E900AE3E12 /* Core */ = {
438423
isa = PBXGroup;
439424
children = (
440-
AA780B3B1CC201A700E0E95E /* ConnectionPool.swift */,
441-
AA780B3C1CC201A700E0E95E /* Dispatcher.swift */,
442425
EE91808D1C46E5230038162A /* SQLite-Bridging.h */,
443426
EE247AEE1C3F06E900AE3E12 /* Blob.swift */,
444427
EE247AEF1C3F06E900AE3E12 /* Connection.swift */,
@@ -809,11 +792,9 @@
809792
03A65E741C6BB2DA0062603F /* Helpers.swift in Sources */,
810793
03A65E831C6BB2FB0062603F /* Operators.swift in Sources */,
811794
03A65E851C6BB2FB0062603F /* Schema.swift in Sources */,
812-
AA780B471CC202F400E0E95E /* Dispatcher.swift in Sources */,
813795
03A65E841C6BB2FB0062603F /* Query.swift in Sources */,
814796
03A65E7C1C6BB2F70062603F /* FTS4.swift in Sources */,
815797
03A65E771C6BB2E60062603F /* Connection.swift in Sources */,
816-
AA780B461CC202F400E0E95E /* ConnectionPool.swift in Sources */,
817798
03A65E7E1C6BB2FB0062603F /* AggregateFunctions.swift in Sources */,
818799
19A17EC0D68BA8C03288ADF7 /* FTS5.swift in Sources */,
819800
);
@@ -824,7 +805,6 @@
824805
buildActionMask = 2147483647;
825806
files = (
826807
03A65E881C6BB3030062603F /* BlobTests.swift in Sources */,
827-
AA780B431CC202CA00E0E95E /* ConnectionPoolTests.swift in Sources */,
828808
03A65E901C6BB3030062603F /* R*TreeTests.swift in Sources */,
829809
03A65E941C6BB3030062603F /* ValueTests.swift in Sources */,
830810
03A65E8F1C6BB3030062603F /* QueryTests.swift in Sources */,
@@ -847,8 +827,6 @@
847827
isa = PBXSourcesBuildPhase;
848828
buildActionMask = 2147483647;
849829
files = (
850-
AA780B491CC202F500E0E95E /* Dispatcher.swift in Sources */,
851-
AA780B481CC202F500E0E95E /* ConnectionPool.swift in Sources */,
852830
);
853831
runOnlyForDeploymentPostprocessing = 0;
854832
};
@@ -870,11 +848,9 @@
870848
EE247B081C3F06E900AE3E12 /* Value.swift in Sources */,
871849
EE247B121C3F06E900AE3E12 /* Operators.swift in Sources */,
872850
EE247B141C3F06E900AE3E12 /* Schema.swift in Sources */,
873-
AA780B3E1CC201A700E0E95E /* Dispatcher.swift in Sources */,
874851
EE247B131C3F06E900AE3E12 /* Query.swift in Sources */,
875852
EE247B061C3F06E900AE3E12 /* SQLite-Bridging.m in Sources */,
876853
EE247B071C3F06E900AE3E12 /* Statement.swift in Sources */,
877-
AA780B3D1CC201A700E0E95E /* ConnectionPool.swift in Sources */,
878854
EE247B0D1C3F06E900AE3E12 /* AggregateFunctions.swift in Sources */,
879855
19A1717B10CC941ACB5533D6 /* FTS5.swift in Sources */,
880856
);
@@ -885,7 +861,6 @@
885861
buildActionMask = 2147483647;
886862
files = (
887863
EE247B261C3F137700AE3E12 /* CoreFunctionsTests.swift in Sources */,
888-
AA780B411CC202C800E0E95E /* ConnectionPoolTests.swift in Sources */,
889864
EE247B291C3F137700AE3E12 /* FTS4Tests.swift in Sources */,
890865
EE247B191C3F134A00AE3E12 /* SetterTests.swift in Sources */,
891866
EE247B311C3F141E00AE3E12 /* SchemaTests.swift in Sources */,
@@ -922,11 +897,9 @@
922897
EE247B641C3F3FDB00AE3E12 /* Helpers.swift in Sources */,
923898
EE247B721C3F3FEC00AE3E12 /* Operators.swift in Sources */,
924899
EE247B741C3F3FEC00AE3E12 /* Schema.swift in Sources */,
925-
AA780B451CC202F300E0E95E /* Dispatcher.swift in Sources */,
926900
EE247B731C3F3FEC00AE3E12 /* Query.swift in Sources */,
927901
EE247B6B1C3F3FEC00AE3E12 /* FTS4.swift in Sources */,
928902
EE247B661C3F3FEC00AE3E12 /* Connection.swift in Sources */,
929-
AA780B441CC202F300E0E95E /* ConnectionPool.swift in Sources */,
930903
EE247B6D1C3F3FEC00AE3E12 /* AggregateFunctions.swift in Sources */,
931904
19A1750CEE9B05267995CF3D /* FTS5.swift in Sources */,
932905
);
@@ -937,7 +910,6 @@
937910
buildActionMask = 2147483647;
938911
files = (
939912
EE247B561C3F3FC700AE3E12 /* CoreFunctionsTests.swift in Sources */,
940-
AA780B421CC202C900E0E95E /* ConnectionPoolTests.swift in Sources */,
941913
EE247B5A1C3F3FC700AE3E12 /* OperatorsTests.swift in Sources */,
942914
EE247B541C3F3FC700AE3E12 /* BlobTests.swift in Sources */,
943915
EE247B5D1C3F3FC700AE3E12 /* SchemaTests.swift in Sources */,

0 commit comments

Comments
 (0)