SQLITE_FORMAT
SQLiteINFOCommonInternalofficial confidence

Auxiliary database format error (not used)

Production Risk

None — not returned by SQLite.

What this means

SQLITE_FORMAT (24) was historically used for auxiliary database (ATTACH) format errors but is no longer returned by any SQLite API. The code is kept for backwards compatibility.

Why it happens
  1. 1Not returned by modern SQLite — historical code.
How to reproduce

Not triggered by any current SQLite API. Historically related to ATTACH.

trigger — this will error
trigger — this will error
# SQLITE_FORMAT (24) is not returned by SQLite 3.x APIs
# Kept for ABI compatibility only

expected output

Not applicable in modern SQLite.

Fix

Treat SQLITE_FORMAT as SQLITE_CORRUPT if encountered in legacy code

WHEN When maintaining older C/C++ code that checks for SQLITE_FORMAT explicitly.

Treat SQLITE_FORMAT as SQLITE_CORRUPT if encountered in legacy code
/* In legacy C code that checks for SQLITE_FORMAT */
#include <sqlite3.h>

int rc = sqlite3_exec(db, sql, NULL, NULL, NULL);
if (rc == SQLITE_FORMAT) {
  /* SQLITE_FORMAT (24) is no longer returned by SQLite 3.x.
     If encountered in old code, treat it like SQLITE_CORRUPT
     and run the integrity check below. */
  sqlite3_exec(db, "PRAGMA integrity_check;", callback, NULL, NULL);
}

Why this works

SQLITE_FORMAT was historically a distinct error for attached auxiliary databases, but was merged conceptually into SQLITE_CORRUPT in SQLite 3.x. The integer value 24 is retained purely for ABI stability — no current SQLite API path returns it. If you see it in legacy code, the safest response is to run PRAGMA integrity_check and, if corruption is confirmed, restore from backup.

Version notes

Sources
Official documentation ↗

sqlite3.h — SQLITE_FORMAT = 24

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All SQLite errors