SQLITE_CONSTRAINT_PINNEDERRORTier 2 — Caution⚠️ MEDIUM confidenceCannot delete a row required by a rowid scan
Category: ConstraintVersions: 3.35.0+
🔴 Production Risk Error
Medium — trigger logic needs redesign.
What this means
SQLITE_CONSTRAINT_PINNED (2835) is returned when an attempt is made to DELETE a row while the row is "pinned" by a recursive trigger or a row value change that is being processed.
Why it happens
- 1Recursive trigger scenario where a trigger attempts to delete a row that is currently being iterated.
- 2Row is pinned by an ongoing UPDATE and cannot be deleted simultaneously.
How to reproduce
Complex trigger chains involving DELETE on rows that are concurrently being modified.
trigger — this will ERROR
-- A recursive trigger that tries to delete the triggering row
-- SQLite protects against this with SQLITE_CONSTRAINT_PINNEDsqlite3.IntegrityError: constraint failed
Fix 1
Why this works
Redesign the trigger logic to avoid deleting pinned rows.
Fix 2
Why this works
Use DEFERRABLE INITIALLY DEFERRED constraints or restructure the trigger.
Version notes
Sources
📚 Official docs: https://www.sqlite.org/rescode.html#constraint_pinned
🔧 Source ref: sqlite3.h — SQLITE_CONSTRAINT_PINNED = 2835
Confidence assessment
⚠️ MEDIUM confidence
Stable.
See also
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →