SQLITE_CONSTRAINT_PINNED
SQLiteERRORNotableConstraintofficial confidence
Cannot delete a row required by a rowid scan
Production Risk
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
trigger — this will error
-- A recursive trigger that tries to delete the triggering row -- SQLite protects against this with SQLITE_CONSTRAINT_PINNED
expected output
sqlite3.IntegrityError: constraint failed
Fix 1
Fix 2
Version notes
Sources
Official documentation ↗
sqlite3.h — SQLITE_CONSTRAINT_PINNED = 2835
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev