Hi,
I've problems using avpops and mongodb, resulting in the error: "ERROR: avpops [avpops_impl.c:123]: dbrow2avp(): wrong field types in dbrow"
In the database:
db.usr_preferences.find()
{ "_id" : ObjectId("5978ab2850d1be89eb15f434"), "uuid" : "", "attribute" : "email", "value" : "sip:555@sip.bla.bla", "type" : 0, "username" : "555", "domain" : null }
In kamailio.cfg:
... # ---- avpops params ---- modparam("avpops", "db_url", DBURL) modparam("avpops", "avp_table", "usr_preferences")
...
if ($rU=~"^(555|222)$") { xlog("bla01"); if (avp_db_load("$to/username", "$avp(s:email)")) { xlog("bla02"); } } xlog("bla03");
...
The result in syslog:
ERROR: <script>: bla01 DEBUG: db_mongodb [mongodb_dbase.c:864]: db_mongodb_query(): query to collection [usr_preferences] DEBUG: db_mongodb [mongodb_dbase.c:898]: db_mongodb_query(): query filter: { "username" : "555", "attribute" : "email" } DEBUG: db_mongodb [mongodb_dbase.c:917]: db_mongodb_query(): columns filter: { "value" : 1, "attribute" : 1, "type" : 1 } DEBUG: <core> [db_res.c:116]: db_new_result(): allocate 56 bytes for result set at 0x7f82c8f4ae30 DEBUG: db_mongodb [mongodb_dbase.c:349]: db_mongodb_get_columns(): 3 columns returned from the query DEBUG: <core> [db_res.c:154]: db_allocate_columns(): allocate 24 bytes for result names at 0x7f82c8f4fd40 DEBUG: <core> [db_res.c:165]: db_allocate_columns(): allocate 12 bytes for result types at 0x7f82c8f70df0 DEBUG: db_mongodb [mongodb_dbase.c:377]: db_mongodb_get_columns(): Found a field[0] named: value DEBUG: db_mongodb [mongodb_dbase.c:403]: db_mongodb_get_columns(): allocate 16 bytes for RES_NAMES[0] at 0x7f82c8f70e48 DEBUG: db_mongodb [mongodb_dbase.c:438]: db_mongodb_get_columns(): use DB1_STRING result type DEBUG: db_mongodb [mongodb_dbase.c:467]: db_mongodb_get_columns(): RES_NAMES(0x7f82c8f70e48)[0]=[value] (2) DEBUG: db_mongodb [mongodb_dbase.c:377]: db_mongodb_get_columns(): Found a field[1] named: attribute DEBUG: db_mongodb [mongodb_dbase.c:403]: db_mongodb_get_columns(): allocate 16 bytes for RES_NAMES[1] at 0x7f82c8f4abc8 DEBUG: db_mongodb [mongodb_dbase.c:438]: db_mongodb_get_columns(): use DB1_STRING result type DEBUG: db_mongodb [mongodb_dbase.c:467]: db_mongodb_get_columns(): RES_NAMES(0x7f82c8f4abc8)[1]=[attribute] (2) DEBUG: db_mongodb [mongodb_dbase.c:377]: db_mongodb_get_columns(): Found a field[2] named: type DEBUG: db_mongodb [mongodb_dbase.c:403]: db_mongodb_get_columns(): allocate 16 bytes for RES_NAMES[2] at 0x7f82c8f4aeb0 DEBUG: db_mongodb [mongodb_dbase.c:423]: db_mongodb_get_columns(): use DB1_DOUBLE result type DEBUG: db_mongodb [mongodb_dbase.c:467]: db_mongodb_get_columns(): RES_NAMES(0x7f82c8f4aeb0)[2]=[type] (1) DEBUG: <core> [db_res.c:184]: db_allocate_rows(): allocate 16000 bytes for rows at 0x7f82c8f80820 DEBUG: db_mongodb [mongodb_dbase.c:684]: db_mongodb_convert_result(): selected document: { "_id" : { "$oid" : "5978ab2850d1be89eb15f434" }, "attribute" : "email", "value" : "sip:555@sip.bla.bla", "type" : 0.000000 } DEBUG: <core> [db_row.c:117]: db_allocate_row(): allocate 96 bytes for row values at 0x7f82c8f4af08 DEBUG: db_mongodb [mongodb_dbase.c:529]: db_mongodb_convert_bson(): looking for field[0] named: value DEBUG: db_mongodb [mongodb_dbase.c:623]: db_mongodb_convert_bson(): RES_NAMES(0x7f82c8f70e48)[0]=[value] (2) DEBUG: db_mongodb [mongodb_dbase.c:529]: db_mongodb_convert_bson(): looking for field[1] named: attribute DEBUG: db_mongodb [mongodb_dbase.c:623]: db_mongodb_convert_bson(): RES_NAMES(0x7f82c8f4abc8)[1]=[attribute] (2) DEBUG: db_mongodb [mongodb_dbase.c:529]: db_mongodb_convert_bson(): looking for field[2] named: type DEBUG: db_mongodb [mongodb_dbase.c:623]: db_mongodb_convert_bson(): RES_NAMES(0x7f82c8f4aeb0)[2]=[type] (1) DEBUG: db_mongodb [mongodb_dbase.c:695]: db_mongodb_convert_result(): retrieved number of rows: 1 ERROR: avpops [avpops_impl.c:123]: dbrow2avp(): wrong field types in dbrow DEBUG: avpops [avpops_db.c:265]: db_close_query(): close avp query DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 3 columns DEBUG: <core> [db_res.c:83]: db_free_columns(): freeing RES_NAMES[0] at 0x7f82c8f70e48 DEBUG: <core> [db_res.c:83]: db_free_columns(): freeing RES_NAMES[1] at 0x7f82c8f4abc8 DEBUG: <core> [db_res.c:83]: db_free_columns(): freeing RES_NAMES[2] at 0x7f82c8f4aeb0 DEBUG: <core> [db_res.c:92]: db_free_columns(): freeing result names at 0x7f82c8f4fd40 DEBUG: <core> [db_res.c:97]: db_free_columns(): freeing result types at 0x7f82c8f70df0 DEBUG: <core> [db_res.c:52]: db_free_rows(): freeing 1 rows DEBUG: <core> [db_row.c:95]: db_free_row(): freeing row values at 0x7f82c8f4af08 DEBUG: <core> [db_res.c:60]: db_free_rows(): freeing rows at 0x7f82c8f80820 DEBUG: <core> [db_res.c:134]: db_free_result(): freeing result set at 0x7f82c8f4ae30 DEBUG: avpops [avpops_impl.c:415]: ops_dbload_avps(): loaded avps = 0 ERROR: <script>: bla03
Does anyone know what I'm doing wrong here?