diff options
author | drh <> | 2023-02-07 21:55:14 +0000 |
---|---|---|
committer | drh <> | 2023-02-07 21:55:14 +0000 |
commit | d4af882a1bebbefa02cb40ba85b78c82d1deebd9 (patch) | |
tree | 601fa788e8c334f3153b5f7fd7fc227eb08f7517 /src/vdbeapi.c | |
parent | c3ea539dc21f193c277851ab44109aef8de8a15d (diff) | |
download | sqlite-d4af882a1bebbefa02cb40ba85b78c82d1deebd9.tar.gz sqlite-d4af882a1bebbefa02cb40ba85b78c82d1deebd9.zip |
Add support for the 'txn' argument to date/time functions that works like
'now' but keeps the same time for the entire transaction.
FossilOrigin-Name: 5e4f45af96247e29910403a63ac148cb313b005f9c014b37a9a49d98f5fef9a6
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r-- | src/vdbeapi.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 476b6a2ad..432c1fa22 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -988,6 +988,29 @@ sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){ } /* +** Return the current time for a transaction. If the current time +** is requested more than once within the same transaction +** the same time is returned for each invocation regardless +** of the amount of time that elapses between invocations. In other words, +** the time returned is always the time of the first call. +*/ +sqlite3_int64 sqlite3TxnCurrentTime(sqlite3_context *p){ + int rc; +#ifndef SQLITE_ENABLE_STAT4 + sqlite3_int64 *piTime = &p->pVdbe->db->txnTime; + assert( p->pVdbe!=0 ); +#else + sqlite3_int64 iTime = 0; + sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->db->txnTime : &iTime; +#endif + if( *piTime==0 ){ + rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime); + if( rc ) *piTime = 0; + } + return *piTime; +} + +/* ** Create a new aggregate context for p and return a pointer to ** its pMem->z element. */ |