summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexanderKaraberov <3254818+AlexanderKaraberov@users.noreply.github.com>2018-05-31 10:23:40 +0200
committerAlexanderKaraberov <3254818+AlexanderKaraberov@users.noreply.github.com>2018-06-29 11:08:56 +0200
commit3358668c079c85968d51b5c55f08cfba48bb88d4 (patch)
tree7ad6e0fbd83890017184349242fe80189b574c6a
parent120903698e0689f0f021411fb4bdbb164a7ae77a (diff)
downloadcouchdb-3358668c079c85968d51b5c55f08cfba48bb88d4.tar.gz
fix(_view changes feed): fix function_clause crash in couch_native_process.
Crash was caused by a missing implementation of ddoc function for <<"views">> FunPath, implementation is based on FilterFun but matches return values of the erlang:put() which is called in the native Emit function and also expects ok and false when docs were not emitted.
-rw-r--r--src/couch/src/couch_native_process.erl12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/couch/src/couch_native_process.erl b/src/couch/src/couch_native_process.erl
index 6d66c936b..8f8ce8b1d 100644
--- a/src/couch/src/couch_native_process.erl
+++ b/src/couch/src/couch_native_process.erl
@@ -226,6 +226,18 @@ ddoc(State, {_, Fun}, [<<"filters">>|_], [Docs, Req]) ->
end,
Resp = lists:map(FilterFunWrapper, Docs),
{State, [true, Resp]};
+ddoc(State, {_, Fun}, [<<"views">>|_], [Docs]) ->
+ MapFunWrapper = fun(Doc) ->
+ case catch Fun(Doc) of
+ undefined -> true;
+ ok -> false;
+ false -> false;
+ [_|_] -> true;
+ {'EXIT', Error} -> couch_log:error("~p", [Error])
+ end
+ end,
+ Resp = lists:map(MapFunWrapper, Docs),
+ {State, [true, Resp]};
ddoc(State, {_, Fun}, [<<"shows">>|_], Args) ->
Resp = case (catch apply(Fun, Args)) of
FunResp when is_list(FunResp) ->