Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Move some files around and bump the version number in preparation for the release of 2.8.10. (CVS 1173) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
74c661850e1899c457d4e822d8284bb6 |
User & Date: | drh 2004-01-14 03:32:37.000 |
Context
2004-01-14
| ||
03:49 | Version 2.8.10 (CVS 1174) (check-in: 8bef75ab85 user: drh tags: trunk) | |
03:32 | Move some files around and bump the version number in preparation for the release of 2.8.10. (CVS 1173) (check-in: 74c661850e user: drh tags: trunk) | |
03:12 | Remove an incomplete comment that somehow snuck into the sources. (CVS 1172) (check-in: ea1ad4653e user: drh tags: trunk) | |
Changes
Changes to VERSION.
|
| | | 1 | 2.8.10 |
Deleted src/shell.tcl.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/threadtest.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added test/threadtest1.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | /* ** 2002 January 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file implements a simple standalone program used to test whether ** or not the SQLite library is threadsafe. ** ** Testing the thread safety of SQLite is difficult because there are very ** few places in the code that are even potentially unsafe, and those ** places execute for very short periods of time. So even if the library ** is compiled with its mutexes disabled, it is likely to work correctly ** in a multi-threaded program most of the time. ** ** This file is NOT part of the standard SQLite library. It is used for ** testing only. */ #include "sqlite.h" #include <pthread.h> #include <sched.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /* ** Enable for tracing */ static int verbose = 0; /* ** Come here to die. */ static void Exit(int rc){ exit(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() */ struct QueryResult { const char *zFile; /* Filename - used for error reporting */ int nElem; /* Number of used entries in azElem[] */ int nAlloc; /* Number of slots allocated for azElem[] */ char **azElem; /* The result of the query */ }; /* ** The callback function for db_query */ static int db_query_callback( void *pUser, /* Pointer to the QueryResult structure */ int nArg, /* Number of columns in this result row */ char **azArg, /* Text of data in all columns */ char **NotUsed /* Names of the columns */ ){ struct QueryResult *pResult = (struct QueryResult*)pUser; int i; if( pResult->nElem + nArg >= pResult->nAlloc ){ if( pResult->nAlloc==0 ){ pResult->nAlloc = nArg+1; }else{ pResult->nAlloc = pResult->nAlloc*2 + nArg + 1; } pResult->azElem = realloc( pResult->azElem, pResult->nAlloc*sizeof(char*)); if( pResult->azElem==0 ){ fprintf(stdout,"%s: malloc failed\n", pResult->zFile); return 1; } } if( azArg==0 ) return 0; for(i=0; i<nArg; i++){ pResult->azElem[pResult->nElem++] = sqlite_mprintf("%s",azArg[i] ? azArg[i] : ""); } return 0; } /* ** Execute a query against the database. NULL values are returned ** as an empty string. The list is terminated by a single NULL pointer. */ char **db_query(sqlite *db, const char *zFile, const char *zFormat, ...){ char *zSql; int rc; char *zErrMsg = 0; va_list ap; struct QueryResult sResult; va_start(ap, zFormat); zSql = sqlite_vmprintf(zFormat, ap); 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(stdout,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); free(zSql); Exit(1); } sqlite_freemem(zSql); if( sResult.azElem==0 ){ db_query_callback(&sResult, 0, 0, 0); } sResult.azElem[sResult.nElem] = 0; return sResult.azElem; } /* ** Execute an SQL statement. */ void db_execute(sqlite *db, const char *zFile, const char *zFormat, ...){ char *zSql; int rc; char *zErrMsg = 0; va_list ap; 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(stdout,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); sqlite_freemem(zSql); Exit(1); } sqlite_freemem(zSql); } /* ** Free the results of a db_query() call. */ void db_query_free(char **az){ int i; for(i=0; az[i]; i++){ sqlite_freemem(az[i]); } free(az); } /* ** Check results */ void db_check(const char *zFile, const char *zMsg, char **az, ...){ va_list ap; int i; char *z; va_start(ap, az); for(i=0; (z = va_arg(ap, char*))!=0; i++){ if( az[i]==0 || strcmp(az[i],z)!=0 ){ fprintf(stdout,"%s: %s: bad result in column %d: %s\n", zFile, zMsg, i+1, az[i]); db_query_free(az); Exit(1); } } va_end(ap); db_query_free(az); } pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t sig = PTHREAD_COND_INITIALIZER; int thread_cnt = 0; static void *worker_bee(void *pArg){ const char *zFilename = (char*)pArg; char *azErr; int i, cnt; int t = atoi(zFilename); char **az; sqlite *db; pthread_mutex_lock(&lock); thread_cnt++; pthread_mutex_unlock(&lock); printf("%s: START\n", zFilename); fflush(stdout); for(cnt=0; cnt<10; cnt++){ db = sqlite_open(&zFilename[2], 0, &azErr); if( db==0 ){ fprintf(stdout,"%s: can't open\n", zFilename); Exit(1); } 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 t%d VALUES(%d,%d,%d);", t, i, i*2, i*i); } 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 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, "DROP TABLE t%d;", t); sqlite_close(db); } printf("%s: END\n", zFilename); /* unlink(zFilename); */ fflush(stdout); pthread_mutex_lock(&lock); thread_cnt--; if( thread_cnt<=0 ){ pthread_cond_signal(&sig); } pthread_mutex_unlock(&lock); return 0; } 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<n; i++){ char zBuf[200]; sprintf(zBuf, "testdb-%d", (i+1)/2); unlink(zBuf); } for(i=0; i<n; i++){ zFile = sqlite_mprintf("%d.testdb-%d", i%2+1, (i+2)/2); unlink(zFile); pthread_create(&id, 0, worker_bee, (void*)zFile); pthread_detach(id); } pthread_mutex_lock(&lock); while( thread_cnt>0 ){ pthread_cond_wait(&sig, &lock); } pthread_mutex_unlock(&lock); for(i=0; i<n; i++){ char zBuf[200]; sprintf(zBuf, "testdb-%d", (i+1)/2); unlink(zBuf); } return 0; } |
Added test/threadtest2.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /* ** 2004 January 13 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file implements a simple standalone program used to test whether ** or not the SQLite library is threadsafe. ** ** This file is NOT part of the standard SQLite library. It is used for ** testing only. */ #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <string.h> #include <stdlib.h> #include "sqlite.h" /* ** Name of the database */ #define DB_FILE "test.db" /* ** When this variable becomes non-zero, all threads stop ** what they are doing. */ volatile int all_stop = 0; /* ** Callback from the integrity check. If the result is anything other ** than "ok" it means the integrity check has failed. Set the "all_stop" ** global variable to stop all other activity. Print the error message ** or print OK if the string "ok" is seen. */ int check_callback(void *notUsed, int argc, char **argv, char **notUsed2){ if( strcmp(argv[0],"ok") ){ all_stop = 1; fprintf(stderr,"pid=%d. %s\n", getpid(), argv[0]); }else{ /* fprintf(stderr,"pid=%d. OK\n", getpid()); */ } return 0; } /* ** Do an integrity check on the database. If the first integrity check ** fails, try it a second time. */ int integrity_check(sqlite *db){ int rc; if( all_stop ) return 0; /* fprintf(stderr,"pid=%d: CHECK\n", getpid()); */ rc = sqlite_exec(db, "pragma integrity_check", check_callback, 0, 0); if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ fprintf(stderr,"pid=%d, Integrity check returns %d\n", getpid(), rc); } if( all_stop ){ sqlite_exec(db, "pragma integrity_check", check_callback, 0, 0); } return 0; } /* ** This is the worker thread */ void *worker(void *notUsed){ sqlite *db; int rc; int cnt = 0; while( !all_stop && cnt++<10000 ){ if( cnt%1000==0 ) printf("pid=%d: %d\n", getpid(), cnt); while( (db = sqlite_open(DB_FILE, 0, 0))==0 ) sched_yield(); sqlite_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0); integrity_check(db); if( all_stop ){ sqlite_close(db); break; } /* fprintf(stderr, "pid=%d: BEGIN\n", getpid()); */ rc = sqlite_exec(db, "INSERT INTO t1 VALUES('bogus data')", 0, 0, 0); /* fprintf(stderr, "pid=%d: END rc=%d\n", getpid(), rc); */ sqlite_close(db); } return 0; } /* ** Initialize the database and start the threads */ int main(int argc, char **argv){ sqlite *db; int i, rc; pthread_t aThread[5]; if( strcmp(DB_FILE,":memory:") ) unlink(DB_FILE); db = sqlite_open(DB_FILE, 0, 0); if( db==0 ){ fprintf(stderr,"unable to initialize database\n"); exit(1); } rc = sqlite_exec(db, "CREATE TABLE t1(x);", 0,0,0); if( rc ){ fprintf(stderr,"cannot create table t1: %d\n", rc); exit(1); } sqlite_close(db); for(i=0; i<sizeof(aThread)/sizeof(aThread[0]); i++){ pthread_create(&aThread[i], 0, worker, 0); } for(i=0; i<sizeof(aThread)/sizeof(aThread[i]); i++){ pthread_join(aThread[i], 0); } if( !all_stop ){ printf("Everything seems ok.\n"); return 0; }else{ printf("We hit an error.\n"); return 1; } } |
Changes to www/changes.tcl.
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | } proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2004 January 5 (2.8.9)} { <li>Fix a 32-bit integer overflow problem that could result in corrupt indices in a database if large negative numbers (less than -2147483648) were inserted into a indexed numeric column.</li> <li>Fix a locking problem on multi-threaded Linux implementations.</li> <li>Always use "." instead of "," as the decimal point even if the locale | > > > > > > > > > > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | } proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2004 January 14 (2.8.10)} { <li>Fix a potential database corruption problem on Unix caused by the fact that all posix advisory locks are cleared whenever you close() a file. The work around it to embargo all close() calls while locks are outstanding.</li> <li>Performance enhancements on some corner cases of COUNT(*).</li> <li>Make sure the in-memory backend response sanely if malloc() fails.</li> <li>Allow sqlite_exec() to be called from within user-defined SQL functions.</li> <li>Improved accuracy of floating-point conversions using "long double".</li> <li>Bug fixes in the experimental date/time functions.</li> } chng {2004 January 5 (2.8.9)} { <li>Fix a 32-bit integer overflow problem that could result in corrupt indices in a database if large negative numbers (less than -2147483648) were inserted into a indexed numeric column.</li> <li>Fix a locking problem on multi-threaded Linux implementations.</li> <li>Always use "." instead of "," as the decimal point even if the locale |
︙ | ︙ |