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

compareElementValues for CodeWScope is broken

    • Minor Change
    • ALL

      f = strcmp( l.codeWScopeScopeDataUnsafe() , r.codeWScopeScopeDataUnsafe() );

      1) codeWScopeScopeDataUnsafe is deprecated because it is broken
      2) strcmp stops at the first NUL byte, which is (almost) guaranteed to be within the BSON size int.
      3) Ideally the comparison wouldn't depend on having the scope serialized to BSON. A simple solution would be to just use the normal BSONObj::woCompare to compare the scopes.
      4) (added later) The code part is also compared with strcmp rather than memcmp.

      Unfortunately this requires an index rev bump to fix since someone (probably mistakenly) might have indexed a field containing CodeWScope.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: