On Tue, 2011-05-31 at 21:13 +0200, Johan Corveleyn wrote: > On Tue, May 31, 2011 at 7:37 PM, <phi...@apache.org> wrote: > > Author: philip > > Date: Tue May 31 17:37:33 2011 > > New Revision: 1129818 > > > > URL: http://svn.apache.org/viewvc?rev=1129818&view=rev > > Log: > > * subversion/libsvn_wc/wc-checks.sql > > (validation_03): Use EXISTS rather than COUNT. > > > > Modified: > > subversion/trunk/subversion/libsvn_wc/wc-checks.sql > > > > Modified: subversion/trunk/subversion/libsvn_wc/wc-checks.sql > > URL: > > http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-checks.sql?rev=1129818&r1=1129817&r2=1129818&view=diff > > ============================================================================== > > --- subversion/trunk/subversion/libsvn_wc/wc-checks.sql (original) > > +++ subversion/trunk/subversion/libsvn_wc/wc-checks.sql Tue May 31 17:37:33 > > 2011 > > @@ -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.
I was concerned about that. I didn't notice this a little earlier when I wrote the "LIMIT 2", but in fact there can never be more than one row matching the WHERE clause because (wc_id, op_depth, local_relpath) is the table's primary key. - Julian