Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving a BLOB from a SELECT query does not work #5

Open
ekgame opened this issue May 13, 2024 · 1 comment
Open

Retrieving a BLOB from a SELECT query does not work #5

ekgame opened this issue May 13, 2024 · 1 comment

Comments

@ekgame
Copy link
Contributor

ekgame commented May 13, 2024

Yet again, I'm not sure if I'm doing something wrong or a byte array as return value from a function is not supported.

Reproduction:

  1. Find ColumnBlob in lib.ua, remove the assertion, uncomment the "Call" function line.
  2. Create a file with this code:
# Experimental!
Sqlite ~ "lib"
Sqlite~Open "test.db"

$ CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, blob BLOB);
Sqlite~Exec ⊙.

$ INSERT INTO test (blob) VALUES (X'010203');
Sqlite~Exec ⊙.

$ SELECT blob FROM test;
Sqlite~Prepare ⊙.
◌Sqlite~StepRow .
◌?Sqlite~ColumnBlob 1

Sqlite~Close
  1. Run the code. A file named "test.db" will be created. You can inspect the database to confirm that bytes 1, 2, 3 were added.
  2. The code will crash with an FFI error.
@kaikalii
Copy link
Member

kaikalii commented May 24, 2024

I've made it possible to return simple pointers from functions.
In addition, I've added the &memcpy and &memfree system functions for working with pointers in ways that the ffi type:len_index syntax doesn't allow for.
Hopefully this should make a proper API for returning blobs possible.

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

No branches or pull requests

2 participants