From 2d0503e3bb0c50c99670c01272ee8c1fe7710f8d Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Mon, 4 May 2009 22:06:12 +0000 Subject: reduce_limit error is thrown when the reduce function output is not small enough compared to the input. Errors can be switched off using the config API. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@771466 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/view_errors.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'share/www/script/test/view_errors.js') diff --git a/share/www/script/test/view_errors.js b/share/www/script/test/view_errors.js index 12225e67..1a613c04 100644 --- a/share/www/script/test/view_errors.js +++ b/share/www/script/test/view_errors.js @@ -75,13 +75,26 @@ couchTests.view_errors = function(debug) { _id:"_design/test", language: "javascript", views: { - no_reduce: {map:"function(doc) {emit(doc._id, null);}"}, - with_reduce: {map:"function (doc) {emit(doc.integer, doc.integer)};", - reduce:"function (keys, values) { return sum(values); };"}, + "no_reduce": {map:"function(doc) {emit(doc._id, null);}"}, + "with_reduce": { + map:"function (doc) {emit(doc.integer, doc.integer)};", + reduce:"function (keys, values) { return sum(values); };"} } }; T(db.save(designDoc).ok); + var designDoc2 = { + _id:"_design/testbig", + language: "javascript", + views: { + "reduce_too_big" : { + map:"function (doc) {emit(doc.integer, doc.integer)};", + reduce:"function (keys, values) { var chars = []; for (var i=0; i < 1000; i++) {chars.push('wazzap');};return chars; };"} + } + }; + T(db.save(designDoc2).ok); + + try { db.view("test/no_reduce", {group: true}); T(0 == 1); @@ -117,4 +130,11 @@ couchTests.view_errors = function(debug) { result = JSON.parse(xhr.responseText); T(result.error == "bad_request"); T(result.reason == "`keys` member must be a array."); + + // if the reduce grows to fast, throw an overflow error + var path = "/test_suite_db/_design/testbig/_view/reduce_too_big"; + xhr = CouchDB.request("GET", path); + T(xhr.status == 500); + result = JSON.parse(xhr.responseText); + T(result.error == "reduce_overflow_error"); }; -- cgit v1.2.3