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

Timestamp comparison is not unsigned since 3.1.x

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0-rc2
    • Affects Version/s: 3.1.3, 3.2.0-rc0, 3.2.0-rc1
    • Component/s: Querying
    • None
    • Fully Compatible
    • ALL
    • Hide
      // Check that timestamp comparisons are unsigned
      (function() {
          'use strict';
          var t = db.compare_timestamps;
          t.drop();
          assert.writeOK(t.insert({a: new Timestamp(-2, 3), b:"non-zero"}));
          assert.writeOK(t.insert({a: new Timestamp(0, 0), b:"zero"}));
          assert.eq(t.find().sort({a:1}).limit(1).next().b, "zero", "timestamp comparison must be unsigned");
      }());
      
      Show
      // Check that timestamp comparisons are unsigned ( function () { 'use strict' ; var t = db.compare_timestamps; t.drop(); assert.writeOK(t.insert({a: new Timestamp(-2, 3), b: "non-zero" })); assert.writeOK(t.insert({a: new Timestamp(0, 0), b: "zero" })); assert.eq(t.find().sort({a:1}).limit(1).next().b, "zero" , "timestamp comparison must be unsigned" ); }());
    • QuInt B (11/02/15)

      When the date_t type was made to contain the unsigned count of millis, Timestamp inadvertently changed to use signed comparison though it is documented and intended to be unsigned.

            Assignee:
            geert.bosch@mongodb.com Geert Bosch
            Reporter:
            geert.bosch@mongodb.com Geert Bosch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: