Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14317

Dead code in IDHackRunner::applyProjection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7.3
    • Affects Version/s: 2.6.2
    • Component/s: Querying
    • ALL

      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

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            kamran.khan Kamran K.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: