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

Insert write command creates db and collection on invalid input

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.6.0-rc2
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Write Ops
    • Minor Change
    • ALL
    • 0

      Legacy insert does not:

      > use newdb
      switched to db newdb
      > db.dropDatabase()
      { "dropped" : "newdb", "ok" : 1 }
      > db.stats()
      {
              "db" : "newdb",
              "collections" : 0,
              "objects" : 0,
              "avgObjSize" : 0,
              "dataSize" : 0,
              "storageSize" : 0,
              "numExtents" : 0,
              "indexes" : 0,
              "indexSize" : 0,
              "fileSize" : 0,
              "dataFileVersion" : {
      
              },
              "ok" : 1
      }
      > db.getMongo().insert('newdb.foo', {$notAllowed: true}, 0);
      > db.stats()
      {
              "db" : "newdb",
              "collections" : 0,
              "objects" : 0,
              "avgObjSize" : 0,
              "dataSize" : 0,
              "storageSize" : 0,
              "numExtents" : 0,
              "indexes" : 0,
              "indexSize" : 0,
              "fileSize" : 0,
              "dataFileVersion" : {
      
              },
              "ok" : 1
      }
      > db.foo.runCommand('insert', {documents: [{$notAllowed: true}]})
      {
              "ok" : 1,
              "n" : 0,
              "writeErrors" : [
                      {
                              "index" : 0,
                              "code" : 2,
                              "errmsg" : "Document can't have $ prefixed field names: $notAllowed"
                      }
              ]
      }
      > db.stats()
      {
              "db" : "newdb",
              "collections" : 3,
              "objects" : 4,
              "avgObjSize" : 64,
              "dataSize" : 256,
              "storageSize" : 24576,
              "numExtents" : 3,
              "indexes" : 1,
              "indexSize" : 8176,
              "fileSize" : 67108864,
              "nsSizeMB" : 16,
              "dataFileVersion" : {
                      "major" : 4,
                      "minor" : 5
              },
              "extentFreeList" : {
                      "num" : 0,
                      "totalSize" : 0
              },
              "ok" : 1
      }
      > db.foo.stats()
      {
              "ns" : "newdb.foo",
              "count" : 0,
              "size" : 0,
              "storageSize" : 8192,
              "numExtents" : 1,
              "nindexes" : 1,
              "lastExtentSize" : 8192,
              "paddingFactor" : 1,
              "systemFlags" : 1,
              "userFlags" : 1,
              "totalIndexSize" : 8176,
              "indexSizes" : {
                      "_id_" : 8176
              },
              "ok" : 1
      }
      

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: