[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:36:24 CET 2013


On 10/30/13 7:08 PM, Juha Heinanen wrote:
> Daniel-Constantin Mierla writes:
>
>> It is no a problem to add a patch that will enhance for defining trees
>> that load from a table that has tname, But should not break the other one.
> which case it is that the patch breaks?  perhaps it is possible to
> enhance the patch avoid breaking existing behavior.

# cat utils/kamctl/mysql/mtree-create.sql

INSERT INTO version (table_name, table_version) values ('mtree','1');
CREATE TABLE mtree (
     id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
     tprefix VARCHAR(32) DEFAULT '' NOT NULL,
     tvalue VARCHAR(128) DEFAULT '' NOT NULL,
     CONSTRAINT tprefix_idx UNIQUE (tprefix)
);

INSERT INTO version (table_name, table_version) values ('mtrees','2');
CREATE TABLE mtrees (
     id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
     tname VARCHAR(128) DEFAULT '' NOT NULL,
     tprefix VARCHAR(32) DEFAULT '' NOT NULL,
     tvalue VARCHAR(128) DEFAULT '' NOT NULL,
     CONSTRAINT tname_tprefix_tvalue_idx UNIQUE (tname, tprefix, tvalue)
);

As you can see from above sal table definitions, 'mtree' doesn't have 
tname column and you introduced a constraint that a table is loaded only 
when 'tname' column is present. So practically, the module doesn't work 
anymore with such table structure.
I could suggest adding a new attribute to table definition, such as 
'multiple=1' (derived from the fact that a db table has records for 
multiple trees), which when present, the load operation will do the 
query with WHERE condition on tname. Otherwise, will do it like it was 
so far.

Daniel

-- 
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