Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
The SQLite now argument is stable within the same query#
I stumbled across an interesting little detail of SQLite today, running the following query:
1select strftime('%s','now') || substr(strftime('%f','now'),4) as t12union all3select strftime('%s','now') || substr(strftime('%f','now'),4)4union all5select strftime('%s','now') || substr(strftime('%f','now'),4)6union all7select strftime('%s','now') || substr(strftime('%f','now'),4)8union all9select strftime('%s','now') || substr(strftime('%f','now'),4)10union all11select strftime('%s','now') || substr(strftime('%f','now'),4)That strftime() pattern is described here and in this TIL, it returns the current Unix timestamp in milliseconds.
The result of the above query is:
| t1 |
|---|
| 1675631847614 |
| 1675631847614 |
| 1675631847614 |
| 1675631847614 |
| 1675631847614 |
| 1675631847614 |
I was expecting each timestamp to differ by a few milliseconds, but they’re all the same.
I spotted why in the SQLite Date and Time Functions documentation:
The ‘now’ argument to date and time functions always returns exactly the same value for multiple invocations within the same sqlite3_step() call.
Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.