mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-29 09:33:48 +00:00
Date functions that use the current time (`date('now')`, `datetime()`,
`strftime('%s')`, `unixepoch('now')`, `julianday('now')`,
`timediff('now', ...)`, date `+`/`-`) called `SystemTime::now()`
directly, so a custom IO's clock had no effect on them. The IO layer
already has `Clock::current_time_wall_clock()` for this. The datetime
functions now take a `&dyn Clock`, and the VDBE passes `pager.io`.
`CURRENT_DATE`, `CURRENT_TIME` and `CURRENT_TIMESTAMP` had the same
problem, and were also computed once when the statement was compiled, so
a prepared statement kept returning the time it was prepared at. They
now compile to runtime calls to `date()`, `time()` and `datetime()`,
like SQLite, so they read the IO clock each time the statement runs.
With an IO whose wall clock returns 1000000000 seconds:
```sql
SELECT datetime('now'), CURRENT_DATE;
-- before: 2026-10-12 13:31:55|2026-10-12
-- after: 2001-09-09 01:46:40|2001-09-09
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fixes #9793
Autofixer wrote this change with Claude Code in an isolated sandbox. A
separate verifier agent tested and reviewed it in its own container
before this PR was opened. A maintainer must review it before merge.
To have Autofixer address review feedback, leave your comments and then
mention @turso-github-handyman; it handles all unanswered comments from
maintainers in one round.
Closes #9797
Limbo Fuzzing
Prerequisites
Ensure you have the following installed:
- Nightly Rust toolchain (required for
cargo-fuzzunless using Nix) cargo-fuzz(install it usingcargo install cargo-fuzz)- Nix (if using a
flake.nixsetup)
Using Nix
nix develop .#fuzz
This will set up the required environment with the nightly toolchain and dependencies.
Running the Fuzzer
If using Nix:
cargo fuzz run <fuzz_target>
If using rustup without Nix:
cargo +nightly fuzz run <fuzz_target>
This will compile the fuzz target and start fuzzing with libFuzzer.
Example
Run the expression target with:
cargo fuzz run expression