diff --git a/manifest b/manifest index d429981aa2..a41b294dc1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s2.7.3\s(CVS\s775) -D 2002-10-31T00:15:10 +C Improvements\sin\sthreadtest.c\s(for\sUnix)\sand\ssome\sminor\sbug\sfixes\sthat\sresult\nfrom\sthe\sbetter\stesting.\s(CVS\s776) +D 2002-11-01T01:55:37 F Makefile.in d6c9a85c2a5e696843201d090dcf8bf2f8716f2a F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -28,7 +28,7 @@ F src/func.c e45cd908b9b723d9b91473d09e12c23f786b3fc2 F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8 F src/insert.c 764300a0bd8074a2174946c0bf8a550bd833397a -F src/main.c ff7c05ef88fa1374e5540ce20173ae8e1836f8a4 +F src/main.c b95d7eeec90f86d05b6a064d07db34b7279e06d4 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565 F src/os.c ede7346dffdbab40c6de20d2f325981f3f1168fd F src/os.h 3009379b06941e7796a9812d1b6cbc59b26248c8 @@ -47,12 +47,12 @@ F src/tclsqlite.c fa646506f02509455c1e4a878d1303bd2d4c3ead F src/test1.c a46e9f61915b32787c5d5a05a4b92e4dacc437d9 F src/test2.c 5fa694d130b3309e3f9c852f0a437750fcb5a006 F src/test3.c 540fa7fc3cb3732517b779b5f90ad9cc4303d0ab -F src/threadtest.c 72bce0a284647314847bbea44616ceb056bfb77f +F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e F src/tokenize.c 75e3bb37305b64e118e709752066f494c4f93c30 F src/trigger.c 5ba917fc226b96065108da28186c2efaec53e481 F src/update.c 881e4c8e7c786545da4fd2d95da19252b2e31137 F src/util.c ca7650ef2cc2d50241e48029fca109a3016144ee -F src/vdbe.c 921f75ea3fbf2df4480c1ec9f8522843d5839997 +F src/vdbe.c a187467bc4e9ef7793969b5010d7297341b19394 F src/vdbe.h b7584044223104ba7896a7f87b66daebdd6022ba F src/where.c 615a0f0bed305bcb27073c69347ea75018e8b58d F test/all.test efd958d048c70a3247997c482f0b33561f7759f0 @@ -149,7 +149,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 8ad018944c3aa8f58e1c68b1fa634ef922d6476f -R f8477ebc66610cd7938692d7ec68ce06 +P 4051dbdb0552620eaff2ccef02f64a2ff97a8dfb +R c21e2859a962756f67fcca7d8aada8c6 U drh -Z e70ab099db1c57aeafd8f952a2b6f584 +Z fd6af700160d9f9561f1698c6ec1c692 diff --git a/manifest.uuid b/manifest.uuid index 55eb74f1f5..f618cb814a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4051dbdb0552620eaff2ccef02f64a2ff97a8dfb \ No newline at end of file +326e0983c34b584a3c4a2300399bff0a8281b9f8 \ No newline at end of file diff --git a/src/main.c b/src/main.c index c4df2e1238..03bd734067 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.102 2002/09/05 23:21:37 drh Exp $ +** $Id: main.c,v 1.103 2002/11/01 01:55:37 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -613,6 +613,10 @@ int sqlite_exec( sqliteSafetyOff(db); return rc; } + if( pzErrMsg ){ + sqliteFree(*pzErrMsg); + *pzErrMsg = 0; + } } if( db->file_format<3 ){ sqliteSafetyOff(db); diff --git a/src/threadtest.c b/src/threadtest.c index b85f7d6abc..89c79a4c7c 100644 --- a/src/threadtest.c +++ b/src/threadtest.c @@ -20,11 +20,17 @@ */ #include "sqlite.h" #include +#include #include #include #include #include +/* +** Enable for tracing +*/ +static int verbose = 0; + /* ** Come here to die. */ @@ -35,6 +41,16 @@ static void Exit(int rc){ extern char *sqlite_mprintf(const char *zFormat, ...); extern char *sqlite_vmprintf(const char *zFormat, va_list); +/* +** When a lock occurs, yield. +*/ +static int db_is_locked(void *NotUsed, const char *zNotUsed, int iNotUsed){ + /* sched_yield(); */ + if( verbose ) printf("BUSY %s\n", (char*)NotUsed); + usleep(100); + return 1; +} + /* ** Used to accumulate query results by db_query() */ @@ -64,7 +80,7 @@ static int db_query_callback( } pResult->azElem = realloc( pResult->azElem, pResult->nAlloc*sizeof(char*)); if( pResult->azElem==0 ){ - fprintf(stderr,"%s: malloc failed\n", pResult->zFile); + fprintf(stdout,"%s: malloc failed\n", pResult->zFile); return 1; } } @@ -91,9 +107,15 @@ char **db_query(sqlite *db, const char *zFile, const char *zFormat, ...){ va_end(ap); memset(&sResult, 0, sizeof(sResult)); sResult.zFile = zFile; + if( verbose ) printf("QUERY %s: %s\n", zFile, zSql); rc = sqlite_exec(db, zSql, db_query_callback, &sResult, &zErrMsg); + if( rc==SQLITE_SCHEMA ){ + if( zErrMsg ) free(zErrMsg); + rc = sqlite_exec(db, zSql, db_query_callback, &sResult, &zErrMsg); + } + if( verbose ) printf("DONE %s %s\n", zFile, zSql); if( zErrMsg ){ - fprintf(stderr,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg); + fprintf(stdout,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); free(zSql); Exit(1); @@ -117,9 +139,15 @@ void db_execute(sqlite *db, const char *zFile, const char *zFormat, ...){ va_start(ap, zFormat); zSql = sqlite_vmprintf(zFormat, ap); va_end(ap); + if( verbose ) printf("EXEC %s: %s\n", zFile, zSql); rc = sqlite_exec(db, zSql, 0, 0, &zErrMsg); + if( rc==SQLITE_SCHEMA ){ + if( zErrMsg ) free(zErrMsg); + rc = sqlite_exec(db, zSql, 0, 0, &zErrMsg); + } + if( verbose ) printf("DONE %s: %s\n", zFile, zSql); if( zErrMsg ){ - fprintf(stderr,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg); + fprintf(stdout,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); sqlite_freemem(zSql); Exit(1); @@ -148,7 +176,7 @@ void db_check(const char *zFile, const char *zMsg, char **az, ...){ va_start(ap, az); for(i=0; (z = va_arg(ap, char*))!=0; i++){ if( az[i]==0 || strcmp(az[i],z)!=0 ){ - fprintf(stderr,"%s: %s: bad result in column %d: %s\n", + fprintf(stdout,"%s: %s: bad result in column %d: %s\n", zFile, zMsg, i+1, az[i]); db_query_free(az); Exit(1); @@ -166,6 +194,7 @@ static void *worker_bee(void *pArg){ const char *zFilename = (char*)pArg; char *azErr; int i, cnt; + int t = atoi(zFilename); char **az; sqlite *db; @@ -175,35 +204,36 @@ static void *worker_bee(void *pArg){ printf("%s: START\n", zFilename); fflush(stdout); for(cnt=0; cnt<10; cnt++){ - db = sqlite_open(zFilename, 0, &azErr); + db = sqlite_open(&zFilename[2], 0, &azErr); if( db==0 ){ - fprintf(stderr,"%s: can't open\n", zFilename); + fprintf(stdout,"%s: can't open\n", zFilename); Exit(1); } - db_execute(db, zFilename, "BEGIN; CREATE TABLE t1(a,b,c);"); + sqlite_busy_handler(db, db_is_locked, zFilename); + db_execute(db, zFilename, "CREATE TABLE t%d(a,b,c);", t); for(i=1; i<=100; i++){ - db_execute(db, zFilename, "INSERT INTO t1 VALUES(%d,%d,%d);", - i, i*2, i*i); + db_execute(db, zFilename, "INSERT INTO t%d VALUES(%d,%d,%d);", + t, i, i*2, i*i); } - az = db_query(db, zFilename, "SELECT count(*) FROM t1"); - db_check(zFilename, "t1 size", az, "100", 0); - az = db_query(db, zFilename, "SELECT avg(b) FROM t1"); - db_check(zFilename, "t1 avg", az, "101", 0); - db_execute(db, zFilename, "DELETE FROM t1 WHERE a>50"); - az = db_query(db, zFilename, "SELECT avg(b) FROM t1"); - db_check(zFilename, "t1 avg2", az, "51", 0); + az = db_query(db, zFilename, "SELECT count(*) FROM t%d", t); + db_check(zFilename, "tX size", az, "100", 0); + az = db_query(db, zFilename, "SELECT avg(b) FROM t%d", t); + db_check(zFilename, "tX avg", az, "101", 0); + db_execute(db, zFilename, "DELETE FROM t%d WHERE a>50", t); + az = db_query(db, zFilename, "SELECT avg(b) FROM t%d", t); + db_check(zFilename, "tX avg2", az, "51", 0); for(i=1; i<=50; i++){ char z1[30], z2[30]; - az = db_query(db, zFilename, "SELECT b, c FROM t1 WHERE a=%d", i); + az = db_query(db, zFilename, "SELECT b, c FROM t%d WHERE a=%d", t, i); sprintf(z1, "%d", i*2); sprintf(z2, "%d", i*i); db_check(zFilename, "readback", az, z1, z2, 0); } - db_execute(db, zFilename, "COMMIT; DROP TABLE t1;"); + db_execute(db, zFilename, "DROP TABLE t%d;", t); sqlite_close(db); } printf("%s: END\n", zFilename); - unlink(zFilename); + /* unlink(zFilename); */ fflush(stdout); pthread_mutex_lock(&lock); thread_cnt--; @@ -218,9 +248,19 @@ int main(int argc, char **argv){ char *zFile; int i, n; pthread_t id; + if( argc>2 && strcmp(argv[1], "-v")==0 ){ + verbose = 1; + argc--; + argv++; + } if( argc<2 || (n=atoi(argv[1]))<1 ) n = 10; for(i=0; i @@ -4874,7 +4874,7 @@ case OP_MemLoad: { if( aStack[tos].flags & STK_Str ){ zStack[tos] = p->aMem[i].z; aStack[tos].flags |= STK_Ephem; - aStack[tos].flags &= ~STK_Dyn; + aStack[tos].flags &= ~(STK_Dyn|STK_Static); } break; } @@ -5306,6 +5306,7 @@ default: { fprintf(p->trace, " ???"); } } + if( rc!=0 ) fprintf(p->trace," rc=%d",rc); fprintf(p->trace,"\n"); } #endif