modernc.org/sqlite re-parses the SQL text on every statement execution,
so the prepared statement in PutMany gave no benefit and parsing
accounted for about half of the time spent per record. Writing 50
records per INSERT ... ON CONFLICT DO UPDATE statement amortizes that
cost: the per-record time in BenchmarkPutManyPreparedStmt dropped from
roughly 100 µs to 50 µs on the same machine.
PutMany is used for the intel filter list import and for the resolver's
delayed cache flushes. Importing a filter list base update is now roughly
twice as fast on the database side.
Stored data is unchanged, including NULL format and value for records
without data. Duplicate keys within one statement resolve to the last
write, as before. A failed prepare now rolls the transaction back
instead of leaving it open.
The new test covers full and partial statements and re-writing existing
keys, for both the batched and the single-row PutMany path.
TestMigrationTimezoneRoundTrip intentionally mutates time.Local to simulate
a non-UTC fixed-offset zone. Suppress gosmopolitan on each time.Local usage
and paralleltest on the function, since parallel execution would race on the
global variable.
Without an explicit time format, modernc.org/sqlite stores time.Time values
using Go's t.String(), which includes a timezone abbreviation (e.g. "UTC+2"
on Windows fixed-offset zones). On read, the driver's time parser uses the
"MST" format verb which only matches alphabetic characters, so abbreviations
containing digits fail silently and the value is returned as a raw string.
database/sql then crashes trying to scan that string into *time.Time when
sql-migrate reads the gorp_migrations table on every startup after the first.
Setting _time_format=sqlite writes timestamps as "YYYY-MM-DD HH:MM:SS±HH:MM"
(no abbreviation, numeric offset only), which is always parsed back correctly.
Fixes https://github.com/safing/portmaster/issues/2191