[SERVER-3276] mongoimport is trimming leading whitespace (including tabs) from every input record Created: 16/Jun/11 Updated: 12/Jul/16 Resolved: 27/Jun/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Tools |
| Affects Version/s: | 1.9.0 |
| Fix Version/s: | 1.9.1 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | richard bucker | Assignee: | Spencer Brody (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | mongoimport | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
n/a |
||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
I have been able to confirm that this is likely a bug, however, as we all know one programmers bug is another's feature. That said.... Here are the particulars: FILE: tools/import.cpp This piece of code... while reading the input file, (skip the JSON part), it trims all of the leading whitespace. However, if this is a TSV then the tab will be gobbled up. I don't think this was the intended behavior. 292 if (_jsonArray) { http://creativyst.com/Doc/Articles/CSV/CSV01.htm I do not every reading a formal spec for CSV but this link is pretty good. In general, however, it's a bug in the design to trim the leading part of the record in this location in the code. The parser should be located as tightly and closely as possible... for the obvious reasons. /r |
| Comments |
| Comment by auto [ 27/Jun/11 ] |
|
Author: {u'login': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@10gen.com'}Message: Fix |
| Comment by richard bucker [ 16/Jun/11 ] |
|
Here is my corrected code with some inline comments.
// handle leading whitespace if (buf[0] == '\0') } else { while (isspace( buf[0] )) { len++; buf++; } } |