Add more system calls to the set that can be overridden in os_unix.c.

Also merge in recent fixes from trunk.

FossilOrigin-Name: 80fac2a6e07221bb67613af84ab9dda3e18b5ceb
This commit is contained in:
drh 2011-03-02 18:01:10 +00:00
commit e562be52cf
5 changed files with 111 additions and 34 deletions

View File

@ -3133,7 +3133,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
int jj;
nodeGetCell(&tree, &node, ii, &cell);
sqlite3_snprintf(512-nCell,&zCell[nCell],"%d", cell.iRowid);
sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
nCell = strlen(zCell);
for(jj=0; jj<tree.nDim*2; jj++){
sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);

34
ext/rtree/rtreeB.test Normal file
View File

@ -0,0 +1,34 @@
# 2011 March 2
#
# 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.
#
#***********************************************************************
# Make sure the rtreenode() testing function can handle entries with
# 64-bit rowids.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
ifcapable !rtree { finish_test ; return }
do_test rtreeB-1.1 {
db eval {
CREATE VIRTUAL TABLE t1 USING rtree(ii, x0, y0, x1, y1);
INSERT INTO t1 VALUES(1073741824, 0.0, 0.0, 100.0, 100.0);
INSERT INTO t1 VALUES(2147483646, 0.0, 0.0, 200.0, 200.0);
INSERT INTO t1 VALUES(4294967296, 0.0, 0.0, 300.0, 300.0);
INSERT INTO t1 VALUES(8589934592, 20.0, 20.0, 150.0, 150.0);
INSERT INTO t1 VALUES(9223372036854775807, 150, 150, 400, 400);
SELECT rtreenode(2, data) FROM t1_node;
}
} {{1073741824 0.000000 0.000000 100.000000 100.000000} {2147483646 0.000000 0.000000 200.000000 200.000000} {4294967296 0.000000 0.000000 300.000000 300.000000} {8589934592 20.000000 20.000000 150.000000 150.000000} {9223372036854775807 150.000000 150.000000 400.000000 400.000000}}
finish_test

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Proof-of-concept\sprototype\sfor\sthe\sproposed\sxSetSystemCall\sextension\smethod\non\sthe\sVFS.
D 2011-03-02T15:09:07.461
C Add\smore\ssystem\scalls\sto\sthe\sset\sthat\scan\sbe\soverridden\sin\sos_unix.c.\nAlso\smerge\sin\srecent\sfixes\sfrom\strunk.
D 2011-03-02T18:01:10.609
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -84,7 +84,7 @@ F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2
F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
F ext/rtree/rtree.c 05b293c85403cf39bb5af0e7c010b0cafeab5e47
F ext/rtree/rtree.c 115b499415ddef9be75615ced99b11232826e64d
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
F ext/rtree/rtree1.test dbd4250ac0ad367a262eb9676f7e3080b0368206
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
@ -96,6 +96,7 @@ F ext/rtree/rtree7.test bcb647b42920b3b5d025846689147778485cc318
F ext/rtree/rtree8.test 9772e16da71e17e02bdebf0a5188590f289ab37d
F ext/rtree/rtree9.test df9843d1a9195249c8d3b4ea6aedda2d5c73e9c2
F ext/rtree/rtreeA.test ace05e729a36e342d40cf94e9efc7b4723d9dcdf
F ext/rtree/rtreeB.test cd45c955cd35a325545671723255f71f2ae9c2e7
F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195
F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0
@ -164,7 +165,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
F src/os_os2.c 2e452c9f2ca507623ad351c33a8a8b27849b1863
F src/os_unix.c 34f0341ab45ba2708714c8e3f7bd35c7ccb5e34d
F src/os_unix.c a13aa2394c337a51f818b33e8abb5922bcd25cbb
F src/os_win.c c2df806a8510ec8c2c2c30fb78b3a25bc1b2f325
F src/pager.c 6aa906b60a59664ba58d3f746164bb010d407ce1
F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1
@ -912,18 +913,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 7b6e30e6a712311d4ef275253b085b85e6e17116
R b432d469c6ed4dca97f566fa093fcbff
T *bgcolor * #a8d3c0
T *branch * syscall-override
T *sym-syscall-override *
T -sym-trunk *
P 92b5a76abc53290e1bb87b6b55bc64bb1b331dfc ec55e8c6bb4f2419b3813aa2fd1a20d8f5016159
R 3565d6dc7b759fbd44b8dfd37d76ad07
U drh
Z 9b09403dc20dd3b2e37d470a4feaa93c
Z d880c71a14ae5250c2798782141ecbce
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFNbl2aoxKgR168RlERAnuDAJ9BNtRHzGqMMOlHR9sjdCvks/uYWQCgiUgt
CkJFrHO5mCcgtbaMpvVY+k0=
=K2zl
iD8DBQFNboXpoxKgR168RlERAi5qAJ48oWmqxPjfRV4pFj4iAbQCs6u9fQCeNLi2
M/sSIPhA4/GCd6qHTyrGyKQ=
=Ttvh
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
92b5a76abc53290e1bb87b6b55bc64bb1b331dfc
80fac2a6e07221bb67613af84ab9dda3e18b5ceb

View File

@ -323,9 +323,56 @@ static struct unix_syscall {
{ "ftruncate", (void*)ftruncate, 0 },
#define osFtruncate ((int(*)(int,off_t))aSyscall[6].pCurrent)
{ "fcntl", (void*)fcntl, 0 },
{ "fcntl", (void*)fcntl, 0 },
#define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
};
{ "read", (void*)read, 0 },
#define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
#if defined(USE_PREAD) || defined(SQLITE_ENABLE_LOCKING_STYLE)
{ "pread", (void*)pread, 0 },
#else
{ "pread", (void*)0, 0 },
#endif
#define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
#if defined(USE_PREAD64)
{ "pread64", (void*)pread64, 0 },
#else
{ "pread64", (void*)0, 0 },
#endif
#define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)
{ "write", (void*)write, 0 },
#define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
#if defined(USE_PREAD) || defined(SQLITE_ENABLE_LOCKING_STYLE)
{ "pwrite", (void*)pwrite, 0 },
#else
{ "pwrite", (void*)0, 0 },
#endif
#define osPwrite ((ssize_t(*)(int,const void*,size_t,off_t))\
aSyscall[12].pCurrent)
#if defined(USE_PREAD64)
{ "pwrite64", (void*)pwrite64, 0 },
#else
{ "pwrite64", (void*)0, 0 },
#endif
#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\
aSyscall[13].pCurrent)
{ "fchmod", (void*)fchmod, 0 },
#define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
{ "fallocate", (void*)posix_fallocate, 0 },
#else
{ "fallocate", (void*)0, 0 },
#endif
#define osFallocate ((int(*)(int,off_t,off_t)aSyscall[15].pCurrent)
}; /* End of the overrideable system calls */
/*
** This is the xSetSystemCall() method of sqlite3_vfs for all of the
@ -1011,7 +1058,7 @@ static int findInodeInfo(
** the first page of the database, no damage is done.
*/
if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){
do{ rc = write(fd, "S", 1); }while( rc<0 && errno==EINTR );
do{ rc = osWrite(fd, "S", 1); }while( rc<0 && errno==EINTR );
if( rc!=1 ){
pFile->lastErrno = errno;
return SQLITE_IOERR;
@ -2783,10 +2830,10 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
#endif
TIMER_START;
#if defined(USE_PREAD)
do{ got = pread(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
do{ got = osPread(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
SimulateIOError( got = -1 );
#elif defined(USE_PREAD64)
do{ got = pread64(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
do{ got = osPread64(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR);
SimulateIOError( got = -1 );
#else
newOffset = lseek(id->h, offset, SEEK_SET);
@ -2799,7 +2846,7 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
}
return -1;
}
do{ got = read(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
do{ got = osRead(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
#endif
TIMER_END;
if( got<0 ){
@ -2861,9 +2908,9 @@ static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){
#endif
TIMER_START;
#if defined(USE_PREAD)
do{ got = pwrite(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
do{ got = osPwrite(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
#elif defined(USE_PREAD64)
do{ got = pwrite64(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
do{ got = osPwrite64(id->h, pBuf, cnt, offset);}while( got<0 && errno==EINTR);
#else
newOffset = lseek(id->h, offset, SEEK_SET);
if( newOffset!=offset ){
@ -2874,7 +2921,7 @@ static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){
}
return -1;
}
do{ got = write(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
do{ got = osWrite(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );
#endif
TIMER_END;
if( got<0 ){
@ -3237,7 +3284,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
int rc;
do{
rc = posix_fallocate(pFile-.h, buf.st_size, nSize-buf.st_size;
rc = osFallocate(pFile->.h, buf.st_size, nSize-buf.st_size;
}while( rc<0 && errno=EINTR );
if( rc ) return SQLITE_IOERR_WRITE;
#else
@ -5115,7 +5162,7 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf );
nBuf = sizeof(t) + sizeof(pid);
}else{
do{ nBuf = read(fd, zBuf, nBuf); }while( nBuf<0 && errno==EINTR );
do{ nBuf = osRead(fd, zBuf, nBuf); }while( nBuf<0 && errno==EINTR );
robust_close(0, fd, __LINE__);
}
}
@ -5638,7 +5685,7 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){
goto end_breaklock;
}
/* read the conch content */
readLen = pread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);
readLen = osPread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);
if( readLen<PROXY_PATHINDEX ){
sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
goto end_breaklock;
@ -5649,7 +5696,7 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){
sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
goto end_breaklock;
}
if( pwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
sqlite3_snprintf(sizeof(errmsg), errmsg, "write failed (%d)", errno);
goto end_breaklock;
}
@ -5714,7 +5761,7 @@ static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
if( nTries==2 ){
char tBuf[PROXY_MAXCONCHLEN];
int len = pread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);
int len = osPread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);
if( len<0 ){
pFile->lastErrno = errno;
return SQLITE_IOERR_LOCK;
@ -5884,17 +5931,16 @@ static int proxyTakeConch(unixFile *pFile){
*/
if( rc==SQLITE_OK && createConch ){
struct stat buf;
int rc;
int err = osFstat(pFile->h, &buf);
if( err==0 ){
mode_t cmode = buf.st_mode&(S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP |
S_IROTH|S_IWOTH);
/* try to match the database file R/W permissions, ignore failure */
#ifndef SQLITE_PROXY_DEBUG
fchmod(conchFile->h, cmode);
osFchmod(conchFile->h, cmode);
#else
do{
rc = fchmod(conchFile->h, cmode);
rc = osFchmod(conchFile->h, cmode);
}while( rc==(-1) && errno==EINTR );
if( rc!=0 ){
int code = errno;
@ -5917,7 +5963,7 @@ static int proxyTakeConch(unixFile *pFile){
OSTRACE(("TRANSPROXY: CLOSE %d\n", pFile->h));
if( rc==SQLITE_OK && pFile->openFlags ){
if( pFile->h>=0 ){
robust_close(pFile, pFile->h, __LINE__) ){
robust_close(pFile, pFile->h, __LINE__);
}
pFile->h = -1;
int fd = osOpen(pCtx->dbPath, pFile->openFlags,