aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2006-09-15 07:28:50 +0000
committerdrh <drh@noemail.net>2006-09-15 07:28:50 +0000
commit4ac285a1c241a792cd5e650bd3edc093432d3de4 (patch)
tree84c0074e297df167a2802af7b34de0a5e589e8b9 /src/os_unix.c
parent8abc58e33b57915a155c9d0569371363f96d8b33 (diff)
downloadsqlite-4ac285a1c241a792cd5e650bd3edc093432d3de4.tar.gz
sqlite-4ac285a1c241a792cd5e650bd3edc093432d3de4.zip
Add support for extended result codes - additional result information
carried in the higher bits of the integer return codes. This must be enabled using the sqlite3_extended_result_code() API. Only a few extra result codes are currently defined. (CVS 3422) FossilOrigin-Name: ba579ddc4361fc6e8ea66f9385770d70dfe94751
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index ed810d6df..ada697463 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -937,8 +937,10 @@ static int unixRead(OsFile *id, void *pBuf, int amt){
SimulateIOError( got=0 );
if( got==amt ){
return SQLITE_OK;
+ }else if( got<0 ){
+ return SQLITE_IOERR_READ;
}else{
- return SQLITE_IOERR;
+ return SQLITE_IOERR_SHORT_READ;
}
}
@@ -982,7 +984,7 @@ static int unixWrite(OsFile *id, const void *pBuf, int amt){
SimulateDiskfullError(( wrote=0, amt=1 ));
if( amt>0 ){
if( wrote<0 ){
- return SQLITE_IOERR;
+ return SQLITE_IOERR_WRITE;
}else{
return SQLITE_FULL;
}
@@ -1065,19 +1067,13 @@ static int full_fsync(int fd, int fullSync, int dataOnly){
#if HAVE_FULLFSYNC
if( fullSync ){
rc = fcntl(fd, F_FULLFSYNC, 0);
- }else{
- rc = 1;
- }
- /* If the FULLSYNC failed, try to do a normal fsync() */
- if( rc ) rc = fsync(fd);
-
-#else /* if !defined(F_FULLSYNC) */
+ }else
+#endif /* HAVE_FULLFSYNC */
if( dataOnly ){
rc = fdatasync(fd);
}else{
rc = fsync(fd);
}
-#endif /* defined(F_FULLFSYNC) */
#endif /* defined(SQLITE_NO_SYNC) */
return rc;
@@ -1106,7 +1102,7 @@ static int unixSync(OsFile *id, int dataOnly){
rc = full_fsync(pFile->h, pFile->fullSync, dataOnly);
SimulateIOError( rc=1 );
if( rc ){
- return SQLITE_IOERR;
+ return SQLITE_IOERR_FSYNC;
}
if( pFile->dirfd>=0 ){
TRACE4("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
@@ -1155,7 +1151,7 @@ int sqlite3UnixSyncDirectory(const char *zDirname){
close(fd);
SimulateIOError( r=1 );
if( r ){
- return SQLITE_IOERR;
+ return SQLITE_IOERR_DIR_FSYNC;
}else{
return SQLITE_OK;
}
@@ -1171,7 +1167,7 @@ static int unixTruncate(OsFile *id, i64 nByte){
rc = ftruncate(((unixFile*)id)->h, nByte);
SimulateIOError( rc=1 );
if( rc ){
- return SQLITE_IOERR;
+ return SQLITE_IOERR_TRUNCATE;
}else{
return SQLITE_OK;
}
@@ -1187,7 +1183,7 @@ static int unixFileSize(OsFile *id, i64 *pSize){
rc = fstat(((unixFile*)id)->h, &buf);
SimulateIOError( rc=1 );
if( rc!=0 ){
- return SQLITE_IOERR;
+ return SQLITE_IOERR_FSTAT;
}
*pSize = buf.st_size;
return SQLITE_OK;
@@ -1397,7 +1393,7 @@ static int unixLock(OsFile *id, int locktype){
lock.l_len = 1L;
lock.l_type = F_UNLCK;
if( fcntl(pFile->h, F_SETLK, &lock)!=0 ){
- rc = SQLITE_IOERR; /* This should never happen */
+ rc = SQLITE_IOERR_UNLOCK; /* This should never happen */
goto end_lock;
}
if( s ){
@@ -1486,7 +1482,7 @@ static int unixUnlock(OsFile *id, int locktype){
lock.l_len = SHARED_SIZE;
if( fcntl(pFile->h, F_SETLK, &lock)!=0 ){
/* This should never happen */
- rc = SQLITE_IOERR;
+ rc = SQLITE_IOERR_RDLOCK;
}
}
lock.l_type = F_UNLCK;
@@ -1496,7 +1492,7 @@ static int unixUnlock(OsFile *id, int locktype){
if( fcntl(pFile->h, F_SETLK, &lock)==0 ){
pLock->locktype = SHARED_LOCK;
}else{
- rc = SQLITE_IOERR; /* This should never happen */
+ rc = SQLITE_IOERR_UNLOCK; /* This should never happen */
}
}
if( locktype==NO_LOCK ){
@@ -1514,7 +1510,7 @@ static int unixUnlock(OsFile *id, int locktype){
if( fcntl(pFile->h, F_SETLK, &lock)==0 ){
pLock->locktype = NO_LOCK;
}else{
- rc = SQLITE_IOERR; /* This should never happen */
+ rc = SQLITE_IOERR_UNLOCK; /* This should never happen */
}
}