SQLite

Check-in [3ac1f6a3cf]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the "now" option for date-time functions for cases when STAT4 is disabled.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3ac1f6a3cf1a8fd3ab1ca96b2564c13c4b8d2234
User & Date: drh 2015-03-12 23:48:27.096
Context
2015-03-13
00:11
Remove debugging logic accidently included in the previous check-in. (check-in: 2887fb38ff user: drh tags: trunk)
2015-03-12
23:48
Fix the "now" option for date-time functions for cases when STAT4 is disabled. (check-in: 3ac1f6a3cf user: drh tags: trunk)
21:22
When STAT4 is enabled, allow probes of the STAT4 table using the value of constant functions computed at compile-time. (check-in: 0f250957cd user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbeapi.c.
637
638
639
640
641
642
643
644
645
646
647
648

649
650
651
652

653
654
655
656
657
658
659
** is requested more than once within the same run of a single prepared
** statement, the exact 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 sqlite3StmtCurrentTime(sqlite3_context *p){
  int rc;
  sqlite3_int64 iTime = 0;
#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
  sqlite3_int64 *piTime = &iTime;
  assert( p->pVdbe!=0 );
#else

  sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
  if( *piTime==0 )
#endif
  {

    rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
    if( rc ) *piTime = 0;
  }
  return *piTime;
}

/*







<

|


>

<

<
>







637
638
639
640
641
642
643

644
645
646
647
648
649

650

651
652
653
654
655
656
657
658
** is requested more than once within the same run of a single prepared
** statement, the exact 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 sqlite3StmtCurrentTime(sqlite3_context *p){
  int rc;

#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
  sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
  assert( p->pVdbe!=0 );
#else
  sqlite3_int64 iTime = 0;
  sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;

#endif

  if( *piTime==0 ){
    rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
    if( rc ) *piTime = 0;
  }
  return *piTime;
}

/*
Changes to test/date.test.
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
# functions always returns exactly the same value for multiple
# invocations within the same sqlite3_step() call.
#
proc sleeper {} {after 100}
do_test date-15.1 {
  db func sleeper sleeper
  db eval {
     SELECT c - a FROM (SELECT julianday('now') AS a,
                               sleeper(), julianday('now') AS c);
  }
} {0.0}
do_test date-15.2 {
  db eval {
     SELECT a==b FROM (SELECT current_timestamp AS a,
                               sleeper(), current_timestamp AS b);







|







536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
# functions always returns exactly the same value for multiple
# invocations within the same sqlite3_step() call.
#
proc sleeper {} {after 100}
do_test date-15.1 {
  db func sleeper sleeper
  db eval {
     SELECT c, a, c - a FROM (SELECT julianday('now') AS a,
                               sleeper(), julianday('now') AS c);
  }
} {0.0}
do_test date-15.2 {
  db eval {
     SELECT a==b FROM (SELECT current_timestamp AS a,
                               sleeper(), current_timestamp AS b);