tags:

views:

31

answers:

1

I'm using sqlite3_bind_text to bind text parameters to 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?

A: 

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.

xscott