Fossil SCM
Update the built-in SQLite version to the latest from trunk, including the patch that sets -wal and -shm files to have the same owner as the database when running as root. That patch help to avoid configuration problems on Fossil servers.
Commit
5ac8c0d7132acd58daa92806998b08fe2be01552
Parent
937514b96854b8b…
2 files changed
+51
-14
+1
-1
+51
-14
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -657,11 +657,11 @@ | ||
| 657 | 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | 659 | */ |
| 660 | 660 | #define SQLITE_VERSION "3.7.11" |
| 661 | 661 | #define SQLITE_VERSION_NUMBER 3007011 |
| 662 | -#define SQLITE_SOURCE_ID "2012-02-07 14:13:50 9497893b1b9219eac4ec2183bd90b4e4b860d9fe" | |
| 662 | +#define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" | |
| 663 | 663 | |
| 664 | 664 | /* |
| 665 | 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | 667 | ** |
| @@ -15216,13 +15216,15 @@ | ||
| 15216 | 15216 | */ |
| 15217 | 15217 | #define SQLITE_MALLOC(x) malloc(x) |
| 15218 | 15218 | #define SQLITE_FREE(x) free(x) |
| 15219 | 15219 | #define SQLITE_REALLOC(x,y) realloc((x),(y)) |
| 15220 | 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 | |
| 15221 | 15224 | #ifdef HAVE_MALLOC_USABLE_SIZE |
| 15222 | 15225 | # ifndef SQLITE_MALLOCSIZE |
| 15223 | -# include <malloc.h> | |
| 15224 | 15226 | # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x) |
| 15225 | 15227 | # endif |
| 15226 | 15228 | #else |
| 15227 | 15229 | # undef SQLITE_MALLOCSIZE |
| 15228 | 15230 | #endif |
| @@ -24970,11 +24972,11 @@ | ||
| 24970 | 24972 | sqlite3_io_methods const *pMethod; /* Always the first entry */ |
| 24971 | 24973 | sqlite3_vfs *pVfs; /* The VFS that created this unixFile */ |
| 24972 | 24974 | unixInodeInfo *pInode; /* Info about locks on this inode */ |
| 24973 | 24975 | int h; /* The file descriptor */ |
| 24974 | 24976 | unsigned char eFileLock; /* The type of lock held on this fd */ |
| 24975 | - unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ | |
| 24977 | + unsigned short int ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ | |
| 24976 | 24978 | int lastErrno; /* The unix errno from last I/O error */ |
| 24977 | 24979 | void *lockingContext; /* Locking style specific state */ |
| 24978 | 24980 | UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ |
| 24979 | 24981 | const char *zPath; /* Name of the file */ |
| 24980 | 24982 | unixShm *pShm; /* Shared memory segment information */ |
| @@ -25021,10 +25023,11 @@ | ||
| 25021 | 25023 | #endif |
| 25022 | 25024 | #define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ |
| 25023 | 25025 | #define UNIXFILE_DELETE 0x20 /* Delete on close */ |
| 25024 | 25026 | #define UNIXFILE_URI 0x40 /* Filename might have query parameters */ |
| 25025 | 25027 | #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */ |
| 25028 | +#define UNIXFILE_CHOWN 0x100 /* File ownership was changed */ | |
| 25026 | 25029 | |
| 25027 | 25030 | /* |
| 25028 | 25031 | ** Include code that is common to all os_*.c files |
| 25029 | 25032 | */ |
| 25030 | 25033 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| @@ -28868,14 +28871,23 @@ | ||
| 28868 | 28871 | openFlags = O_RDONLY; |
| 28869 | 28872 | pShmNode->isReadonly = 1; |
| 28870 | 28873 | } |
| 28871 | 28874 | pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777)); |
| 28872 | 28875 | if( pShmNode->h<0 ){ |
| 28873 | - if( pShmNode->h<0 ){ | |
| 28874 | - rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShmFilename); | |
| 28875 | - goto shm_open_err; | |
| 28876 | - } | |
| 28876 | + rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShmFilename); | |
| 28877 | + goto shm_open_err; | |
| 28878 | + } | |
| 28879 | + | |
| 28880 | + /* If this process is running as root, make sure that the SHM file | |
| 28881 | + ** is owned by the same user that owns the original database. Otherwise, | |
| 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; | |
| 28877 | 28889 | } |
| 28878 | 28890 | |
| 28879 | 28891 | /* Check to see if another process is holding the dead-man switch. |
| 28880 | 28892 | ** If not, truncate the file to zero length. |
| 28881 | 28893 | */ |
| @@ -29865,14 +29877,18 @@ | ||
| 29865 | 29877 | ** the default permissions. |
| 29866 | 29878 | */ |
| 29867 | 29879 | static int findCreateFileMode( |
| 29868 | 29880 | const char *zPath, /* Path of file (possibly) being created */ |
| 29869 | 29881 | int flags, /* Flags passed as 4th argument to xOpen() */ |
| 29870 | - mode_t *pMode /* OUT: Permissions to open file with */ | |
| 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 */ | |
| 29871 | 29885 | ){ |
| 29872 | 29886 | int rc = SQLITE_OK; /* Return Code */ |
| 29873 | 29887 | *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS; |
| 29888 | + *pUid = 0; | |
| 29889 | + *pGid = 0; | |
| 29874 | 29890 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 29875 | 29891 | char zDb[MAX_PATHNAME+1]; /* Database file path */ |
| 29876 | 29892 | int nDb; /* Number of valid bytes in zDb */ |
| 29877 | 29893 | struct stat sStat; /* Output of stat() on database file */ |
| 29878 | 29894 | |
| @@ -29902,10 +29918,12 @@ | ||
| 29902 | 29918 | memcpy(zDb, zPath, nDb); |
| 29903 | 29919 | zDb[nDb] = '\0'; |
| 29904 | 29920 | |
| 29905 | 29921 | if( 0==osStat(zDb, &sStat) ){ |
| 29906 | 29922 | *pMode = sStat.st_mode & 0777; |
| 29923 | + *pUid = sStat.st_uid; | |
| 29924 | + *pGid = sStat.st_gid; | |
| 29907 | 29925 | }else{ |
| 29908 | 29926 | rc = SQLITE_IOERR_FSTAT; |
| 29909 | 29927 | } |
| 29910 | 29928 | }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ |
| 29911 | 29929 | *pMode = 0600; |
| @@ -30048,11 +30066,13 @@ | ||
| 30048 | 30066 | if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); |
| 30049 | 30067 | openFlags |= (O_LARGEFILE|O_BINARY); |
| 30050 | 30068 | |
| 30051 | 30069 | if( fd<0 ){ |
| 30052 | 30070 | mode_t openMode; /* Permissions to create file with */ |
| 30053 | - rc = findCreateFileMode(zName, flags, &openMode); | |
| 30071 | + uid_t uid; /* Userid for the file */ | |
| 30072 | + gid_t gid; /* Groupid for the file */ | |
| 30073 | + rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid); | |
| 30054 | 30074 | if( rc!=SQLITE_OK ){ |
| 30055 | 30075 | assert( !p->pUnused ); |
| 30056 | 30076 | assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL ); |
| 30057 | 30077 | return rc; |
| 30058 | 30078 | } |
| @@ -30069,10 +30089,21 @@ | ||
| 30069 | 30089 | } |
| 30070 | 30090 | if( fd<0 ){ |
| 30071 | 30091 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); |
| 30072 | 30092 | goto open_finished; |
| 30073 | 30093 | } |
| 30094 | + | |
| 30095 | + /* If this process is running as root and if creating a new rollback | |
| 30096 | + ** journal or WAL file, set the ownership of the journal or WAL to be | |
| 30097 | + ** the same as the original database. If we are not running as root, | |
| 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 | + } | |
| 30074 | 30105 | } |
| 30075 | 30106 | assert( fd>=0 ); |
| 30076 | 30107 | if( pOutFlags ){ |
| 30077 | 30108 | *pOutFlags = flags; |
| 30078 | 30109 | } |
| @@ -30380,11 +30411,11 @@ | ||
| 30380 | 30411 | ** tests repeatable. |
| 30381 | 30412 | */ |
| 30382 | 30413 | memset(zBuf, 0, nBuf); |
| 30383 | 30414 | #if !defined(SQLITE_TEST) |
| 30384 | 30415 | { |
| 30385 | - int pid, fd; | |
| 30416 | + int pid, fd, got; | |
| 30386 | 30417 | fd = robust_open("/dev/urandom", O_RDONLY, 0); |
| 30387 | 30418 | if( fd<0 ){ |
| 30388 | 30419 | time_t t; |
| 30389 | 30420 | time(&t); |
| 30390 | 30421 | memcpy(zBuf, &t, sizeof(t)); |
| @@ -30391,11 +30422,11 @@ | ||
| 30391 | 30422 | pid = getpid(); |
| 30392 | 30423 | memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid)); |
| 30393 | 30424 | assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf ); |
| 30394 | 30425 | nBuf = sizeof(t) + sizeof(pid); |
| 30395 | 30426 | }else{ |
| 30396 | - do{ nBuf = osRead(fd, zBuf, nBuf); }while( nBuf<0 && errno==EINTR ); | |
| 30427 | + do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR ); | |
| 30397 | 30428 | robust_close(0, fd, __LINE__); |
| 30398 | 30429 | } |
| 30399 | 30430 | } |
| 30400 | 30431 | #endif |
| 30401 | 30432 | return nBuf; |
| @@ -58636,12 +58667,18 @@ | ||
| 58636 | 58667 | ** the second condition under the assumption that addition overflow causes |
| 58637 | 58668 | ** values to wrap around. On x86 hardware, the third term is always |
| 58638 | 58669 | ** true and could be omitted. But we leave it in because other |
| 58639 | 58670 | ** architectures might behave differently. |
| 58640 | 58671 | */ |
| 58641 | - if( pMem->r==(double)pMem->u.i && pMem->u.i>SMALLEST_INT64 | |
| 58642 | - && ALWAYS(pMem->u.i<LARGEST_INT64) ){ | |
| 58672 | + if( pMem->r==(double)pMem->u.i | |
| 58673 | + && pMem->u.i>SMALLEST_INT64 | |
| 58674 | +#if defined(__i486__) || defined(__x86_64__) | |
| 58675 | + && ALWAYS(pMem->u.i<LARGEST_INT64) | |
| 58676 | +#else | |
| 58677 | + && pMem->u.i<LARGEST_INT64 | |
| 58678 | +#endif | |
| 58679 | + ){ | |
| 58643 | 58680 | pMem->flags |= MEM_Int; |
| 58644 | 58681 | } |
| 58645 | 58682 | } |
| 58646 | 58683 | |
| 58647 | 58684 | /* |
| @@ -86423,11 +86460,11 @@ | ||
| 86423 | 86460 | ** in a way that is testable, mask the sign bit off of negative |
| 86424 | 86461 | ** values, resulting in a positive value. Then take the |
| 86425 | 86462 | ** 2s complement of that positive value. The end result can |
| 86426 | 86463 | ** therefore be no less than -9223372036854775807. |
| 86427 | 86464 | */ |
| 86428 | - r = -(r ^ (((sqlite3_int64)1)<<63)); | |
| 86465 | + r = -(r & LARGEST_INT64); | |
| 86429 | 86466 | } |
| 86430 | 86467 | sqlite3_result_int64(context, r); |
| 86431 | 86468 | } |
| 86432 | 86469 | |
| 86433 | 86470 | /* |
| 86434 | 86471 |
| --- 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-07 14:13:50 9497893b1b9219eac4ec2183bd90b4e4b860d9fe" |
| 663 | |
| 664 | /* |
| 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | ** |
| @@ -15216,13 +15216,15 @@ | |
| 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 | #ifdef HAVE_MALLOC_USABLE_SIZE |
| 15222 | # ifndef SQLITE_MALLOCSIZE |
| 15223 | # include <malloc.h> |
| 15224 | # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x) |
| 15225 | # endif |
| 15226 | #else |
| 15227 | # undef SQLITE_MALLOCSIZE |
| 15228 | #endif |
| @@ -24970,11 +24972,11 @@ | |
| 24970 | sqlite3_io_methods const *pMethod; /* Always the first entry */ |
| 24971 | sqlite3_vfs *pVfs; /* The VFS that created this unixFile */ |
| 24972 | unixInodeInfo *pInode; /* Info about locks on this inode */ |
| 24973 | int h; /* The file descriptor */ |
| 24974 | unsigned char eFileLock; /* The type of lock held on this fd */ |
| 24975 | unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ |
| 24976 | int lastErrno; /* The unix errno from last I/O error */ |
| 24977 | void *lockingContext; /* Locking style specific state */ |
| 24978 | UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ |
| 24979 | const char *zPath; /* Name of the file */ |
| 24980 | unixShm *pShm; /* Shared memory segment information */ |
| @@ -25021,10 +25023,11 @@ | |
| 25021 | #endif |
| 25022 | #define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ |
| 25023 | #define UNIXFILE_DELETE 0x20 /* Delete on close */ |
| 25024 | #define UNIXFILE_URI 0x40 /* Filename might have query parameters */ |
| 25025 | #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */ |
| 25026 | |
| 25027 | /* |
| 25028 | ** Include code that is common to all os_*.c files |
| 25029 | */ |
| 25030 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| @@ -28868,14 +28871,23 @@ | |
| 28868 | openFlags = O_RDONLY; |
| 28869 | pShmNode->isReadonly = 1; |
| 28870 | } |
| 28871 | pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777)); |
| 28872 | if( pShmNode->h<0 ){ |
| 28873 | if( pShmNode->h<0 ){ |
| 28874 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShmFilename); |
| 28875 | goto shm_open_err; |
| 28876 | } |
| 28877 | } |
| 28878 | |
| 28879 | /* Check to see if another process is holding the dead-man switch. |
| 28880 | ** If not, truncate the file to zero length. |
| 28881 | */ |
| @@ -29865,14 +29877,18 @@ | |
| 29865 | ** the default permissions. |
| 29866 | */ |
| 29867 | static int findCreateFileMode( |
| 29868 | const char *zPath, /* Path of file (possibly) being created */ |
| 29869 | int flags, /* Flags passed as 4th argument to xOpen() */ |
| 29870 | mode_t *pMode /* OUT: Permissions to open file with */ |
| 29871 | ){ |
| 29872 | int rc = SQLITE_OK; /* Return Code */ |
| 29873 | *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS; |
| 29874 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 29875 | char zDb[MAX_PATHNAME+1]; /* Database file path */ |
| 29876 | int nDb; /* Number of valid bytes in zDb */ |
| 29877 | struct stat sStat; /* Output of stat() on database file */ |
| 29878 | |
| @@ -29902,10 +29918,12 @@ | |
| 29902 | memcpy(zDb, zPath, nDb); |
| 29903 | zDb[nDb] = '\0'; |
| 29904 | |
| 29905 | if( 0==osStat(zDb, &sStat) ){ |
| 29906 | *pMode = sStat.st_mode & 0777; |
| 29907 | }else{ |
| 29908 | rc = SQLITE_IOERR_FSTAT; |
| 29909 | } |
| 29910 | }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ |
| 29911 | *pMode = 0600; |
| @@ -30048,11 +30066,13 @@ | |
| 30048 | if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); |
| 30049 | openFlags |= (O_LARGEFILE|O_BINARY); |
| 30050 | |
| 30051 | if( fd<0 ){ |
| 30052 | mode_t openMode; /* Permissions to create file with */ |
| 30053 | rc = findCreateFileMode(zName, flags, &openMode); |
| 30054 | if( rc!=SQLITE_OK ){ |
| 30055 | assert( !p->pUnused ); |
| 30056 | assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL ); |
| 30057 | return rc; |
| 30058 | } |
| @@ -30069,10 +30089,21 @@ | |
| 30069 | } |
| 30070 | if( fd<0 ){ |
| 30071 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); |
| 30072 | goto open_finished; |
| 30073 | } |
| 30074 | } |
| 30075 | assert( fd>=0 ); |
| 30076 | if( pOutFlags ){ |
| 30077 | *pOutFlags = flags; |
| 30078 | } |
| @@ -30380,11 +30411,11 @@ | |
| 30380 | ** tests repeatable. |
| 30381 | */ |
| 30382 | memset(zBuf, 0, nBuf); |
| 30383 | #if !defined(SQLITE_TEST) |
| 30384 | { |
| 30385 | int pid, fd; |
| 30386 | fd = robust_open("/dev/urandom", O_RDONLY, 0); |
| 30387 | if( fd<0 ){ |
| 30388 | time_t t; |
| 30389 | time(&t); |
| 30390 | memcpy(zBuf, &t, sizeof(t)); |
| @@ -30391,11 +30422,11 @@ | |
| 30391 | pid = getpid(); |
| 30392 | memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid)); |
| 30393 | assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf ); |
| 30394 | nBuf = sizeof(t) + sizeof(pid); |
| 30395 | }else{ |
| 30396 | do{ nBuf = osRead(fd, zBuf, nBuf); }while( nBuf<0 && errno==EINTR ); |
| 30397 | robust_close(0, fd, __LINE__); |
| 30398 | } |
| 30399 | } |
| 30400 | #endif |
| 30401 | return nBuf; |
| @@ -58636,12 +58667,18 @@ | |
| 58636 | ** the second condition under the assumption that addition overflow causes |
| 58637 | ** values to wrap around. On x86 hardware, the third term is always |
| 58638 | ** true and could be omitted. But we leave it in because other |
| 58639 | ** architectures might behave differently. |
| 58640 | */ |
| 58641 | if( pMem->r==(double)pMem->u.i && pMem->u.i>SMALLEST_INT64 |
| 58642 | && ALWAYS(pMem->u.i<LARGEST_INT64) ){ |
| 58643 | pMem->flags |= MEM_Int; |
| 58644 | } |
| 58645 | } |
| 58646 | |
| 58647 | /* |
| @@ -86423,11 +86460,11 @@ | |
| 86423 | ** in a way that is testable, mask the sign bit off of negative |
| 86424 | ** values, resulting in a positive value. Then take the |
| 86425 | ** 2s complement of that positive value. The end result can |
| 86426 | ** therefore be no less than -9223372036854775807. |
| 86427 | */ |
| 86428 | r = -(r ^ (((sqlite3_int64)1)<<63)); |
| 86429 | } |
| 86430 | sqlite3_result_int64(context, r); |
| 86431 | } |
| 86432 | |
| 86433 | /* |
| 86434 |
| --- 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 | ** |
| @@ -15216,13 +15216,15 @@ | |
| 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) |
| 15227 | # endif |
| 15228 | #else |
| 15229 | # undef SQLITE_MALLOCSIZE |
| 15230 | #endif |
| @@ -24970,11 +24972,11 @@ | |
| 24972 | sqlite3_io_methods const *pMethod; /* Always the first entry */ |
| 24973 | sqlite3_vfs *pVfs; /* The VFS that created this unixFile */ |
| 24974 | unixInodeInfo *pInode; /* Info about locks on this inode */ |
| 24975 | int h; /* The file descriptor */ |
| 24976 | unsigned char eFileLock; /* The type of lock held on this fd */ |
| 24977 | unsigned short int ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ |
| 24978 | int lastErrno; /* The unix errno from last I/O error */ |
| 24979 | void *lockingContext; /* Locking style specific state */ |
| 24980 | UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ |
| 24981 | const char *zPath; /* Name of the file */ |
| 24982 | unixShm *pShm; /* Shared memory segment information */ |
| @@ -25021,10 +25023,11 @@ | |
| 25023 | #endif |
| 25024 | #define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ |
| 25025 | #define UNIXFILE_DELETE 0x20 /* Delete on close */ |
| 25026 | #define UNIXFILE_URI 0x40 /* Filename might have query parameters */ |
| 25027 | #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */ |
| 25028 | #define UNIXFILE_CHOWN 0x100 /* File ownership was changed */ |
| 25029 | |
| 25030 | /* |
| 25031 | ** Include code that is common to all os_*.c files |
| 25032 | */ |
| 25033 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| @@ -28868,14 +28871,23 @@ | |
| 28871 | openFlags = O_RDONLY; |
| 28872 | pShmNode->isReadonly = 1; |
| 28873 | } |
| 28874 | pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777)); |
| 28875 | if( pShmNode->h<0 ){ |
| 28876 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShmFilename); |
| 28877 | goto shm_open_err; |
| 28878 | } |
| 28879 | |
| 28880 | /* If this process is running as root, make sure that the SHM file |
| 28881 | ** is owned by the same user that owns the original database. Otherwise, |
| 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. |
| 28893 | */ |
| @@ -29865,14 +29877,18 @@ | |
| 29877 | ** the default permissions. |
| 29878 | */ |
| 29879 | static int findCreateFileMode( |
| 29880 | const char *zPath, /* Path of file (possibly) being created */ |
| 29881 | int flags, /* Flags passed as 4th argument to xOpen() */ |
| 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 */ |
| 29893 | struct stat sStat; /* Output of stat() on database file */ |
| 29894 | |
| @@ -29902,10 +29918,12 @@ | |
| 29918 | memcpy(zDb, zPath, nDb); |
| 29919 | zDb[nDb] = '\0'; |
| 29920 | |
| 29921 | if( 0==osStat(zDb, &sStat) ){ |
| 29922 | *pMode = sStat.st_mode & 0777; |
| 29923 | *pUid = sStat.st_uid; |
| 29924 | *pGid = sStat.st_gid; |
| 29925 | }else{ |
| 29926 | rc = SQLITE_IOERR_FSTAT; |
| 29927 | } |
| 29928 | }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ |
| 29929 | *pMode = 0600; |
| @@ -30048,11 +30066,13 @@ | |
| 30066 | if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); |
| 30067 | openFlags |= (O_LARGEFILE|O_BINARY); |
| 30068 | |
| 30069 | if( fd<0 ){ |
| 30070 | mode_t openMode; /* Permissions to create file with */ |
| 30071 | uid_t uid; /* Userid for the file */ |
| 30072 | gid_t gid; /* Groupid for the file */ |
| 30073 | rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid); |
| 30074 | if( rc!=SQLITE_OK ){ |
| 30075 | assert( !p->pUnused ); |
| 30076 | assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL ); |
| 30077 | return rc; |
| 30078 | } |
| @@ -30069,10 +30089,21 @@ | |
| 30089 | } |
| 30090 | if( fd<0 ){ |
| 30091 | rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); |
| 30092 | goto open_finished; |
| 30093 | } |
| 30094 | |
| 30095 | /* If this process is running as root and if creating a new rollback |
| 30096 | ** journal or WAL file, set the ownership of the journal or WAL to be |
| 30097 | ** the same as the original database. If we are not running as root, |
| 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; |
| 30109 | } |
| @@ -30380,11 +30411,11 @@ | |
| 30411 | ** tests repeatable. |
| 30412 | */ |
| 30413 | memset(zBuf, 0, nBuf); |
| 30414 | #if !defined(SQLITE_TEST) |
| 30415 | { |
| 30416 | int pid, fd, got; |
| 30417 | fd = robust_open("/dev/urandom", O_RDONLY, 0); |
| 30418 | if( fd<0 ){ |
| 30419 | time_t t; |
| 30420 | time(&t); |
| 30421 | memcpy(zBuf, &t, sizeof(t)); |
| @@ -30391,11 +30422,11 @@ | |
| 30422 | pid = getpid(); |
| 30423 | memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid)); |
| 30424 | assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf ); |
| 30425 | nBuf = sizeof(t) + sizeof(pid); |
| 30426 | }else{ |
| 30427 | do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR ); |
| 30428 | robust_close(0, fd, __LINE__); |
| 30429 | } |
| 30430 | } |
| 30431 | #endif |
| 30432 | return nBuf; |
| @@ -58636,12 +58667,18 @@ | |
| 58667 | ** the second condition under the assumption that addition overflow causes |
| 58668 | ** values to wrap around. On x86 hardware, the third term is always |
| 58669 | ** true and could be omitted. But we leave it in because other |
| 58670 | ** architectures might behave differently. |
| 58671 | */ |
| 58672 | if( pMem->r==(double)pMem->u.i |
| 58673 | && pMem->u.i>SMALLEST_INT64 |
| 58674 | #if defined(__i486__) || defined(__x86_64__) |
| 58675 | && ALWAYS(pMem->u.i<LARGEST_INT64) |
| 58676 | #else |
| 58677 | && pMem->u.i<LARGEST_INT64 |
| 58678 | #endif |
| 58679 | ){ |
| 58680 | pMem->flags |= MEM_Int; |
| 58681 | } |
| 58682 | } |
| 58683 | |
| 58684 | /* |
| @@ -86423,11 +86460,11 @@ | |
| 86460 | ** in a way that is testable, mask the sign bit off of negative |
| 86461 | ** values, resulting in a positive value. Then take the |
| 86462 | ** 2s complement of that positive value. The end result can |
| 86463 | ** therefore be no less than -9223372036854775807. |
| 86464 | */ |
| 86465 | r = -(r & LARGEST_INT64); |
| 86466 | } |
| 86467 | sqlite3_result_int64(context, r); |
| 86468 | } |
| 86469 | |
| 86470 | /* |
| 86471 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.11" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007011 |
| 112 | -#define SQLITE_SOURCE_ID "2012-02-07 14:13:50 9497893b1b9219eac4ec2183bd90b4e4b860d9fe" | |
| 112 | +#define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 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-07 14:13:50 9497893b1b9219eac4ec2183bd90b4e4b860d9fe" |
| 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-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |