diff options
author | drh <drh@noemail.net> | 2011-10-12 23:13:43 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2011-10-12 23:13:43 +0000 |
commit | 3170225f197cbd15a9ecadb7ed9631445b2b74c0 (patch) | |
tree | 78fba0d17a736b822af489bac75b79649167d414 /src/os_unix.c | |
parent | c3c8dac7419ee34dfcd31e60c30d86a8ea195199 (diff) | |
download | sqlite-3170225f197cbd15a9ecadb7ed9631445b2b74c0.tar.gz sqlite-3170225f197cbd15a9ecadb7ed9631445b2b74c0.zip |
The date/time functions return NULL if the xCurrentTime or
xCurrentTimeInt64 VFS methods fail.
Ticket [0b803bff856c644c]
FossilOrigin-Name: c96651dd6ceadd51c9e1f4d942177d3c128c47b4
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 6e87a4bfd..7e0a7e840 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5428,10 +5428,12 @@ int sqlite3_current_time = 0; /* Fake system time in seconds since 1970. */ ** epoch of noon in Greenwich on November 24, 4714 B.C according to the ** proleptic Gregorian calendar. ** -** On success, return 0. Return 1 if the time and date cannot be found. +** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date +** cannot be found. */ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; + int rc = SQLITE_OK; #if defined(NO_GETTOD) time_t t; time(&t); @@ -5442,8 +5444,11 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000; #else struct timeval sNow; - gettimeofday(&sNow, 0); - *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; + if( gettimeofday(&sNow, 0)==0 ){ + *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; + }else{ + rc = SQLITE_ERROR; + } #endif #ifdef SQLITE_TEST @@ -5452,7 +5457,7 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ } #endif UNUSED_PARAMETER(NotUsed); - return 0; + return rc; } /* @@ -5462,10 +5467,11 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ */ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){ sqlite3_int64 i; + int rc; UNUSED_PARAMETER(NotUsed); - unixCurrentTimeInt64(0, &i); + rc = unixCurrentTimeInt64(0, &i); *prNow = i/86400000.0; - return 0; + return rc; } /* |