Fossil SCM

Update to the latest version of SQLite, which among other things, includes the fix for unix whereby the umask is ignored when creating journal files. That means that any process that has write permission on a repository should be able to recover hot journals.

drh 2012-02-13 20:19 trunk
Commit 0a72346109624fec7b85481bfe8227b4fb14cd7f
2 files changed +55 -34 +1 -1
+55 -34
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657657
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658658
** [sqlite_version()] and [sqlite_source_id()].
659659
*/
660660
#define SQLITE_VERSION "3.7.11"
661661
#define SQLITE_VERSION_NUMBER 3007011
662
-#define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0"
662
+#define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130"
663663
664664
/*
665665
** CAPI3REF: Run-Time Library Version Numbers
666666
** KEYWORDS: sqlite3_version, sqlite3_sourceid
667667
**
@@ -15156,16 +15156,12 @@
1515615156
** the malloc_usable_size() interface exists
1515715157
** on the target platform. Or, this symbol
1515815158
** can be set manually, if desired.
1515915159
** If an equivalent interface exists by
1516015160
** a different name, using a separate -D
15161
-** option to rename it. This symbol will
15162
-** be enabled automatically on windows
15163
-** systems, and malloc_usable_size() will
15164
-** be redefined to _msize(), unless the
15165
-** SQLITE_WITHOUT_MSIZE macro is defined.
15166
-**
15161
+** option to rename it.
15162
+**
1516715163
** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone
1516815164
** memory allocator. Set this symbol to enable
1516915165
** building on older macs.
1517015166
**
1517115167
** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
@@ -15180,17 +15176,15 @@
1518015176
** macros.
1518115177
*/
1518215178
#ifdef SQLITE_SYSTEM_MALLOC
1518315179
1518415180
/*
15185
-** Windows systems have malloc_usable_size() but it is called _msize().
15181
+** The MSVCRT has malloc_usable_size() but it is called _msize().
1518615182
** The use of _msize() is automatic, but can be disabled by compiling
1518715183
** with -DSQLITE_WITHOUT_MSIZE
1518815184
*/
15189
-#if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN \
15190
- && !defined(SQLITE_WITHOUT_MSIZE)
15191
-# define HAVE_MALLOC_USABLE_SIZE 1
15185
+#if defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)
1519215186
# define SQLITE_MALLOCSIZE _msize
1519315187
#endif
1519415188
1519515189
#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
1519615190
@@ -15216,11 +15210,12 @@
1521615210
*/
1521715211
#define SQLITE_MALLOC(x) malloc(x)
1521815212
#define SQLITE_FREE(x) free(x)
1521915213
#define SQLITE_REALLOC(x,y) realloc((x),(y))
1522015214
15221
-#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE)
15215
+#if (defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)) \
15216
+ || (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))
1522215217
# include <malloc.h> /* Needed for malloc_usable_size on linux */
1522315218
#endif
1522415219
#ifdef HAVE_MALLOC_USABLE_SIZE
1522515220
# ifndef SQLITE_MALLOCSIZE
1522615221
# define SQLITE_MALLOCSIZE(x) malloc_usable_size(x)
@@ -25388,10 +25383,16 @@
2538825383
#define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)
2538925384
2539025385
{ "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
2539125386
#define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
2539225387
25388
+ { "fchown", (sqlite3_syscall_ptr)fchown, 0 },
25389
+#define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)
25390
+
25391
+ { "umask", (sqlite3_syscall_ptr)umask, 0 },
25392
+#define osUmask ((mode_t(*)(mode_t))aSyscall[21].pCurrent)
25393
+
2539325394
}; /* End of the overrideable system calls */
2539425395
2539525396
/*
2539625397
** This is the xSetSystemCall() method of sqlite3_vfs for all of the
2539725398
** "unix" VFSes. Return SQLITE_OK opon successfully updating the
@@ -25474,15 +25475,40 @@
2547425475
}
2547525476
return 0;
2547625477
}
2547725478
2547825479
/*
25479
-** Retry open() calls that fail due to EINTR
25480
+** Invoke open(). Do so multiple times, until it either succeeds or
25481
+** files for some reason other than EINTR.
25482
+**
25483
+** If the file creation mode "m" is 0 then set it to the default for
25484
+** SQLite. The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally
25485
+** 0644) as modified by the system umask. If m is not 0, then
25486
+** make the file creation mode be exactly m ignoring the umask.
25487
+**
25488
+** The m parameter will be non-zero only when creating -wal, -journal,
25489
+** and -shm files. We want those files to have *exactly* the same
25490
+** permissions as their original database, unadulterated by the umask.
25491
+** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a
25492
+** transaction crashes and leaves behind hot journals, then any
25493
+** process that is able to write to the database will also be able to
25494
+** recover the hot journals.
2548025495
*/
25481
-static int robust_open(const char *z, int f, int m){
25496
+static int robust_open(const char *z, int f, mode_t m){
2548225497
int rc;
25483
- do{ rc = osOpen(z,f,m); }while( rc<0 && errno==EINTR );
25498
+ mode_t m2;
25499
+ mode_t origM;
25500
+ if( m==0 ){
25501
+ m2 = SQLITE_DEFAULT_FILE_PERMISSIONS;
25502
+ }else{
25503
+ m2 = m;
25504
+ origM = osUmask(0);
25505
+ }
25506
+ do{ rc = osOpen(z,f,m2); }while( rc<0 && errno==EINTR );
25507
+ if( m ){
25508
+ osUmask(origM);
25509
+ }
2548425510
return rc;
2548525511
}
2548625512
2548725513
/*
2548825514
** Helper functions to obtain and relinquish the global mutex. The
@@ -28826,12 +28852,11 @@
2882628852
if( pShmNode==0 ){
2882728853
struct stat sStat; /* fstat() info for database file */
2882828854
2882928855
/* Call fstat() to figure out the permissions on the database file. If
2883028856
** a new *-shm file is created, an attempt will be made to create it
28831
- ** with the same permissions. The actual permissions the file is created
28832
- ** with are subject to the current umask setting.
28857
+ ** with the same permissions.
2883328858
*/
2883428859
if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){
2883528860
rc = SQLITE_IOERR_FSTAT;
2883628861
goto shm_open_err;
2883728862
}
@@ -28882,11 +28907,11 @@
2888228907
** the original owner will not be able to connect. If this process is
2888328908
** not root, the following fchown() will fail, but we don't care. The
2888428909
** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler
2888528910
** warnings.
2888628911
*/
28887
- if( fchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){
28912
+ if( osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){
2888828913
pDbFd->ctrlFlags |= UNIXFILE_CHOWN;
2888928914
}
2889028915
2889128916
/* Check to see if another process is holding the dead-man switch.
2889228917
** If not, truncate the file to zero length.
@@ -29858,16 +29883,14 @@
2985829883
** to create new files with. If no error occurs, then SQLITE_OK is returned
2985929884
** and a value suitable for passing as the third argument to open(2) is
2986029885
** written to *pMode. If an IO error occurs, an SQLite error code is
2986129886
** returned and the value of *pMode is not modified.
2986229887
**
29863
-** If the file being opened is a temporary file, it is always created with
29864
-** the octal permissions 0600 (read/writable by owner only). If the file
29865
-** is a database or master journal file, it is created with the permissions
29866
-** mask SQLITE_DEFAULT_FILE_PERMISSIONS.
29867
-**
29868
-** Finally, if the file being opened is a WAL or regular journal file, then
29888
+** In most cases cases, this routine sets *pMode to 0, which will become
29889
+** an indication to robust_open() to create the file using
29890
+** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.
29891
+** But if the file being opened is a WAL or regular journal file, then
2986929892
** this function queries the file-system for the permissions on the
2987029893
** corresponding database file and sets *pMode to this value. Whenever
2987129894
** possible, WAL and journal files are created using the same permissions
2987229895
** as the associated database file.
2987329896
**
@@ -29882,11 +29905,11 @@
2988229905
mode_t *pMode, /* OUT: Permissions to open file with */
2988329906
uid_t *pUid, /* OUT: uid to set on the file */
2988429907
gid_t *pGid /* OUT: gid to set on the file */
2988529908
){
2988629909
int rc = SQLITE_OK; /* Return Code */
29887
- *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS;
29910
+ *pMode = 0;
2988829911
*pUid = 0;
2988929912
*pGid = 0;
2989029913
if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
2989129914
char zDb[MAX_PATHNAME+1]; /* Database file path */
2989229915
int nDb; /* Number of valid bytes in zDb */
@@ -30098,11 +30121,11 @@
3009830121
** then the fchown() call will fail, but that's ok. The "if(){}" and
3009930122
** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler
3010030123
** warnings from gcc.
3010130124
*/
3010230125
if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
30103
- if( fchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; }
30126
+ if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; }
3010430127
}
3010530128
}
3010630129
assert( fd>=0 );
3010730130
if( pOutFlags ){
3010830131
*pOutFlags = flags;
@@ -30826,21 +30849,21 @@
3082630849
if( !pUnused ){
3082730850
return SQLITE_NOMEM;
3082830851
}
3082930852
}
3083030853
if( fd<0 ){
30831
- fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS);
30854
+ fd = robust_open(path, openFlags, 0);
3083230855
terrno = errno;
3083330856
if( fd<0 && errno==ENOENT && islockfile ){
3083430857
if( proxyCreateLockPath(path) == SQLITE_OK ){
30835
- fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS);
30858
+ fd = robust_open(path, openFlags, 0);
3083630859
}
3083730860
}
3083830861
}
3083930862
if( fd<0 ){
3084030863
openFlags = O_RDONLY;
30841
- fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS);
30864
+ fd = robust_open(path, openFlags, 0);
3084230865
terrno = errno;
3084330866
}
3084430867
if( fd<0 ){
3084530868
if( islockfile ){
3084630869
return SQLITE_BUSY;
@@ -30960,12 +30983,11 @@
3096030983
if( readLen<PROXY_PATHINDEX ){
3096130984
sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
3096230985
goto end_breaklock;
3096330986
}
3096430987
/* write it out to the temporary break file */
30965
- fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL),
30966
- SQLITE_DEFAULT_FILE_PERMISSIONS);
30988
+ fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);
3096730989
if( fd<0 ){
3096830990
sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
3096930991
goto end_breaklock;
3097030992
}
3097130993
if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
@@ -31238,12 +31260,11 @@
3123831260
int fd;
3123931261
if( pFile->h>=0 ){
3124031262
robust_close(pFile, pFile->h, __LINE__);
3124131263
}
3124231264
pFile->h = -1;
31243
- fd = robust_open(pCtx->dbPath, pFile->openFlags,
31244
- SQLITE_DEFAULT_FILE_PERMISSIONS);
31265
+ fd = robust_open(pCtx->dbPath, pFile->openFlags, 0);
3124531266
OSTRACE(("TRANSPROXY: OPEN %d\n", fd));
3124631267
if( fd>=0 ){
3124731268
pFile->h = fd;
3124831269
}else{
3124931270
rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called
@@ -31808,11 +31829,11 @@
3180831829
};
3180931830
unsigned int i; /* Loop counter */
3181031831
3181131832
/* Double-check that the aSyscall[] array has been constructed
3181231833
** correctly. See ticket [bb3a86e890c8e96ab] */
31813
- assert( ArraySize(aSyscall)==20 );
31834
+ assert( ArraySize(aSyscall)==22 );
3181431835
3181531836
/* Register all VFSes defined in the aVfs[] array */
3181631837
for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
3181731838
sqlite3_vfs_register(&aVfs[i], i==0);
3181831839
}
3181931840
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.11"
661 #define SQLITE_VERSION_NUMBER 3007011
662 #define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -15156,16 +15156,12 @@
15156 ** the malloc_usable_size() interface exists
15157 ** on the target platform. Or, this symbol
15158 ** can be set manually, if desired.
15159 ** If an equivalent interface exists by
15160 ** a different name, using a separate -D
15161 ** option to rename it. This symbol will
15162 ** be enabled automatically on windows
15163 ** systems, and malloc_usable_size() will
15164 ** be redefined to _msize(), unless the
15165 ** SQLITE_WITHOUT_MSIZE macro is defined.
15166 **
15167 ** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone
15168 ** memory allocator. Set this symbol to enable
15169 ** building on older macs.
15170 **
15171 ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
@@ -15180,17 +15176,15 @@
15180 ** macros.
15181 */
15182 #ifdef SQLITE_SYSTEM_MALLOC
15183
15184 /*
15185 ** Windows systems have malloc_usable_size() but it is called _msize().
15186 ** The use of _msize() is automatic, but can be disabled by compiling
15187 ** with -DSQLITE_WITHOUT_MSIZE
15188 */
15189 #if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN \
15190 && !defined(SQLITE_WITHOUT_MSIZE)
15191 # define HAVE_MALLOC_USABLE_SIZE 1
15192 # define SQLITE_MALLOCSIZE _msize
15193 #endif
15194
15195 #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
15196
@@ -15216,11 +15210,12 @@
15216 */
15217 #define SQLITE_MALLOC(x) malloc(x)
15218 #define SQLITE_FREE(x) free(x)
15219 #define SQLITE_REALLOC(x,y) realloc((x),(y))
15220
15221 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE)
 
15222 # include <malloc.h> /* Needed for malloc_usable_size on linux */
15223 #endif
15224 #ifdef HAVE_MALLOC_USABLE_SIZE
15225 # ifndef SQLITE_MALLOCSIZE
15226 # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x)
@@ -25388,10 +25383,16 @@
25388 #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)
25389
25390 { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
25391 #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
25392
 
 
 
 
 
 
25393 }; /* End of the overrideable system calls */
25394
25395 /*
25396 ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
25397 ** "unix" VFSes. Return SQLITE_OK opon successfully updating the
@@ -25474,15 +25475,40 @@
25474 }
25475 return 0;
25476 }
25477
25478 /*
25479 ** Retry open() calls that fail due to EINTR
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25480 */
25481 static int robust_open(const char *z, int f, int m){
25482 int rc;
25483 do{ rc = osOpen(z,f,m); }while( rc<0 && errno==EINTR );
 
 
 
 
 
 
 
 
 
 
 
25484 return rc;
25485 }
25486
25487 /*
25488 ** Helper functions to obtain and relinquish the global mutex. The
@@ -28826,12 +28852,11 @@
28826 if( pShmNode==0 ){
28827 struct stat sStat; /* fstat() info for database file */
28828
28829 /* Call fstat() to figure out the permissions on the database file. If
28830 ** a new *-shm file is created, an attempt will be made to create it
28831 ** with the same permissions. The actual permissions the file is created
28832 ** with are subject to the current umask setting.
28833 */
28834 if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){
28835 rc = SQLITE_IOERR_FSTAT;
28836 goto shm_open_err;
28837 }
@@ -28882,11 +28907,11 @@
28882 ** the original owner will not be able to connect. If this process is
28883 ** not root, the following fchown() will fail, but we don't care. The
28884 ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler
28885 ** warnings.
28886 */
28887 if( fchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){
28888 pDbFd->ctrlFlags |= UNIXFILE_CHOWN;
28889 }
28890
28891 /* Check to see if another process is holding the dead-man switch.
28892 ** If not, truncate the file to zero length.
@@ -29858,16 +29883,14 @@
29858 ** to create new files with. If no error occurs, then SQLITE_OK is returned
29859 ** and a value suitable for passing as the third argument to open(2) is
29860 ** written to *pMode. If an IO error occurs, an SQLite error code is
29861 ** returned and the value of *pMode is not modified.
29862 **
29863 ** If the file being opened is a temporary file, it is always created with
29864 ** the octal permissions 0600 (read/writable by owner only). If the file
29865 ** is a database or master journal file, it is created with the permissions
29866 ** mask SQLITE_DEFAULT_FILE_PERMISSIONS.
29867 **
29868 ** Finally, if the file being opened is a WAL or regular journal file, then
29869 ** this function queries the file-system for the permissions on the
29870 ** corresponding database file and sets *pMode to this value. Whenever
29871 ** possible, WAL and journal files are created using the same permissions
29872 ** as the associated database file.
29873 **
@@ -29882,11 +29905,11 @@
29882 mode_t *pMode, /* OUT: Permissions to open file with */
29883 uid_t *pUid, /* OUT: uid to set on the file */
29884 gid_t *pGid /* OUT: gid to set on the file */
29885 ){
29886 int rc = SQLITE_OK; /* Return Code */
29887 *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS;
29888 *pUid = 0;
29889 *pGid = 0;
29890 if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
29891 char zDb[MAX_PATHNAME+1]; /* Database file path */
29892 int nDb; /* Number of valid bytes in zDb */
@@ -30098,11 +30121,11 @@
30098 ** then the fchown() call will fail, but that's ok. The "if(){}" and
30099 ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler
30100 ** warnings from gcc.
30101 */
30102 if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
30103 if( fchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; }
30104 }
30105 }
30106 assert( fd>=0 );
30107 if( pOutFlags ){
30108 *pOutFlags = flags;
@@ -30826,21 +30849,21 @@
30826 if( !pUnused ){
30827 return SQLITE_NOMEM;
30828 }
30829 }
30830 if( fd<0 ){
30831 fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS);
30832 terrno = errno;
30833 if( fd<0 && errno==ENOENT && islockfile ){
30834 if( proxyCreateLockPath(path) == SQLITE_OK ){
30835 fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS);
30836 }
30837 }
30838 }
30839 if( fd<0 ){
30840 openFlags = O_RDONLY;
30841 fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS);
30842 terrno = errno;
30843 }
30844 if( fd<0 ){
30845 if( islockfile ){
30846 return SQLITE_BUSY;
@@ -30960,12 +30983,11 @@
30960 if( readLen<PROXY_PATHINDEX ){
30961 sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
30962 goto end_breaklock;
30963 }
30964 /* write it out to the temporary break file */
30965 fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL),
30966 SQLITE_DEFAULT_FILE_PERMISSIONS);
30967 if( fd<0 ){
30968 sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
30969 goto end_breaklock;
30970 }
30971 if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
@@ -31238,12 +31260,11 @@
31238 int fd;
31239 if( pFile->h>=0 ){
31240 robust_close(pFile, pFile->h, __LINE__);
31241 }
31242 pFile->h = -1;
31243 fd = robust_open(pCtx->dbPath, pFile->openFlags,
31244 SQLITE_DEFAULT_FILE_PERMISSIONS);
31245 OSTRACE(("TRANSPROXY: OPEN %d\n", fd));
31246 if( fd>=0 ){
31247 pFile->h = fd;
31248 }else{
31249 rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called
@@ -31808,11 +31829,11 @@
31808 };
31809 unsigned int i; /* Loop counter */
31810
31811 /* Double-check that the aSyscall[] array has been constructed
31812 ** correctly. See ticket [bb3a86e890c8e96ab] */
31813 assert( ArraySize(aSyscall)==20 );
31814
31815 /* Register all VFSes defined in the aVfs[] array */
31816 for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
31817 sqlite3_vfs_register(&aVfs[i], i==0);
31818 }
31819
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.11"
661 #define SQLITE_VERSION_NUMBER 3007011
662 #define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -15156,16 +15156,12 @@
15156 ** the malloc_usable_size() interface exists
15157 ** on the target platform. Or, this symbol
15158 ** can be set manually, if desired.
15159 ** If an equivalent interface exists by
15160 ** a different name, using a separate -D
15161 ** option to rename it.
15162 **
 
 
 
 
15163 ** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone
15164 ** memory allocator. Set this symbol to enable
15165 ** building on older macs.
15166 **
15167 ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
@@ -15180,17 +15176,15 @@
15176 ** macros.
15177 */
15178 #ifdef SQLITE_SYSTEM_MALLOC
15179
15180 /*
15181 ** The MSVCRT has malloc_usable_size() but it is called _msize().
15182 ** The use of _msize() is automatic, but can be disabled by compiling
15183 ** with -DSQLITE_WITHOUT_MSIZE
15184 */
15185 #if defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)
 
 
15186 # define SQLITE_MALLOCSIZE _msize
15187 #endif
15188
15189 #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
15190
@@ -15216,11 +15210,12 @@
15210 */
15211 #define SQLITE_MALLOC(x) malloc(x)
15212 #define SQLITE_FREE(x) free(x)
15213 #define SQLITE_REALLOC(x,y) realloc((x),(y))
15214
15215 #if (defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)) \
15216 || (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))
15217 # include <malloc.h> /* Needed for malloc_usable_size on linux */
15218 #endif
15219 #ifdef HAVE_MALLOC_USABLE_SIZE
15220 # ifndef SQLITE_MALLOCSIZE
15221 # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x)
@@ -25388,10 +25383,16 @@
25383 #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)
25384
25385 { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
25386 #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
25387
25388 { "fchown", (sqlite3_syscall_ptr)fchown, 0 },
25389 #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)
25390
25391 { "umask", (sqlite3_syscall_ptr)umask, 0 },
25392 #define osUmask ((mode_t(*)(mode_t))aSyscall[21].pCurrent)
25393
25394 }; /* End of the overrideable system calls */
25395
25396 /*
25397 ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
25398 ** "unix" VFSes. Return SQLITE_OK opon successfully updating the
@@ -25474,15 +25475,40 @@
25475 }
25476 return 0;
25477 }
25478
25479 /*
25480 ** Invoke open(). Do so multiple times, until it either succeeds or
25481 ** files for some reason other than EINTR.
25482 **
25483 ** If the file creation mode "m" is 0 then set it to the default for
25484 ** SQLite. The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally
25485 ** 0644) as modified by the system umask. If m is not 0, then
25486 ** make the file creation mode be exactly m ignoring the umask.
25487 **
25488 ** The m parameter will be non-zero only when creating -wal, -journal,
25489 ** and -shm files. We want those files to have *exactly* the same
25490 ** permissions as their original database, unadulterated by the umask.
25491 ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a
25492 ** transaction crashes and leaves behind hot journals, then any
25493 ** process that is able to write to the database will also be able to
25494 ** recover the hot journals.
25495 */
25496 static int robust_open(const char *z, int f, mode_t m){
25497 int rc;
25498 mode_t m2;
25499 mode_t origM;
25500 if( m==0 ){
25501 m2 = SQLITE_DEFAULT_FILE_PERMISSIONS;
25502 }else{
25503 m2 = m;
25504 origM = osUmask(0);
25505 }
25506 do{ rc = osOpen(z,f,m2); }while( rc<0 && errno==EINTR );
25507 if( m ){
25508 osUmask(origM);
25509 }
25510 return rc;
25511 }
25512
25513 /*
25514 ** Helper functions to obtain and relinquish the global mutex. The
@@ -28826,12 +28852,11 @@
28852 if( pShmNode==0 ){
28853 struct stat sStat; /* fstat() info for database file */
28854
28855 /* Call fstat() to figure out the permissions on the database file. If
28856 ** a new *-shm file is created, an attempt will be made to create it
28857 ** with the same permissions.
 
28858 */
28859 if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){
28860 rc = SQLITE_IOERR_FSTAT;
28861 goto shm_open_err;
28862 }
@@ -28882,11 +28907,11 @@
28907 ** the original owner will not be able to connect. If this process is
28908 ** not root, the following fchown() will fail, but we don't care. The
28909 ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler
28910 ** warnings.
28911 */
28912 if( osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){
28913 pDbFd->ctrlFlags |= UNIXFILE_CHOWN;
28914 }
28915
28916 /* Check to see if another process is holding the dead-man switch.
28917 ** If not, truncate the file to zero length.
@@ -29858,16 +29883,14 @@
29883 ** to create new files with. If no error occurs, then SQLITE_OK is returned
29884 ** and a value suitable for passing as the third argument to open(2) is
29885 ** written to *pMode. If an IO error occurs, an SQLite error code is
29886 ** returned and the value of *pMode is not modified.
29887 **
29888 ** In most cases cases, this routine sets *pMode to 0, which will become
29889 ** an indication to robust_open() to create the file using
29890 ** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.
29891 ** But if the file being opened is a WAL or regular journal file, then
 
 
29892 ** this function queries the file-system for the permissions on the
29893 ** corresponding database file and sets *pMode to this value. Whenever
29894 ** possible, WAL and journal files are created using the same permissions
29895 ** as the associated database file.
29896 **
@@ -29882,11 +29905,11 @@
29905 mode_t *pMode, /* OUT: Permissions to open file with */
29906 uid_t *pUid, /* OUT: uid to set on the file */
29907 gid_t *pGid /* OUT: gid to set on the file */
29908 ){
29909 int rc = SQLITE_OK; /* Return Code */
29910 *pMode = 0;
29911 *pUid = 0;
29912 *pGid = 0;
29913 if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
29914 char zDb[MAX_PATHNAME+1]; /* Database file path */
29915 int nDb; /* Number of valid bytes in zDb */
@@ -30098,11 +30121,11 @@
30121 ** then the fchown() call will fail, but that's ok. The "if(){}" and
30122 ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler
30123 ** warnings from gcc.
30124 */
30125 if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
30126 if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; }
30127 }
30128 }
30129 assert( fd>=0 );
30130 if( pOutFlags ){
30131 *pOutFlags = flags;
@@ -30826,21 +30849,21 @@
30849 if( !pUnused ){
30850 return SQLITE_NOMEM;
30851 }
30852 }
30853 if( fd<0 ){
30854 fd = robust_open(path, openFlags, 0);
30855 terrno = errno;
30856 if( fd<0 && errno==ENOENT && islockfile ){
30857 if( proxyCreateLockPath(path) == SQLITE_OK ){
30858 fd = robust_open(path, openFlags, 0);
30859 }
30860 }
30861 }
30862 if( fd<0 ){
30863 openFlags = O_RDONLY;
30864 fd = robust_open(path, openFlags, 0);
30865 terrno = errno;
30866 }
30867 if( fd<0 ){
30868 if( islockfile ){
30869 return SQLITE_BUSY;
@@ -30960,12 +30983,11 @@
30983 if( readLen<PROXY_PATHINDEX ){
30984 sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
30985 goto end_breaklock;
30986 }
30987 /* write it out to the temporary break file */
30988 fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);
 
30989 if( fd<0 ){
30990 sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
30991 goto end_breaklock;
30992 }
30993 if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
@@ -31238,12 +31260,11 @@
31260 int fd;
31261 if( pFile->h>=0 ){
31262 robust_close(pFile, pFile->h, __LINE__);
31263 }
31264 pFile->h = -1;
31265 fd = robust_open(pCtx->dbPath, pFile->openFlags, 0);
 
31266 OSTRACE(("TRANSPROXY: OPEN %d\n", fd));
31267 if( fd>=0 ){
31268 pFile->h = fd;
31269 }else{
31270 rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called
@@ -31808,11 +31829,11 @@
31829 };
31830 unsigned int i; /* Loop counter */
31831
31832 /* Double-check that the aSyscall[] array has been constructed
31833 ** correctly. See ticket [bb3a86e890c8e96ab] */
31834 assert( ArraySize(aSyscall)==22 );
31835
31836 /* Register all VFSes defined in the aVfs[] array */
31837 for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
31838 sqlite3_vfs_register(&aVfs[i], i==0);
31839 }
31840
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.7.11"
111111
#define SQLITE_VERSION_NUMBER 3007011
112
-#define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0"
112
+#define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.11"
111 #define SQLITE_VERSION_NUMBER 3007011
112 #define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.11"
111 #define SQLITE_VERSION_NUMBER 3007011
112 #define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button