c - CREATE and DROP a table while another statement is in place -
in previous implementation, streaming results sqlite3 table directly output application. however, since changing interface temporary data structure, need number of rows. preferred way seems temporary table, original
sprintf(query,"select %s x, avg(%s) y, avg((%s)*(%s)) ysq %s %s=%s , %s group x;",x,y,y,y,from,across,val,where); sqlite3_prepare_v2(db, query, -1, &acresult,null); while(sqlite3_step(acresult)==sqlite_row) { ... } sqlite3_finalize(acresult);
turns into
sprintf(query,"create temp table tt select %s x, avg(%s) y, avg((%s)*(%s)) ysq %s %s=%s , %s group x;",x,y,y,y,from,across,val,where); sqlite3_prepare_v2(db, query, -1, &acresult,null); sqlite3_step(acresult); sqlite3_finalize(acresult); sqlite3_prepare_v2(db, "select count(*) tt;", -1, &acresult, null); sqlite3_step(acresult); int length = sqlite3_column_int(acresult,0); sqlite3_finalize(acresult); sqlite3_prepare_v2(db, "select x,y, ysq tt;", -1, &acresult, null); while(sqlite3_step(acresult)==sqlite_row) { ... } sqlite3_finalize(acresult); sqlite3_prepare_v2(db, "drop table tt;", -1, &acresult, null); sqlite3_step(acresult); sqlite3_finalize(acresult);
now, works. problem have inside loop across stepping query, seems responsible table being locked when try drop it. if finalize query, "works" (the drop works; else breaks because it's part of logic). there no possible way outer query referencing tt
, because created within "scope".
is there way of reminding sqlite shouldn't locked, or stuck switching outer loop away streaming well?
this read-only application (with exception of temp table), if helps.
Comments
Post a Comment