[SERVER-6766] DocumentSourceGroup does not properly serialize constant expressions, can cause a valid expression on mongos to be unparsable on shards. Created: 14/Aug/12  Updated: 11/Jul/16  Resolved: 21/Aug/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.2.0-rc2, 2.3.0

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

The addToBsonObj calls below should be passed requireExpression == true. I've already written some tests, and the fix is pretty straightforward.

    void DocumentSourceGroup::sourceToBson(
        BSONObjBuilder *pBuilder, bool explain) const {
        BSONObjBuilder insides;
 
        /* add the _id */
        pIdExpression->addToBsonObj(&insides, Document::idName.c_str(), false);
 
        /* add the remaining fields */
        const size_t n = vFieldName.size();
        for(size_t i = 0; i < n; ++i) {
            intrusive_ptr<Accumulator> pA((*vpAccumulatorFactory[i])(pExpCtx));
            pA->addOperand(vpExpression[i]);
            pA->addToBsonObj(&insides, vFieldName[i], false);
        }
 
        pBuilder->append(groupName, insides.done());
    }

May also need to similarly change Accumulator serialization.



 Comments   
Comment by auto [ 21/Aug/12 ]

Author:

{u'date': u'2012-08-14T16:23:59-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-6766 Properly serialize DocumentSourceGroup for transmission to shards.
Branch: v2.2
https://github.com/mongodb/mongo/commit/3c7061b50bcbd66c864da8771ddb3f77823008f9

Comment by auto [ 20/Aug/12 ]

Author:

{u'date': u'2012-08-14T16:23:59-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}

Message: SERVER-6766 Properly serialize DocumentSourceGroup for transmission to shards.
Branch: master
https://github.com/mongodb/mongo/commit/a781bbc6b3da118c0969c9cc0be9148719c1c67c

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