You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2017/06/01 07:49:09 UTC
[couchdb] 01/01: Fix compatibility with master local document
revisions
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch COUCHDB-3287-pluggable-storage-engines-use-integers-for-local-revs
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 96330b694c74ab4bd386f62387a0fdc2052863e5
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Wed May 31 18:17:17 2017 -0400
Fix compatibility with master local document revisions
Previously local doc revisions were integers. Keep them that way to allow
downgrading back to previous CouchDB version.
---
src/couch/src/couch_bt_engine.erl | 17 +++++++----------
src/couch/src/couch_db_updater.erl | 8 ++++----
src/couch/src/test_engine_util.erl | 6 +++---
3 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl
index ca98d01..36636f3 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -593,27 +593,24 @@ seq_tree_reduce(reduce, DocInfos) ->
seq_tree_reduce(rereduce, Reds) ->
lists:sum(Reds).
-
-local_tree_split(#doc{} = Doc) ->
+local_tree_split(#doc{revs = {0, [Rev]}} = Doc) when is_binary(Rev) ->
#doc{
id = Id,
- revs = {0, [Rev]},
body = BodyData
} = Doc,
- {Id, {Rev, BodyData}}.
-
-
-local_tree_join(Id, {Rev, BodyData}) when is_binary(Rev) ->
+ {Id, {binary_to_integer(Rev), BodyData}};
+local_tree_split(#doc{revs = {0, [Rev]}} = Doc) when is_integer(Rev) ->
#doc{
id = Id,
- revs = {0, [Rev]},
body = BodyData
- };
+ } = Doc,
+ {Id, {Rev, BodyData}}.
+
local_tree_join(Id, {Rev, BodyData}) when is_integer(Rev) ->
#doc{
id = Id,
- revs = {0, [list_to_binary(integer_to_list(Rev))]},
+ revs = {0, [integer_to_binary(Rev)]},
body = BodyData
}.
diff --git a/src/couch/src/couch_db_updater.erl b/src/couch/src/couch_db_updater.erl
index 4b591b3..7577fe5 100644
--- a/src/couch/src/couch_db_updater.erl
+++ b/src/couch/src/couch_db_updater.erl
@@ -645,17 +645,17 @@ update_local_doc_revs(Docs) ->
} = NewDoc,
case PrevRevs of
[RevStr | _] ->
- PrevRev = list_to_integer(?b2l(RevStr));
+ PrevRev = binary_to_integer(RevStr);
[] ->
PrevRev = 0
end,
NewRev = case Delete of
false ->
- ?l2b(integer_to_list(PrevRev + 1));
+ PrevRev + 1;
true ->
- <<"0">>
+ 0
end,
- send_result(Client, NewDoc, {ok, {0, NewRev}}),
+ send_result(Client, NewDoc, {ok, {0, integer_to_binary(NewRev)}}),
NewDoc#doc{
revs = {0, [NewRev]}
}
diff --git a/src/couch/src/test_engine_util.erl b/src/couch/src/test_engine_util.erl
index d19b7f1..c81acd0 100644
--- a/src/couch/src/test_engine_util.erl
+++ b/src/couch/src/test_engine_util.erl
@@ -161,13 +161,13 @@ gen_local_write(Engine, St, {Action, {DocId, Body}}) ->
[#doc{revs = {0, []}}] ->
0;
[#doc{revs = {0, [RevStr | _]}}] ->
- list_to_integer(binary_to_list(RevStr))
+ binary_to_integer(RevStr)
end,
{RevId, Deleted} = case Action of
Action when Action == create; Action == update ->
- {list_to_binary(integer_to_list(PrevRev + 1)), false};
+ {PrevRev + 1, false};
delete ->
- {<<"0">>, true}
+ {0, true}
end,
#doc{
id = DocId,
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.