Skip to content

Commit

Permalink
MB-7631 Interpret bp of 0 as empty body
Browse files Browse the repository at this point in the history
By convention, in Couchstore/.couch files a body pointer of zero
indicates that the item has no body/has an empty body.

This commit makes CouchDB also have this behavior (otherwise, it will
attempt to read data from position 0 in the file when encountering a
deleted item)

Change-Id: If4229b68a2b6fc79484535619b7acfbc5055ca0e
Reviewed-on: http://review.couchbase.org/24586
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-on: http://review.couchbase.org/24596
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
  • Loading branch information
apage43 authored and fdmanana committed Feb 14, 2013
1 parent c6e7157 commit 8e96188
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/couchdb/couch_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,11 @@ open_doc_int(Db, <<?LOCAL_DOC_PREFIX, _/binary>> = Id, Options) ->
end;
open_doc_int(Db, #doc_info{id=Id,deleted=IsDeleted,rev=RevInfo, body_ptr=Bp,
content_meta=ContentMeta}=DocInfo, Options) ->
{ok, Body} = couch_file:pread_iolist(Db#db.fd, Bp),
Body = case Bp of
0 -> <<>>;
_ -> {ok, Body0} = couch_file:pread_iolist(Db#db.fd, Bp),
Body0
end,
Doc = #doc{
id = Id,
rev = RevInfo,
Expand Down

0 comments on commit 8e96188

Please sign in to comment.