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

Loss of type information for covered queries in WiredTiger

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • Index Maintenance, Storage
    • None
    • Fully Compatible
    • ALL
    • Hide

      #include <iostream>
      #include <vector>
      #include "mongo/client/dbclient.h"
       
      using namespace std;
      using namespace mongo;
       
      int main() {
          client::initialize();
          DBClientConnection c;
          c.connect("localhost");
       
          c.dropDatabase("test");
          c.createIndex("test.wow", IndexSpec().addKeys(BSON("a" << 1)));
       
          BSONObj toInsert = BSON("a" << 1);
          cout << "type in: " << toInsert.getField("a").type() << endl;
          c.insert("test.wow", toInsert);
       
          BSONObj distinct;
          c.runCommand("test", BSON(
              "distinct" << "wow" <<
              "key" << "a"
          ), distinct);
       
          vector<BSONElement> result = distinct.getField("values").Array();
          cout << "type out: " << result[0].type() << endl;
      }

      $ g++ test.cpp -I ./include -L ./lib -lmongoclient -lboost_system -lboost_regex -lboost_thread
      $ ./a.out                                                                                     
      type in: 16
      type out: 1

      Show
      #include <iostream> #include <vector> #include "mongo/client/dbclient.h"   using namespace std; using namespace mongo;   int main() { client::initialize(); DBClientConnection c; c.connect( "localhost" );   c.dropDatabase( "test" ); c.createIndex( "test.wow" , IndexSpec().addKeys(BSON( "a" << 1)));   BSONObj toInsert = BSON( "a" << 1); cout << "type in: " << toInsert.getField( "a" ).type() << endl; c.insert( "test.wow" , toInsert);   BSONObj distinct; c.runCommand( "test" , BSON( "distinct" << "wow" << "key" << "a" ), distinct);   vector<BSONElement> result = distinct.getField( "values" ).Array(); cout << "type out: " << result[0].type() << endl; } $ g++ test.cpp -I ./include -L ./lib -lmongoclient -lboost_system -lboost_regex -lboost_thread $ ./a.out type in: 16 type out: 1

    Description

      I'm not sure if this is by design but I have observed this behavior change between WiredTiger and MMAPv1.

      Using MMAP the covered distinct result has the same bson type as the data that was inserted. However when using WiredTiger the distinct result has type double instead of Int32.

      I realize that this is due to the new index key format for WiredTiger but I was surprised that distinct would product this result.

      Attachments

        Issue Links

          Activity

            People

              mathias@mongodb.com Mathias Stearn
              tyler@10gen.com Tyler Brock
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: