You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/02/09 19:59:18 UTC

[GitHub] [couchdb] iilyak opened a new pull request #3929: Add couch_mrview_debug:view_signature/2

iilyak opened a new pull request #3929:
URL: https://github.com/apache/couchdb/pull/3929


   ## Overview
   
   This PR introduces a function to display view signature which corresponds to a given ddoc. 
   The function is intended for using in remsh while debugging view upgrade issues.
   
   ## Testing recommendations
   
   1. start couch `dev/run --admin=adm:pass`
   2. start `remsh` session `dev/remsh`
   3. call a function for a database which has a ddoc `couch_mrview_debug:view_signature(<<"db321">>, <<"ddoc321">>).`
   4. make sure the help message for a function makes sense `couch_mrview_debug:help(view_signature).`
   5. make sure the function is listed in an output from `couch_mrview_debug:help().`
   
   ## Related Issues or Pull Requests
   
   N/A
   
   ## Checklist
   
   - [x] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
   - [ ] A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation
   


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

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

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



[GitHub] [couchdb] nickva commented on a change in pull request #3929: Add couch_mrview_debug:view_signature/2

Posted by GitBox <gi...@apache.org>.
nickva commented on a change in pull request #3929:
URL: https://github.com/apache/couchdb/pull/3929#discussion_r803052966



##########
File path: src/couch_mrview/src/couch_mrview_debug.erl
##########
@@ -0,0 +1,50 @@
+% 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.
+
+-module(couch_mrview_debug).
+
+-export([
+    help/0,
+    help/1
+]).
+
+-export([
+    view_signature/2
+]).
+
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+help() ->
+    [
+        view_signature
+    ].
+
+-spec help(Function :: atom()) -> ok.
+%% erlfmt-ignore
+help(view_signature) ->
+    io:format("
+    view_signature(DbName, DDocName)
+    --------------
+    Returns a view signature for given ddoc for a given database

Review comment:
       Maybe a slight rewording to mention that this would be a shard name not a clustered db?




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

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

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



[GitHub] [couchdb] iilyak merged pull request #3929: Add couch_mrview_debug:view_signature/2

Posted by GitBox <gi...@apache.org>.
iilyak merged pull request #3929:
URL: https://github.com/apache/couchdb/pull/3929


   


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

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

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



[GitHub] [couchdb] nickva commented on a change in pull request #3929: Add couch_mrview_debug:view_signature/2

Posted by GitBox <gi...@apache.org>.
nickva commented on a change in pull request #3929:
URL: https://github.com/apache/couchdb/pull/3929#discussion_r803053339



##########
File path: src/couch_mrview/src/couch_mrview_debug.erl
##########
@@ -0,0 +1,50 @@
+% 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.
+
+-module(couch_mrview_debug).
+
+-export([
+    help/0,
+    help/1
+]).
+
+-export([
+    view_signature/2
+]).
+
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+help() ->
+    [
+        view_signature
+    ].
+
+-spec help(Function :: atom()) -> ok.
+%% erlfmt-ignore
+help(view_signature) ->
+    io:format("
+    view_signature(DbName, DDocName)
+    --------------
+    Returns a view signature for given ddoc for a given database
+    ---
+    ", []);
+help(Unknown) ->
+    io:format("Unknown function: `~p`. Please try one of the following:~n", [Unknown]),
+    [io:format("    - ~s~n", [Function]) || Function <- help()],
+    io:format("    ---~n", []),
+    ok.
+
+view_signature(DbName, DDocName) ->
+    {ok, Db} = couch_db:open_int(DbName, []),
+    {ok, DDoc} = couch_db:open_doc_int(Db, <<"_design/", DDocName/binary>>, []),
+    {ok, IdxState} = couch_mrview_util:ddoc_to_mrst(DDocName, DDoc),
+    couch_util:to_hex(IdxState#mrst.sig).

Review comment:
       Tiny nit: add a newline to avoid the red diff marker. 




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

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

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