On 18 Nov 2015, at 10:05am, Dominique Devienne <ddevienne at gmail.com> wrote:

> Given this pragma, then showing the FK name on immediate
> mode is possible, no?

Unfortunately not.  [following explanation is, I suspect, simplified]

When the table schema is read from the file the table's constraints are 
'compiled' into a set of rules.  A single rule might express the requirements 
of many different constraints.  Rules are more compact, faster and simpler to 
apply than analyzing and applying each constraint for each value changed.  
Unfortunately because the structure of the rules doesn't map 1-to-1 into the 
constraints they came from it's not possible to tell, just from 'rule fails', 
which of the constraints that made up the rule was broken.

Applying the original constraints one by one would make SQLite far slower even 
for operations which did not violate any constraints, and the majority of 
users, who don't violate constraints, would get no benefit from it.

An earlier poster came up with a good solution: the existing 'fast check' is 
done first and then, if and only if a rule fails, a more complicated slower 
check has to be done to figure out which constraint to report as causing the 
error.  This would complicate SQLite's code, and as before most users wouldn't 
benefit from it.

As mentioned above SQLite4 is written differently and it's possible that 
reporting the violated constraint might be 'cheaper' to add to that.

Simon.

Reply via email to