You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2021/12/20 21:59:20 UTC

[GitHub] [couchdb] rnewson commented on a change in pull request #3881: Enforce row limit in mango

rnewson commented on a change in pull request #3881:
URL: https://github.com/apache/couchdb/pull/3881#discussion_r772693587



##########
File path: src/couch_mrview/src/couch_mrview_util.erl
##########
@@ -439,28 +439,30 @@ validate_args(#mrst{} = State, Args0) ->
             mrverror(Msg2)
     end.
 
-apply_limit(ViewPartitioned, Args) ->
-    Options = Args#mrargs.extra,
-    IgnorePQLimit = lists:keyfind(ignore_partition_query_limit, 1, Options),
-    LimitType =
-        case {ViewPartitioned, IgnorePQLimit} of
-            {true, false} -> "partition_query_limit";
-            {true, _} -> "query_limit";
-            {false, _} -> "query_limit"
-        end,
+apply_limit(ViewPartitioned, #mrargs{} = Args) ->
+    LimitType = case ViewPartitioned of
+        true -> "partition_query_limit";
+        false -> "query_limit"
+    end,
 
-    MaxLimit = config:get_integer(
-        "query_server_config",
-        LimitType,
-        ?MAX_VIEW_LIMIT
-    ),
+    IsMangoQuery = lists:keyfind(is_mango_query, 1, Args#mrargs.extra),
+    MaxLimit = case IsMangoQuery of
+        {is_mango_query, true} ->
+            ?MAX_VIEW_LIMIT;
+        false ->
+            config:get_integer(
+                "query_server_config",
+                LimitType,
+                ?MAX_VIEW_LIMIT)
+    end,
 
     % Set the highest limit possible if a user has not
-    % specified a limit
+    % specified a limit or if this is a mango query
     Args1 =
-        case Args#mrargs.limit == ?MAX_VIEW_LIMIT of
-            true -> Args#mrargs{limit = MaxLimit};
-            false -> Args
+        case {Args#mrargs.limit == ?MAX_VIEW_LIMIT, IsMangoQuery} of
+            {_, {is_mango_query, true}} -> Args#mrargs{limit = ?MAX_VIEW_LIMIT};
+            {true, false} -> Args#mrargs{limit = MaxLimit};

Review comment:
       ah, sorry, that is really for the `{false, {is_mango_query, true}}` case where we _don't_ want to pass the user-specified limit down to couch_mrview (and get the incorrect responses from before your change). it is (obviously) redundant to change limit to MAX_VIEW_LIMIT for the `{true, {is_mango_query, true}}` case since it already is, but it avoids writing a separate clause. Unless I've misunderstood this section of code? I have verified the behaviour with dev/run and it seemed to do the right thing.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org