Johan Corveleyn <jcor...@gmail.com> writes: >> @@ -54,10 +54,9 @@ CREATE TEMPORARY TRIGGER validation_03 B >> WHEN NOT ( >> (new.op_depth = relpath_depth(new.local_relpath)) >> OR >> - ((SELECT COUNT(*) FROM nodes >> - WHERE wc_id = new.wc_id AND op_depth = new.op_depth >> - AND local_relpath = new.parent_relpath >> - LIMIT 2) == 1) >> + (EXISTS (SELECT 1 FROM nodes >> + WHERE wc_id = new.wc_id AND op_depth = new.op_depth >> + AND local_relpath = new.parent_relpath)) >> ) >> BEGIN >> SELECT RAISE(FAIL, 'WC DB validity check 03 failed'); > > I don't know the context, but are you sure this is a non-functional change? > > The SELECT COUNT you removed checked for == 1. The EXISTS allows for >>= 1. So if there are 2 such nodes, the condition you removed would > have been false, but the one you put in place would be true.
(wc_id, op_depth, local_relpath) is the primary key so the count can only be zero or one. -- Philip