Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use VFS method xCurrentTimeInt64 instead of xCurrentTime when it is available. Provide an implementation of xCurrentTimeInt64 for os_unix.c. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ab77b3ae6da3370d8bc3b2c9c0edc723 |
User & Date: | drh 2010-05-03 14:32:30.000 |
Context
2010-05-03
| ||
15:58 | Have sqlite3_wal_checkpoint() handle a zero-length string in the same way as a NULL pointer. Fix "PRAGMA wal_checkpoint" so that it checkpoints all attached databases. (check-in: 7fecd21f45 user: dan tags: trunk) | |
14:32 | Use VFS method xCurrentTimeInt64 instead of xCurrentTime when it is available. Provide an implementation of xCurrentTimeInt64 for os_unix.c. (check-in: ab77b3ae6d user: drh tags: trunk) | |
14:08 | Merge the write-ahead-logging changes into the trunk. (check-in: de9ae443cc user: drh tags: trunk) | |
Changes
Changes to src/date.c.
︙ | ︙ | |||
310 311 312 313 314 315 316 | return 0; } /* ** Set the time to the current time reported by the VFS */ static void setDateTimeToCurrent(sqlite3_context *context, DateTime *p){ | < | < | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | return 0; } /* ** Set the time to the current time reported by the VFS */ static void setDateTimeToCurrent(sqlite3_context *context, DateTime *p){ sqlite3 *db = sqlite3_context_db_handle(context); sqlite3OsCurrentTimeInt64(db->pVfs, &p->iJD); p->validJD = 1; } /* ** Attempt to parse the given string into a Julian Day Number. Return ** the number of errors. ** |
︙ | ︙ | |||
1034 1035 1036 1037 1038 1039 1040 | sqlite3_context *context, int argc, sqlite3_value **argv ){ time_t t; char *zFormat = (char *)sqlite3_user_data(context); sqlite3 *db; | | | < | < < < < < < | 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 | sqlite3_context *context, int argc, sqlite3_value **argv ){ time_t t; char *zFormat = (char *)sqlite3_user_data(context); sqlite3 *db; sqlite3_int64 iT; char zBuf[20]; UNUSED_PARAMETER(argc); UNUSED_PARAMETER(argv); db = sqlite3_context_db_handle(context); sqlite3OsCurrentTimeInt64(db->pVfs, &iT); t = (iT - 100*(sqlite3_int64)244058755)/1000; #ifdef HAVE_GMTIME_R { struct tm sNow; gmtime_r(&t, &sNow); strftime(zBuf, 20, zFormat, &sNow); } #else |
︙ | ︙ |
Changes to src/os.c.
︙ | ︙ | |||
157 158 159 160 161 162 163 | #endif /* SQLITE_OMIT_LOAD_EXTENSION */ int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ return pVfs->xRandomness(pVfs, nByte, zBufOut); } int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){ return pVfs->xSleep(pVfs, nMicro); } | | > > > > > | > > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | #endif /* SQLITE_OMIT_LOAD_EXTENSION */ int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ return pVfs->xRandomness(pVfs, nByte, zBufOut); } int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){ return pVfs->xSleep(pVfs, nMicro); } int sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){ int rc; if( pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64 ){ rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut); }else{ double r; rc = pVfs->xCurrentTime(pVfs, &r); *pTimeOut = (sqlite3_int64)(r*86400000.0); } return rc; } int sqlite3OsOpenMalloc( sqlite3_vfs *pVfs, const char *zFile, sqlite3_file **ppFile, int flags, |
︙ | ︙ |
Changes to src/os.h.
︙ | ︙ | |||
255 256 257 258 259 260 261 | void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); void sqlite3OsDlError(sqlite3_vfs *, int, char *); void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void); void sqlite3OsDlClose(sqlite3_vfs *, void *); #endif /* SQLITE_OMIT_LOAD_EXTENSION */ int sqlite3OsRandomness(sqlite3_vfs *, int, char *); int sqlite3OsSleep(sqlite3_vfs *, int); | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); void sqlite3OsDlError(sqlite3_vfs *, int, char *); void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void); void sqlite3OsDlClose(sqlite3_vfs *, void *); #endif /* SQLITE_OMIT_LOAD_EXTENSION */ int sqlite3OsRandomness(sqlite3_vfs *, int, char *); int sqlite3OsSleep(sqlite3_vfs *, int); int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*); /* ** Convenience functions for opening and closing files using ** sqlite3_malloc() to obtain space for the file-handle structure. */ int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*); int sqlite3OsCloseFree(sqlite3_file *); |
︙ | ︙ |
Changes to src/os_unix.c.
︙ | ︙ | |||
4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 | ** The following variable, if set to a non-zero value, is interpreted as ** the number of seconds since 1970 and is used to set the result of ** sqlite3OsCurrentTime() during testing. */ #ifdef SQLITE_TEST int sqlite3_current_time = 0; /* Fake system time in seconds since 1970. */ #endif /* ** Find the current time (in Universal Coordinated Time). Write the ** current time and date as a Julian Day number into *prNow and ** return 0. Return 1 if the time and date cannot be found. */ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < | < < < < < < < < < < < < < | < < | < < < | 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 | ** The following variable, if set to a non-zero value, is interpreted as ** the number of seconds since 1970 and is used to set the result of ** sqlite3OsCurrentTime() during testing. */ #ifdef SQLITE_TEST int sqlite3_current_time = 0; /* Fake system time in seconds since 1970. */ #endif /* ** Find the current time (in Universal Coordinated Time). Write into *piNow ** the current time and date as a Julian Day number times 86_400_000. In ** other words, write into *piNow the number of milliseconds since the Julian ** 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. */ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; #if defined(NO_GETTOD) time_t t; time(&t); *piNow = ((sqlite3_int64)i)*1000 + unixEpoch; #elif OS_VXWORKS struct timespec sNow; clock_gettime(CLOCK_REALTIME, &sNow); *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; #endif #ifdef SQLITE_TEST if( sqlite3_current_time ){ *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; } #endif UNUSED_PARAMETER(NotUsed); return 0; } /* ** Find the current time (in Universal Coordinated Time). Write the ** current time and date as a Julian Day number into *prNow and ** return 0. Return 1 if the time and date cannot be found. */ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){ sqlite3_int64 i; unixCurrentTimeInt64(0, &i); *prNow = i*86400000.0; return 0; } /* ** We added the xGetLastError() method with the intention of providing ** better low-level error messages when operating-system problems come up ** during SQLite operation. But so far, none of that has been implemented |
︙ | ︙ | |||
6597 6598 6599 6600 6601 6602 6603 | unixShmOpen, /* xShmOpen */ \ unixShmSize, /* xShmSize */ \ unixShmGet, /* xShmGet */ \ unixShmRelease, /* xShmRelease */ \ unixShmLock, /* xShmLock */ \ unixShmClose, /* xShmClose */ \ 0, /* xRename */ \ | | | 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 | unixShmOpen, /* xShmOpen */ \ unixShmSize, /* xShmSize */ \ unixShmGet, /* xShmGet */ \ unixShmRelease, /* xShmRelease */ \ unixShmLock, /* xShmLock */ \ unixShmClose, /* xShmClose */ \ 0, /* xRename */ \ unixCurrentTimeInt64, /* xCurrentTimeInt64 */ \ } /* ** All default VFSes for unix are contained in the following array. ** ** Note that the sqlite3_vfs.pNext field of the VFS object is modified ** by the SQLite core when the VFS is registered. So the following |
︙ | ︙ |
Changes to src/test_devsym.c.
︙ | ︙ | |||
342 343 344 345 346 347 348 | return sqlite3OsSleep(g.pVfs, nMicro); } /* ** Return the current time as a Julian Day number in *pTimeOut. */ static int devsymCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ | | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | return sqlite3OsSleep(g.pVfs, nMicro); } /* ** Return the current time as a Julian Day number in *pTimeOut. */ static int devsymCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ return g.pVfs->xCurrentTime(g.pVfs, pTimeOut); } static int devsymShmOpen( sqlite3_vfs *pVfs, const char *zName, sqlite3_shm **pp |
︙ | ︙ |
Changes to src/test_journal.c.
︙ | ︙ | |||
797 798 799 800 801 802 803 | return sqlite3OsSleep(g.pVfs, nMicro); } /* ** Return the current time as a Julian Day number in *pTimeOut. */ static int jtCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ | | | 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 | return sqlite3OsSleep(g.pVfs, nMicro); } /* ** Return the current time as a Julian Day number in *pTimeOut. */ static int jtCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ return g.pVfs->xCurrentTime(g.pVfs, pTimeOut); } /************************************************************************** ** Start of public API. */ /* |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
373 374 375 376 377 378 379 | db->u1.isInterrupted = 0; } assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 ); #ifndef SQLITE_OMIT_TRACE if( db->xProfile && !db->init.busy ){ | < | < < < | | < < | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | db->u1.isInterrupted = 0; } assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 ); #ifndef SQLITE_OMIT_TRACE if( db->xProfile && !db->init.busy ){ sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); } #endif db->activeVdbeCnt++; if( p->readOnly==0 ) db->writeVdbeCnt++; p->pc = 0; } #ifndef SQLITE_OMIT_EXPLAIN if( p->explain ){ rc = sqlite3VdbeList(p); }else #endif /* SQLITE_OMIT_EXPLAIN */ { rc = sqlite3VdbeExec(p); } #ifndef SQLITE_OMIT_TRACE /* Invoke the profile callback if there is one */ if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){ sqlite3_int64 iNow; sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); db->xProfile(db->pProfileArg, p->zSql, iNow - p->startTime); } #endif if( rc==SQLITE_DONE ){ assert( p->rc==SQLITE_OK ); p->rc = doWalCallbacks(db); if( p->rc!=SQLITE_OK ){ |
︙ | ︙ |