Comments (12)
I had the same issue, so had to turn statement caching off
from fmdb.
Besides turning off statement caching, are there any proposed fixes? I'm not sure that there is real solution to this. Nested result sets list this just aren't going to work without removing the benefits of cached statements. At least, that's the conclusion I've come to with a tiny bit of thought involved. I'm fine with being proven wrong :)
from fmdb.
I'm probably missing something important but had a couple ideas:
A simple fix is to allow passing a custom key to use for the cached statement. If each level of nesting uses a unique key things should work as expected.
It may also be possible to handle this automatically:
- FMStatement has a weak reference to the object using it.
- The owning object (FMResultSet) zeros the reference on dealloc, happens automatically in some environments.
- cachedStatements has an NSArray for each query. When fetching a statement it finds the first that has a nil owner. If there isn't one a new statement is created for the same query and added to the pool. (Since this is an edge case a class test could be used to only switch to an array when needed).
The danger here is if a lot of FMResultSets are created in a loop and not released until the loop ends you'll get a bunch of cached statements you don't need. But if you run this loop multiple times it will be fast :-)
from fmdb.
Yea, it could probably have some sort of flag that says "I'm in use right now".
Since there's a reasonable workaround for now, it won't be a high priority for me. But if you do end up writing a patch, let me know.
from fmdb.
My feeling is that FMDB should have a mechanism for exposing the FMStatement to the app, which the app can reuse as desired. Then there is no need to have "statement caching" at all.
Something like this:
- (FMStatement_) statementForSql: (NSString_) sql;
- (FMResultSet_) executeStatement: (FMStatement_) statement, ...;
from fmdb.
Suggestion: Mention the issues with the caching in the tutorial. We just spent 6 hours debugging and then found out it was FMDBs caching that caused problems...
from fmdb.
Is this still an issue?
from fmdb.
Yes, it's still an issue.
from fmdb.
This issue was reported 2.5 years ago.
We started using FMDB in a highly multithreaded, database driven, iOS application 1.5 years ago.
And we just spent about 2 days debugging our code, until someone thought it might be related to statement caching, disabled it, and found this issue here.
Is there a chance of it being fixed like @TomSwift suggests, or at least mentioning the issue in the tutorial as suggested by @ChristianKienle?
If we contribute the code, will it be added to master?
from fmdb.
If the code is reasonable, has tests, and doesn't break existing installs, then yes I would be happy to add it to the master branch.
from fmdb.
Curious - did issue #191 fix this?
from fmdb.
Yep, looks like it. I'll close this bug.
from fmdb.
Related Issues (20)
- Can the current version be used stably? HOT 3
- closing FMDB database HOT 11
- Support for visionOS HOT 6
- Apple Privacy Manifest HOT 9
- FMDB 2.7.8 is not published on cocoapods HOT 3
- I encountered an issue where using UPDATE fails to update, but using INSERT OR REPLACE doesn't. HOT 1
- 无法通过git clone下载到本地 HOT 2
- PrivacyInfo.xcprivacy file did not be exposed HOT 6
- FMDB 2.7.8 is not available on cocoapods HOT 2
- xcodebuild: xcodebuild: error: Found no destinations for the scheme 'FMDB' and action clean
- get CocoaPods back on the rails HOT 24
- backfill CocoaPods versions HOT 1
- XCFrameworks are not codesigned HOT 7
- UT Coverage HOT 2
- FMDB.podspec of tag 2.7.10 declares wrong version HOT 2
- The subspec 'SQLCipher' required privacy file location declaration HOT 1
- Can you publish new release 2.7.11 HOT 6
- re-enable standalone CocoaPods subspecs HOT 2
- FMDB w/SQLCipher and an App Clip HOT 6
- How to insert multiple rows in a single SQL? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fmdb.