On Thu, Sep 02, 2004 at 08:24:21PM -0400, D. Richard Hipp wrote:
>
> If you do separate sqlite3_open() calls for each statement,
> the behavior will be more along the lines of what you expect.
Attached test case still doesn't seem to wait.
$ ./testcase
elapsed seconds 0
rc is 5 error database is locked
testcase: testcase.c:55: main: Assertion `rc == 101' failed.
Aborted
#include <assert.h>
#include <sqlite3.h>
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
int main(void) {
sqlite3 *pDb1, *pDb2;
sqlite3_stmt *pStmt1, *pStmt2;
const char *zLeftover;
int rc, i;
time_t t1, t2;
rc = sqlite3_open("/tmp/testdb", &pDb1);
assert(rc == SQLITE_OK);
rc = sqlite3_open("/tmp/testdb", &pDb2);
assert(rc == SQLITE_OK);
sqlite3_busy_timeout(pDb1, 30000);
rc = sqlite3_prepare(pDb1, "create table foo(bar)", -1, &pStmt1,
&zLeftover);
assert(rc == SQLITE_OK);
rc = sqlite3_step(pStmt1);
assert(rc == SQLITE_DONE);
rc = sqlite3_finalize(pStmt1);
assert(rc == SQLITE_OK);
rc = sqlite3_prepare(pDb1, "insert into foo values(?)", -1, &pStmt1,
&zLeftover);
assert(rc == SQLITE_OK);
for (i=0; i<2; i++) {
rc = sqlite3_bind_int(pStmt1, 1, i);
assert(rc == SQLITE_OK);
rc = sqlite3_step(pStmt1);
assert(rc == SQLITE_DONE);
rc = sqlite3_reset(pStmt1);
assert(rc == SQLITE_OK);
}
rc = sqlite3_prepare(pDb1, "select * from foo", -1, &pStmt1, &zLeftover);
assert(rc == SQLITE_OK);
rc = sqlite3_step(pStmt1);
assert(rc == SQLITE_ROW);
rc = sqlite3_prepare(pDb2, "insert into foo values(1)", -1, &pStmt2,
&zLeftover);
assert(rc == SQLITE_OK);
t1 = time(NULL);
rc = sqlite3_step(pStmt2);
t2 = time(NULL);
printf("elapsed seconds %ld\n", (int) t2 - t1);
printf("rc is %d error %s\n", rc, sqlite3_errmsg(pDb2));
assert(rc == SQLITE_DONE);
rc = sqlite3_finalize(pStmt2);
assert(rc == SQLITE_OK);
return 0;
}