[SERVER-3614] strings with embedded nulls cannot be retrieved correctly Created: 16/Aug/11  Updated: 29/Aug/13  Resolved: 08/Mar/13

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 1.8.2, 1.9.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Tested on Vista


Issue Links:
Depends
Duplicate
duplicates SERVER-6646 Strings with NUL bytes don't round-tr... Closed
Related
is related to SERVER-1300 use memcmp, not strcmp for comparing ... Closed
Operating System: ALL
Participants:

 Description   

For QA-3, attempted to verify SERVER-1300 using the following:

db = db.getSiblingDB("qadb");

db.mns.drop();
db.mns.save(

{i: 1, s:'abcdefghijklmnopqrstuvwxyz'}

);
db.mns.save(

{i: 2, s:'abcde\0fghijklmnopqrstuvwxyz'}

);
db.mns.save(

{i: 3, s:'abcdefghijklm\0nopqrstuvwxyz'}

);
db.mns.save(

{i: 4, s:'abcdefghijklm\0nopqrssuvwxyz'}

);
db.mns.save(

{i: 5, s:'abcdefghijklmnopqrst\0uvwxyz'}

);
db.mns.save(

{i: 6, s:'abcdefghijklmnopqrstuvwx\0yz'}

);
db.mns.ensureIndex(

{s: 1}

);

var r = db.mns.find().sort(

{s:1}

);

The result in 1.9.2 is

> r

{ "_id" : ObjectId("4e4a97d2f1c165e78e8abf66"), "i" : 2, "s" : "abcde" } { "_id" : ObjectId("4e4a97d2f1c165e78e8abf68"), "i" : 4, "s" : "abcdefghijklm" } { "_id" : ObjectId("4e4a97d2f1c165e78e8abf67"), "i" : 3, "s" : "abcdefghijklm" } { "_id" : ObjectId("4e4a97d2f1c165e78e8abf69"), "i" : 5, "s" : "abcdefghijklmnop qrst" } { "_id" : ObjectId("4e4a97d2f1c165e78e8abf6a"), "i" : 6, "s" : "abcdefghijklmnop qrstuvwx" } { "_id" : ObjectId("4e4a97d2f1c165e78e8abf65"), "i" : 1, "s" : "abcdefghijklmnop qrstuvwxyz" }

Since we can't retrieve these strings, what's the point of worrying about the sort?

Note this isn't a JavaScript issue, because you can create such strings and get them in the shell:
> a = 'abcdef\0ghijklm'
abcdef ghijklm
> a
abcdef ghijklm
>



 Comments   
Comment by Eliot Horowitz (Inactive) [ 16/Aug/11 ]

Best thing to do is add a test in dbtests/jstests.cpp that shows problem

Comment by Eliot Horowitz (Inactive) [ 16/Aug/11 ]

That just tests js -> js
js -> mongo -> js is probably broken, specifically mongo -> js

Comment by Chris Westin [ 16/Aug/11 ]

I suppose it could be, but that last example (setting a string-value variable to a string with an embedded null) seems to indicate that the shell can handle this.

Comment by Eliot Horowitz (Inactive) [ 16/Aug/11 ]

What do you mean can't retrieve them?
This looks like a mongo -> shell issue?

Generated at Thu Feb 08 03:03:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.