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 2019/09/05 20:14:11 UTC
[couchdb] 01/01: Handle update_seq for _local_docs
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch prototype/fdb-layer-fix-update-seq-for-local-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 17b0bc9a174ca727a844522d8d78c3a602472fb4
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Sep 5 16:03:17 2019 -0400
Handle update_seq for _local_docs
On master `_local_docs&update_seq=true` returns the update sequence of the
database. Even though it might not make much sense since updating local docs
doesn't bump the sequence, it's probably a good idea to stay consistent.
It's also worth mentioning another inconsistency is when FDB returns a
`total_rows` count for `_local_docs` while master returns `null`. I think
that's probably acceptable. Master would return the count if had it available
easily and having it seems like a useful thing and an improvement.
---
src/fabric/src/fabric2_db.erl | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index f3036e4..853b502 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -738,15 +738,7 @@ fold_docs(Db, UserFun, UserAcc0, Options) ->
} = TxDb,
Prefix = erlfdb_tuple:pack({?DB_ALL_DOCS}, DbPrefix),
- NS = couch_util:get_value(namespace, Options),
- DocCount = get_doc_count(TxDb, NS),
- Meta = case lists:keyfind(update_seq, 1, Options) of
- {_, true} ->
- UpdateSeq = fabric2_db:get_update_seq(TxDb),
- [{update_seq, UpdateSeq}];
- _ ->
- []
- end ++ [{total, DocCount}, {offset, null}],
+ Meta = get_all_docs_meta(TxDb, Options),
UserAcc1 = maybe_stop(UserFun({meta, Meta}, UserAcc0)),
@@ -780,8 +772,7 @@ fold_local_docs(Db, UserFun, UserAcc0, Options) ->
} = TxDb,
Prefix = erlfdb_tuple:pack({?DB_LOCAL_DOCS}, DbPrefix),
- DocCount = get_doc_count(TxDb, <<"doc_local_count">>),
- Meta = [{total, DocCount}, {offset, null}],
+ Meta = get_all_docs_meta(TxDb, Options),
UserAcc1 = maybe_stop(UserFun({meta, Meta}, UserAcc0)),
@@ -959,6 +950,18 @@ new_revid(Db, Doc) ->
}.
+get_all_docs_meta(TxDb, Options) ->
+ NS = couch_util:get_value(namespace, Options),
+ DocCount = get_doc_count(TxDb, NS),
+ case lists:keyfind(update_seq, 1, Options) of
+ {_, true} ->
+ UpdateSeq = fabric2_db:get_update_seq(TxDb),
+ [{update_seq, UpdateSeq}];
+ _ ->
+ []
+ end ++ [{total, DocCount}, {offset, null}].
+
+
maybe_set_user_ctx(Db, Options) ->
case fabric2_util:get_value(user_ctx, Options) of
#user_ctx{} = UserCtx ->