From 74b5bd2bfaa1d15c8e2f379b33ae601c9da2de13 Mon Sep 17 00:00:00 2001
From: Noah Slater
Date: Wed, 7 Jul 2010 18:49:29 +0000
Subject: update trunk with version info assuming 1.0.0 passes the vote
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961477 13f79535-47bb-0310-9956-ffa450edef68
---
CHANGES | 5 ++++-
NEWS | 5 ++++-
acinclude.m4.in | 4 ++--
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/CHANGES b/CHANGES
index 2224718f..1c609a20 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,11 +1,14 @@
Apache CouchDB CHANGES
======================
-Version 1.0.0
+Version 1.1.0
--------------
This version has not been released yet.
+Version 1.0.0
+--------------
+
HTTP Interface:
* Mask passwords in active tasks and logging.
diff --git a/NEWS b/NEWS
index b4fcdf32..cbda7fda 100644
--- a/NEWS
+++ b/NEWS
@@ -7,11 +7,14 @@ For details about backwards incompatible changes, see:
Each release section notes when backwards incompatible changes have been made.
-Version 1.0.0
+Version 1.1.0
--------------
This version has not been released yet.
+Version 1.0.0
+--------------
+
* Mask passwords in active tasks and logging.
* Update mochijson2 to allow output of BigNums not in float form.
* Added support for X-HTTP-METHOD-OVERRIDE.
diff --git a/acinclude.m4.in b/acinclude.m4.in
index ccfe9da7..253831be 100644
--- a/acinclude.m4.in
+++ b/acinclude.m4.in
@@ -16,8 +16,8 @@ m4_define([LOCAL_PACKAGE_IDENTIFIER], [couchdb])
m4_define([LOCAL_PACKAGE_TARNAME], [apache-couchdb])
m4_define([LOCAL_PACKAGE_NAME], [Apache CouchDB])
m4_define([LOCAL_BUG_URI], [https://issues.apache.org/jira/browse/COUCHDB])
-m4_define([LOCAL_VERSION_MAJOR], [0])
-m4_define([LOCAL_VERSION_MINOR], [12])
+m4_define([LOCAL_VERSION_MAJOR], [1])
+m4_define([LOCAL_VERSION_MINOR], [1])
m4_define([LOCAL_VERSION_REVISION], [0])
m4_define([LOCAL_VERSION_STAGE], [a])
m4_define([LOCAL_VERSION_RELEASE], [%release%])
--
cgit v1.2.3
From b458999a36785410d7a45b5d4cb5bea2d5638994 Mon Sep 17 00:00:00 2001
From: Noah Slater
Date: Wed, 7 Jul 2010 20:10:20 +0000
Subject: fixed up version numbers, etc
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961493 13f79535-47bb-0310-9956-ffa450edef68
---
CHANGES | 32 ++++++++++++++++++++++----------
NEWS | 18 ++++++++++++------
2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/CHANGES b/CHANGES
index 1c609a20..8cf39aab 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,11 +2,32 @@ Apache CouchDB CHANGES
======================
Version 1.1.0
---------------
+-------------
This version has not been released yet.
Version 1.0.0
+-------------
+
+Security:
+
+* Added authentication caching, to avoid repeated opening and closing of the
+ users database for each request requiring authentication.
+
+Storage System:
+
+* Small optimization for reordering result lists.
+* More efficient header commits.
+* Use O_APPEND to save lseeks.
+* Faster implementation of pread_iolist(). Further improves performance on
+ concurrent reads.
+
+View Server:
+
+* Faster default view collation.
+* Added option to include update_seq in view responses.
+
+Version 0.11.1
--------------
HTTP Interface:
@@ -43,8 +64,6 @@ Build and System Integration:
Security:
* Added authentication redirect URL to log in clients.
- * Added authentication caching, to avoid repeated opening and closing of the
- users database for each request requiring authentication.
* Fixed query parameter encoding issue in oauth.js.
* Made authentication timeout configurable.
* Temporary views are now admin-only resources.
@@ -56,14 +75,9 @@ Storage System:
it's correct.
* Make file deletions async to avoid pauses during compaction and db
deletion.
- * Small optimization for reordering result lists.
* Fixed for wrong offset when writing headers and converting them to blocks,
only triggered when header is larger than 4k.
- * More efficient header commits.
* Preserve _revs_limit and instance_start_time after compaction.
- * Use O_APPEND to save lseeks.
- * Faster implementation of pread_iolist(). Further improves performance on
- concurrent reads.
Configuration System:
@@ -84,9 +98,7 @@ View Server:
* Provide a UUID to update functions (and all other functions) that they can
use to create new docs.
- * Faster default view collation.
* Upgrade CommonJS modules support to 1.1.1.
- * Added option to include update_seq in view responses.
* Fixed erlang filter funs and normalize filter fun API.
* Fixed hang in view shutdown.
diff --git a/NEWS b/NEWS
index cbda7fda..d0ad8cfd 100644
--- a/NEWS
+++ b/NEWS
@@ -8,11 +8,22 @@ For details about backwards incompatible changes, see:
Each release section notes when backwards incompatible changes have been made.
Version 1.1.0
---------------
+-------------
This version has not been released yet.
Version 1.0.0
+-------------
+
+* More efficient header commits.
+* Use O_APPEND to save lseeks.
+* Faster implementation of pread_iolist(). Further improves performance on
+ concurrent reads.
+* Added authentication caching
+* Faster default view collation.
+* Added option to include update_seq in view responses.
+
+Version 0.11.1
--------------
* Mask passwords in active tasks and logging.
@@ -41,11 +52,7 @@ Version 1.0.0
deletion.
* Fixed for wrong offset when writing headers and converting them to blocks,
only triggered when header is larger than 4k.
- * More efficient header commits.
* Preserve _revs_limit and instance_start_time after compaction.
- * Use O_APPEND to save lseeks.
- * Faster implementation of pread_iolist(). Further improves performance on
- concurrent reads.
* Fixed timeout with large .ini files.
* Added tests for couch.js and jquery.couch.js
* Added various API features to jquery.couch.js
@@ -61,7 +68,6 @@ Version 1.0.0
* Allow isolation of databases with vhosts.
* Made the test suite overall more reliable.
-
Version 0.11.0
--------------
--
cgit v1.2.3
From ddd9811edb767d6ca9ba77ce6ae1eedffac6a8ca Mon Sep 17 00:00:00 2001
From: "Damien F. Katz"
Date: Thu, 8 Jul 2010 14:54:29 +0000
Subject: Fix for occasional failed tests caused by responding with 202 success
to compaction requests before the compaction actually begins.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961791 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_db.erl | 2 +-
src/couchdb/couch_db_updater.erl | 15 ++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index cf25dc62..80f0d7bf 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -103,7 +103,7 @@ monitor(#db{main_pid=MainPid}) ->
erlang:monitor(process, MainPid).
start_compact(#db{update_pid=Pid}) ->
- gen_server:cast(Pid, start_compact).
+ gen_server:call(Pid, start_compact).
delete_doc(Db, Id, Revisions) ->
DeletedDocs = [#doc{id=Id, revs=[Rev], deleted=true} || Rev <- Revisions],
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index 30275012..f0879700 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -143,21 +143,22 @@ handle_call({purge_docs, IdRevs}, _From, Db) ->
ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
couch_db_update_notifier:notify({updated, Db#db.name}),
- {reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2}.
-
-
-handle_cast(start_compact, Db) ->
+ {reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2};
+handle_call(start_compact, _From, Db) ->
case Db#db.compactor_pid of
nil ->
?LOG_INFO("Starting compaction for db \"~s\"", [Db#db.name]),
Pid = spawn_link(fun() -> start_copy_compact(Db) end),
Db2 = Db#db{compactor_pid=Pid},
ok = gen_server:call(Db#db.main_pid, {db_updated, Db2}),
- {noreply, Db2};
+ {reply, ok, Db2};
_ ->
% compact currently running, this is a no-op
- {noreply, Db}
- end;
+ {reply, ok, Db}
+ end.
+
+
+
handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
{ok, NewFd} = couch_file:open(CompactFilepath),
{ok, NewHeader} = couch_file:read_header(NewFd),
--
cgit v1.2.3
From 5c55239750edc5540825ef0bbf83fccb1bed459f Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Thu, 8 Jul 2010 18:09:20 +0000
Subject: use json as the default content-type for requests from
jquery.couch.js
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961854 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/script/jquery.couch.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index f9647ecd..879c2444 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -595,6 +595,7 @@
function ajax(obj, options, errorMessage, ajaxOptions) {
options = $.extend({successStatus: 200}, options);
+ ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions);
errorMessage = errorMessage || "Unknown error";
$.ajax($.extend($.extend({
type: "GET", dataType: "json", cache : !$.browser.msie,
--
cgit v1.2.3
From f3442c25ae26369a516cf12b94f86cdec406c5b6 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Thu, 8 Jul 2010 19:23:33 +0000
Subject: Fix deletion of view files after compaction. Also added test for view
compaction.
Thanks Adam for reporting the issue.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961893 13f79535-47bb-0310-9956-ffa450edef68
---
share/Makefile.am | 1 +
share/www/script/couch_tests.js | 1 +
share/www/script/test/view_compaction.js | 102 +++++++++++++++++++++++++++++++
src/couchdb/couch_view_group.erl | 4 +-
4 files changed, 106 insertions(+), 2 deletions(-)
create mode 100644 share/www/script/test/view_compaction.js
diff --git a/share/Makefile.am b/share/Makefile.am
index fc052de0..c85f683f 100644
--- a/share/Makefile.am
+++ b/share/Makefile.am
@@ -162,6 +162,7 @@ nobase_dist_localdata_DATA = \
www/script/test/view_collation.js \
www/script/test/view_collation_raw.js \
www/script/test/view_conflicts.js \
+ www/script/test/view_compaction.js \
www/script/test/view_errors.js \
www/script/test/view_include_docs.js \
www/script/test/view_multi_key_all_docs.js \
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index dc283bba..c5257ea6 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -85,6 +85,7 @@ loadTest("uuids.js");
loadTest("view_collation.js");
loadTest("view_collation_raw.js");
loadTest("view_conflicts.js");
+loadTest("view_compaction.js");
loadTest("view_errors.js");
loadTest("view_include_docs.js");
loadTest("view_multi_key_all_docs.js");
diff --git a/share/www/script/test/view_compaction.js b/share/www/script/test/view_compaction.js
new file mode 100644
index 00000000..318dfdb5
--- /dev/null
+++ b/share/www/script/test/view_compaction.js
@@ -0,0 +1,102 @@
+// 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.
+
+couchTests.view_compaction = function(debug) {
+
+ if (debug) debugger;
+
+ var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit": "true"});
+
+ db.deleteDb();
+ db.createDb();
+
+ var ddoc = {
+ _id: "_design/foo",
+ language: "javascript",
+ views: {
+ view1: {
+ map: "function(doc) { emit(doc._id, doc.value) }"
+ },
+ view2: {
+ map: "function(doc) { emit(doc._id, doc.value); }",
+ reduce: "function(keys, values, rereduce) { return sum(values); }"
+ }
+ }
+ };
+ T(db.save(ddoc).ok);
+
+ var docs = makeDocs(0, 1000);
+ db.bulkSave(docs);
+
+ var resp = db.view('foo/view1', {});
+ T(resp.rows.length === 1000);
+
+ resp = db.view('foo/view2', {});
+ T(resp.rows.length === 1);
+
+ resp = db.designInfo("_design/foo");
+ T(resp.view_index.update_seq === 1001);
+
+
+ // update docs
+ for (var i = 0; i < docs.length; i++) {
+ docs[i].integer = docs[i].integer + 1;
+ }
+ db.bulkSave(docs);
+
+
+ resp = db.view('foo/view1', {});
+ T(resp.rows.length === 1000);
+
+ resp = db.view('foo/view2', {});
+ T(resp.rows.length === 1);
+
+ resp = db.designInfo("_design/foo");
+ T(resp.view_index.update_seq === 2001);
+
+
+ // update docs again...
+ for (var i = 0; i < docs.length; i++) {
+ docs[i].integer = docs[i].integer + 2;
+ }
+ db.bulkSave(docs);
+
+
+ resp = db.view('foo/view1', {});
+ T(resp.rows.length === 1000);
+
+ resp = db.view('foo/view2', {});
+ T(resp.rows.length === 1);
+
+ resp = db.designInfo("_design/foo");
+ T(resp.view_index.update_seq === 3001);
+
+
+ // compact view group
+ var xhr = CouchDB.request("POST", "/" + db.name + "/_compact" + "/foo");
+ T(JSON.parse(xhr.responseText).ok === true);
+
+ resp = db.designInfo("_design/foo");
+ while (resp.view_index.compact_running === true) {
+ resp = db.designInfo("_design/foo");
+ }
+
+
+ resp = db.view('foo/view1', {});
+ T(resp.rows.length === 1000);
+
+ resp = db.view('foo/view2', {});
+ T(resp.rows.length === 1);
+
+ resp = db.designInfo("_design/foo");
+ T(resp.view_index.update_seq === 3001);
+};
\ No newline at end of file
diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl
index 8d3a3d86..f01befdf 100644
--- a/src/couchdb/couch_view_group.erl
+++ b/src/couchdb/couch_view_group.erl
@@ -186,7 +186,7 @@ handle_cast({compact_done, #group{current_seq=NewSeq} = NewGroup},
?LOG_INFO("View index compaction complete for ~s ~s", [DbName, GroupId]),
FileName = index_file_name(RootDir, DbName, GroupSig),
CompactName = index_file_name(compact, RootDir, DbName, GroupSig),
- couch_file:delete(FileName),
+ ok = couch_file:delete(RootDir, FileName),
ok = file:rename(CompactName, FileName),
%% if an updater is running, kill it and start a new one
@@ -545,7 +545,7 @@ reset_file(Db, Fd, DbName, #group{sig=Sig,name=Name} = Group) ->
init_group(Db, Fd, reset_group(Group), nil).
delete_index_file(RootDir, DbName, GroupSig) ->
- couch_file:delete(index_file_name(RootDir, DbName, GroupSig)).
+ couch_file:delete(RootDir, index_file_name(RootDir, DbName, GroupSig)).
init_group(Db, Fd, #group{views=Views}=Group, nil) ->
init_group(Db, Fd, Group,
--
cgit v1.2.3
From fe73841cf1d2efe08d918d979db003e176aa258f Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Thu, 8 Jul 2010 19:47:08 +0000
Subject: validate admin and content type for compact requests
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961904 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_httpd_db.erl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index f1514785..783ed9f9 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -111,12 +111,15 @@ handle_changes_req(#httpd{method='GET'}=Req, Db) ->
handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
send_method_not_allowed(Req, "GET,HEAD").
-handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, _Db) ->
+handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, Db) ->
+ ok = couch_db:check_is_admin(Db),
couch_httpd:validate_ctype(Req, "application/json"),
ok = couch_view_compactor:start_compact(DbName, Id),
send_json(Req, 202, {[{ok, true}]});
handle_compact_req(#httpd{method='POST'}=Req, Db) ->
+ ok = couch_db:check_is_admin(Db),
+ couch_httpd:validate_ctype(Req, "application/json"),
ok = couch_db:start_compact(Db),
send_json(Req, 202, {[{ok, true}]});
@@ -125,6 +128,8 @@ handle_compact_req(Req, _Db) ->
handle_view_cleanup_req(#httpd{method='POST'}=Req, Db) ->
% delete unreferenced index files
+ ok = couch_db:check_is_admin(Db),
+ couch_httpd:validate_ctype(Req, "application/json"),
ok = couch_view:cleanup_index_files(Db),
send_json(Req, 202, {[{ok, true}]});
--
cgit v1.2.3
From 44fe80dfdcf8540402e80580bcfa4f184cbc3b21 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Fri, 9 Jul 2010 09:25:44 +0000
Subject: Adding one more assertion to the view_compaction.js test to verify
that the view group disk size is smaller after compaction.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@962460 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/script/test/view_compaction.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/share/www/script/test/view_compaction.js b/share/www/script/test/view_compaction.js
index 318dfdb5..a11fb7bd 100644
--- a/share/www/script/test/view_compaction.js
+++ b/share/www/script/test/view_compaction.js
@@ -80,6 +80,7 @@ couchTests.view_compaction = function(debug) {
resp = db.designInfo("_design/foo");
T(resp.view_index.update_seq === 3001);
+ var disk_size_before_compact = resp.view_index.disk_size;
// compact view group
var xhr = CouchDB.request("POST", "/" + db.name + "/_compact" + "/foo");
@@ -99,4 +100,5 @@ couchTests.view_compaction = function(debug) {
resp = db.designInfo("_design/foo");
T(resp.view_index.update_seq === 3001);
+ T(resp.view_index.disk_size < disk_size_before_compact);
};
\ No newline at end of file
--
cgit v1.2.3
From ba34253d2bb6fa561a247fb0ed2f5acd7cd66e7f Mon Sep 17 00:00:00 2001
From: Noah Slater
Date: Fri, 9 Jul 2010 15:51:32 +0000
Subject: added some list padding to NEWS and CHANGES
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@962577 13f79535-47bb-0310-9956-ffa450edef68
---
CHANGES | 18 +++++++++---------
NEWS | 14 +++++++-------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/CHANGES b/CHANGES
index 8cf39aab..d6ab8cf6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -11,21 +11,21 @@ Version 1.0.0
Security:
-* Added authentication caching, to avoid repeated opening and closing of the
- users database for each request requiring authentication.
+ * Added authentication caching, to avoid repeated opening and closing of the
+ users database for each request requiring authentication.
Storage System:
-* Small optimization for reordering result lists.
-* More efficient header commits.
-* Use O_APPEND to save lseeks.
-* Faster implementation of pread_iolist(). Further improves performance on
- concurrent reads.
+ * Small optimization for reordering result lists.
+ * More efficient header commits.
+ * Use O_APPEND to save lseeks.
+ * Faster implementation of pread_iolist(). Further improves performance on
+ concurrent reads.
View Server:
-* Faster default view collation.
-* Added option to include update_seq in view responses.
+ * Faster default view collation.
+ * Added option to include update_seq in view responses.
Version 0.11.1
--------------
diff --git a/NEWS b/NEWS
index d0ad8cfd..8e4f4e8b 100644
--- a/NEWS
+++ b/NEWS
@@ -15,13 +15,13 @@ This version has not been released yet.
Version 1.0.0
-------------
-* More efficient header commits.
-* Use O_APPEND to save lseeks.
-* Faster implementation of pread_iolist(). Further improves performance on
- concurrent reads.
-* Added authentication caching
-* Faster default view collation.
-* Added option to include update_seq in view responses.
+ * More efficient header commits.
+ * Use O_APPEND to save lseeks.
+ * Faster implementation of pread_iolist(). Further improves performance on
+ concurrent reads.
+ * Added authentication caching
+ * Faster default view collation.
+ * Added option to include update_seq in view responses.
Version 0.11.1
--------------
--
cgit v1.2.3
From 10ba6ce1529f04e567e3a71a9898b2c9a623dd51 Mon Sep 17 00:00:00 2001
From: Adam Kocoloski
Date: Sun, 11 Jul 2010 01:00:50 +0000
Subject: deleting a DB while it was being opened would crash couch_server
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@962964 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_server.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 43fd9044..88bd6107 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -326,7 +326,7 @@ handle_call({delete, DbName, _Options}, _From, Server) ->
couch_util:shutdown_sync(Pid),
true = ets:delete(couch_dbs_by_name, DbName),
true = ets:delete(couch_dbs_by_pid, Pid),
- [gen_server:send_result(F, not_found) || F <- Froms],
+ [gen_server:reply(F, not_found) || F <- Froms],
true;
[{_, {opened, Pid, LruTime}}] ->
couch_util:shutdown_sync(Pid),
--
cgit v1.2.3
From 828d8eba2628fed701cbb59e0edd6da8fb482293 Mon Sep 17 00:00:00 2001
From: Adam Kocoloski
Date: Sun, 11 Jul 2010 01:02:14 +0000
Subject: thank you dialyzer
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@962965 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_httpd_db.erl | 4 +---
src/couchdb/couch_query_servers.erl | 20 +++++---------------
2 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 783ed9f9..60bf38cb 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -970,9 +970,7 @@ db_attachment_req(#httpd{method=Method,mochi_req=MochiReq}=Req, Db, DocId, FileN
end,
- fun() -> couch_httpd:recv(Req, 0) end;
- Length ->
- exit({length_not_integer, Length})
+ fun() -> couch_httpd:recv(Req, 0) end
end,
att_len = case couch_httpd:header_value(Req,"Content-Length") of
undefined ->
diff --git a/src/couchdb/couch_query_servers.erl b/src/couchdb/couch_query_servers.erl
index b2aa7a12..3df7beb0 100644
--- a/src/couchdb/couch_query_servers.erl
+++ b/src/couchdb/couch_query_servers.erl
@@ -130,8 +130,6 @@ os_reduce(Lang, OsRedSrcs, KVs) ->
end,
{ok, OsResults}.
-os_rereduce(_Lang, [], _KVs) ->
- {ok, []};
os_rereduce(Lang, OsRedSrcs, KVs) ->
Proc = get_os_process(Lang),
try proc_prompt(Proc, [<<"rereduce">>, OsRedSrcs, KVs]) of
@@ -275,23 +273,15 @@ handle_call({get_proc, #doc{body={Props}}=DDoc, DDocKey}, _From, {Langs, PidProc
case ets:lookup(LangProcs, Lang) of
[{Lang, [P|Rest]}] ->
% find a proc in the set that has the DDoc
- case proc_with_ddoc(DDoc, DDocKey, [P|Rest]) of
- {ok, Proc} ->
- rem_from_list(LangProcs, Lang, Proc),
- {reply, {ok, Proc, get_query_server_config()}, Server};
- Error ->
- {reply, Error, Server}
- end;
+ {ok, Proc} = proc_with_ddoc(DDoc, DDocKey, [P|Rest]),
+ rem_from_list(LangProcs, Lang, Proc),
+ {reply, {ok, Proc, get_query_server_config()}, Server};
_ ->
case (catch new_process(Langs, Lang)) of
{ok, Proc} ->
add_value(PidProcs, Proc#proc.pid, Proc),
- case proc_with_ddoc(DDoc, DDocKey, [Proc]) of
- {ok, Proc2} ->
- {reply, {ok, Proc2, get_query_server_config()}, Server};
- Error ->
- {reply, Error, Server}
- end;
+ {ok, Proc2} = proc_with_ddoc(DDoc, DDocKey, [Proc]),
+ {reply, {ok, Proc2, get_query_server_config()}, Server};
Error ->
{reply, Error, Server}
end
--
cgit v1.2.3
From d4446bfb78a2f5f9049e5aa52f2927769e239286 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Sun, 11 Jul 2010 10:11:55 +0000
Subject: Removing couch_util:read_file_size/1 because same functionality is
provided by filelib:file_size/1.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963038 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_log.erl | 2 +-
src/couchdb/couch_util.erl | 10 +---------
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index 2d62cbb5..d21f7ecc 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -139,7 +139,7 @@ log(Fd, Pid, Level, Format, Args) ->
read(Bytes, Offset) ->
LogFileName = couch_config:get("log", "file"),
- LogFileSize = couch_util:file_read_size(LogFileName),
+ LogFileSize = filelib:file_size(LogFileName),
{ok, Fd} = file:open(LogFileName, [read]),
Start = lists:max([LogFileSize - Bytes, 0]) + Offset,
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index e50ab2fe..ff4cbe36 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -18,7 +18,7 @@
-export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]).
-export([encodeBase64Url/1, decodeBase64Url/1]).
-export([to_hex/1, parse_term/1, dict_find/3]).
--export([file_read_size/1, get_nested_json_value/2, json_user_ctx/1]).
+-export([get_nested_json_value/2, json_user_ctx/1]).
-export([proplist_apply_field/2, json_apply_field/2]).
-export([to_binary/1, to_integer/1, to_list/1, url_encode/1]).
-export([json_encode/1, json_decode/1]).
@@ -314,14 +314,6 @@ dict_find(Key, Dict, DefaultValue) ->
DefaultValue
end.
-
-file_read_size(FileName) ->
- case file:read_file_info(FileName) of
- {ok, FileInfo} ->
- FileInfo#file_info.size;
- Error -> Error
- end.
-
to_binary(V) when is_binary(V) ->
V;
to_binary(V) when is_list(V) ->
--
cgit v1.2.3
From f5f04686b010d6326e88cfafcdc6629560c36d0d Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Sun, 11 Jul 2010 10:31:38 +0000
Subject: Removing unnecessary code.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963042 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_util.erl | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index ff4cbe36..252d4e04 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -144,18 +144,11 @@ get_nested_json_value(Value, []) ->
get_nested_json_value(_NotJSONObj, _) ->
throw({not_found, json_mismatch}).
-proplist_apply_field(H, L) ->
- {R} = json_apply_field(H, {L}),
- R.
-
-json_apply_field(H, {L}) ->
- json_apply_field(H, L, []).
-json_apply_field({Key, NewValue}, [{Key, _OldVal} | Headers], Acc) ->
- json_apply_field({Key, NewValue}, Headers, Acc);
-json_apply_field({Key, NewValue}, [{OtherKey, OtherVal} | Headers], Acc) ->
- json_apply_field({Key, NewValue}, Headers, [{OtherKey, OtherVal} | Acc]);
-json_apply_field({Key, NewValue}, [], Acc) ->
- {[{Key, NewValue}|Acc]}.
+proplist_apply_field({K, _V} = KV, L) ->
+ lists:keystore(K, 1, L, KV).
+
+json_apply_field({K, _V} = KV, {L}) ->
+ {lists:keystore(K, 1, L, KV)}.
json_user_ctx(#db{name=DbName, user_ctx=Ctx}) ->
{[{<<"db">>, DbName},
--
cgit v1.2.3
From c795df0dd2176e919dac722dd59d41c25df19b98 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Sun, 11 Jul 2010 10:50:34 +0000
Subject: Removing unused function couch_util:ascii_lower/1. If ever needed,
the exact same functionality is provided by string:to_lower/1 (ASCII based,
not Unicode nor charset based).
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963045 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_util.erl | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index 252d4e04..80c92271 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -15,7 +15,7 @@
-export([priv_dir/0, start_driver/1, normpath/1]).
-export([should_flush/0, should_flush/1, to_existing_atom/1]).
-export([rand32/0, implode/2, collate/2, collate/3]).
--export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]).
+-export([abs_pathname/1,abs_pathname/2, trim/1]).
-export([encodeBase64Url/1, decodeBase64Url/1]).
-export([to_hex/1, parse_term/1, dict_find/3]).
-export([get_nested_json_value/2, json_user_ctx/1]).
@@ -196,18 +196,6 @@ separate_cmd_args(" " ++ Rest, CmdAcc) ->
separate_cmd_args([Char|Rest], CmdAcc) ->
separate_cmd_args(Rest, [Char | CmdAcc]).
-% lowercases string bytes that are the ascii characters A-Z.
-% All other characters/bytes are ignored.
-ascii_lower(String) ->
- ascii_lower(String, []).
-
-ascii_lower([], Acc) ->
- lists:reverse(Acc);
-ascii_lower([Char | RestString], Acc) when Char >= $A, Char =< $B ->
- ascii_lower(RestString, [Char + ($a-$A) | Acc]);
-ascii_lower([Char | RestString], Acc) ->
- ascii_lower(RestString, [Char | Acc]).
-
% Is a character whitespace?
is_whitespace($\s) -> true;
is_whitespace($\t) -> true;
--
cgit v1.2.3
From c5e6b0459adae4c9ef9386170993d7dd1b320cd0 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Sun, 11 Jul 2010 21:30:46 +0000
Subject: Simplification - avoid 2 proplists lookups and an unnecessary list to
binary conversion.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963151 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_httpd_db.erl | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 60bf38cb..05979e46 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -600,13 +600,12 @@ db_doc_req(#httpd{method='POST'}=Req, Db, DocId) ->
couch_doc:validate_docid(DocId),
couch_httpd:validate_ctype(Req, "multipart/form-data"),
Form = couch_httpd:parse_form(Req),
- case proplists:is_defined("_doc", Form) of
- true ->
- Json = ?JSON_DECODE(couch_util:get_value("_doc", Form)),
- Doc = couch_doc_from_req(Req, DocId, Json);
- false ->
- Rev = couch_doc:parse_rev(list_to_binary(couch_util:get_value("_rev", Form))),
- {ok, [{ok, Doc}]} = couch_db:open_doc_revs(Db, DocId, [Rev], [])
+ case couch_util:get_value("_doc", Form) of
+ undefined ->
+ Rev = couch_doc:parse_rev(couch_util:get_value("_rev", Form)),
+ {ok, [{ok, Doc}]} = couch_db:open_doc_revs(Db, DocId, [Rev], []);
+ Json ->
+ Doc = couch_doc_from_req(Req, DocId, ?JSON_DECODE(Json))
end,
UpdatedAtts = [
#att{name=validate_attachment_name(Name),
--
cgit v1.2.3
From 9599f7cd77ef8a6feacec3c8ead9432af02a57d3 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Mon, 12 Jul 2010 17:24:00 +0000
Subject: Reverting revision 963042 - lists:keystore/4 only replaces the first
occurrence in the list.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963367 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_util.erl | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index 80c92271..2aa69af8 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -144,11 +144,18 @@ get_nested_json_value(Value, []) ->
get_nested_json_value(_NotJSONObj, _) ->
throw({not_found, json_mismatch}).
-proplist_apply_field({K, _V} = KV, L) ->
- lists:keystore(K, 1, L, KV).
-
-json_apply_field({K, _V} = KV, {L}) ->
- {lists:keystore(K, 1, L, KV)}.
+proplist_apply_field(H, L) ->
+ {R} = json_apply_field(H, {L}),
+ R.
+
+json_apply_field(H, {L}) ->
+ json_apply_field(H, L, []).
+json_apply_field({Key, NewValue}, [{Key, _OldVal} | Headers], Acc) ->
+ json_apply_field({Key, NewValue}, Headers, Acc);
+json_apply_field({Key, NewValue}, [{OtherKey, OtherVal} | Headers], Acc) ->
+ json_apply_field({Key, NewValue}, Headers, [{OtherKey, OtherVal} | Acc]);
+json_apply_field({Key, NewValue}, [], Acc) ->
+ {[{Key, NewValue}|Acc]}.
json_user_ctx(#db{name=DbName, user_ctx=Ctx}) ->
{[{<<"db">>, DbName},
--
cgit v1.2.3
From 934693735ad6c6358a240a466d4ce121f150e1aa Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Tue, 13 Jul 2010 14:25:03 +0000
Subject: test and fix for deleting users documents
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963723 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/script/test/users_db.js | 7 ++++++-
src/couchdb/couch_js_functions.hrl | 8 ++++----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/share/www/script/test/users_db.js b/share/www/script/test/users_db.js
index b85adf08..667ff3c1 100644
--- a/share/www/script/test/users_db.js
+++ b/share/www/script/test/users_db.js
@@ -85,8 +85,13 @@ couchTests.users_db = function(debug) {
T(/conflict/.test(e.reason))
}
+ // you can delete a user doc
+ s = CouchDB.session().userCtx;
+ T(s.name == null);
+ T(s.roles.indexOf("_admin") !== -1);
+ T(usersDb.deleteDoc(jchrisWithConflict).ok);
};
-
+
usersDb.deleteDb();
run_on_modified_server(
[{section: "couch_httpd_auth",
diff --git a/src/couchdb/couch_js_functions.hrl b/src/couchdb/couch_js_functions.hrl
index 3214b1f6..1f314f6e 100644
--- a/src/couchdb/couch_js_functions.hrl
+++ b/src/couchdb/couch_js_functions.hrl
@@ -12,10 +12,6 @@
-define(AUTH_DB_DOC_VALIDATE_FUNCTION, <<"
function(newDoc, oldDoc, userCtx) {
- if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
- throw({forbidden : 'doc.type must be user'});
- } // we only allow user docs for now
-
if (newDoc._deleted === true) {
// allow deletes by admins and matching users
// without checking the other fields
@@ -27,6 +23,10 @@
}
}
+ if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
+ throw({forbidden : 'doc.type must be user'});
+ } // we only allow user docs for now
+
if (!newDoc.name) {
throw({forbidden: 'doc.name is required'});
}
--
cgit v1.2.3
From 32c60cf5c554a1ff3819cc658ebf5846ccb9d6be Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Tue, 13 Jul 2010 14:25:06 +0000
Subject: show the complete document body even when the document is deleted
(Couch lets you store data with a delete but did not render it to JSON)
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963725 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_doc.erl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index 50dbd9d0..acae0c55 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -27,8 +27,8 @@ to_json_rev(0, []) ->
to_json_rev(Start, [FirstRevId|_]) ->
[{<<"_rev">>, ?l2b([integer_to_list(Start),"-",revid_to_str(FirstRevId)])}].
-to_json_body(true, _Body) ->
- [{<<"_deleted">>, true}];
+to_json_body(true, {Body}) ->
+ Body ++ [{<<"_deleted">>, true}];
to_json_body(false, {Body}) ->
Body.
--
cgit v1.2.3
From d44a6346ecd5869c626452df9eb22711c32f119e Mon Sep 17 00:00:00 2001
From: Jan Lehnardt
Date: Wed, 14 Jul 2010 09:18:03 +0000
Subject: fix test report sharing
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@963982 13f79535-47bb-0310-9956-ffa450edef68
---
share/Makefile.am | 1 +
1 file changed, 1 insertion(+)
diff --git a/share/Makefile.am b/share/Makefile.am
index c85f683f..b6f97e29 100644
--- a/share/Makefile.am
+++ b/share/Makefile.am
@@ -52,6 +52,7 @@ nobase_dist_localdata_DATA = \
www/dialog/_delete_database.html \
www/dialog/_delete_document.html \
www/dialog/_database_security.html \
+ www/dialog/_share_test_reports.html \
www/dialog/_save_view_as.html \
www/dialog/_upload_attachment.html \
www/document.html \
--
cgit v1.2.3
From 0dfa5afb632d06cfeb98853aa2c41f4aa763546a Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Wed, 14 Jul 2010 17:49:39 +0000
Subject: Bug fix: badmatch error after deleting a user doc (uncovered by
revision 963723).
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964108 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/script/test/auth_cache.js | 12 ++++++++++++
src/couchdb/couch_auth_cache.erl | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/share/www/script/test/auth_cache.js b/share/www/script/test/auth_cache.js
index 4d380e41..8c3fa943 100644
--- a/share/www/script/test/auth_cache.js
+++ b/share/www/script/test/auth_cache.js
@@ -225,7 +225,19 @@ couchTests.auth_cache = function(debug) {
T(misses_after === misses_before);
T(hits_after === (hits_before + 2));
+ T(authDb.deleteDoc(fdmanana).ok);
T(CouchDB.logout().ok);
+
+ hits_before = hits_after;
+ misses_before = misses_after;
+
+ T(CouchDB.login("fdmanana", "javascript").error === "unauthorized");
+
+ hits_after = hits();
+ misses_after = misses();
+
+ T(misses_after === (misses_before + 1));
+ T(hits_after === hits_before);
}
diff --git a/src/couchdb/couch_auth_cache.erl b/src/couchdb/couch_auth_cache.erl
index bff801fa..078bfcc1 100644
--- a/src/couchdb/couch_auth_cache.erl
+++ b/src/couchdb/couch_auth_cache.erl
@@ -289,7 +289,7 @@ refresh_entry(Db, #doc_info{high_seq = DocSeq} = DocInfo) ->
[] ->
ok;
[{UserName, {_OldCreds, ATime}}] ->
- {ok, Doc} = couch_db:open_doc(Db, DocInfo, [conflicts]),
+ {ok, Doc} = couch_db:open_doc(Db, DocInfo, [conflicts, deleted]),
NewCreds = user_creds(Doc),
true = ets:insert(?BY_USER, {UserName, {NewCreds, ATime}})
end;
--
cgit v1.2.3
From de53d5ca550ce54bf72273bb05687b87b4817483 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Wed, 14 Jul 2010 17:56:06 +0000
Subject: Fix test assertions introduced in revision 964108.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964111 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/script/test/auth_cache.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/share/www/script/test/auth_cache.js b/share/www/script/test/auth_cache.js
index 8c3fa943..75827dbd 100644
--- a/share/www/script/test/auth_cache.js
+++ b/share/www/script/test/auth_cache.js
@@ -236,8 +236,8 @@ couchTests.auth_cache = function(debug) {
hits_after = hits();
misses_after = misses();
- T(misses_after === (misses_before + 1));
- T(hits_after === hits_before);
+ T(misses_after === misses_before);
+ T(hits_after === (hits_before + 1));
}
--
cgit v1.2.3
From 29f789e66f71f08434985df0c7622407f0b54102 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Wed, 14 Jul 2010 21:12:19 +0000
Subject: Adapt test to change introduced in revision 963725 - deleted
documents can now have non-empty bodies.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964201 13f79535-47bb-0310-9956-ffa450edef68
---
test/etap/031-doc-to-json.t | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/etap/031-doc-to-json.t b/test/etap/031-doc-to-json.t
index 05425d38..605a6d00 100755
--- a/test/etap/031-doc-to-json.t
+++ b/test/etap/031-doc-to-json.t
@@ -78,8 +78,8 @@ test_to_json_success() ->
},
{
#doc{deleted=true, body={[{<<"foo">>, <<"bar">>}]}},
- {[{<<"_id">>, <<>>}, {<<"_deleted">>, true}]},
- "Deleted docs drop body members."
+ {[{<<"_id">>, <<>>}, {<<"foo">>, <<"bar">>}, {<<"_deleted">>, true}]},
+ "Deleted docs no longer drop body members."
},
{
#doc{meta=[
--
cgit v1.2.3
From 501e2bd5b85eb4df71e071e3df284df9bf36d92a Mon Sep 17 00:00:00 2001
From: Robert Newson
Date: Thu, 15 Jul 2010 19:39:18 +0000
Subject: Update AUTHORS to use my new apache.org address.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964549 13f79535-47bb-0310-9956-ffa450edef68
---
AUTHORS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/AUTHORS b/AUTHORS
index b1a3559e..e0181c1d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -15,6 +15,6 @@ documentation or developing software. Some of these people are:
* Mark Hammond
* Benoît Chesneau
* Filipe Manana
- * Robert Newson
+ * Robert Newson
For a list of other credits see the `THANKS` file.
--
cgit v1.2.3
From aa979801f94952acd558f7809417b40104846cfb Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Fri, 16 Jul 2010 21:32:57 +0000
Subject: Fix for a pull replication, targeted to a 1.0 CouchDB server, where
the source DB is in a remote CouchDB 0.11.0 server and the target DB is local
(1.0 CouchDB DB).
Closes ticket COUCHDB-827.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964956 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_db.erl | 16 +++++++++++++---
src/couchdb/couch_rep_att.erl | 8 ++++++--
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 80f0d7bf..b445046f 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -901,10 +901,20 @@ with_stream(Fd, #att{md5=InMd5,type=Type,encoding=Enc}=Att, Fun) ->
write_streamed_attachment(_Stream, _F, 0) ->
ok;
+% LenLeft might be different from the total size of what function F returns.
+% This happens when doing a pull replication of compressed attachments from a
+% 0.11.0 server, where LenLeft will match the uncompressed size but we end up
+% receiving the attachment compressed (therefore a size different from LenLeft).
+% This is because 0.11.0 doesn't understand the query parameter
+% "?att_encoding_info=true" when we do a doc request (GET /somedb/somedoc).
write_streamed_attachment(Stream, F, LenLeft) ->
- Bin = F(),
- ok = couch_stream:write(Stream, Bin),
- write_streamed_attachment(Stream, F, LenLeft - size(Bin)).
+ case F() of
+ Bin when is_binary(Bin) ->
+ ok = couch_stream:write(Stream, Bin),
+ write_streamed_attachment(Stream, F, LenLeft - size(Bin));
+ eof ->
+ ok
+ end.
enum_docs_since_reduce_to_count(Reds) ->
couch_btree:final_reduce(
diff --git a/src/couchdb/couch_rep_att.erl b/src/couchdb/couch_rep_att.erl
index 28b8945c..367afbb5 100644
--- a/src/couchdb/couch_rep_att.erl
+++ b/src/couchdb/couch_rep_att.erl
@@ -81,8 +81,12 @@ receive_data(Ref, ReqId, ContentEncoding) ->
% ?LOG_DEBUG("got ~p bytes for ~p", [size(Data), ReqId]),
Data;
{ibrowse_async_response_end, ReqId} ->
- ?LOG_ERROR("streaming att. ended but more data requested ~p", [ReqId]),
- throw({attachment_request_failed, premature_end})
+ % This means ibrowse received all the data it was supposed to.
+ % In case of not receiving the whole data, due to a network link
+ % failure for example, we would have received an error message.
+ % In other words, this message doesn't represent an error - look into
+ % ibrowse_http_client.erl.
+ eof
after 31000 ->
throw({attachment_request_failed, timeout})
end.
--
cgit v1.2.3
From 2cb0b6ba823521792ad481d6faf8e52af09c531f Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Fri, 16 Jul 2010 22:55:14 +0000
Subject: Revert revision 964956 (COUCHDB-827) - solution had secondary
effects.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964969 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_db.erl | 16 +++-------------
src/couchdb/couch_rep_att.erl | 8 ++------
2 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index b445046f..80f0d7bf 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -901,20 +901,10 @@ with_stream(Fd, #att{md5=InMd5,type=Type,encoding=Enc}=Att, Fun) ->
write_streamed_attachment(_Stream, _F, 0) ->
ok;
-% LenLeft might be different from the total size of what function F returns.
-% This happens when doing a pull replication of compressed attachments from a
-% 0.11.0 server, where LenLeft will match the uncompressed size but we end up
-% receiving the attachment compressed (therefore a size different from LenLeft).
-% This is because 0.11.0 doesn't understand the query parameter
-% "?att_encoding_info=true" when we do a doc request (GET /somedb/somedoc).
write_streamed_attachment(Stream, F, LenLeft) ->
- case F() of
- Bin when is_binary(Bin) ->
- ok = couch_stream:write(Stream, Bin),
- write_streamed_attachment(Stream, F, LenLeft - size(Bin));
- eof ->
- ok
- end.
+ Bin = F(),
+ ok = couch_stream:write(Stream, Bin),
+ write_streamed_attachment(Stream, F, LenLeft - size(Bin)).
enum_docs_since_reduce_to_count(Reds) ->
couch_btree:final_reduce(
diff --git a/src/couchdb/couch_rep_att.erl b/src/couchdb/couch_rep_att.erl
index 367afbb5..28b8945c 100644
--- a/src/couchdb/couch_rep_att.erl
+++ b/src/couchdb/couch_rep_att.erl
@@ -81,12 +81,8 @@ receive_data(Ref, ReqId, ContentEncoding) ->
% ?LOG_DEBUG("got ~p bytes for ~p", [size(Data), ReqId]),
Data;
{ibrowse_async_response_end, ReqId} ->
- % This means ibrowse received all the data it was supposed to.
- % In case of not receiving the whole data, due to a network link
- % failure for example, we would have received an error message.
- % In other words, this message doesn't represent an error - look into
- % ibrowse_http_client.erl.
- eof
+ ?LOG_ERROR("streaming att. ended but more data requested ~p", [ReqId]),
+ throw({attachment_request_failed, premature_end})
after 31000 ->
throw({attachment_request_failed, timeout})
end.
--
cgit v1.2.3
From 66ab269ccf9945a72f7108f07454eca14060b632 Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Sat, 17 Jul 2010 00:11:00 +0000
Subject: note about firefox support in test suite
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964987 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/couch_tests.html | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/share/www/couch_tests.html b/share/www/couch_tests.html
index 46893d71..f10bad23 100644
--- a/share/www/couch_tests.html
+++ b/share/www/couch_tests.html
@@ -68,7 +68,10 @@ specific language governing permissions and limitations under the License.
Note: Each of the tests will block the browser. If the
connection to your CouchDB server is slow, running the tests will take
some time, and you'll not be able to do much with your browser while
- a test is being executed.
+ a test is being executed. Also: The test suite is designed
+ to work with Firefox (with Firebug disabled). Patches are welcome for
+ convenience compatibility with other browsers, but official support is
+ for Firefox (latest stable version) only.
--
cgit v1.2.3
From 4c780ad5eb81e0e4c66b45fd70fbb623c3a19be6 Mon Sep 17 00:00:00 2001
From: Robert Newson
Date: Mon, 19 Jul 2010 00:10:11 +0000
Subject: COUCHDB-810: Adds port to replication checkpoints.
New replication checkpoints now include the port number, which allows for efficient replication between multiple couchdb instances running on the same machine.
Old replication checkpoints are recognized (Full replication is not induced) and they are automatically migrated to the new checkpoint format.
Thanks to Randall Leeds for the patch.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@965331 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_rep.erl | 77 +++++++++++++++++++++++++++++++++++------------
1 file changed, 58 insertions(+), 19 deletions(-)
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index b741f86f..4f6fb673 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -19,6 +19,8 @@
-include("couch_db.hrl").
+-define(REP_ID_VERSION, 2).
+
-record(state, {
changes_feed,
missing_revs,
@@ -59,7 +61,9 @@ replicate(Source, Target) when is_binary(Source), is_binary(Target) ->
%% function handling POST to _replicate
replicate({Props}=PostBody, UserCtx) ->
- {BaseId, Extension} = make_replication_id(PostBody, UserCtx),
+ BaseId = make_replication_id({Props}, UserCtx, ?REP_ID_VERSION),
+ Extension = maybe_append_options(
+ [<<"continuous">>, <<"create_target">>], Props),
Replicator = {BaseId ++ Extension,
{gen_server, start_link, [?MODULE, [BaseId, PostBody, UserCtx], []]},
temporary,
@@ -144,8 +148,9 @@ do_init([RepId, {PostProps}, UserCtx] = InitArgs) ->
_ ->
% Replication using the _changes API (DB sequence update numbers).
- SourceLog = open_replication_log(Source, RepId),
- TargetLog = open_replication_log(Target, RepId),
+
+ [SourceLog, TargetLog] = find_replication_logs(
+ [Source, Target], RepId, {PostProps}, UserCtx),
{StartSeq, History} = compare_replication_logs(SourceLog, TargetLog),
@@ -451,13 +456,23 @@ maybe_append_options(Options, Props) ->
end
end, [], Options).
-make_replication_id({Props}, UserCtx) ->
- %% funky algorithm to preserve backwards compatibility
+% Versioned clauses for generating replication ids
+% If a change is made to how replications are identified
+% add a new clause and increase ?REP_ID_VERSION at the top
+make_replication_id({Props}, UserCtx, 2) ->
+ {ok, HostName} = inet:gethostname(),
+ Port = mochiweb_socket_server:get(couch_httpd, port),
+ Src = get_rep_endpoint(UserCtx, couch_util:get_value(<<"source">>, Props)),
+ Tgt = get_rep_endpoint(UserCtx, couch_util:get_value(<<"target">>, Props)),
+ maybe_append_filters({Props}, [HostName, Port, Src, Tgt]);
+make_replication_id({Props}, UserCtx, 1) ->
{ok, HostName} = inet:gethostname(),
- % Port = mochiweb_socket_server:get(couch_httpd, port),
Src = get_rep_endpoint(UserCtx, couch_util:get_value(<<"source">>, Props)),
Tgt = get_rep_endpoint(UserCtx, couch_util:get_value(<<"target">>, Props)),
- Base = [HostName, Src, Tgt] ++
+ maybe_append_filters({Props}, [HostName, Src, Tgt]).
+
+maybe_append_filters({Props}, Base) ->
+ Base2 = Base ++
case couch_util:get_value(<<"filter">>, Props) of
undefined ->
case couch_util:get_value(<<"doc_ids">>, Props) of
@@ -469,9 +484,7 @@ make_replication_id({Props}, UserCtx) ->
Filter ->
[Filter, couch_util:get_value(<<"query_params">>, Props, {[]})]
end,
- Extension = maybe_append_options(
- [<<"continuous">>, <<"create_target">>], Props),
- {couch_util:to_hex(couch_util:md5(term_to_binary(Base))), Extension}.
+ couch_util:to_hex(couch_util:md5(term_to_binary(Base2))).
maybe_add_trailing_slash(Url) ->
re:replace(Url, "[^/]$", "&/", [{return, list}]).
@@ -493,26 +506,52 @@ get_rep_endpoint(_UserCtx, <<"https://",_/binary>>=Url) ->
get_rep_endpoint(UserCtx, <>) ->
{local, DbName, UserCtx}.
-open_replication_log(#http_db{}=Db, RepId) ->
- DocId = ?LOCAL_DOC_PREFIX ++ RepId,
- Req = Db#http_db{resource=couch_util:url_encode(DocId)},
+find_replication_logs(Logs, RepId, {Props}, UserCtx) ->
+ LogId = ?l2b(?LOCAL_DOC_PREFIX ++ RepId),
+ fold_replication_logs(Logs, ?REP_ID_VERSION,
+ LogId, LogId, {Props}, UserCtx, []).
+
+% Accumulate the replication logs
+% Falls back to older log document ids and migrates them
+fold_replication_logs([], _Vsn, _LogId, _NewId, {_Props}, _UserCtx, Acc) ->
+ lists:reverse(Acc);
+fold_replication_logs([Db|Rest]=Dbs, Vsn, LogId, NewId,
+ {Props}, UserCtx, Acc) ->
+ case open_replication_log(Db, LogId) of
+ {error, not_found} when Vsn > 1 ->
+ OldRepId = make_replication_id({Props}, UserCtx, Vsn - 1),
+ fold_replication_logs(Dbs, Vsn - 1,
+ ?l2b(?LOCAL_DOC_PREFIX ++ OldRepId), NewId, {Props}, UserCtx, Acc);
+ {error, not_found} ->
+ fold_replication_logs(Rest, ?REP_ID_VERSION, NewId, NewId,
+ {Props}, UserCtx, [#doc{id=NewId}|Acc]);
+ {ok, Doc} when LogId =:= NewId ->
+ fold_replication_logs(Rest, ?REP_ID_VERSION, NewId, NewId,
+ {Props}, UserCtx, [Doc|Acc]);
+ {ok, Doc} ->
+ MigratedLog = #doc{id=NewId,body=Doc#doc.body},
+ fold_replication_logs(Rest, ?REP_ID_VERSION, NewId, NewId,
+ {Props}, UserCtx, [MigratedLog|Acc])
+ end.
+
+open_replication_log(#http_db{}=Db, DocId) ->
+ Req = Db#http_db{resource=couch_util:url_encode(?b2l(DocId))},
case couch_rep_httpc:request(Req) of
{[{<<"error">>, _}, {<<"reason">>, _}]} ->
?LOG_DEBUG("didn't find a replication log for ~s", [Db#http_db.url]),
- #doc{id=?l2b(DocId)};
+ {error, not_found};
Doc ->
?LOG_DEBUG("found a replication log for ~s", [Db#http_db.url]),
- couch_doc:from_json_obj(Doc)
+ {ok, couch_doc:from_json_obj(Doc)}
end;
-open_replication_log(Db, RepId) ->
- DocId = ?l2b(?LOCAL_DOC_PREFIX ++ RepId),
+open_replication_log(Db, DocId) ->
case couch_db:open_doc(Db, DocId, []) of
{ok, Doc} ->
?LOG_DEBUG("found a replication log for ~s", [Db#db.name]),
- Doc;
+ {ok, Doc};
_ ->
?LOG_DEBUG("didn't find a replication log for ~s", [Db#db.name]),
- #doc{id=DocId}
+ {error, not_found}
end.
open_db(Props, UserCtx) ->
--
cgit v1.2.3
From 11aa4f9db32ef33ef8b9e17ee2a685c95bc553b2 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Mon, 19 Jul 2010 11:32:46 +0000
Subject: Fix possible bad match error - WriteFun might not return the atom
'ok'.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@965434 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_doc.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index acae0c55..a6d23a91 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -437,7 +437,7 @@ atts_to_mp([Att | RestAtts], Boundary, WriteFun,
true ->
fun att_foldl/3
end,
- AttFun(Att, fun(Data, ok) -> WriteFun(Data) end, ok),
+ AttFun(Att, fun(Data, _) -> WriteFun(Data) end, ok),
WriteFun(<<"\r\n--", Boundary/binary>>),
atts_to_mp(RestAtts, Boundary, WriteFun, SendEncodedAtts).
--
cgit v1.2.3
From 662bf6812ef0a4fa80cf137761f9b1b5a93821c0 Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Mon, 19 Jul 2010 22:46:14 +0000
Subject: remove unguarded atom creation to prevent DOS attacks. closes
COUCHDB-829
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@965667 13f79535-47bb-0310-9956-ffa450edef68
---
src/couchdb/couch_db.hrl | 1 -
src/couchdb/couch_doc.erl | 2 +-
src/couchdb/couch_httpd.erl | 2 +-
src/couchdb/couch_httpd_rewrite.erl | 66 +++++++++++++++---------------
src/couchdb/couch_httpd_stats_handlers.erl | 3 +-
src/couchdb/couch_httpd_view.erl | 4 +-
src/couchdb/couch_os_process.erl | 4 +-
src/couchdb/couch_rep.erl | 2 +-
src/couchdb/couch_util.erl | 4 +-
9 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl
index 4497dc8f..a35745ef 100644
--- a/src/couchdb/couch_db.hrl
+++ b/src/couchdb/couch_db.hrl
@@ -20,7 +20,6 @@
-define(JSON_ENCODE(V), couch_util:json_encode(V)).
-define(JSON_DECODE(V), couch_util:json_decode(V)).
--define(b2a(V), list_to_atom(binary_to_list(V))).
-define(b2l(V), binary_to_list(V)).
-define(l2b(V), list_to_binary(V)).
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index a6d23a91..d15cd7de 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -267,7 +267,7 @@ att_encoding_info(BinProps) ->
{identity, DiskLen};
Enc ->
EncodedLen = couch_util:get_value(<<"encoded_length">>, BinProps, DiskLen),
- {list_to_atom(?b2l(Enc)), EncodedLen}
+ {list_to_existing_atom(?b2l(Enc)), EncodedLen}
end.
to_doc_info(FullDocInfo) ->
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 079b9367..faf14bcc 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -225,7 +225,7 @@ handle_request_int(MochiReq, DefaultFun,
true ->
?LOG_INFO("MethodOverride: ~s (real method was ~s)", [MethodOverride, Method1]),
case Method1 of
- 'POST' -> list_to_atom(MethodOverride);
+ 'POST' -> couch_util:to_existing_atom(MethodOverride);
_ ->
% Ignore X-HTTP-Method-Override when the original verb isn't POST.
% I'd like to send a 406 error to the client, but that'd require a nasty refactor.
diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erl
index 6c909994..ca4ac1f0 100644
--- a/src/couchdb/couch_httpd_rewrite.erl
+++ b/src/couchdb/couch_httpd_rewrite.erl
@@ -20,7 +20,7 @@
-include("couch_db.hrl").
-define(SEPARATOR, $\/).
--define(MATCH_ALL, '*').
+-define(MATCH_ALL, {bind, <<"*">>}).
%% doc The http rewrite handler. All rewriting is done from
@@ -118,7 +118,7 @@ handle_rewrite_req(#httpd{
DesignId = <<"_design/", DesignName/binary>>,
Prefix = <<"/", DbName/binary, "/", DesignId/binary>>,
QueryList = couch_httpd:qs(Req),
- QueryList1 = [{to_atom(K), V} || {K, V} <- QueryList],
+ QueryList1 = [{to_binding(K), V} || {K, V} <- QueryList],
#doc{body={Props}} = DDoc,
@@ -132,12 +132,12 @@ handle_rewrite_req(#httpd{
DispatchList = [make_rule(Rule) || {Rule} <- Rules],
%% get raw path by matching url to a rule.
- RawPath = case try_bind_path(DispatchList, Method, PathParts,
+ RawPath = case try_bind_path(DispatchList, couch_util:to_binary(Method), PathParts,
QueryList1) of
no_dispatch_path ->
throw(not_found);
{NewPathParts, Bindings} ->
- Parts = [mochiweb_util:quote_plus(X) || X <- NewPathParts],
+ Parts = [quote_plus(X) || X <- NewPathParts],
% build new path, reencode query args, eventually convert
% them to json
@@ -183,7 +183,10 @@ handle_rewrite_req(#httpd{
UrlHandlers, DbUrlHandlers, DesignUrlHandlers)
end.
-
+quote_plus({bind, X}) ->
+ mochiweb_util:quote_plus(X);
+quote_plus(X) ->
+ mochiweb_util:quote_plus(X).
%% @doc Try to find a rule matching current url. If none is found
%% 404 error not_found is raised
@@ -196,15 +199,13 @@ try_bind_path([Dispatch|Rest], Method, PathParts, QueryList) ->
case bind_path(PathParts1, PathParts, []) of
{ok, Remaining, Bindings} ->
Bindings1 = Bindings ++ QueryList,
-
% we parse query args from the rule and fill
% it eventually with bindings vars
QueryArgs1 = make_query_list(QueryArgs, Bindings1, []),
-
% remove params in QueryLists1 that are already in
% QueryArgs1
Bindings2 = lists:foldl(fun({K, V}, Acc) ->
- K1 = to_atom(K),
+ K1 = to_binding(K),
KV = case couch_util:get_value(K1, QueryArgs1) of
undefined -> [{K1, V}];
_V1 -> []
@@ -230,15 +231,15 @@ make_query_list([], _Bindings, Acc) ->
Acc;
make_query_list([{Key, {Value}}|Rest], Bindings, Acc) ->
Value1 = to_json({Value}),
- make_query_list(Rest, Bindings, [{to_atom(Key), Value1}|Acc]);
+ make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]);
make_query_list([{Key, Value}|Rest], Bindings, Acc) when is_binary(Value) ->
Value1 = replace_var(Key, Value, Bindings),
- make_query_list(Rest, Bindings, [{to_atom(Key), Value1}|Acc]);
+ make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]);
make_query_list([{Key, Value}|Rest], Bindings, Acc) when is_list(Value) ->
Value1 = replace_var(Key, Value, Bindings),
- make_query_list(Rest, Bindings, [{to_atom(Key), Value1}|Acc]);
+ make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]);
make_query_list([{Key, Value}|Rest], Bindings, Acc) ->
- make_query_list(Rest, Bindings, [{to_atom(Key), Value}|Acc]).
+ make_query_list(Rest, Bindings, [{to_binding(Key), Value}|Acc]).
replace_var(Key, Value, Bindings) ->
case Value of
@@ -274,7 +275,7 @@ replace_var(Key, Value, Bindings) ->
get_var(VarName, Props, Default) ->
- VarName1 = list_to_atom(binary_to_list(VarName)),
+ VarName1 = to_binding(VarName),
couch_util:get_value(VarName1, Props, Default).
%% doc: build new patch from bindings. bindings are query args
@@ -288,8 +289,8 @@ make_new_path([?MATCH_ALL], _Bindings, Remaining, Acc) ->
make_new_path([?MATCH_ALL|_Rest], _Bindings, Remaining, Acc) ->
Acc1 = lists:reverse(Acc) ++ Remaining,
Acc1;
-make_new_path([P|Rest], Bindings, Remaining, Acc) when is_atom(P) ->
- P2 = case couch_util:get_value(P, Bindings) of
+make_new_path([{bind, P}|Rest], Bindings, Remaining, Acc) ->
+ P2 = case couch_util:get_value({bind, P}, Bindings) of
undefined -> << "undefined">>;
P1 -> P1
end,
@@ -304,7 +305,7 @@ make_new_path([P|Rest], Bindings, Remaining, Acc) ->
%% depending on HTTP method.
bind_method(?MATCH_ALL, _Method) ->
true;
-bind_method(Method, Method) ->
+bind_method({bind, Method}, Method) ->
true;
bind_method(_, _) ->
false.
@@ -318,8 +319,8 @@ bind_path([?MATCH_ALL], Rest, Bindings) when is_list(Rest) ->
{ok, Rest, Bindings};
bind_path(_, [], _) ->
fail;
-bind_path([Token|RestToken],[Match|RestMatch],Bindings) when is_atom(Token) ->
- bind_path(RestToken, RestMatch, [{Token, Match}|Bindings]);
+bind_path([{bind, Token}|RestToken],[Match|RestMatch],Bindings) ->
+ bind_path(RestToken, RestMatch, [{{bind, Token}, Match}|Bindings]);
bind_path([Token|RestToken], [Token|RestMatch], Bindings) ->
bind_path(RestToken, RestMatch, Bindings);
bind_path(_, _, _) ->
@@ -350,15 +351,15 @@ normalize_path1([Path|Rest], Acc) ->
%% @doc transform json rule in erlang for pattern matching
make_rule(Rule) ->
Method = case couch_util:get_value(<<"method">>, Rule) of
- undefined -> '*';
- M -> list_to_atom(?b2l(M))
+ undefined -> ?MATCH_ALL;
+ M -> to_binding(M)
end,
QueryArgs = case couch_util:get_value(<<"query">>, Rule) of
undefined -> [];
{Args} -> Args
end,
FromParts = case couch_util:get_value(<<"from">>, Rule) of
- undefined -> ['*'];
+ undefined -> [?MATCH_ALL];
From ->
parse_path(From)
end,
@@ -396,30 +397,29 @@ path_to_list([<<"..">>|R], Acc, DotDotCount) ->
path_to_list([P|R], Acc, DotDotCount) ->
P1 = case P of
<<":", Var/binary>> ->
- list_to_atom(binary_to_list(Var));
+ to_binding(Var);
_ -> P
end,
path_to_list(R, [P1|Acc], DotDotCount).
encode_query(Props) ->
- Props1 = lists:foldl(fun ({K, V}, Acc) ->
- V1 = case is_list(V) of
+ Props1 = lists:foldl(fun ({{bind, K}, V}, Acc) ->
+ V1 = case is_list(V) orelse is_binary(V) of
true -> V;
- false when is_binary(V) ->
- V;
false ->
- mochiweb_util:quote_plus(V)
+ % probably it's a number
+ quote_plus(V)
end,
[{K, V1} | Acc]
end, [], Props),
lists:flatten(mochiweb_util:urlencode(Props1)).
-to_atom(V) when is_atom(V) ->
- V;
-to_atom(V) when is_binary(V) ->
- to_atom(?b2l(V));
-to_atom(V) ->
- list_to_atom(V).
+to_binding({bind, V}) ->
+ {bind, V};
+to_binding(V) when is_list(V) ->
+ to_binding(?l2b(V));
+to_binding(V) ->
+ {bind, V}.
to_json(V) ->
iolist_to_binary(?JSON_ENCODE(V)).
diff --git a/src/couchdb/couch_httpd_stats_handlers.erl b/src/couchdb/couch_httpd_stats_handlers.erl
index 26c8891d..41aeaed0 100644
--- a/src/couchdb/couch_httpd_stats_handlers.erl
+++ b/src/couchdb/couch_httpd_stats_handlers.erl
@@ -29,7 +29,8 @@ handle_stats_req(#httpd{method='GET', path_parts=[_, _Mod]}) ->
handle_stats_req(#httpd{method='GET', path_parts=[_, Mod, Key]}=Req) ->
flush(Req),
- Stats = couch_stats_aggregator:get_json({?b2a(Mod), ?b2a(Key)}, range(Req)),
+ Stats = couch_stats_aggregator:get_json({list_to_atom(binary_to_list(Mod)),
+ list_to_atom(binary_to_list(Key))}, range(Req)),
send_json(Req, {[{Mod, {[{Key, Stats}]}}]});
handle_stats_req(#httpd{method='GET', path_parts=[_, _Mod, _Key | _Extra]}) ->
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index 704136ca..65aa364a 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -196,10 +196,10 @@ reverse_key_default(?MAX_STR) -> ?MIN_STR;
reverse_key_default(Key) -> Key.
get_stale_type(Req) ->
- list_to_atom(couch_httpd:qs_value(Req, "stale", "nil")).
+ list_to_existing_atom(couch_httpd:qs_value(Req, "stale", "nil")).
get_reduce_type(Req) ->
- list_to_atom(couch_httpd:qs_value(Req, "reduce", "true")).
+ list_to_existing_atom(couch_httpd:qs_value(Req, "reduce", "true")).
load_view(Req, Db, {ViewDesignId, ViewName}, Keys) ->
Stale = get_stale_type(Req),
diff --git a/src/couchdb/couch_os_process.erl b/src/couchdb/couch_os_process.erl
index 070b86fc..5776776b 100644
--- a/src/couchdb/couch_os_process.erl
+++ b/src/couchdb/couch_os_process.erl
@@ -93,10 +93,10 @@ readjson(OsProc) when is_record(OsProc, os_proc) ->
?LOG_INFO("OS Process ~p Log :: ~s", [OsProc#os_proc.port, Msg]),
readjson(OsProc);
[<<"error">>, Id, Reason] ->
- throw({list_to_atom(binary_to_list(Id)),Reason});
+ throw({couch_util:to_existing_atom(Id),Reason});
[<<"fatal">>, Id, Reason] ->
?LOG_INFO("OS Process ~p Fatal Error :: ~s ~p",[OsProc#os_proc.port, Id, Reason]),
- throw({list_to_atom(binary_to_list(Id)),Reason});
+ throw({couch_util:to_existing_atom(Id),Reason});
Result ->
Result
end.
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index 4f6fb673..1e36f58e 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -367,7 +367,7 @@ strip_password(Url) ->
dbinfo(#http_db{} = Db) ->
{DbProps} = couch_rep_httpc:request(Db),
- [{list_to_atom(?b2l(K)), V} || {K,V} <- DbProps];
+ [{list_to_existing_atom(?b2l(K)), V} || {K,V} <- DbProps];
dbinfo(Db) ->
{ok, Info} = couch_db:get_db_info(Db),
Info.
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index 2aa69af8..f2bf6297 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -70,9 +70,9 @@ normparts([Part | RestParts], Acc) ->
% works like list_to_existing_atom, except can be list or binary and it
% gives you the original value instead of an error if no existing atom.
to_existing_atom(V) when is_list(V) ->
- try list_to_existing_atom(V) catch _ -> V end;
+ try list_to_existing_atom(V) catch _:_ -> V end;
to_existing_atom(V) when is_binary(V) ->
- try list_to_existing_atom(?b2l(V)) catch _ -> V end;
+ try list_to_existing_atom(?b2l(V)) catch _:_ -> V end;
to_existing_atom(V) when is_atom(V) ->
V.
--
cgit v1.2.3
From ae1499d95d5337870da57620130eab79cc0b8490 Mon Sep 17 00:00:00 2001
From: John Christopher Anderson
Date: Tue, 20 Jul 2010 01:03:10 +0000
Subject: require application/json content-type in the remaining places where a
POST has side-effects
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@965700 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/script/test/view_errors.js | 4 ++--
src/couchdb/couch_httpd_db.erl | 1 +
src/couchdb/couch_httpd_misc_handlers.erl | 3 +++
src/couchdb/couch_httpd_view.erl | 2 ++
src/couchdb/couch_rep.erl | 5 +++--
5 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/share/www/script/test/view_errors.js b/share/www/script/test/view_errors.js
index c6607ad4..a211c061 100644
--- a/share/www/script/test/view_errors.js
+++ b/share/www/script/test/view_errors.js
@@ -56,14 +56,14 @@ couchTests.view_errors = function(debug) {
});
T(JSON.parse(xhr.responseText).error == "bad_request");
- // views should ignore Content-Type, like the rest of CouchDB
+ // content type must be json
var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view", {
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: JSON.stringify({language: "javascript",
map : "function(doc){}"
})
});
- T(xhr.status == 200);
+ T(xhr.status == 415);
var map = function (doc) {emit(doc.integer, doc.integer);};
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 05979e46..29b20c21 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -242,6 +242,7 @@ db_req(#httpd{path_parts=[_DbName]}=Req, _Db) ->
send_method_not_allowed(Req, "DELETE,GET,HEAD,POST");
db_req(#httpd{method='POST',path_parts=[_,<<"_ensure_full_commit">>]}=Req, Db) ->
+ couch_httpd:validate_ctype(Req, "application/json"),
UpdateSeq = couch_db:get_update_seq(Db),
CommittedSeq = couch_db:get_committed_update_seq(Db),
{ok, StartTime} =
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index 205ebc6f..0a6f4a42 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -79,6 +79,7 @@ handle_task_status_req(Req) ->
send_method_not_allowed(Req, "GET,HEAD").
handle_replicate_req(#httpd{method='POST'}=Req) ->
+ couch_httpd:validate_ctype(Req, "application/json"),
PostBody = couch_httpd:json_body_obj(Req),
try couch_rep:replicate(PostBody, Req#httpd.user_ctx) of
{ok, {continuous, RepId}} ->
@@ -102,6 +103,7 @@ handle_replicate_req(Req) ->
handle_restart_req(#httpd{method='POST'}=Req) ->
+ couch_httpd:validate_ctype(Req, "application/json"),
ok = couch_httpd:verify_is_server_admin(Req),
couch_server_sup:restart_core_server(),
send_json(Req, 200, {[{ok, true}]});
@@ -189,6 +191,7 @@ handle_config_req(Req) ->
% httpd db handlers
increment_update_seq_req(#httpd{method='POST'}=Req, Db) ->
+ couch_httpd:validate_ctype(Req, "application/json"),
{ok, NewSeq} = couch_db:increment_update_seq(Db),
send_json(Req, {[{ok, true},
{update_seq, NewSeq}
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index 65aa364a..fc0c24a8 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -61,6 +61,7 @@ handle_view_req(#httpd{method='GET',
handle_view_req(#httpd{method='POST',
path_parts=[_, _, DName, _, ViewName]}=Req, Db, _DDoc) ->
+ couch_httpd:validate_ctype(Req, "application/json"),
{Fields} = couch_httpd:json_body_obj(Req),
case couch_util:get_value(<<"keys">>, Fields, nil) of
nil ->
@@ -77,6 +78,7 @@ handle_view_req(Req, _Db, _DDoc) ->
send_method_not_allowed(Req, "GET,POST,HEAD").
handle_temp_view_req(#httpd{method='POST'}=Req, Db) ->
+ couch_httpd:validate_ctype(Req, "application/json"),
ok = couch_db:check_is_admin(Db),
couch_stats_collector:increment({httpd, temporary_view_reads}),
{Props} = couch_httpd:json_body_obj(Req),
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index 1e36f58e..07ee8416 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -696,8 +696,9 @@ ensure_full_commit(#http_db{headers = Headers} = Target) ->
Req = Target#http_db{
resource = "_ensure_full_commit",
method = post,
- headers = [{"content-type", "application/json"} | Headers]
+ headers = couch_util:proplist_apply_field({"Content-Type", "application/json"}, Headers)
},
+ ?LOG_ERROR("Req ~p",[Req]),
{ResultProps} = couch_rep_httpc:request(Req),
true = couch_util:get_value(<<"ok">>, ResultProps),
couch_util:get_value(<<"instance_start_time">>, ResultProps);
@@ -722,7 +723,7 @@ ensure_full_commit(#http_db{headers = Headers} = Source, RequiredSeq) ->
resource = "_ensure_full_commit",
method = post,
qs = [{seq, RequiredSeq}],
- headers = [{"content-type", "application/json"} | Headers]
+ headers = couch_util:proplist_apply_field({"Content-Type", "application/json"}, Headers)
},
{ResultProps} = couch_rep_httpc:request(Req),
case couch_util:get_value(<<"ok">>, ResultProps) of
--
cgit v1.2.3
From 5fc1e706ee5015e6a555f46a5eea601b4ec3bf63 Mon Sep 17 00:00:00 2001
From: Jan Lehnardt
Date: Tue, 20 Jul 2010 10:42:21 +0000
Subject: add link to the wiki about the messed up ubuntu install situation.
Closes COUCHDB-830
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@965790 13f79535-47bb-0310-9956-ffa450edef68
---
INSTALL.Unix | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/INSTALL.Unix b/INSTALL.Unix
index 93b4803d..768e3846 100644
--- a/INSTALL.Unix
+++ b/INSTALL.Unix
@@ -18,8 +18,17 @@ You will need the following installed:
It is recommended that you install Erlang OTP R12B-5 or above where possible.
-Debian-based (inc. Ubuntu) Systems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Ubuntu
+~~~~~~
+
+See
+
+ http://wiki.apache.org/couchdb/Installing_on_Ubuntu
+
+for updated instructions on how to install on Ubuntu.
+
+Debian-based Systems
+~~~~~~~~~~~~~~~~~~~~
You can install the build tools by running:
--
cgit v1.2.3
From 6bd11d1195f63380bcfd4a1ac6aa6a10700ad5f2 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana
Date: Wed, 21 Jul 2010 15:43:07 +0000
Subject: Add "Stale views" checkbox to Futon's database pages.
Closes COUCHDB-550.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@966283 13f79535-47bb-0310-9956-ffa450edef68
---
share/www/database.html | 11 +++++++++++
share/www/script/futon.browse.js | 8 +++++++-
share/www/style/layout.css | 7 +++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/share/www/database.html b/share/www/database.html
index 5142ed1b..39507398 100644
--- a/share/www/database.html
+++ b/share/www/database.html
@@ -81,6 +81,9 @@ specific language governing permissions and limitations under the License.
$("#perpage").val($.futon.storage.get("per_page"));
+ var staleViews = $.futon.storage.get("stale");
+ $("#staleviews :checkbox")[0].checked = staleViews;
+
page.populateViewsMenu();
page.populateViewEditor();
if (page.isTempView) {
@@ -94,6 +97,9 @@ specific language governing permissions and limitations under the License.
location.href = "?" + encodeURIComponent(page.db.name) +
(viewName ? "/" + viewName : "");
});
+ $("#staleviews :checkbox").click(function() {
+ $.futon.storage.set("stale", this.checked);
+ });
$("#documents thead th.key span").click(function() {
$(this).closest("th").toggleClass("desc");
page.updateDocumentListing();
@@ -148,6 +154,11 @@ specific language governing permissions and limitations under the License.
+
+
+