<h5>opensips.cfg</h5>

<pre><code># ----- drouting -----
modparam("drouting", "db_url", "sqlite://var/db/opensips")
</code></pre>

<h5>opensips.log</h5>

<pre><code>Apr 18 15:39:39 localhost opensips: INFO:drouting:dr_init: Dynamic-Routing - initializing
Apr 18 15:39:39 localhost opensips: ERROR:db_sqlite:db_sqlite_query: failed to prepare: (no such table: version)
Apr 18 15:39:39 localhost opensips: ERROR:db_sqlite:db_sqlite_get_query_rows: failed to prepare query
</code></pre>

<h5>opens incorrect sqlite db handler:</h5>

<pre><code># ls -al /var/db
-rw-r--r--  1 root root      0 Apr 18 15:28 opensips?  &lt;-- this is created
</code></pre>

<h5>gdb</h5>

<pre><code>(gdb) break modules/db_sqlite/dbase.c:162
(gdb) print _h-&gt;url
$2 = {s = 0x7ffff7431bd0 "sqlite://var/db/opensips8", len = 24}
(gdb) print query_holder
$3 = {s = 0x852740 &lt;sql_buf&gt; "select table_version from version where table_name='dr_gateways's", len = 64}
167     if (ret!=SQLITE_OK)
(gdb) s
168         LM_ERR("failed to prepare: (%s)\n", sqlite3_errmsg(CON_CONNECTION(_h)));
(gdb) print ret
$4 = 1
</code></pre>

<h5>Synopsis</h5>

<p>Seems like the pointer arithmetic in val2str for type DB_STR (modules/db_sqlite/val.c:229) is off (the trailing s is from the previous sql_buf that dialog populates however the length is correct), but the other issue is its not accessing the proper db_url string that is set correctly.  It's weird that the other modules do not seem to have this issue.  </p>

<p>For example, dialog is the first to load, and the gdb printout of <em>h-&gt;url returns the same data for its query and everything else seems ok.  Perhaps there is an invalid or lacking CON</em> macro call?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/issues/471">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciaRp1F4-brDNL6BAhTTCeEuJ_jg9ks5oAnVTgaJpZM4EDZbV.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/OpenSIPS/opensips/issues/471"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>