{"action":"created","issue":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/132","repository_url":"https://api.github.com/repos/groue/GRDB.swift","labels_url":"https://api.github.com/repos/groue/GRDB.swift/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/groue/GRDB.swift/issues/132/comments","events_url":"https://api.github.com/repos/groue/GRDB.swift/issues/132/events","html_url":"https://github.com/groue/GRDB.swift/issues/132","id":179551819,"number":132,"title":"Interrupt all connections on a DatabaseQueue or DatabasePool","user":{"login":"palpatim","id":227982,"avatar_url":"https://avatars.githubusercontent.com/u/227982?v=3","gravatar_id":"","url":"https://api.github.com/users/palpatim","html_url":"https://github.com/palpatim","followers_url":"https://api.github.com/users/palpatim/followers","following_url":"https://api.github.com/users/palpatim/following{/other_user}","gists_url":"https://api.github.com/users/palpatim/gists{/gist_id}","starred_url":"https://api.github.com/users/palpatim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palpatim/subscriptions","organizations_url":"https://api.github.com/users/palpatim/orgs","repos_url":"https://api.github.com/users/palpatim/repos","events_url":"https://api.github.com/users/palpatim/events{/privacy}","received_events_url":"https://api.github.com/users/palpatim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-27T16:57:21Z","updated_at":"2016-09-27T17:21:05Z","closed_at":null,"body":"The sqlite interface provides `void sqlite3_interrupt(sqlite3*);`, which cancels in-process queries on a connection. GRDB provides access to the raw database connection via `db.sqliteConnection`, as you describe in the docs.\r\n\r\nHowever, if there is an in-process query that I want to interrupt, I don't see a way of getting access to the handle, and it would probably be dangerous for me to try in any case.\r\n\r\nIs there an API-supported way of interrupting long-running queries?"},"comment":{"url":"https://api.github.com/repos/groue/GRDB.swift/issues/comments/249934560","html_url":"https://github.com/groue/GRDB.swift/issues/132#issuecomment-249934560","issue_url":"https://api.github.com/repos/groue/GRDB.swift/issues/132","id":249934560,"user":{"login":"groue","id":54219,"avatar_url":"https://avatars.githubusercontent.com/u/54219?v=3","gravatar_id":"","url":"https://api.github.com/users/groue","html_url":"https://github.com/groue","followers_url":"https://api.github.com/users/groue/followers","following_url":"https://api.github.com/users/groue/following{/other_user}","gists_url":"https://api.github.com/users/groue/gists{/gist_id}","starred_url":"https://api.github.com/users/groue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/groue/subscriptions","organizations_url":"https://api.github.com/users/groue/orgs","repos_url":"https://api.github.com/users/groue/repos","events_url":"https://api.github.com/users/groue/events{/privacy}","received_events_url":"https://api.github.com/users/groue/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T17:21:05Z","updated_at":"2016-09-27T17:21:05Z","body":"Hello @palpatim!\r\n\r\n> The sqlite interface provides `void sqlite3_interrupt(sqlite3*);`, which cancels in-process queries on a connection.\r\n\r\nI didn't know this function, thanks for talking about it.\r\n\r\n> GRDB provides access to the raw database connection via `db.sqliteConnection`, as you describe in the docs.\r\n\r\nAn area of the doc that should probably be updated: I'm not sure that the SQLite symbols are available right away, without importing extra an extra module: `import SQLiteMacOSX` (`SQLiteiPhoneOS` on iOS, and `SQLiteiPhoneSimulator` on iPhone simulator).\r\n\r\nStill, you're right: assuming this import succeeds, the `sqlite3_interrupt` function will be available.\r\n\r\n> However, if there is an in-process query that I want to interrupt, I don't see a way of getting access to the handle\r\n\r\nIf you use a database queue, it's easy because it uses a single connection:\r\n\r\n```swift\r\ndbQueue.inDatabase { db in\r\n    sqlite3_interrupt(db.sqliteConnection)\r\n}\r\n```\r\n\r\nFor database pools, you're out of luck: there is currently no API that would grant you access to all database handles.\r\n\r\n> and it would probably be dangerous for me to try in any case.\r\n\r\nI don't know sqlite3_interrupt enough to tell.\r\n\r\n> Is there an API-supported way of interrupting long-running queries?\r\n\r\nAs you have guessed, the answer is no.\r\n\r\nThere are several ways to answer your request:\r\n\r\n- one being documenting properly the access to raw SQLite handles, AND provide a new API that gives access to all open database connections. This would help you calling `sqlite3_interrupt`, but this would solve other situations as well.\r\n- another being providing an explicit API\r\n\r\nIn both case, I need more details and context. I'm interested in the general goal you want to achieve.\r\n\r\n*Extra bonus (optional question)*: if you feel comfortable with threads and queues, please tell me more about your scheduling needs. For example, the [releaseMemory](https://github.com/groue/GRDB.swift#memory-management) method blocks the current thread until all database handles have executed the `sqlite3_db_release_memory` functions. **But** it does not prevent concurrent threads from consuming some new memory before it has ended iterating database connections. Would such a model fit your need? Is it too strong? Is it too weak?"}}
{"actor":{"display_login":"groue"}}