svn commit: r766338 - in /couchdb/trunk: README etc/Makefile.am etc/init/couchdb.tpl.in var/Makefile.am
Author: nslater Date: Sat Apr 18 15:20:00 2009 New Revision: 766338 URL: http://svn.apache.org/viewvc?rev=766338view=rev Log: create /var/run/couchdb during init script Modified: couchdb/trunk/README couchdb/trunk/etc/Makefile.am couchdb/trunk/etc/init/couchdb.tpl.in couchdb/trunk/var/Makefile.am Modified: couchdb/trunk/README URL: http://svn.apache.org/viewvc/couchdb/trunk/README?rev=766338r1=766337r2=766338view=diff == --- couchdb/trunk/README (original) +++ couchdb/trunk/README Sat Apr 18 15:20:00 2009 @@ -150,14 +150,12 @@ chown -R couchdb:couchdb /usr/local/etc/couchdb chown -R couchdb:couchdb /usr/local/var/lib/couchdb chown -R couchdb:couchdb /usr/local/var/log/couchdb -chown -R couchdb:couchdb /usr/local/var/run/couchdb Change the permission of the Apache CouchDB directories by running: chmod -R 0770 /usr/local/etc/couchdb chmod -R 0770 /usr/local/var/lib/couchdb chmod -R 0770 /usr/local/var/log/couchdb -chmod -R 0770 /usr/local/var/run/couchdb Running Manually Modified: couchdb/trunk/etc/Makefile.am URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/Makefile.am?rev=766338r1=766337r2=766338view=diff == --- couchdb/trunk/etc/Makefile.am (original) +++ couchdb/trunk/etc/Makefile.am Sat Apr 18 15:20:00 2009 @@ -44,6 +44,7 @@ -e s|%bindir%|$(bindir)| \ -e s|%sysconfdir%|$(sysconfdir)| \ -e s|%localerlangbindir%|$(localerlangbindir)| \ + -e s|%localstaterundir%|$(localstaterundir)| \ -e s|%couchdb_command_name%|$(couchdb_command_name)| \ $ $@ Modified: couchdb/trunk/etc/init/couchdb.tpl.in URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/init/couchdb.tpl.in?rev=766338r1=766337r2=766338view=diff == --- couchdb/trunk/etc/init/couchdb.tpl.in (original) +++ couchdb/trunk/etc/init/couchdb.tpl.in Sat Apr 18 15:20:00 2009 @@ -30,6 +30,7 @@ SCRIPT_NAME=`basename $0` COUCHDB=%bindir%/%couchdb_command_name% CONFIGURATION_FILE=%sysconfdir%/default/couchdb +RUN_DIR=%localstaterundir% LSB_LIBRARY=/lib/lsb/init-functions if test ! -x $COUCHDB; then @@ -75,7 +76,9 @@ if test -n $COUCHDB_OPTIONS; then command=$command $COUCHDB_OPTIONS fi +mkdir -p $RUN_DIR if test -n $COUCHDB_USER; then +chown $COUCHDB_USER $RUN_DIR if su $COUCHDB_USER -c $command /dev/null; then return $SCRIPT_OK else Modified: couchdb/trunk/var/Makefile.am URL: http://svn.apache.org/viewvc/couchdb/trunk/var/Makefile.am?rev=766338r1=766337r2=766338view=diff == --- couchdb/trunk/var/Makefile.am (original) +++ couchdb/trunk/var/Makefile.am Sat Apr 18 15:20:00 2009 @@ -14,10 +14,8 @@ if test ! $(mkdir_p) = ; then \ $(mkdir_p) $(DESTDIR)$(localstatelibdir); \ $(mkdir_p) $(DESTDIR)$(localstatelogdir); \ - $(mkdir_p) $(DESTDIR)$(localstaterundir); \ else \ echo WARNING: You may have to create these directories by hand.; \ mkdir -p $(DESTDIR)$(localstatelibdir); \ mkdir -p $(DESTDIR)$(localstatelogdir); \ - mkdir -p $(DESTDIR)$(localstaterundir); \ fi
svn commit: r766348 - in /couchdb/branches/0.9.x: ./ etc/default/couchdb share/www/script/test/view_errors.js src/couchdb/couch_db.hrl src/couchdb/couch_httpd_view.erl
Author: davisp Date: Sat Apr 18 16:22:55 2009 New Revision: 766348 URL: http://svn.apache.org/viewvc?rev=766348view=rev Log: Merged 766347 from trunk. Modified: couchdb/branches/0.9.x/ (props changed) couchdb/branches/0.9.x/etc/default/couchdb (props changed) couchdb/branches/0.9.x/share/www/script/test/view_errors.js couchdb/branches/0.9.x/src/couchdb/couch_db.hrl couchdb/branches/0.9.x/src/couchdb/couch_httpd_view.erl Propchange: couchdb/branches/0.9.x/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Apr 18 16:22:55 2009 @@ -1,3 +1,3 @@ /couchdb/branches/design_resources:751716-751803 /couchdb/branches/form:729440-730015 -/couchdb/trunk:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420 +/couchdb/trunk:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420,766347 Propchange: couchdb/branches/0.9.x/etc/default/couchdb -- --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Apr 18 16:22:55 2009 @@ -1,4 +1,4 @@ /couchdb/branches/design_resources/etc/default/couchdb:751716-751803 /couchdb/branches/form/etc/default/couchdb:729440-730015 -/couchdb/trunk/etc/default/couchdb:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420 +/couchdb/trunk/etc/default/couchdb:758717,760442,760503,760532,760535,760537-760539,761343,761347-761348,761352-761353,761355,762016,765420,766347 /incubator/couchdb/trunk/etc/default/couchdb:642419-694440 Modified: couchdb/branches/0.9.x/share/www/script/test/view_errors.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.9.x/share/www/script/test/view_errors.js?rev=766348r1=766347r2=766348view=diff == --- couchdb/branches/0.9.x/share/www/script/test/view_errors.js (original) +++ couchdb/branches/0.9.x/share/www/script/test/view_errors.js Sat Apr 18 16:22:55 2009 @@ -81,6 +81,14 @@ } try { +db.view(test/no_reduce, {reduce: true}); +T(0 == 1); + } catch(e) { +T(db.last_req.status == 400); +T(e.error == query_parse_error); + } + + try { db.view(test/with_reduce, {group: true, reduce: false}); T(0 == 1); } catch(e) { Modified: couchdb/branches/0.9.x/src/couchdb/couch_db.hrl URL: http://svn.apache.org/viewvc/couchdb/branches/0.9.x/src/couchdb/couch_db.hrl?rev=766348r1=766347r2=766348view=diff == --- couchdb/branches/0.9.x/src/couchdb/couch_db.hrl (original) +++ couchdb/branches/0.9.x/src/couchdb/couch_db.hrl Sat Apr 18 16:22:55 2009 @@ -155,6 +155,7 @@ skip = 0, group_level = 0, reduce = true, +req_reduce = false, inclusive_end=true, % aka a closed-interval include_docs = false }). Modified: couchdb/branches/0.9.x/src/couchdb/couch_httpd_view.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.9.x/src/couchdb/couch_httpd_view.erl?rev=766348r1=766347r2=766348view=diff == --- couchdb/branches/0.9.x/src/couchdb/couch_httpd_view.erl (original) +++ couchdb/branches/0.9.x/src/couchdb/couch_httpd_view.erl Sat Apr 18 16:22:55 2009 @@ -363,9 +363,15 @@ {inclusive_end, false} - Args#view_query_args{inclusive_end=false}; {reduce, true} - -Args#view_query_args{reduce=true}; +Args#view_query_args{ +reduce=true, +req_reduce=true +}; {reduce, false} - -Args#view_query_args{reduce=false}; +Args#view_query_args{ +reduce=false, +req_reduce=true +}; {include_docs, Value} - case Value of true - @@ -400,7 +406,18 @@ ok end; _ - -ok +case QueryArgs#view_query_args.req_reduce of +true - +case QueryArgs#view_query_args.reduce of +true - +ErrMsg = Bad URL parameter: reduce=true, +throw({query_parse_error, ErrMsg}); +_ - +ok +end; +_ - +ok +end end, case Keys of nil -
svn commit: r766353 - in /couchdb/trunk: THANKS src/couchdb/couch_external_manager.erl
Author: davisp Date: Sat Apr 18 16:34:33 2009 New Revision: 766353 URL: http://svn.apache.org/viewvc?rev=766353view=rev Log: Fixes COUCHDB-311 Returns an _external error as a binary. Modified: couchdb/trunk/THANKS couchdb/trunk/src/couchdb/couch_external_manager.erl Modified: couchdb/trunk/THANKS URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=766353r1=766352r2=766353view=diff == --- couchdb/trunk/THANKS (original) +++ couchdb/trunk/THANKS Sat Apr 18 16:34:33 2009 @@ -25,5 +25,6 @@ * Eric Casteleijn eric.castele...@canonical.com * Maarten Thibaut mthib...@cisco.com * Florian Ebeling florian.ebel...@gmail.com + * Volker Mische volker.mis...@gmail.com For a list of authors see the `AUTHORS` file. Modified: couchdb/trunk/src/couchdb/couch_external_manager.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_external_manager.erl?rev=766353r1=766352r2=766353view=diff == --- couchdb/trunk/src/couchdb/couch_external_manager.erl (original) +++ couchdb/trunk/src/couchdb/couch_external_manager.erl Sat Apr 18 16:34:33 2009 @@ -53,9 +53,9 @@ [] - case couch_config:get(external, UrlName, nil) of nil - -Mesg = lists:flatten( +Msg = lists:flatten( io_lib:format(No server configured for ~p., [UrlName])), -{reply, {error, {unknown_external_server, Mesg}}, Handlers}; +{reply, {error, {unknown_external_server, ?l2b(Msg)}}, Handlers}; Command - {ok, NewPid} = couch_external_server:start_link(UrlName, Command), true = ets:insert(Handlers, {UrlName, NewPid}),
svn commit: r766358 - /couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
Author: davisp Date: Sat Apr 18 17:12:38 2009 New Revision: 766358 URL: http://svn.apache.org/viewvc?rev=766358view=rev Log: Fixes COUCHDB-310 Change the hardcoded /_utils/ redirect to append a '/' to the current path. Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=766358r1=766357r2=766358view=diff == --- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Sat Apr 18 17:12:38 2009 @@ -50,7 +50,8 @@ couch_httpd:serve_file(Req, RelativePath, DocumentRoot); {_ActionKey, , _RelativePath} - % GET /_utils -couch_httpd:send_redirect(Req, /_utils/) +RedirectPath = couch_httpd:path(Req) ++ /, +couch_httpd:send_redirect(Req, RedirectPath) end; handle_utils_dir_req(Req, _) - send_method_not_allowed(Req, GET,HEAD).
svn commit: r766373 - in /couchdb/trunk: share/www/script/test/basics.js share/www/script/test/view_errors.js src/couchdb/couch_httpd_db.erl src/couchdb/couch_httpd_view.erl
Author: davisp Date: Sat Apr 18 18:34:31 2009 New Revision: 766373 URL: http://svn.apache.org/viewvc?rev=766373view=rev Log: Resolves COUCHDB-306 - Wacky error responses to malformed documents Mostly adds improvements to the parsing of Json bodies for _bulk_docs and multi-get queries. Includes tests in basics.js and view_errors.js. Modified: couchdb/trunk/share/www/script/test/basics.js couchdb/trunk/share/www/script/test/view_errors.js couchdb/trunk/src/couchdb/couch_httpd_db.erl couchdb/trunk/src/couchdb/couch_httpd_view.erl Modified: couchdb/trunk/share/www/script/test/basics.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/basics.js?rev=766373r1=766372r2=766373view=diff == --- couchdb/trunk/share/www/script/test/basics.js (original) +++ couchdb/trunk/share/www/script/test/basics.js Sat Apr 18 18:34:31 2009 @@ -168,4 +168,32 @@ // deleting a non-existent doc should be 404 xhr = CouchDB.request(DELETE, /test_suite_db/doc-does-not-exist); T(xhr.status == 404); + +// Check some common error responses. +// PUT body not an object +xhr = CouchDB.request(PUT, /test_suite_db/bar, {body: []}); +T(xhr.status == 400); +result = JSON.parse(xhr.responseText); +T(result.error == bad_request); +T(result.reason == Document must be a JSON object); + +// Body of a _bulk_docs is not an object +xhr = CouchDB.request(POST, /test_suite_db/_bulk_docs, {body: []}); +T(xhr.status == 400); +result = JSON.parse(xhr.responseText); +T(result.error == bad_request); +T(result.reason == Body must be a JSON object); + +// Body of an _all_docs multi-get is not a {key: [...]} structure. +xhr = CouchDB.request(POST, /test_suite_db/_all_docs, {body: []}); +T(xhr.status == 400); +result = JSON.parse(xhr.responseText); +T(result.error == bad_request); +T(result.reason == Body must be a JSON object); +var data = {\keys\: 1}; +xhr = CouchDB.request(POST, /test_suite_db/_all_docs, {body:data}); +T(xhr.status == 400); +result = JSON.parse(xhr.responseText); +T(result.error == bad_request); +T(result.reason == `keys` member must be a array.); }; Modified: couchdb/trunk/share/www/script/test/view_errors.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_errors.js?rev=766373r1=766372r2=766373view=diff == --- couchdb/trunk/share/www/script/test/view_errors.js (original) +++ couchdb/trunk/share/www/script/test/view_errors.js Sat Apr 18 18:34:31 2009 @@ -94,4 +94,18 @@ } catch(e) { T(e.error == query_parse_error); } + + // Check error responses for invalid multi-get bodies. + var path = /test_suite_db/_design/test/_view/no_reduce; + var xhr = CouchDB.request(POST, path, {body: []}); + T(xhr.status == 400); + result = JSON.parse(xhr.responseText); + T(result.error == bad_request); + T(result.reason == Body must be a JSON object); + var data = {\keys\: 1}; + xhr = CouchDB.request(POST, path, {body:data}); + T(xhr.status == 400); + result = JSON.parse(xhr.responseText); + T(result.error == bad_request); + T(result.reason == `keys` member must be a array.); }; Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=766373r1=766372r2=766373view=diff == --- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Sat Apr 18 18:34:31 2009 @@ -126,7 +126,13 @@ db_req(#httpd{method='POST',path_parts=[_,_bulk_docs]}=Req, Db) - couch_stats_collector:increment({httpd, bulk_requests}), -{JsonProps} = couch_httpd:json_body(Req), +JsonProps = +case couch_httpd:json_body(Req) of +{Fields} - +Fields; +_ - +throw({bad_request, Body must be a JSON object}) +end, DocsArray = proplists:get_value(docs, JsonProps), case couch_httpd:header_value(Req, X-Couch-Full-Commit, false) of true - @@ -220,9 +226,20 @@ all_docs_view(Req, Db, nil); db_req(#httpd{method='POST',path_parts=[_,_all_docs]}=Req, Db) - -{Props} = couch_httpd:json_body(Req), -Keys = proplists:get_value(keys, Props, nil), -all_docs_view(Req, Db, Keys); +case couch_httpd:json_body(Req) of +{Fields} - +case proplists:get_value(keys, Fields, nil) of +nil - +?LOG_DEBUG(POST to _all_docs with no keys member., []), +all_docs_view(Req, Db, nil); +Keys when is_list(Keys) - +all_docs_view(Req, Db, Keys); +_ - +throw({bad_request, `keys` member must be a array.}) +end; +_ - +throw({bad_request, Body must be a JSON object}) +end;
svn commit: r766383 - in /couchdb/trunk: share/server/ share/www/script/test/ src/couchdb/
Author: jchris Date: Sat Apr 18 20:15:44 2009 New Revision: 766383 URL: http://svn.apache.org/viewvc?rev=766383view=rev Log: refactor main.js into many files and improve show/list error handling Added: couchdb/trunk/share/server/loop.js (with props) couchdb/trunk/share/server/mainjs.sh (with props) couchdb/trunk/share/server/render.js (with props) couchdb/trunk/share/server/state.js (with props) couchdb/trunk/share/server/util.js (with props) couchdb/trunk/share/server/validate.js (with props) couchdb/trunk/share/server/views.js (with props) Modified: couchdb/trunk/share/server/main.js couchdb/trunk/share/www/script/test/list_views.js couchdb/trunk/share/www/script/test/show_documents.js couchdb/trunk/src/couchdb/couch_httpd.erl couchdb/trunk/src/couchdb/couch_httpd_show.erl couchdb/trunk/src/couchdb/couch_httpd_view.erl Added: couchdb/trunk/share/server/loop.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/server/loop.js?rev=766383view=auto == --- couchdb/trunk/share/server/loop.js (added) +++ couchdb/trunk/share/server/loop.js Sat Apr 18 20:15:44 2009 @@ -0,0 +1,62 @@ +// Licensed under the Apache License, Version 2.0 (the License); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +var sandbox = null; + +try { + // if possible, use evalcx (not always available) + sandbox = evalcx(''); + sandbox.emit = emit; + sandbox.sum = sum; + sandbox.log = log; + sandbox.toJSON = toJSON; + sandbox.respondWith = respondWith; + sandbox.registerType = registerType; +} catch (e) {} + +// Commands are in the form of json arrays: +// [commandname,..optional args...]\n +// +// Responses are json values followed by a new line (\n) + +var cmd, cmdkey; + +var dispatch = { + reset : State.reset, + add_fun: State.addFun, + map_doc: Views.mapDoc, + reduce : Views.reduce, + rereduce : Views.rereduce, + validate : Validate.validate, + show_doc : Render.showDoc, + list_begin : Render.listBegin, + list_row : Render.listRow, + list_tail : Render.listTail +}; + +while (cmd = eval(readline())) { + try { +cmdkey = cmd.shift(); +if (dispatch[cmdkey]) { + // run the correct responder with the cmd body + dispatch[cmdkey].apply(this, cmd); +} else { + // unknown command, quit and hope the restarted version is better + respond({ +error: query_server_error, +reason: unknown command ' + cmdkey + '}); + quit(); +} + } catch(e) { +respond(e); + } +}; Propchange: couchdb/trunk/share/server/loop.js -- svn:eol-style = native Modified: couchdb/trunk/share/server/main.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/server/main.js?rev=766383r1=766382r2=766383view=diff == --- couchdb/trunk/share/server/main.js [utf-8] (original) +++ couchdb/trunk/share/server/main.js [utf-8] Sat Apr 18 20:15:44 2009 @@ -10,33 +10,6 @@ // License for the specific language governing permissions and limitations under // the License. -var cmd; -var funs = [];// holds functions used for computation -var map_results = []; // holds temporary emitted values during doc map -var row_line = {}; // holds row number in list per func - -var sandbox = null; - -emit = function(key, value) { - map_results.push([key, value]); -} - -sum = function(values) { - var rv = 0; - for (var i in values) { -rv += values[i]; - } - return rv; -} - -log = function(message) { - if (typeof message == undefined) { -message = Error: attempting to log message of 'undefined'.; - } else if (typeof message != string) { -message = toJSON(message); - } - print(toJSON({log: message})); -} // mimeparse.js // http://code.google.com/p/mimeparse/ @@ -46,12 +19,12 @@ var Mimeparse = (function() { function strip(string) { -return string.replace(/^\s+/, '').replace(/\s+$/, '') +return string.replace(/^\s+/, '').replace(/\s+$/, ''); }; function parseRanges(ranges) { var parsedRanges = [], rangeParts = ranges.split(,); for (var i=0; i rangeParts.length; i++) { - parsedRanges.push(publicMethods.parseMediaRange(rangeParts[i])) + parsedRanges.push(publicMethods.parseMediaRange(rangeParts[i])); }; return parsedRanges; }; @@ -130,12 +103,12 @@ var parsedHeader =
svn commit: r766406 - in /couchdb/trunk/share: Makefile.am server/main.js server/mainjs.sh server/render.js
Author: jan Date: Sat Apr 18 23:32:56 2009 New Revision: 766406 URL: http://svn.apache.org/viewvc?rev=766406view=rev Log: move main.js generation to Makefile Removed: couchdb/trunk/share/server/main.js couchdb/trunk/share/server/mainjs.sh Modified: couchdb/trunk/share/Makefile.am couchdb/trunk/share/server/render.js Modified: couchdb/trunk/share/Makefile.am URL: http://svn.apache.org/viewvc/couchdb/trunk/share/Makefile.am?rev=766406r1=766405r2=766406view=diff == --- couchdb/trunk/share/Makefile.am (original) +++ couchdb/trunk/share/Makefile.am Sat Apr 18 23:32:56 2009 @@ -10,16 +10,19 @@ ## License for the specific language governing permissions and limitations ## under the License. +# loop.js MUST be last! MAKEJS_FILES = \ -server/loop.js \ server/render.js \ server/state.js \ server/util.js \ server/validate.js \ -server/views.js +server/views.js \ +server/loop.js server/main.js: $(MAKEJS_FILES) - server/mainjs.sh + @echo // Generated from *.js by make on `date` server/main.js + @echo // DO NOT EDIT BY HAND\n server/main.js + @cat $(MAKEJS_FILES) server/main.js CLEANFILES = server/main.js Modified: couchdb/trunk/share/server/render.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/server/render.js?rev=766406r1=766405r2=766406view=diff == --- couchdb/trunk/share/server/render.js (original) +++ couchdb/trunk/share/server/render.js Sat Apr 18 23:32:56 2009 @@ -10,7 +10,6 @@ // License for the specific language governing permissions and limitations under // the License. - // mimeparse.js // http://code.google.com/p/mimeparse/ // Code with comments: http://mimeparse.googlecode.com/svn/trunk/mimeparse.js