<p>mtree.h defines MT_MAX_DEPTH as 32 and the tprefix database table field is defined as a varchar(32) but the module fails to start if a prefix of 32 characters is present in the database table mapped to the mtree. The error message on start is:</p>

<blockquote>
<p>0(10465) ERROR: mtree [mtree.c:156]: mt_add_to_tree(): max prefix len exceeded<br>
0(10465) ERROR: mtree [mtree_mod.c:603]: mt_load_db(): Error adding info to tree</p>
</blockquote>

<p>To reproduce do the following:</p>

<p>Kamailio script: </p>

<pre><code>loadmodule "mtree.so"
modparam("mtree", "db_url", DBURL)
modparam("mtree", "mtree", "name=mtree;dbtable=mtree;type=0;multi=0")
modparam("mtree", "char_list", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-.")
</code></pre>

<p>MySQL:<br>
(create a table called mtree per the code in utils/kamctl/mysql/mtree-create.sql)</p>

<div class="highlight highlight-sql"><pre><span class="pl-k">insert into</span> mtree <span class="pl-k">values</span> (<span class="pl-c1">1</span>, <span class="pl-s"><span class="pl-pds">'</span>12345678901234567890123456789012<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>foo<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>bar<span class="pl-pds">'</span></span>, <span class="pl-c1">current_timestamp</span>, <span class="pl-s"><span class="pl-pds">'</span>baz<span class="pl-pds">'</span></span>);</pre></div>

<p>Start kamailio and observe that it fails to start. Enable debugging to see the error messages specified above.</p>

<p>Changing the tprefix to '1234567890123456789012345678901' makes Kamailio start successfully.</p>

<p>I propose a fix would entail making Kamailio support prefixes of 32 characters since we then can use GUIDs/UUIDs as "prefixes" without alteration and also adding to the mtree documentation that the maximum prefix length is 32 characters. Another fix would be to let the mtree code be but change the table creation scripts under utils/kamctl/ to create the tprefix field as varchar(31) (and add info about the constraint to the documentation).</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/179">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZbScLlmJbXVtPInBtOTVoDKU4Mjsks5oNroigaJpZM4EtGIp.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/179"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>