On Fri, 2007-08-10 at 11:28 +0200, Jef Driesen wrote: > When using sqlite3_bind_text() (or a similar function) with > SQLITE_STATIC, how long does the pointer have to remain valid? As long > as the sqlite3_stmt is not finalized?
Pretty much. It has to be valid during all subsequent calls to sqlite3_step() on the statement handle. Or until you bind a different value to the same parameter. So the technique below is fine. Dan. > > It is clear to me the following will cause no problem: > > sqlite3_bind_text (stmt, column, "some text", -1, SQLITE_STATIC); > > But what about this: > > void some_func (const char* text) > { > sqlite3_stmt *stmt = 0; > sqlite3_prepare_v2 (db, sql, -1, &stmt, NULL); > sqlite3_bind_text (stmt, column, text, -1, SQLITE_STATIC); > sqlite3_step (stmt); > ... > sqlite3_finalize (stmt); > } > > In this case the pointer remains unchanged as long as the statement is > valid, but it can change afterwards. Is that a problem and should I use > SQLITE_TRANSIENT here? > > > > ----------------------------------------------------------------------------- > To unsubscribe, send email to [EMAIL PROTECTED] > ----------------------------------------------------------------------------- > ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------