ejabberd - Comments for "mod_admin_extra not working with ejabberd 13.12" https://www.ejabberd.im/node/16554 en UPDATE: I've dug deeper in https://www.ejabberd.im/node/16554#comment-62863 <p>UPDATE:</p> <p>I've dug deeper in the code.</p> <p>The command <strong>srg_list</strong> give you this code <strong>mod_shared_roster:list_groups(Host)</strong> which correspond to <strong>list_groups(Host, gen_mod:db_type(Host, ?MODULE)).</strong> since the <strong>db_type</strong> I'm using is <strong>mnesia</strong> I take the function <strong>list_groups(Host, mnesia).</strong></p> <p>This function give me this code:</p> <div class="codeblock"><code>&nbsp;&nbsp;&nbsp; mnesia:dirty_select(sr_group,<br /> [{#sr_group{group_host = {&#039;$1&#039;, &#039;$2&#039;}, _ = &#039;_&#039;},<br /> &nbsp; [{&#039;==&#039;, &#039;$2&#039;, Host}], [&#039;$1&#039;]}]);</code></div> <p>If I copy and paste this code it gives me this error: <strong>record sr_group undefined</strong></p> <p>From then I've done a basic select on the <strong>sr_group</strong> table using this code :</p> <div class="codeblock"><code>F = fun() -&gt; mnesia:select(&#039;sr_group&#039;,[{&#039;_&#039;,[],[&#039;$_&#039;]}]) end,<br />mnesia:activity(transaction, F).</code></div> <p>and this gave this result :</p> <div class="codeblock"><code>[{sr_group,{&lt;&lt;&quot;SharedRosterTest1&quot;&gt;&gt;,&lt;&lt;&quot;xmpp.mydomain.com&quot;&gt;&gt;},<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [{name,&lt;&lt;&quot;SharedRosterTest1&quot;&gt;&gt;},<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {displayed_groups,[&lt;&lt;&quot;SharedRosterTest1&quot;&gt;&gt;,&lt;&lt;&quot;SharedRosterTest2&quot;&gt;&gt;]}]},<br /> {sr_group,{&lt;&lt;&quot;SharedRosterTest2&quot;&gt;&gt;,&lt;&lt;&quot;xmpp.mydomain.com&quot;&gt;&gt;},<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [{name,&lt;&lt;&quot;SharedRosterTest2&quot;&gt;&gt;},<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {displayed_groups,[&lt;&lt;&quot;SharedRosterTest2&quot;&gt;&gt;]},<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {all_users,true}]}]</code></div> <p>So I tried to modified the <strong>dirty_select</strong> to a <strong>select</strong> because it is the same according the mnesia documentation here : <noindex><a href="http://www.erlang.org/doc/man/mnesia.html#dirty_select-2" title="http://www.erlang.org/doc/man/mnesia.html#dirty_select-2" rel="nofollow" >http://www.erlang.org/doc/man/mnesia.html#dirty_select-2</a></noindex></p> <p>Here the modified version</p> <div class="codeblock"><code>F = fun() -&gt;<br />Host = &#039;xmpp.mydomain.com&#039;,<br />MatchHead = #sr_group{group_host = {&#039;$1&#039;, &#039;$2&#039;}, _ = &#039;_&#039;},<br />Guard = {&#039;==&#039;, &#039;$2&#039;, Host},<br />Result = &#039;$1&#039;,<br />mnesia:select(&#039;sr_group&#039;,[{MatchHead, [Guard], [Result]}]) end,<br />mnesia:activity(transaction, F).</code></div> <p>and this give the same error : <strong>* 3: record sr_group undefined</strong></p> <p>So I dug deeper in the mnesia database and in the table sr_group using this command <strong>mnesia:schema(sr_group)</strong></p> <p>Here is the result:</p> <div class="codeblock"><code>-- Properties for sr_group table ---<br />access_mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; read_write<br />active_replicas&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; [ejabberd@localhost]<br />all_nodes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; [ejabberd@localhost]<br />arity&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; 3<br />attributes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; [group_host,opts]<br />checkpoints&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />commit_work&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />cookie&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; {{1388,483739,236368},ejabberd@localhost}<br />disc_copies&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; [ejabberd@localhost]<br />disc_only_copies&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />frag_properties&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />index&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />load_by_force&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; false<br />load_node&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; ejabberd@localhost<br />load_order&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; 0<br />load_reason&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; local_only<br />local_content&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; false<br />majority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; false<br />master_nodes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />memory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; 635<br />ram_copies&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />record_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; sr_group<br />record_validation&nbsp;&nbsp;&nbsp; -&gt; {sr_group,3,set}<br />setorbag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; set<br />size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; 7<br />snmp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />storage_properties&nbsp;&nbsp; -&gt; []<br />storage_type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; disc_copies<br />subscribers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />user_properties&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; []<br />version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; {{2,0},[]}<br />where_to_commit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; [{ejabberd@localhost,disc_copies}]<br />where_to_read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; ejabberd@localhost<br />where_to_wlock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; {[ejabberd@localhost],false}<br />where_to_write&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; [ejabberd@localhost]<br />wild_pattern&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; {sr_group,&#039;_&#039;,&#039;_&#039;} <p>ok</p></code></div> <p>As we see the record <strong>sr_group</strong> exist and the <strong>group_host</strong> attribute also as written in the original dirty_select</p> <p>So after a little google I've seen that in erlang you have to define the record in the shell before using it so fair enough I've user this command <strong>rd(sr_group, {group_host, opts})</strong></p> <p>then I can select with </p> <div class="codeblock"><code>mnesia:dirty_select(sr_group, [{#sr_group{group_host = {&#039;$1&#039;, &#039;$2&#039;}, _ = &#039;_&#039;}, [{&#039;==&#039;, &#039;$2&#039;, &#039;xmpp.mydomain.com&#039;}], [&#039;$1&#039;]}]).</code></div> <p>but it return me nothing.</p> <div class="codeblock"><code>mnesia:dirty_select(sr_group, [{#sr_group{group_host = {&#039;$1&#039;, &#039;$2&#039;}, _ = &#039;_&#039;}, [], [&#039;$2&#039;]}]). </code></div> <p> returns me </p> <div class="codeblock"><code>[&lt;&lt;&quot;SharedRosterTest1&quot;&gt;&gt;,&lt;&lt;&quot;SharedRosterTest1&quot;&gt;&gt;,&#039;test&#039;]</code></div> <p>Note the <strong>test</strong> at the end, this one has been created with mod_admin_extra:srg_create so I see that when your creating a shared roster using the webadmin you can't retreive it using srg_list.</p> <p>You have to create it using srg_create<br /> I think it is a bug because when you type ejabberdctl with a command from admin extra it dose interpret well the argument</p> Wed, 15 Jan 2014 20:49:09 +0000 neodolphin comment 62863 at https://www.ejabberd.im