On Wed, Feb 29, 2012 at 2:25 PM, Roger Binns <rog...@rogerbinns.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 29/02/12 09:22, Pete wrote:
> > The problem I have is that the error messages that come back from
> > constraint violations are extremely generic (e.g. "constraint failed")
> > and would mean nothing to a user.
>
> An issue first reported in 2006:
>
>  http://www.sqlite.org/src/tktview?name=23b2128201
>
> I think (but have not tried) that you can make a user defined function and
> have that do the checks.  It can then either directly error, or put a
> message in a buffer somewhere that you can retrieve on constraint failure.
>

SQLite implements CHECK constraints by concatenating all expressions from
all CHECK constraints on the table using AND and then evaluating the
resulting boolean to see if it is false.  If it is false, an
SQLITE_CONSTRAINT error is raised.

We *could* keep track of each separate CHECK expression and remember the
constraint name and evaluate each expression separately and output a
customized error message for each failure.  But that would require a lot of
extra code space, which is not "lite".


>
> Roger
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
>
> iEYEARECAAYFAk9Oe6wACgkQmOOfHg372QTEoQCg2K3BFZ+hwOAYKvSoKDCg1+kZ
> s6IAoJ1OyzISCz9sYK2nKBn+Z4wqCn8y
> =2KAk
> -----END PGP SIGNATURE-----
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to