[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] How hard is it to add the constraint name to the 'FOREIGN KEY constraint failed' messag
From:       "James K. Lowden" <jklowden () schemamania ! org>
Date:       2015-11-23 15:55:19
Message-ID: 20151123105519.66665490.jklowden () schemamania ! org
[Download RAW message or body]

On Tue, 17 Nov 2015 22:29:10 -0500
Richard Hipp <drh@sqlite.org> wrote:

> With CHECK, and UNIQUE, and NOT NULL constraints, you do know that the
> constraint has failed right away.  And for those constraints, SQLite
> does provide more detail about exactly which constraint failed.  But
> for FK constraints, you never know if a constraint that is failing
> right now might be resolved before the end of the transaction.

As a matter of fact, violation of UNIQUE & PK constraints is enforced
rather too strictly in SQLite.  Any UPDATE statement that modifie more
than one row of a UNIQUE column can fail because two rows may
*transiently* have the same value.  SQLite will fail the statement
even though the completed transactation leaves the constraint
unviolated.  

	sqlite> create table T(t int not null primary key);
	sqlite> insert into T values (1), (2);
	sqlite> update T set t = t+1;
	Error: UNIQUE constraint failed: T.t

--jkl
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic