Search code examples
jsonsqliteerror-handlingsyntax-error

How can I find with what extensions has my copy of sqlite been built?


I have a script involving sqlite3 which runs fine on one system but malfunctions on a different system, complaining about the SQL syntax. The syntax relies on the sqlite JSON extension, so I suspect the malfunctioning sqlite has just not been compiled with support for this extension. (It comes from the linux distribution; if I really have to I'll hunt down the package source.) How can I confirm or deny this hunch? sqlite3 -version doesn't provide this information, unfortunately.

Bonus question: It seems sqlite exits with status 0 even after it complains after these errors! This has caused me to lose a bunch of data (because the script merrily proceeded to its cleanup stage). Isn't this a bug?


Solution

  • The JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22).

    They can be omitted by adding the -DSQLITE_OMIT_JSON compile-time option. Prior to version 3.38.0, the JSON functions were an extension that would only be included in builds if the -DSQLITE_ENABLE_JSON1 compile-time option was included. In other words, the JSON functions went from being opt-in with SQLite version 3.37.2 and earlier to opt-out with SQLite version 3.38.0 and later.