[SERVER-14317] Dead code in IDHackRunner::applyProjection Created: 19/Jun/14  Updated: 11/Jul/16  Resolved: 25/Jun/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.2
Fix Version/s: 2.7.3

Type: Bug Priority: Minor - P4
Reporter: Kamran K. Assignee: David Storch
Resolution: Done Votes: 0
Labels: 28qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

IDHackRunner::applyProjection checks if _query->getProj()->wantIndexKey() is true in two separate conditions (on line 188 and line 195). The condition on line 195 can never be true, though, because the first if block would have already executed.

idhack_runner.cpp::

188        if (_query->getProj()->wantIndexKey()) {
189            // $returnKey is specified. This overrides everything else.
190            BSONObjBuilder bob;
191            const BSONObj& queryObj = _query->getParsed().getFilter();
192            bob.append(queryObj["_id"]);
193            return bob.obj();
194        }
195        else if (_query->getProj()->requiresDocument() || _query->getProj()->wantIndexKey()) {
                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196            // Not a simple projection, so fallback on the regular projection path.
197            BSONObj projectedObj;
198            ProjectionExec projExec(projObj, _query->root());
199            projExec.transform(docObj, &projectedObj);
200            return projectedObj;
201        }


Version: 3d19c459fe80fb7aa3244174b61994f13f71c21f



 Comments   
Comment by Githook User [ 25/Jun/14 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-14317 remove extraneous check in idhack runner
Branch: master
https://github.com/mongodb/mongo/commit/cdfdc8ee6bbe09cc76724a2f559fe0dc98faa220

Generated at Thu Feb 08 03:34:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.