The value obtained from sqlite3_column_blob() is valid only after sqlite3_step() returned SQLITE_ROW and will - at the very latest - go out of scope the moment the queries' idea of "current row" changes, i.e. one of sqlite3_step(), sqlite3_reset() or sqlite3_finalize() is called.
It may also change if certain other sqlite3_column_xxx() functions are called that have the side effect of changing the buffer contents, notably calls the coerce the value into a specified encoding. See also http://www.sqlite.org/c3ref/column_blob.html " The pointers returned are valid until a type conversion occurs as described above, or until sqlite3_step() or sqlite3_reset() or sqlite3_finalize() is called." -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Jens Alfke Gesendet: Mittwoch, 21. Dezember 2016 22:23 An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Betreff: Re: [sqlite] What's the lifespan of a text/blob value returned from a virtual table? > On Dec 21, 2016, at 11:49 AM, Richard Hipp <d...@sqlite.org> wrote: > >> [Can] a column result value from a virtual table can have a lifespan >> that outlives the table’s current iteration, i.e. >> after the next call to reset(). >> > > You mean sqlite3_reset()? No. Oops, not “reset”; I was mixing up the name with one of my internal functions. Sorry! The lifespan I’m talking about is the data of the current table row being processed by the SELECT, which is where the blob column value comes from that my virtual table is parsing. I’d like to be able to hand out internal pointers into that blob via sqlite3_result_text. The use case is similar to this example from the JSON1 documentation: SELECT DISTINCT user.name FROM user, json_each(user.phone) WHERE json_each.value LIKE '704-%'; Here would it be valid for the callback that implements ‘json_each.value’ to return a pointer into the ‘user.phone’ blob? Or does it need to mark it as transient? —Jens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick Software Engineer Scientific Games International GmbH FN 157284 a, HG Wien Klitschgasse 2-4, A-1130 Vienna, Austria Tel: +43 1 80100 0 E-Mail: h...@scigames.at This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users