>BTW, is ‘now’ value locked during the query execution to avoid the
>possibility (however small) of two columns ending up with different
>age calculations (e.g., running during date crossover on someone’s
>birthday)?

By default, 'now' is step stable (that is, it will return the same value for 
all usage within the same step of a statement) -- ie, for each row.  

You can make it statement stable with a small patch to sqlite3VdbeExec and 
compiling with -DSQLITE_NOW_STABILITY_STMT.  This will cause the 
p->iCurrentTime to be reset ONLY when step 0 of the VDBE program is executed, 
rather than on each step.

  assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY );
  assert( p->bIsReader || p->readOnly!=0 );
#ifdef SQLITE_NOW_STABILITY_STMT        /* INSERT */
  if (p->pc == 0)                               /* INSERT */
#endif                                          /* INSERT */
  p->iCurrentTime = 0;

I believe that since the addition of the SLOCHG option the value of 'now' is 
statement stable by default (ie, it is deterministic for the purposes of 
indexes but not for the query planner), however I still have the above 
suspenders in place just to be sure it is statement stable.

Since the time is cached in the VDBE it can only be made statement stable (all 
steps in the same statement), not transaction stable (all statements in the 
same transaction).  You would have to write your own User-Defined-Function that 
attaches to the commit/rollback hooks to have the 'now' be transaction stable 
if that was required.





_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to