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

Possible to create indexes with invalid orderings

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.4
    • Component/s: Index Maintenance
    • None
    • ALL

      With float and booleans, the value is used as-is and also incorporated into the name. I would expect to see validation that the ordering be either negative or positive one (either an integer or float). I also found that invalid index orderings (e.g. the ORLY object below, and strings like "not2d") are simply ignored (reported separately in SERVER-12540).

      > db.foo.ensureIndex({a:4.5})
      > db.foo.ensureIndex({a:-4.5})
      > db.foo.ensureIndex({a:true})
      > db.foo.ensureIndex({a:false})
      > db.foo.ensureIndex({a:{ORLY:"YARLY"}})
      > db.foo.getIndexes()
      [
      	{
      		"v" : 1,
      		"key" : {
      			"_id" : 1
      		},
      		"name" : "_id_",
      		"ns" : "test.foo"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"a" : 4.5
      		},
      		"name" : "a_4.5",
      		"ns" : "test.foo"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"a" : -4.5
      		},
      		"name" : "a_-4.5",
      		"ns" : "test.foo"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"a" : true
      		},
      		"name" : "a_true",
      		"ns" : "test.foo"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"a" : false
      		},
      		"name" : "a_false",
      		"ns" : "test.foo"
      	}
      ]
      

      And build info:

      > db.runCommand('buildInfo')
      {
      	"version" : "2.5.5-pre-",
      	"gitVersion" : "92cf0713b74ce2f8b011e6768a66c4e99d75a8ea",
      	"OpenSSLVersion" : "",
      	"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
      	"loaderFlags" : "-fPIC -pthread -Wl,-z,now -rdynamic",
      	"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp",
      	"allocator" : "tcmalloc",
      	"versionArray" : [
      		2,
      		5,
      		5,
      		-100
      	],
      	"javascriptEngine" : "V8",
      	"bits" : 64,
      	"debug" : false,
      	"maxBsonObjectSize" : 16777216,
      	"ok" : 1
      }
      

      The above was the latest nightly found on http://www.mongodb.org/downloads. All commits to master since that commit are: https://github.com/mongodb/mongo/compare/92cf0713b74ce2f8b011e6768a66c4e99d75a8ea...master

      In particular, https://github.com/mongodb/mongo/commit/4ae262e2715092700e8fab73eb0b2bea1a119a3b (createIndexes command for SERVER-1627) did not exist in the build I tested with; however, hari.khalsa@10gen.com seemed to think that this sort of validation should have been in place for some time now.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: