1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Add extra tests to threadtest4.c. Fix a benign data race accessing the

text encoding using ENC(db).

FossilOrigin-Name: d7bb7ea4ab97ad26f4c84c9b8dc2827010093803
This commit is contained in:
drh
2014-12-12 23:17:54 +00:00
parent 0420954606
commit 9bd3cc4681
7 changed files with 51 additions and 16 deletions

View File

@ -305,20 +305,49 @@ static void *worker_thread(void *pArg){
}else if( sqlite3_column_int(pStmt, 0)!=400 ){
worker_error(p, "Wrong result: %d", sqlite3_column_int(pStmt,0));
}
if( p->nErr ) break;
sqlite3_finalize(pStmt);
if( p->nErr ) break;
if( ((iOuter+p->tid)%3)==0 ){
sqlite3_db_release_memory(p->db);
p->nTest++;
}
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "BEGIN;");
run_sql(p, "UPDATE t1 SET c=NULL WHERE a=55");
run_sql(p, "UPDATE t2 SET f=NULL WHERE d=42");
run_sql(p, "UPDATE t3 SET z=NULL WHERE x=31");
run_sql(p, "ROLLBACK;");
p->nTest++;
pthread_mutex_unlock(p->pWrMutex);
if( iOuter==p->tid ){
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "VACUUM");
pthread_mutex_unlock(p->pWrMutex);
}
pStmt = prep_sql(p->db,
"SELECT t1.rowid, t2.rowid, t3.rowid"
" FROM t1, t2, t3"
" WHERE t1.tid=%d AND t2.tid=%d AND t3.tid=%d"
" AND t1.a<>t2.d AND t2.d<>t3.x"
" ORDER BY 1, 2, 3"
,p->tid, p->tid, p->tid);
worker_trace(p, "query [%s]", sqlite3_sql(pStmt));
for(i=0; i<p->nWorker; i++){
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ){
worker_error(p, "Failed to step: %s", sqlite3_sql(pStmt));
break;
}
sched_yield();
}
sqlite3_finalize(pStmt);
if( p->nErr ) break;
worker_delete_all_content(p, (p->tid+iOuter)%2);
worker_close_connection(p);
p->db = 0;