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

Deno 2.0 FFI #39

Closed
ggpwnkthx opened this issue Oct 28, 2024 · 3 comments
Closed

Deno 2.0 FFI #39

ggpwnkthx opened this issue Oct 28, 2024 · 3 comments

Comments

@ggpwnkthx
Copy link

This isn't an issue with the node-neo package, but I'm unsure where else would have a community that is the most knowledgable of this topic since there don't seem to be any active Deno specific DuckDB repos. Probably because the node DuckDB package already works just fine with Deno 2.0. That said, I'm in the process of learning how to use the updated Foriegn Function Interface with DuckDB. I'm getting stuck due to my limited C/C++ understanding.

I have a repo that can successfully open, connect, query, get column names and types, as well as disconnect and close. However, I'm really struggling to understand how to get the data chunks from the duckdb_result pointer - or honestly if I'm even using the pointers vs buffers correctly at all.

I was hoping someone might be willing to look over my shoulder and push me in the right direction. Thank you!

@elefeint
Copy link
Contributor

whenever I have to work with C API, I like to look at how DuckDB's own tests use it, for example this test

But also, DuckDB improved its C API documentation a lot, so this might be a better resource by now -- https://duckdb.org/docs/api/c/query#value-extraction

@ggpwnkthx
Copy link
Author

I feel dumb for not diving deeper into the API docs. I jumped to the reference page and assumed the majority of what I'd need to know would be there. And checking the tests is a great idea, too. Thank you!

@ggpwnkthx
Copy link
Author

@elefeint, thanks again for pointing me in the right direction. I realized I was mistakenly treating buffers as pointers and not defining the structs for those buffers. What confused me was that the duckdb.h often shows pointers as expected parameters or results, but in DuckDB some structs are actually just an internal pointer. This meant that treating those values as a u64 (when they were internal pointer structs) worked fine, but failed for other types of structured buffers, like duckdb_results. This now makes a lot more sense to me.

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

3 participants