Skip to content
Commit Detail

Commit ed138c0

Author
Justin Mazzola Paluska <jmp@cloudflare.com> 2025-02-24 08:43:39 -0500
Parents
f7bcdbb
Tree
04ffdf6
sqlite: Parse number part of PragmaSignature: NULL_OR_NUMBER as an int32_t

The [SQLite
documentation](https://www.sqlite.org/pragma.html#pragma_optimize) for
`PRAGMA optimize` says:

> To see all optimizations that would have been done without actually
> doing them, run "PRAGMA optimize(-1)".

We parsed the mask as a `uint` (which makes sense for a mask!), but
that precludes us from parsing negative literals and caused `PRAGMA
optimize(-1)` to fail.  Parsing as an `int32_t` admits this statement.

(I chose to use `int32_t` rather than `int` because SQLite uses a
32-bit integer for the mask.)

Annoyingly, SQLite’s internal `sqlite3GetInt32` function doesn’t allow
you to write a negative number with hex strings, so the best way to
flip (almost) all the bits using hex is using the 0x7fffffff literal.

Files changed

2 files changed~2 modified