Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a bug in the handling of sqlite3OsTruncate by the test_async.c demo. Added trans.test to the suite of tests for asychronous I/O. (CVS 3091) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5b16c43542194d6c736bf7aadaaa7f31 |
User & Date: | drh 2006-02-13 18:35:06.000 |
Context
2006-02-13
| ||
18:42 | Disable the /./ and /../ collapser logic in sqlite3OsFullPathname under Unix. (CVS 3092) (check-in: 111a426b3e user: drh tags: trunk) | |
18:35 | Fix a bug in the handling of sqlite3OsTruncate by the test_async.c demo. Added trans.test to the suite of tests for asychronous I/O. (CVS 3091) (check-in: 5b16c43542 user: drh tags: trunk) | |
17:03 | Add in-process file locking to test_async.c. The unix implementation of sqlite3OsFullPathname() now attempts to remove /./ and /../ elements from the path. (CVS 3090) (check-in: 42379c6230 user: drh tags: trunk) | |
Changes
Changes to src/test_async.c.
︙ | ︙ | |||
493 494 495 496 497 498 499 | } rc = sqlite3OsSeek(pFile->pBaseRead, pFile->iOffset); if( rc!=SQLITE_OK ){ goto asyncread_out; } nRead = MIN(filesize - pFile->iOffset, amt); if( nRead>0 ){ | | > > | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | } rc = sqlite3OsSeek(pFile->pBaseRead, pFile->iOffset); if( rc!=SQLITE_OK ){ goto asyncread_out; } nRead = MIN(filesize - pFile->iOffset, amt); if( nRead>0 ){ rc = sqlite3OsRead(pFile->pBaseRead, obuf, nRead); TRACE(("READ %s %d bytes at %d\n", pFile->zName, nRead, pFile->iOffset)); } } if( rc==SQLITE_OK ){ AsyncWrite *p; i64 iOffset = pFile->iOffset; /* Current seek offset */ for(p=async.pQueueFirst; p; p = p->pNext){ if( p->pFile==pFile && p->op==ASYNC_WRITE ){ int iBeginOut = (p->iOffset - iOffset); int iBeginIn = -iBeginOut; int nCopy; if( iBeginIn<0 ) iBeginIn = 0; if( iBeginOut<0 ) iBeginOut = 0; nCopy = MIN(p->nByte-iBeginIn, amt-iBeginOut); if( nCopy>0 ){ memcpy(&((char *)obuf)[iBeginOut], &p->zBuf[iBeginIn], nCopy); TRACE(("OVERREAD %d bytes at %d\n", nCopy, iBeginOut+iOffset)); } } } pFile->iOffset += (i64)amt; } |
︙ | ︙ | |||
619 620 621 622 623 624 625 | static int asyncCheckReservedLock(OsFile *id){ AsyncFile *pFile = (AsyncFile*)id; int rc; pthread_mutex_lock(&async.lockMutex); rc = (int)sqlite3HashFind(&async.aLock, pFile->zName, pFile->nName); pthread_mutex_unlock(&async.lockMutex); TRACE(("CHECK-LOCK %d (%s)\n", rc, pFile->zName)); | | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | static int asyncCheckReservedLock(OsFile *id){ AsyncFile *pFile = (AsyncFile*)id; int rc; pthread_mutex_lock(&async.lockMutex); rc = (int)sqlite3HashFind(&async.aLock, pFile->zName, pFile->nName); pthread_mutex_unlock(&async.lockMutex); TRACE(("CHECK-LOCK %d (%s)\n", rc, pFile->zName)); return rc>SHARED_LOCK; } /* ** This is broken. But sqlite3OsLockState() is only used for testing anyway. */ static int asyncLockState(OsFile *id){ return SQLITE_OK; |
︙ | ︙ | |||
875 876 877 878 879 880 881 | }else{ TRACE(("IDLE\n")); pthread_cond_wait(&async.queueSignal, &async.queueMutex); TRACE(("WAKEUP\n")); } } if( p==0 ) break; | < < | 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | }else{ TRACE(("IDLE\n")); pthread_cond_wait(&async.queueSignal, &async.queueMutex); TRACE(("WAKEUP\n")); } } if( p==0 ) break; /* Right now this thread is holding the mutex on the write-op queue. ** Variable 'p' points to the first entry in the write-op queue. In ** the general case, we hold on to the mutex for the entire body of ** the loop. ** ** However in the cases enumerated below, we relinquish the mutex, |
︙ | ︙ | |||
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | switch( p->op ){ case ASYNC_NOOP: break; case ASYNC_WRITE: assert( pBase ); rc = sqlite3OsSeek(pBase, p->iOffset); if( rc==SQLITE_OK ){ rc = sqlite3OsWrite(pBase, (const void *)(p->zBuf), p->nByte); } break; case ASYNC_SYNC: assert( pBase ); rc = sqlite3OsSync(pBase, p->nByte); break; case ASYNC_TRUNCATE: assert( pBase ); | > > > > | > > > > > > | 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 | switch( p->op ){ case ASYNC_NOOP: break; case ASYNC_WRITE: assert( pBase ); TRACE(("WRITE %s %d bytes at %d\n", p->pFile->zName, p->nByte, p->iOffset)); rc = sqlite3OsSeek(pBase, p->iOffset); if( rc==SQLITE_OK ){ rc = sqlite3OsWrite(pBase, (const void *)(p->zBuf), p->nByte); } break; case ASYNC_SYNC: assert( pBase ); TRACE(("SYNC %s\n", p->pFile->zName)); rc = sqlite3OsSync(pBase, p->nByte); break; case ASYNC_TRUNCATE: assert( pBase ); TRACE(("TRUNCATE %s to %d bytes\n", p->pFile->zName, p->iOffset)); rc = sqlite3OsTruncate(pBase, p->iOffset); break; case ASYNC_CLOSE: TRACE(("CLOSE %s\n", p->pFile->zName)); sqlite3OsClose(&p->pFile->pBaseRead); sqlite3OsClose(&p->pFile->pBaseWrite); sqlite3OsFree(p->pFile); break; case ASYNC_OPENDIRECTORY: assert( pBase ); TRACE(("OPENDIR %s\n", p->zBuf)); sqlite3OsOpenDirectory(pBase, p->zBuf); break; case ASYNC_SETFULLSYNC: assert( pBase ); TRACE(("SETFULLSYNC %s %d\n", p->pFile->zName, p->nByte)); sqlite3OsSetFullSync(pBase, p->nByte); break; case ASYNC_DELETE: TRACE(("DELETE %s\n", p->zBuf)); rc = xOrigDelete(p->zBuf); break; case ASYNC_SYNCDIRECTORY: TRACE(("SYNCDIR %s\n", p->zBuf)); rc = xOrigSyncDirectory(p->zBuf); break; case ASYNC_OPENEXCLUSIVE: { AsyncFile *pFile = p->pFile; int delFlag = ((p->iOffset)?1:0); OsFile *pBase = 0; TRACE(("OPEN %s delFlag=%d\n", p->zBuf, delFlag)); rc = xOrigOpenExclusive(p->zBuf, &pBase, delFlag); assert( holdingMutex==0 ); pthread_mutex_lock(&async.queueMutex); holdingMutex = 1; if( rc==SQLITE_OK ){ pFile->pBaseRead = pBase; } |
︙ | ︙ | |||
1171 1172 1173 1174 1175 1176 1177 | TRACE(("WAIT\n")); pthread_mutex_lock(&async.queueMutex); pthread_cond_broadcast(&async.queueSignal); pthread_mutex_unlock(&async.queueMutex); pthread_mutex_lock(&async.writerMutex); pthread_mutex_unlock(&async.writerMutex); }else{ | | | 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 | TRACE(("WAIT\n")); pthread_mutex_lock(&async.queueMutex); pthread_cond_broadcast(&async.queueSignal); pthread_mutex_unlock(&async.queueMutex); pthread_mutex_lock(&async.writerMutex); pthread_mutex_unlock(&async.writerMutex); }else{ TRACE(("NO-WAIT\n")); } return TCL_OK; } #endif /* OS_UNIX and THREADSAFE and defined(SQLITE_ENABLE_REDEF_IO) */ |
︙ | ︙ |
Changes to test/async.test.
1 2 3 4 5 6 7 8 | # # 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 runs all tests. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # # 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 runs all tests. # # $Id: async.test,v 1.4 2006/02/13 18:35:06 drh Exp $ if {[catch {sqlite3async_enable}]} { # The async logic is not built into this system return } |
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 | select1.test select2.test select3.test select4.test insert.test insert2.test insert3.test } #set INCLUDE [lrange $INCLUDE 0 0] # Enable asynchronous IO. sqlite3async_enable 1 | > < < | | < | 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 | select1.test select2.test select3.test select4.test insert.test insert2.test insert3.test trans.test } #set INCLUDE [lrange $INCLUDE 0 0] # Enable asynchronous IO. sqlite3async_enable 1 rename do_test really_do_test proc do_test {name args} { uplevel really_do_test async_io-$name $args sqlite3async_halt idle sqlite3async_start sqlite3async_wait } foreach testfile [lsort -dictionary [glob $testdir/*.test]] { set tail [file tail $testfile] if {[lsearch -exact $INCLUDE $tail]<0} continue source $testfile catch {db close} |
︙ | ︙ |
Changes to test/trans.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 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 regression tests for SQLite library. The # focus of this script is database locks. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 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 regression tests for SQLite library. The # focus of this script is database locks. # # $Id: trans.test,v 1.30 2006/02/13 18:35:06 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create several tables to work with. |
︙ | ︙ | |||
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | BEGIN; CREATE TABLE t3 AS SELECT * FROM t2; DELETE FROM t2; } sqlite_abort } close $fd do_test trans-8.1 { catch {exec [info nameofexec] test.tcl} execsql {SELECT md5sum(x,y,z) FROM t2} } $checksum do_test trans-8.2 { execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master} } $checksum2 integrity_check trans-8.3 | > > > | 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 | BEGIN; CREATE TABLE t3 AS SELECT * FROM t2; DELETE FROM t2; } sqlite_abort } close $fd exec cp -f test.db test.db-bu1 do_test trans-8.1 { catch {exec [info nameofexec] test.tcl} exec cp -f test.db test.db-bu2 exec cp -f test.db-journal test.db-bu2-journal execsql {SELECT md5sum(x,y,z) FROM t2} } $checksum do_test trans-8.2 { execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master} } $checksum2 integrity_check trans-8.3 |
︙ | ︙ |