{"action":"created","issue":{"url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/106","repository_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw","labels_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/106/comments","events_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/106/events","html_url":"https://github.com/ericsink/SQLitePCL.raw/issues/106","id":181749002,"number":106,"title":"Unable to use the new \"SQLitePCL.raw.sqlite3_config()\" to set threading mode","user":{"login":"ggirard07","id":2625886,"avatar_url":"https://avatars.githubusercontent.com/u/2625886?v=3","gravatar_id":"","url":"https://api.github.com/users/ggirard07","html_url":"https://github.com/ggirard07","followers_url":"https://api.github.com/users/ggirard07/followers","following_url":"https://api.github.com/users/ggirard07/following{/other_user}","gists_url":"https://api.github.com/users/ggirard07/gists{/gist_id}","starred_url":"https://api.github.com/users/ggirard07/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggirard07/subscriptions","organizations_url":"https://api.github.com/users/ggirard07/orgs","repos_url":"https://api.github.com/users/ggirard07/repos","events_url":"https://api.github.com/users/ggirard07/events{/privacy}","received_events_url":"https://api.github.com/users/ggirard07/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-07T19:25:47Z","updated_at":"2016-10-10T17:17:26Z","closed_at":null,"body":"**Steps to reproduce**\r\n\r\n1. Create a new solution with a PCL project (in my case profile 259).\r\n2. Add a platform specific project with a dependency to the PCL (in my case Android).\r\n3. Add necessary packages to those projects to use the bundle green edition.\r\n4. From the PCL code, configure SQLite in serialized mode:\r\n\r\n```\r\nSQLitePCL.Batteries.Init();\r\nvar result = SQLitePCL.raw.sqlite3_config(SQLitePCL.raw.SQLITE_CONFIG_SERIALIZED);\r\nif (result != SQLitePCL.raw.SQLITE_OK)\r\n{\r\n    System.Diagnostics.Debug.WriteLine($\"Unable to set SQLIte in Serialized mode (error code = {result})\");\r\n}\r\n```\r\n\r\n**Expected result**\r\nAs I am understanding that bundles and providers are used to inject platform specific bits from the PCL by using bait/switch, this should be considered a possible case.\r\n\r\n**Actual result**\r\nConfig call is failing and returning a SQLITE_MISUSE error.\r\n\r\n**Remarks**\r\nSQLite serialized mode cannot be set after `SQLitePCL.Batteries.Init()` or `SQLitePCL.raw.SetProvider()` as this last call try to open then close the DB which internally init the SQLite library. Once SQLite has been initialized, this is no longer permitted to use config to set the threading mode and result in a misuse error.\r\nEven by doing so at the platform level, `SQLitePCL.raw.sqlite3_config()` still requires to call Init or SetProvider first, which prevent usage.\r\n\r\nI am not sufficiently experienced with SQLite and your libraries to determine if there is an other way to validate the lib injection other than by opening/closing it..."},"comment":{"url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/comments/252683284","html_url":"https://github.com/ericsink/SQLitePCL.raw/issues/106#issuecomment-252683284","issue_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/106","id":252683284,"user":{"login":"bordoley","id":2886153,"avatar_url":"https://avatars.githubusercontent.com/u/2886153?v=3","gravatar_id":"","url":"https://api.github.com/users/bordoley","html_url":"https://github.com/bordoley","followers_url":"https://api.github.com/users/bordoley/followers","following_url":"https://api.github.com/users/bordoley/following{/other_user}","gists_url":"https://api.github.com/users/bordoley/gists{/gist_id}","starred_url":"https://api.github.com/users/bordoley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bordoley/subscriptions","organizations_url":"https://api.github.com/users/bordoley/orgs","repos_url":"https://api.github.com/users/bordoley/repos","events_url":"https://api.github.com/users/bordoley/events{/privacy}","received_events_url":"https://api.github.com/users/bordoley/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T17:17:26Z","updated_at":"2016-10-10T17:17:26Z","body":"Unrelated to whether this should work, I'm curious why you are electing to use SQLite's serialized thread mode, as opposed to doing explicit locking in your application, or using a higher level library that guarantees thread safety?\r\n\r\nA given SQLite connection isn't really meant to be used from multiple threads at the same time, hence the thread safe mode adds locks to all api calls. In this mode you need to be careful not to make SQLite calls from the mainloop of your application (assuming this is a mobile app), to avoid blocking the UI. To avoid this issue, Akavache, SQLite-net, and SQLitePCL.pretty all use variants of an internal scheduler to queue and schedule work for a given SQLite DB connection, dispatched to a task pool thread."}}
{"actor":{"display_login":"bordoley"}}