From dev-return-15627-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Sun Apr 17 12:20:45 2011 Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 84232 invoked from network); 17 Apr 2011 12:20:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Apr 2011 12:20:45 -0000 Received: (qmail 56442 invoked by uid 500); 17 Apr 2011 12:20:44 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 56403 invoked by uid 500); 17 Apr 2011 12:20:44 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 56395 invoked by uid 99); 17 Apr 2011 12:20:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Apr 2011 12:20:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Apr 2011 12:20:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id EA9C1A5100 for ; Sun, 17 Apr 2011 12:20:05 +0000 (UTC) Date: Sun, 17 Apr 2011 12:20:05 +0000 (UTC) From: "Jan Lehnardt (JIRA)" To: dev@couchdb.apache.org Message-ID: <951629775.63143.1303042805957.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <28941487.168691290054733206.JavaMail.jira@thor> Subject: [jira] [Commented] (COUCHDB-954) typo in key tree logic when latest=true MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-954?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D130= 20783#comment-13020783 ]=20 Jan Lehnardt commented on COUCHDB-954: -------------------------------------- It's not easy to find a case here that breaks this. I had to go into etap and provide (as far as I can tell) invalid keys to tr= igger this behaviour. This code is frequently exercised, but either KeysToGet2 is [] or LeafKeysF= ound is not to be found in KeysToGet2. Or in Erlang terms: [] =3D [] -- ["foo"], % no badmatch ["bar"] =3D ["bar"] -- ["foo"], ; no badmatch This is the etap test and code fix that exercises the badmatch, but I don't= know if we can ever trigger this from the outside: diff --git a/test/etap/063-kt-get-leaves.t b/test/etap/063-kt-get-leaves.t index 6d4e800..0de7347 100755 --- a/test/etap/063-kt-get-leaves.t +++ b/test/etap/063-kt-get-leaves.t @@ -60,6 +60,12 @@ test() -> ), =20 etap:is( + {[{"bar",{1,["1b","1"]}}],[]}, + couch_key_tree:get_key_leafs(TwoChildSibs, ["bar", {1, "1b"}]), + "COUCHDB-954 =E2=80=94 invalid keys." + ), + + etap:is( {[{0,[{"1", "foo"}]}],[]}, couch_key_tree:get_full_key_paths(TwoChildSibs, [{0, "1"}]), "retrieve full key paths." diff --git a/src/couchdb/couch_key_tree.erl b/src/couchdb/couch_key_tree.er= l index 990f3f2..2cbb45e 100644 --- a/src/couchdb/couch_key_tree.erl +++ b/src/couchdb/couch_key_tree.erl @@ -231,8 +231,8 @@ get_key_leafs_simple(Pos, [{Key, _Value, SubTree}=3DTre= e | RestTree], KeysToGet, K KeysToGet2 -> LeafsFound =3D get_all_leafs_simple(Pos, [Tree], KeyPathAcc), LeafKeysFound =3D [LeafKeyFound || {LeafKeyFound, _} <- LeafsFound= ], - KeysToGet2 =3D KeysToGet2 -- LeafKeysFound, - {RestLeafsFound, KeysRemaining} =3D get_key_leafs_simple(Pos, Rest= Tree, KeysToGet2, KeyPathAcc), + KeysToGet3 =3D KeysToGet2 -- LeafKeysFound, + {RestLeafsFound, KeysRemaining} =3D get_key_leafs_simple(Pos, Rest= Tree, KeysToGet3, KeyPathAcc), {LeafsFound ++ RestLeafsFound, KeysRemaining} end. > typo in key tree logic when latest=3Dtrue > --------------------------------------- > > Key: COUCHDB-954 > URL: https://issues.apache.org/jira/browse/COUCHDB-954 > Project: CouchDB > Issue Type: Bug > Components: Database Core > Reporter: Adam Kocoloski > > This line > https://github.com/apache/couchdb/blob/7fe84eba9982ebb3bcaa48b7aa28fdd2e1= 30422d/src/couchdb/couch_key_tree.erl#L195 > seems like it should read KeysToGet3 =3D KeysToGet2 -- LeafKeysFound, and= then KeysToGet3 should be supplied to the following invocation of get_key_= leafs_simple. I think the current code would crash if a user made an open_= revs call with latest=3Dtrue and a pair of revisions that have a parent/chi= ld relationship, or at least it would crash if latest=3Dtrue was implemente= d (COUCHDB-953). -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira