Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | More changes prior to release 2.0.2. Mostly comment changes. But there was also a minor change to temptable.test so that it would work under Windows. (CVS 282) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
864349de6fba5b38a3fbf7ab50292293 |
User & Date: | drh 2001-10-09 12:39:24.000 |
Context
2001-10-09
| ||
12:44 | Remove files before rebuilding. (CVS 283) (check-in: 6307641d46 user: drh tags: trunk) | |
12:39 | More changes prior to release 2.0.2. Mostly comment changes. But there was also a minor change to temptable.test so that it would work under Windows. (CVS 282) (check-in: 864349de6f user: drh tags: trunk) | |
04:21 | Version 2.0.2 (CVS 281) (check-in: 765359c77e user: drh tags: trunk) | |
Changes
Changes to src/os.c.
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #endif #if OS_WIN # include <winbase.h> #endif #if OS_UNIX /* ** An instance of the following structure serves as the key used ** to locate a particular lockInfo structure given its inode. */ struct inodeKey { dev_t dev; /* Device number */ ino_t ino; /* Inode number */ }; /* ** An instance of the following structure is allocated for each inode. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | > > | | 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 | #endif #if OS_WIN # include <winbase.h> #endif #if OS_UNIX /* ** Here is the dirt on POSIX advisory locks: ANSI STD 1003.1 (1996) ** section 6.5.2.2 lines 483 through 490 specify that when a process ** sets or clears a lock, that operation overrides any prior locks set ** by the same process. It does not explicitly say so, but this implies ** that it overrides locks set by the same process using a different ** file descriptor. Consider this test case: ** ** int fd1 = open("./file1", O_RDWR|O_CREAT, 0644); ** int fd2 = open("./file2", O_RDWR|O_CREAT, 0644); ** ** Suppose ./file1 and ./file2 are really be the same file (because ** one is a hard or symbolic link to the other) then if you set ** an exclusive lock on fd1, then try to get an exclusive lock ** on fd2, it works. I would have expected the second lock to ** fail since there was already a lock on the file due to fd1. ** But not so. Since both locks came from the same process, the ** second overrides the first, even though they were on different ** file descriptors opened on different file names. ** ** Bummer. If you ask me, this is broken. Badly broken. It means ** that we cannot use POSIX locks to synchronize file access among ** competing threads of the same process. POSIX locks will work fine ** to synchronize access for threads in separate processes, but not ** threads within the same process. ** ** To work around the problem, SQLite has to manage file locks internally ** on its own. Whenever a new database is opened, we have to find the ** specific inode of the database file (the inode is determined by the ** st_dev and st_ino fields of the stat structure the stat() fills in) ** and check for locks already existing on that inode. When locks are ** created or removed, we have to look at our own internal record of the ** locks to see if another thread has previously set a lock on that same ** inode. ** ** The OsFile structure for POSIX is no longer just an integer file ** descriptor. It is now a structure that holds the integer file ** descriptor and a pointer to a structure that describes the internal ** locks on the corresponding inode. There is one locking structure ** per inode, so if the same inode is opened twice, both OsFile structures ** point to the same locking structure. The locking structure keeps ** a reference count (so we will know when to delete it) and a "cnt" ** field that tells us its internal lock status. cnt==0 means the ** file is unlocked. cnt==-1 means the file has an exclusive lock. ** cnt>0 means there are cnt shared locks on the file. ** ** Any attempt to lock or unlock a file first checks the locking ** structure. The fcntl() system call is only invoked to set a ** POSIX lock if the internal lock structure transitions between ** a locked and an unlocked state. */ /* ** An instance of the following structure serves as the key used ** to locate a particular lockInfo structure given its inode. */ struct inodeKey { dev_t dev; /* Device number */ ino_t ino; /* Inode number */ }; /* ** An instance of the following structure is allocated for each inode. ** A single inode can have multiple file descriptors, so each OsFile ** structure contains a pointer to an instance of this object and this ** object keeps a count of the number of OsFiles pointing to it. */ struct lockInfo { struct inodeKey key; /* The lookup key */ int cnt; /* 0: unlocked. -1: write lock. >=1: read lock */ int nRef; /* Number of pointers to this structure */ }; /* ** This hash table maps inodes (in the form of inodeKey structures) into ** pointers to lockInfo structures. */ static Hash lockHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; /* ** Given a file descriptor, locate a lockInfo structure that describes ** that file descriptor. Create a new one if necessary. NULL might ** be returned if malloc() fails. */ static struct lockInfo *findLockInfo(int fd){ int rc; struct inodeKey key; struct stat statbuf; struct lockInfo *pInfo; rc = fstat(fd, &statbuf); if( rc!=0 ) return 0; key.dev = statbuf.st_dev; key.ino = statbuf.st_ino; pInfo = (struct lockInfo*)sqliteHashFind(&lockHash, &key, sizeof(key)); if( pInfo==0 ){ pInfo = sqliteMalloc( sizeof(*pInfo) ); if( pInfo==0 ) return 0; pInfo->key = key; pInfo->nRef = 1; pInfo->cnt = 0; sqliteHashInsert(&lockHash, &pInfo->key, sizeof(key), pInfo); }else{ pInfo->nRef++; } return pInfo; } /* ** Release a lockInfo structure previously allocated by findLockInfo(). */ static void releaseLockInfo(struct lockInfo *pInfo){ pInfo->nRef--; if( pInfo->nRef==0 ){ sqliteHashInsert(&lockHash, &pInfo->key, sizeof(pInfo->key), 0); sqliteFree(pInfo); } } #endif /** POSIX advisory lock work-around **/ /* ** Delete the named file */ int sqliteOsDelete(const char *zFilename){ #if OS_UNIX |
︙ | ︙ |
Changes to test/temptable.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for temporary tables and indices. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for temporary tables and indices. # # $Id: temptable.test,v 1.3 2001/10/09 12:39:24 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create an alternative connection to the database # do_test temptable-1.0 { |
︙ | ︙ | |||
220 221 222 223 224 225 226 227 228 | execsql { SELECT y FROM t2 WHERE x=1; } } {2} do_test temptable-5.9 { execsql {SELECT y FROM t2 WHERE x=9} } {8} finish_test | > > | 220 221 222 223 224 225 226 227 228 229 230 | execsql { SELECT y FROM t2 WHERE x=1; } } {2} do_test temptable-5.9 { execsql {SELECT y FROM t2 WHERE x=9} } {8} db2 close finish_test |
Changes to www/changes.tcl.
︙ | ︙ | |||
14 15 16 17 18 19 20 | proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2001 Oct 9 (2.0.2)} { | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2001 Oct 9 (2.0.2)} { <li>Fix two bugs in the locking protocol. (One was masking the other.)</li> <li>Removed some unused "#include <unistd.h>" that were causing problems for VC++.</li> <li>Fixed <b>sqlite.h</b> so that it is usable from C++</li> <li>Added the FULL_COLUMN_NAMES pragma. When set to "ON", the names of columns are reported back as TABLE.COLUMN instead of just COLUMN.</li> <li>Added the TABLE_INFO() and INDEX_INFO() pragmas to help support the ODBC interface.</li> |
︙ | ︙ |