Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

[SQLiteStore] Accept SQLITE_MISUSE for sqlite3_config(SQLITE_CONFIG_URI, 1) #577

Merged
merged 1 commit into from
Feb 3, 2023

Conversation

DmitriyKirakosyan
Copy link
Contributor

This PR fixes a crash when using the library along with another library which consumes SQLitePCL.raw.
The library should not throw exception if raw.sqlite3_config(raw.SQLITE_CONFIG_URI, 1) returns SQLITE_MISUSE as it would mean that the config was already set.
See microsoft/appcenter-sdk-dotnet#1725 (comment) for details.

https://github.com/Azure/azure-mobile-apps/issues/573
microsoft/appcenter-sdk-dotnet#1725


NOTE: I haven't tested the changes.

@adrianhall
Copy link
Member

Thanks for this. It passes all tests, but I'll take a look at this PR on Friday.

@adrianhall adrianhall merged commit a7ef64c into Azure:main Feb 3, 2023
@amertlich
Copy link

This fixes the exception thrown after SqlitePCL.raw.sqlite3_config but I still get an exception thrown after the subsequent open call here: https://github.com/Azure/azure-mobile-apps/blob/main/sdk/dotnet/src/Microsoft.Datasync.Client.SQLiteStore/Driver/SqliteConnection.cs#L59

I still have to use the workaround described here even with 5.0.21
microsoft/appcenter-sdk-dotnet#1725 (comment)

@adrianhall
Copy link
Member

Please open a new issue with the actual error you are receiving. We accept SQLITE_MISUSE now, so it's something else going wrong. Without an appropriate error, we can't fix it.

@amertlich
Copy link

I'll have to clone and reference the source repo since the return code is not bubbled up and I just get the general exception. I'll try to get to it soon.

@DmitriyKirakosyan DmitriyKirakosyan deleted the fix/sqlite-config-crash branch February 13, 2023 10:35
@amertlich
Copy link

So I've been dealing with this workaround and decided to remove it and found it's still not working.

The error code it's responding with is (14) SQLITE_CANTOPEN

  at Microsoft.Datasync.Client.SQLiteStore.Driver.SqliteConnection..ctor (System.String connectionString)
  at Microsoft.Datasync.Client.SQLiteStore.OfflineSQLiteStore..ctor (System.String connectionString)
  at Microsoft.Datasync.Client.SQLiteStore.OfflineSQLiteStore..ctor (System.String connectionString, Microsoft.Extensions.Logging.ILogger logger)

Should I open a new bug for this?

I'm leaving the workaround in place for now -- which is to just let the mobile apps SDK initialize SQLite first, before app center does.

@kj4bix
Copy link

kj4bix commented Oct 25, 2023

Using 6.0.4 I still get the (14) exception if I already have another SQLite instance/connection open.

If I only use the datasync.client (SQLite) there is no issue. Opening a SQLite database before letting datasync.client open it's database gets the 14 exception above. Even though it works fine without the other database. 6.0.4 has the check for MISUSE which allows it to get further.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants