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

Insert write command creates db and collection on invalid input

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.6.0-rc0
    • Fix Version/s: 2.6.0-rc2
    • Component/s: Write Ops
    • Labels:
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Linked BF Score:
      0

      Description

      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
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              greg_10gen Greg Studer
              Reporter:
              redbeard0531 Mathias Stearn
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: