SQLite Forum

Unexpected return from the NULL column
Login
[Check-in e3794997c34f03db][1] enhances the ALTER TABLE ADD COLUMN command
so that (if necessary) it will run the equivalent of
"[PRAGMA quick_check][2]" on the modified table
after adding the new column in order to ensure that any NOT NULL or CHECK
constraints added as part of the new column are satisfied by existing rows
of the table.  If any constraints are violated, the ADD COLUMN is aborted
and the changes are rolled back.

The existing documentation for [ALTER TABLE ADD COLUMN][3] says that when adding
a CHECK constraint....

> "the CHECK constraint is not tested against preexisting rows of the table. This can result in a table that contains data that is in violation of the CHECK constraint. Future versions of SQLite might change to validate CHECK constraints as they are added."

The "future versions of SQLite" mentioned in this remark means
[check-in e3794997c34f03db][1] and later.  And this applies to NOT NULL
constraints on generated columns as well.  The documentation will be updated
for the next release (3.37.0).

[1]: src:/timeline?c=e3794997c34f03db
[2]: https://sqlite.org/pragma.html#pragma_quick_check
[3]: https://sqlite.org/lang_altertable.html#altertabaddcol