title: How can I enable CDR logging via the cdr_adaptive_odbc.so module in Asterisk 1.8.5?
body: <p>I am running</p>
  
  <ul>
  <li>an <strong>Asterisk 1.8.5</strong> with CEL and CDR via</li>
  <li><strong>ODBC</strong> (connected to MySQL).</li>
  </ul>
  
  <p>The CEL works fine (see below) but the CDR is not working via adaptive ODBC. (Standard ODBC and direct MySQL writing is working for CDR btw.) </p>
  
  <p>The asterisk can find the correct table and columns for CEL. See for yourself:</p>
  
  <pre><code>dev-lt-tk1*CLI&gt; core set verbose 99
  Verbosity is at least 99
  
  dev-lt-tk1*CLI&gt; module reload cel_odbc.so 
      -- Reloading module 'cel_odbc.so' (ODBC CEL backend)
    == Parsing '/opt/gemeinschaft/etc/asterisk/cel_odbc.conf':   == Found
      -- Found CEL table cel@odbc-voipstat101.
         &gt; Found id column with type 4 with len 10, octetlen 10, and numlen (0,10)
         &gt; Found eventtype column with type 12 with len 30, octetlen 30, and numlen (0,0)
         &gt; Found eventtime column with type 93 with len 19, octetlen 19, and numlen (0,10)
         &gt; Found userdeftype column with type 12 with len 255, octetlen 255, and numlen (0,0)
         &gt; Found cid_name column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found cid_num column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found cid_ani column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found cid_rdnis column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found cid_dnid column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found exten column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found context column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found channame column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found appname column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found appdata column with type 12 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found accountcode column with type 12 with len 20, octetlen 20, and numlen (0,0)
         &gt; Found peeraccount column with type 12 with len 20, octetlen 20, and numlen (0,0)
         &gt; Found uniqueid column with type 12 with len 150, octetlen 150, and numlen (0,0)
         &gt; Found linkedid column with type 12 with len 150, octetlen 150, and numlen (0,0)
         &gt; Found amaflags column with type 4 with len 10, octetlen 10, and numlen (0,10)
         &gt; Found userfield column with type 12 with len 255, octetlen 255, and numlen (0,0)
         &gt; Found peer column with type 12 with len 80, octetlen 80, and numlen (0,0)
  </code></pre>
  
  <p>Here's my table structure for CEL:</p>
  
  <pre><code>mysql&gt; describe cel;
  +-------------+--------------+------+-----+-------------------+-----------------------------+
  | Field       | Type         | Null | Key | Default           | Extra                       |
  +-------------+--------------+------+-----+-------------------+-----------------------------+
  | id          | int(30)      | NO   | PRI | NULL              | auto_increment              |
  | eventtype   | varchar(30)  | NO   |     | NULL              |                             |
  | eventtime   | timestamp    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
  | userdeftype | varchar(255) | NO   |     | NULL              |                             |
  | cid_name    | varchar(80)  | NO   |     | NULL              |                             |
  | cid_num     | varchar(80)  | NO   |     | NULL              |                             |
  | cid_ani     | varchar(80)  | NO   |     | NULL              |                             |
  | cid_rdnis   | varchar(80)  | NO   |     | NULL              |                             |
  | cid_dnid    | varchar(80)  | NO   |     | NULL              |                             |
  | exten       | varchar(80)  | NO   |     | NULL              |                             |
  | context     | varchar(80)  | NO   |     | NULL              |                             |
  | channame    | varchar(80)  | NO   |     | NULL              |                             |
  | appname     | varchar(80)  | NO   |     | NULL              |                             |
  | appdata     | varchar(80)  | NO   |     | NULL              |                             |
  | accountcode | varchar(20)  | NO   |     | NULL              |                             |
  | peeraccount | varchar(20)  | NO   |     | NULL              |                             |
  | uniqueid    | varchar(150) | NO   |     | NULL              |                             |
  | linkedid    | varchar(150) | NO   |     | NULL              |                             |
  | amaflags    | int(11)      | NO   |     | NULL              |                             |
  | userfield   | varchar(255) | NO   |     | NULL              |                             |
  | peer        | varchar(80)  | NO   |     | NULL              |                             |
  +-------------+--------------+------+-----+-------------------+-----------------------------+
  21 rows in set (0.00 sec)
  </code></pre>
  
  <h2>THE PROBLEM:</h2>
  
  <p>Now when I use cdr_adaptive_odbc I get these strange results when loading the module. The column type cannot be matched to an SQL column type.</p>
  
  <pre><code>dev-lt-tk1*CLI&gt; module reload cdr_adaptive_odbc.so 
      -- Reloading module 'cdr_adaptive_odbc.so' (Adaptive ODBC CDR backend)
    == Parsing '/opt/gemeinschaft/etc/asterisk/cdr_adaptive_odbc.conf':   == Found
      -- Found adaptive CDR table ast_cdr@odbc-voipstat101.
         &gt; Found _id column with type 4 with len 10, octetlen 10, and numlen (0,10)
         &gt; Found calldate column with type 93 with len 19, octetlen 19, and numlen (0,10)
         &gt; Found uniqueid column with type -9 with len 32, octetlen 32, and numlen (0,0)
         &gt; Found clid column with type -9 with len 80, octetlen 240, and numlen (0,0)
         &gt; Found src column with type -9 with len 30, octetlen 30, and numlen (0,0)
         &gt; Found dst column with type -9 with len 30, octetlen 30, and numlen (0,0)
         &gt; Found dcontext column with type -9 with len 50, octetlen 50, and numlen (0,0)
         &gt; Found channel column with type -9 with len 60, octetlen 60, and numlen (0,0)
         &gt; Found dstchannel column with type -9 with len 60, octetlen 60, and numlen (0,0)
         &gt; Found lastapp column with type -9 with len 30, octetlen 30, and numlen (0,0)
         &gt; Found lastdata column with type -9 with len 80, octetlen 80, and numlen (0,0)
         &gt; Found duration column with type 4 with len 8, octetlen 8, and numlen (0,10)
         &gt; Found billsec column with type 4 with len 8, octetlen 8, and numlen (0,10)
         &gt; Found disposition column with type -9 with len 15, octetlen 15, and numlen (0,0)
         &gt; Found amaflags column with type -6 with len 3, octetlen 3, and numlen (0,10)
         &gt; Found accountcode column with type -9 with len 25, octetlen 25, and numlen (0,0)
         &gt; Found userfield column with type -9 with len 255, octetlen 255, and numlen (0,0)
         &gt; Found sequence column with type -8 with len 32, octetlen 32, and numlen (0,0)
         &gt; Found linkedid column with type -8 with len 32, octetlen 32, and numlen (0,0)
  </code></pre>
  
  <p>Here's our CDR table structure:</p>
  
  <pre><code>mysql&gt; describe ast_cdr;
  +-------------+-----------------------+------+-----+-------------------+----------------+
  | Field       | Type                  | Null | Key | Default           | Extra          |
  +-------------+-----------------------+------+-----+-------------------+----------------+
  | _id         | int(10) unsigned      | NO   | PRI | NULL              | auto_increment |
  | calldate    | timestamp             | NO   | MUL | CURRENT_TIMESTAMP |                |
  | uniqueid    | varchar(32)           | NO   | MUL | NULL              |                |
  | clid        | varchar(80)           | NO   |     |                   |                |
  | src         | varchar(30)           | NO   | MUL |                   |                |
  | dst         | varchar(30)           | NO   | MUL |                   |                |
  | dcontext    | varchar(50)           | NO   |     |                   |                |
  | channel     | varchar(60)           | NO   |     |                   |                |
  | dstchannel  | varchar(60)           | NO   |     |                   |                |
  | lastapp     | varchar(30)           | NO   |     |                   |                |
  | lastdata    | varchar(80)           | NO   |     |                   |                |
  | duration    | mediumint(8) unsigned | NO   |     | 0                 |                |
  | billsec     | mediumint(8) unsigned | NO   |     | 0                 |                |
  | disposition | varchar(15)           | NO   |     |                   |                |
  | amaflags    | tinyint(3) unsigned   | NO   |     | 0                 |                |
  | accountcode | varchar(25)           | NO   | MUL |                   |                |
  | userfield   | varchar(255)          | NO   |     |                   |                |
  | sequence    | char(32)              | YES  |     | NULL              |                |
  | linkedid    | char(32)              | YES  |     | NULL              |                |
  +-------------+-----------------------+------+-----+-------------------+----------------+
  19 rows in set (0.00 sec)
  </code></pre>
  
  <p>Does anybody know why this happens? I've looked into the cel_odbc.c and cdr_adaptive_odbc.c sources and they seem heavily copy pasted. </p>