ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

Adding sqlite3_serialize and sqlite3_deserialize #530

Closed Trinitek closed 7 months ago

Trinitek commented 1 year ago

I have some code that brings in sqlite3_serialize() and sqlite3_deserialize() and uses raw.GetNativeLibraryName() to do so dynamically, and I think it would be good to bring these into SQLitePCL officially. I have one question before I open a PR however: sqlite3_serialize() has the potential to return a pointer that must be freed using sqlite3_free(). I noticed that the providers implement sqlite3_free() but it is not exposed in raw. Do you have any objections to exposing this?

ericsink commented 1 year ago

No problem with bringing sqlite3_free further up.

If you do end up submitting a PR, I'll give it a look.

tipa commented 1 year ago

I would love to use the sqlite3_serialize() method. My use-case is as follows: My app works on a local SQLite database, which contents can by synced through the Cloud. However, that database is potentially very large and has to be split up before uploading (in my case, I completely strip the table that contains large file BLOBs). The most efficient way I have found to do that is creating a second database file, attaching it to the main database and then transfer all tables over (except the one with the file BLOBs). After that, the file is read into memory and uploaded to the Cloud. I think performance could be further improved if that second, small database is never stored on disk in the first place, but created as in-memory database. Currently, it is not possible for me to retrieve those bytes from an in-memory database - I hope that the sqlite3_serialize() method would be able to do that.

ericsink commented 1 year ago

Interesting use case.

There is a PR for this at #536 but it hasn't had any activity in a while.

Trinitek commented 1 year ago

I finally have some time I can work on this. I'll open a PR either today or tomorrow if #536 isn't moving.