Re: [sqlite] why is the data file locked after after using transaction?
You are right I have mend the fault, ^_^ Thank You a lot! Igor Tandetnik wrote: > > liubin liu wrote: >> why is the data file locked after after using transaction? >> >> the last result of printf() is: >> # IN END, ret = 5 >> >> It means to the database file is locked? >> why does it happen after using transaction although using >> sqlite3_finalize()? > > You call sqlite3_prepare_v2 n+2 times, but sqlite3_finalize only once. > You leak statement handles like there's no tomorrow. > > Igor Tandetnik > > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://www.nabble.com/why-is-the-data-file-locked-after-after-using-transaction--tp24085034p24085861.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] why is the data file locked after after using transaction?
liubin liu wrote: > why is the data file locked after after using transaction? > > the last result of printf() is: > # IN END, ret = 5 > > It means to the database file is locked? > why does it happen after using transaction although using > sqlite3_finalize()? You call sqlite3_prepare_v2 n+2 times, but sqlite3_finalize only once. You leak statement handles like there's no tomorrow. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] why is the data file locked after after using transaction?
why is the data file locked after after using transaction? the last result of printf() is: # IN END, ret = 5 It means to the database file is locked? why does it happen after using transaction although using sqlite3_finalize()? PS: if shielding the codes relating with the transaction, all the result of printf() is correct. ___ // basic9.c #include // for sleep(); #include // for system(); #include // for printf(); #include int main ( void ) { int ret = 0; int i = 0; int n = 10; sqlite3 *db = NULL; sqlite3_stmt *p_stmt = NULL; char *sql_ct = "CREATE TABLE table1 (id INTEGER, m INTEGER, con VARCHAR(512))"; char *sql_in = "INSERT INTO table1 VALUES (%d, %d, %Q)"; char *sql = NULL; ret = sqlite3_open ( "test.db", &db ); printf ( "# AFTER sqlite3_open, ret = %d\n", ret ); ret = sqlite3_exec ( db, sql_ct, NULL, NULL, NULL ); printf ( "# AFTER sqlite3_exec, create table, ret = %d\n", ret ); // system ( "free" ); // 采用事务; ret = sqlite3_prepare_v2 ( db, "BEGIN", -1, &p_stmt, 0 ); ret = sqlite3_step ( p_stmt ); // 创建事务; for ( i=0; ihttp://www.nabble.com/why-is-the-data-file-locked-after-after-using-transaction--tp24085034p24085034.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users