[sr-dev] git:master: modules/mtree: when loading data from db, load each tree separately

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 30 21:00:38 CET 2013


On 10/30/13 4:49 PM, Juha Heinanen wrote:
> Daniel-Constantin Mierla writes:
>
>> mtree module works with two types of database tables:
>> - one having only (tprefix, tvalue)
>> - one having also tree name (tname, tprefix, tvalue)
>>
>> Your change seems to affect the first case, which is supposed not to
>> have tname column, thus not working.
> there is another function mt_load_db_trees() that load all the trees at
> one shot. my change didn't affect that branch of the code.

This is the one you should use when you store many trees in one database 
table.

The code you changed is for dedicated table per tree, where tname column 
is not present (and not needed as there are only the records for one 
tree, thus the value will be the same).

Therefore, you should not define the trees in config file, just set the 
db table name in config.

Cheers,
Daniel

>
> -- juha
>
> 	if(mt_defined_trees())
> 	{
> 		LM_DBG("static trees defined\n");
>
> 		pt = mt_get_first_tree();
>
> 		while(pt!=NULL)
> 		{
> 		        LM_DBG("loading from tree <%.*s>\n",
> 			        pt->tname.len, pt->tname.s);
>
> 			/* loading all information from database */
> 			if(mt_load_db(&pt->tname)!=0)
> 			{
> 				LM_ERR("cannot load info from database\n");
> 				goto error1;
> 			}
> 			pt = pt->next;
> 		}
> 	} else {
> 		if(db_table.len<=0)
> 		{
> 			LM_ERR("no trees table defined\n");
> 			goto error1;
> 		}
> 		if(mt_init_list_head()<0)
> 		{
> 			LM_ERR("unable to init trees list head\n");
> 			goto error1;
> 		}
> 		/* loading all information from database */
> 		if(mt_load_db_trees()!=0)
> 		{
> 			LM_ERR("cannot load trees from database\n");
> 			goto error1;
> 		}
> 	}

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Trainings - Berlin, Nov 25-28
   - more details about Kamailio trainings at http://www.asipto.com -




More information about the sr-dev mailing list