Index: mptest/crash02.subtest ================================================================== --- mptest/crash02.subtest +++ mptest/crash02.subtest @@ -2,11 +2,11 @@ ** This script is called from crash01.test and config02.test and perhaps other ** script. After the database file has been set up, make a big rollback ** journal in client 1, then crash client 1. ** Then in the other clients, do an integrity check. */ ---task 1 +--task 1 leave-hot-journal --sleep 5 --finish PRAGMA cache_size=10; BEGIN; UPDATE t1 SET b=randomblob(20000); @@ -20,38 +20,34 @@ UPDATE t4 SET b=NULL; UPDATE t5 SET b=NULL; --print Task one crashing an incomplete transaction --exit 1 --end ---task 2 - SELECT count(*) FROM t1; - --match 64 - --sleep 100 - PRAGMA integrity_check(10); - --output - --match ok ---end ---task 3 - SELECT count(*) FROM t1; - --match 64 - --sleep 100 - PRAGMA integrity_check(10); - --output - --match ok ---end ---task 4 - SELECT count(*) FROM t1; - --match 64 - --sleep 100 - PRAGMA integrity_check(10); - --output - --match ok ---end ---task 5 - SELECT count(*) FROM t1; - --match 64 - --sleep 100 - PRAGMA integrity_check(10); - --output +--task 2 integrity_check-2 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check(10); + --match ok +--end +--task 3 integrity_check-3 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check(10); + --match ok +--end +--task 4 integrity_check-4 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check(10); + --match ok +--end +--task 5 integrity_check-5 + SELECT count(*) FROM t1; + --match 64 + --sleep 100 + PRAGMA integrity_check(10); --match ok --end --wait all Index: mptest/mptest.c ================================================================== --- mptest/mptest.c +++ mptest/mptest.c @@ -518,11 +518,12 @@ ** task as being under way. */ static int startScript( int iClient, /* The client number */ char **pzScript, /* Write task script here */ - int *pTaskId /* Write task number here */ + int *pTaskId, /* Write task number here */ + char **pzTaskName /* Name of the task */ ){ sqlite3_stmt *pStmt = 0; int taskId; int rc; int totalTime = 0; @@ -553,19 +554,20 @@ g.iTimeout = DEFAULT_TIMEOUT; runSql("COMMIT TRANSACTION;"); return SQLITE_DONE; } pStmt = prepareSql( - "SELECT script, id FROM task" + "SELECT script, id, name FROM task" " WHERE client=%d AND starttime IS NULL" " ORDER BY id LIMIT 1", iClient); rc = sqlite3_step(pStmt); if( rc==SQLITE_ROW ){ int n = sqlite3_column_bytes(pStmt, 0); *pzScript = sqlite3_malloc(n+1); strcpy(*pzScript, (const char*)sqlite3_column_text(pStmt, 0)); *pTaskId = taskId = sqlite3_column_int(pStmt, 1); + *pzTaskName = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 2)); sqlite3_finalize(pStmt); runSql("UPDATE task" " SET starttime=strftime('%%Y-%%m-%%d %%H:%%M:%%f','now')" " WHERE id=%d;", taskId); g.iTimeout = DEFAULT_TIMEOUT; @@ -801,10 +803,18 @@ }else{ errorMessage("%stimeout waiting for all clients", zErrPrefix); } } } + +/* Return a pointer to the tail of a filename +*/ +static char *filenameTail(char *z){ + int i, j; + for(i=j=0; z[i]; i++) if( z[i]=='/' ) j = i+1; + return z+j; +} /* Maximum number of arguments to a --command */ #define MX_ARG 2 /* @@ -1037,20 +1047,27 @@ */ if( strcmp(zCmd, "task")==0 && iClient==0 ){ int iTarget = atoi(azArg[0]); int iEnd; char *zTask; + char *zTName; iEnd = findEnd(zScript+ii+len, &lineno); if( iTarget<0 ){ errorMessage("line %d of %s: bad client number: %d", prevLine, zFilename, iTarget); }else{ zTask = sqlite3_mprintf("%.*s", iEnd, zScript+ii+len); + if( nArg>1 ){ + zTName = sqlite3_mprintf("%s", azArg[1]); + }else{ + zTName = sqlite3_mprintf("%s:%d", filenameTail(zFilename), prevLine); + } startClient(iTarget); - runSql("INSERT INTO task(client,script)" - " VALUES(%d,'%q')", iTarget, zTask); + runSql("INSERT INTO task(client,script,name)" + " VALUES(%d,'%q',%Q)", iTarget, zTask, zTName); sqlite3_free(zTask); + sqlite3_free(zTName); } iEnd += tokenLength(zScript+ii+len+iEnd, &lineno); len += iEnd; iBegin = ii+len; }else @@ -1215,19 +1232,18 @@ if( !g.bSync ) trySql("PRAGMA synchronous=OFF"); if( iClient>0 ){ if( n>0 ) unrecognizedArguments(argv[0], n, argv+2); if( g.iTrace ) logMessage("start-client"); while(1){ - char zTaskName[50]; - rc = startScript(iClient, &zScript, &taskId); + char *zTaskName = 0; + rc = startScript(iClient, &zScript, &taskId, &zTaskName); if( rc==SQLITE_DONE ) break; - sqlite3_snprintf(sizeof(zTaskName), zTaskName, "client%02d-task-%d", - iClient, taskId); - if( g.iTrace ) logMessage("begin %s", zTaskName); + if( g.iTrace ) logMessage("begin %s (%d)", zTaskName, taskId); runScript(iClient, taskId, zScript, zTaskName); - if( g.iTrace ) logMessage("end %s", zTaskName); + if( g.iTrace ) logMessage("end %s (%d)", zTaskName, taskId); finishScript(iClient, taskId, 0); + sqlite3_free(zTaskName); sqlite3_sleep(10); } if( g.iTrace ) logMessage("end-client"); }else{ sqlite3_stmt *pStmt; @@ -1237,10 +1253,11 @@ } if( n>1 ) unrecognizedArguments(argv[0], n, argv+2); runSql( "CREATE TABLE task(\n" " id INTEGER PRIMARY KEY,\n" + " name TEXT,\n" " client INTEGER,\n" " starttime DATE,\n" " endtime DATE,\n" " script TEXT\n" ");" Index: mptest/multiwrite01.test ================================================================== --- mptest/multiwrite01.test +++ mptest/multiwrite01.test @@ -1,10 +1,10 @@ /* ** This script sets up five different tasks all writing and updating ** the database at the same time, but each in its own table. */ ---task 1 +--task 1 build-t1 DROP TABLE IF EXISTS t1; CREATE TABLE t1(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t1 VALUES(1, randomblob(2000)); INSERT INTO t1 VALUES(2, randomblob(1000)); @@ -32,11 +32,11 @@ SELECT a FROM t1 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end ---task 2 +--task 2 build-t2 DROP TABLE IF EXISTS t2; CREATE TABLE t2(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t2 VALUES(1, randomblob(2000)); INSERT INTO t2 VALUES(2, randomblob(1000)); @@ -63,11 +63,11 @@ --match 17 SELECT a FROM t2 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end ---task 3 +--task 3 build-t3 DROP TABLE IF EXISTS t3; CREATE TABLE t3(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t3 VALUES(1, randomblob(2000)); INSERT INTO t3 VALUES(2, randomblob(1000)); @@ -94,11 +94,11 @@ --match 17 SELECT a FROM t3 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end ---task 4 +--task 4 build-t4 DROP TABLE IF EXISTS t4; CREATE TABLE t4(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t4 VALUES(1, randomblob(2000)); INSERT INTO t4 VALUES(2, randomblob(1000)); @@ -125,11 +125,11 @@ --match 17 SELECT a FROM t4 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; --match 29 28 27 26 25 --end ---task 5 +--task 5 build-t5 DROP TABLE IF EXISTS t5; CREATE TABLE t5(a INTEGER PRIMARY KEY, b); --sleep 1 INSERT INTO t5 VALUES(1, randomblob(2000)); INSERT INTO t5 VALUES(2, randomblob(1000));