开发者

SQLite string management in transaction mode

开发者 https://www.devze.com 2023-01-16 20:09 出处:网络
I\'m using sqlite3_bind_text to bind text parameters t开发者_开发知识库o my queries, with the SQLITE_STATIC flag, since I know the text pointer remains valid at least up until the query is executed.

I'm using sqlite3_bind_text to bind text parameters t开发者_开发知识库o my queries, with the SQLITE_STATIC flag, since I know the text pointer remains valid at least up until the query is executed.

Recently I've made changes so that the queries are executed in the transaction mode (many such queries in a single transaction). Should the text buffer remain valid up until the transaction is finished?

I mean, my text buffers are valid for the duration of a single query, but no the whole transaction. Should I specify the SQLITE_TRANSIENT flag?


Yes, if you're using SQLITE_STATIC, you should leave the contents alone until after the transaction is finished. Even more so, you should leave the contents alone until you've either rebound the parameter to something else or until you've freed the statement.

SQLITE_TRANSIENT requests that Sqlite make an internal copy of the string which it will manage appropriately. Given your description, this is probably what you should use. Otherwise, you'll have to manage your own copy of each string for each statement.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号