Commit 037c7378

037c73788699Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

Merge pull request #686 from rubys/sqlite-readme-stale-note

docs(examples/ffi/sqlite): retire stale "MVP FFI can't construct :ptr from sentinel" note

Details

Commit
037c73788699
Parent
7e88b7b64305
Merge parent
ac73cd4fbf7f

examples/ffi/sqlite/README.mdmodifiedView file

@@ -65,9 +65,10 @@
6565
6666 ## Notes
6767
68-The demo uses inline-quoted SQL with `Sql.q` for escaping, not bound
69-parameters. The reason: `sqlite3_bind_text`'s last argument is a
70-destructor callback (the `SQLITE_TRANSIENT` sentinel is `(void *)-1`),
71-and the MVP FFI can't yet construct a `:ptr` from a sentinel integer.
72-For real applications you'd write a tiny C helper that wraps `bind_text`
73-with `SQLITE_TRANSIENT` baked in and link it alongside.
68+The demo uses inline-quoted SQL with `Sql.q` for escaping, kept as the
69+minimal path through `prepare_v2` / `step` / `finalize`. For bound
70+parameters, `sqlite3_bind_text` is supported directly — pass `-1` as
71+the destructor argument to get `SQLITE_TRANSIENT` (`(void *)-1`); the
72+FFI accepts an integer literal in a `:ptr` arg slot and emits
73+`((void *)-1LL)`. See `sqlite3_lib.rb` for the `ffi_func` declaration
74+and `test/ffi_ptr_int_literal.rb` for the regression test.