Index: test/threadtest3.c ================================================================== --- test/threadtest3.c +++ test/threadtest3.c @@ -119,11 +119,14 @@ struct MD5Context { int isInit; uint32 buf[4]; uint32 bits[2]; - unsigned char in[64]; + union { + unsigned char in[64]; + uint32 in32[16]; + } u; }; typedef struct MD5Context MD5Context; /* * Note: this code is harmless on little-endian machines. @@ -268,37 +271,37 @@ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if ( t ) { - unsigned char *p = (unsigned char *)ctx->in + t; + unsigned char *p = (unsigned char *)ctx->u.in + t; t = 64-t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *)ctx->in); + byteReverse(ctx->u.in, 16); + MD5Transform(ctx->buf, (uint32 *)ctx->u.in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *)ctx->in); + memcpy(ctx->u.in, buf, 64); + byteReverse(ctx->u.in, 16); + MD5Transform(ctx->buf, (uint32 *)ctx->u.in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + memcpy(ctx->u.in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) @@ -310,36 +313,36 @@ /* Compute number of bytes mod 64 */ count = (ctx->bits[0] >> 3) & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ - p = ctx->in + count; + p = ctx->u.in + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *)ctx->in); + byteReverse(ctx->u.in, 16); + MD5Transform(ctx->buf, (uint32 *)ctx->u.in); /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); + memset(ctx->u.in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count-8); } - byteReverse(ctx->in, 14); + byteReverse(ctx->u.in, 14); /* Append length in bits and transform */ - ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0]; - ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1]; + ctx->u.in32[14] = ctx->bits[0]; + ctx->u.in32[15] = ctx->bits[1]; - MD5Transform(ctx->buf, (uint32 *)ctx->in); + MD5Transform(ctx->buf, (uint32 *)ctx->u.in); byteReverse((unsigned char *)ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); /* In case it is sensitive */ } @@ -1443,11 +1446,11 @@ { create_drop_index_1, "create_drop_index_1", 10000 }, { lookaside1, "lookaside1", 10000 }, { vacuum1, "vacuum1", 10000 }, { stress1, "stress1", 10000 }, - { stress2, "stress2", 10000 }, + { stress2, "stress2", 60000 }, }; int i; int bTestfound = 0; Index: test/tt3_stress.c ================================================================== --- test/tt3_stress.c +++ test/tt3_stress.c @@ -122,11 +122,10 @@ } execsql(&err, &db, "DELETE FROM t1 WHERE (rowid % 4)==:i", &i); i1++; if( err.rc ) i2++; clear_error(&err, SQLITE_LOCKED); - clear_error(&err, SQLITE_ERROR); } closedb(&err, &db); print_and_free_err(&err); return sqlite3_mprintf("deleted from t1 %d/%d attempts", i2, i1); } @@ -182,77 +181,70 @@ ** 14. Integrity-check. ** 17. Switch the journal mode from delete to wal and back again. ** 19. Open and close database connections rapidly. */ -#define STRESS2_TABCNT 5 +#define STRESS2_TABCNT 5 /* count1 in SDS test */ + +#define STRESS2_COUNT2 200 /* count2 in SDS test */ +#define STRESS2_COUNT3 57 /* count2 in SDS test */ static void stress2_workload1(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); + int iTab = (i % (STRESS2_TABCNT-1)) + 1; sql_script_printf(pErr, pDb, "CREATE TABLE IF NOT EXISTS t%d(x PRIMARY KEY, y, z);", iTab ); } static void stress2_workload2(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); + int iTab = (i % (STRESS2_TABCNT-1)) + 1; sql_script_printf(pErr, pDb, "DROP TABLE IF EXISTS t%d;", iTab); } static void stress2_workload3(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); - sql_script_printf(pErr, pDb, "SELECT * FROM t%d WHERE z = 'small'", iTab); + sql_script(pErr, pDb, "SELECT * FROM t0 WHERE z = 'small'"); } static void stress2_workload4(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); - sql_script_printf(pErr, pDb, "SELECT * FROM t%d WHERE z = 'big'", iTab); + sql_script(pErr, pDb, "SELECT * FROM t0 WHERE z = 'big'"); } static void stress2_workload5(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); - sql_script_printf(pErr, pDb, - "INSERT INTO t%d VALUES(random(), hex(randomblob(57)), 'small');", iTab + sql_script(pErr, pDb, + "INSERT INTO t0 VALUES(hex(random()), hex(randomblob(200)), 'small');" ); } static void stress2_workload6(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); - sql_script_printf(pErr, pDb, - "INSERT INTO t%d VALUES(random(), hex(randomblob(2000)), 'big');", iTab + sql_script(pErr, pDb, + "INSERT INTO t0 VALUES(hex(random()), hex(randomblob(57)), 'big');" ); } static void stress2_workload7(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); sql_script_printf(pErr, pDb, - "UPDATE t%d SET y = hex(randomblob(57)) " - "WHERE (x %% 5)==(%d %% 5) AND z='small';" - ,iTab, i + "UPDATE t0 SET y = hex(randomblob(200)) " + "WHERE x LIKE hex((%d %% 5)) AND z='small';" + ,i ); } static void stress2_workload8(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); sql_script_printf(pErr, pDb, - "UPDATE t%d SET y = hex(randomblob(2000)) " - "WHERE (x %% 5)==(%d %% 5) AND z='big';" - ,iTab, i + "UPDATE t0 SET y = hex(randomblob(57)) " + "WHERE x LIKE hex(%d %% 5) AND z='big';" + ,i ); } static void stress2_workload9(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); sql_script_printf(pErr, pDb, - "DELETE FROM t%d WHERE (x %% 5)==(%d %% 5) AND z='small';" - ,iTab, i + "DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='small';", i ); } static void stress2_workload10(Error *pErr, Sqlite *pDb, int i){ - int iTab = (i % STRESS2_TABCNT); sql_script_printf(pErr, pDb, - "DELETE FROM t%d WHERE (x %% 5)==(%d %% 5) AND z='big';" - ,iTab, i + "DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='big';", i ); } static void stress2_workload11(Error *pErr, Sqlite *pDb, int i){ sql_script(pErr, pDb, "VACUUM"); @@ -294,17 +286,20 @@ Error err = {0}; /* Error code and message */ Sqlite db = {0}; /* SQLite database connection */ int i1 = 0; int i2 = 0; - opendb(&err, &db, pCtx->zDb, 0); while( !timetostop(&err) ){ - pCtx->xProc(&err, &db, i1); - i2 += (err.rc==SQLITE_OK); - clear_error(&err, SQLITE_LOCKED); - clear_error(&err, SQLITE_ERROR); - i1++; + int cnt; + opendb(&err, &db, pCtx->zDb, 0); + for(cnt=0; err.rc==SQLITE_OK && cntxProc(&err, &db, i1); + i2 += (err.rc==SQLITE_OK); + clear_error(&err, SQLITE_LOCKED); + i1++; + } + closedb(&err, &db); } print_and_free_err(&err); return sqlite3_mprintf("ok %d/%d", i2, i1); } @@ -337,45 +332,37 @@ { stress2_workload10 }, { stress2_workload11 }, { stress2_workload14 }, { stress2_workload17 }, }; - const char *azDb[] = { - "test.db", - "file::memory:?cache=shared" - }; - int j; - - for(j=0; j