SQLite Forum

CHECK violation during table definition ignored, normal or bug?
Login
The check expression is not limited to having only one column as its term(s). What you are suggesting is that a check constraint violation should additionally produce and emit data from which "what was wrong" can be inferred. Yes, that would be doable (letting "Lite" considerations slide) for simple expressions involving just one unknown or variable term. But it would cover only a subset of the cases and the runtime cost would be out of balance with the benefits.

Keith's answer has, beyond the virtue of being right for SQLite as it is, merit as arguably the best way to permit (but not require [a]) enough of a clue to be emitted that debugging can be begin with a very limited scope, without imposing a inescapable runtime cost on everybody who uses table/column constraints.

[a. The "Lite" considerations work against forcing the additional byte code to be generated that are necessary for the clue to be emitted when the violation occurs. ]

Your comment regarding how a constraint name might fail to track changes to its logic is true in a limited sense.  I would say that the name may indeed be inadequate (or entirely missing), at inception or later.  So might the constraint logic or any query or DDL/DML that humans have devised. Whose problem is that? [b] The answer leads to the party in the best position to solve it. That would be the person(s) responsible for the code. The tool (SQLite) is never going to be able to eliminate the need for diligence and skill in writing the SQL it sees.

[b. As elaborated in a great book for those who face, frame and often solve problems, "[Are Your Lights On?](https://www.barnesandnoble.com/w/are-your-lights-on-donald-c-gause/1111620163?ean=2940012304674)", this question is crucial. ]