[SERVER-2935] shallow woEqual check used for index dup checking Created: 12/Apr/11  Updated: 12/Jul/16  Resolved: 01/Jun/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 1.9.1

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Dwight Merriman
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Dwight noticed this yesterday. We probably want to do woCompare to handle cases like int/double comparison.

bool BtreeBucket::exists(const IndexDetails& idx, const DiskLoc &thisLoc, const BSONObj& key, const Ordering& order) const {
int pos;
bool found;
DiskLoc b = locate(idx, thisLoc, key, order, pos, found, minDiskLoc);

// skip unused keys
while ( 1 )

{ if( b.isNull() ) break; const BtreeBucket *bucket = b.btree(); const _KeyNode& kn = bucket->k(pos); if ( kn.isUsed() ) return bucket->keyAt(pos).woEqual(key); b = bucket->advance(b, pos, 1, "BtreeBucket::exists"); }

return false;
}

bool BtreeBucket::wouldCreateDup(
const IndexDetails& idx, const DiskLoc &thisLoc,
const BSONObj& key, const Ordering& order,
const DiskLoc &self) const {
int pos;
bool found;
DiskLoc b = locate(idx, thisLoc, key, order, pos, found, minDiskLoc);

while ( !b.isNull() ) {
// we skip unused keys
const BtreeBucket *bucket = b.btree();
const _KeyNode& kn = bucket->k(pos);
if ( kn.isUsed() )

{ if( bucket->keyAt(pos).woEqual(key) ) return kn.recordLoc != self; break; }

b = bucket->advance(b, pos, 1, "BtreeBucket::dupCheck");
}

return false;
}



 Comments   
Comment by auto [ 01/Jun/11 ]

Author:

{u'login': u'dwight', u'name': u'dwight', u'email': u'dwight@10gen.com'}

Message: SERVER-2935 fix woEqual which wasnt equalling ints and doubles
Branch: master
https://github.com/mongodb/mongo/commit/600f2eef36c299b32810ce1a79c8bb4bb120c2ab

Comment by Dwight Merriman [ 13/May/11 ]

@mathias yes - want to make a jira for that or something? or just do it if you can in 5 minutes.

Comment by Mathias Stearn [ 12/May/11 ]

We should probably also consider reversed indexes to be dups so people don't have both

{a:1}

and

{a:-1}
Generated at Thu Feb 08 03:01:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.