Module: sip-router Branch: master Commit: a12f916596057443ad8c5824af1a1d4e03cb7ce0 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a12f9165...
Author: Juha Heinanen jh@tutpro.com Committer: Juha Heinanen jh@tutpro.com Date: Tue Apr 3 14:30:03 2012 +0300
modules_k/domain: did column of domain table is by default NULL
- In order to make migration from 3.2 easier, allow did column of domain table to be NULL. If NULL, value of did is assumed to be same as value of domain.
---
lib/srdb1/schema/domain.xml | 6 +++--- modules_k/domain/README | 3 ++- modules_k/domain/doc/domain_admin.xml | 4 +++- modules_k/domain/domain.c | 33 +++++++++++++++++++-------------- 4 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/lib/srdb1/schema/domain.xml b/lib/srdb1/schema/domain.xml index 7e6a6aa..83be326 100644 --- a/lib/srdb1/schema/domain.xml +++ b/lib/srdb1/schema/domain.xml @@ -39,9 +39,9 @@ <name>did</name> <type>string</type> <size>&domain_len;</size> - <description>Domain id</description> - <default/> - <natural/> + <description>Domain id. Value of did column may be NULL, which + means that it has the same value as domain column.</description> + <null/> </column>
<column> diff --git a/modules_k/domain/README b/modules_k/domain/README index aa9bf2f..e57406e 100644 --- a/modules_k/domain/README +++ b/modules_k/domain/README @@ -174,7 +174,8 @@ modparam("domain", "domain_attrs_table", "local_domain_attributes") 3.4. did_col (string)
Name of column containing domain id (did) of domain in domain and - domain_attrs tables. + domain_attrs tables. In domain table, a did column value may be NULL, + which means that it has same value as domain column.
Default value is “did”.
diff --git a/modules_k/domain/doc/domain_admin.xml b/modules_k/domain/doc/domain_admin.xml index 9d89555..f11466e 100644 --- a/modules_k/domain/doc/domain_admin.xml +++ b/modules_k/domain/doc/domain_admin.xml @@ -102,7 +102,9 @@ modparam("domain", "domain_attrs_table", "local_domain_attributes") <title><varname>did_col</varname> (string)</title> <para> Name of column containing domain id (did) of domain in domain - and domain_attrs tables. + and domain_attrs tables. In domain table, a did column value + may be NULL, which means that it has same value as + domain column. </para> <para> Default value is <quote>did</quote>. diff --git a/modules_k/domain/domain.c b/modules_k/domain/domain.c index 61e2b07..82d4b41 100644 --- a/modules_k/domain/domain.c +++ b/modules_k/domain/domain.c @@ -414,8 +414,8 @@ int reload_tables ( void ) domain_dbf.free_result(db_handle, res); res = NULL;
- cols[0] = &did_col; - cols[1] = &domain_col; + cols[0] = &domain_col; + cols[1] = &did_col;
if (domain_dbf.use_table(db_handle, &domain_table) < 0) { LM_ERR("error while trying to use domain table\n"); @@ -437,26 +437,31 @@ int reload_tables ( void )
if ((VAL_NULL(ROW_VALUES(row)) == 1) || (VAL_TYPE(ROW_VALUES(row)) != DB1_STRING)) { - LM_ERR("did at row <%u> is null or not string\n", i); + LM_ERR("domain at row <%u> is null or not string\n", i); goto err; } - did.s = (char *)VAL_STRING(ROW_VALUES(row)); - did.len = strlen(did.s); - if (did.len == 0) { - LM_ERR("did at row <%u> is empty string\n", i); + domain.s = (char *)VAL_STRING(ROW_VALUES(row)); + domain.len = strlen(domain.s); + if (domain.len == 0) { + LM_ERR("domain at row <%u> is empty string\n", i); goto err; }
- if ((VAL_NULL(ROW_VALUES(row) + 1) == 1) || + if ((VAL_NULL(ROW_VALUES(row) + 1) != 1) && (VAL_TYPE(ROW_VALUES(row) + 1) != DB1_STRING)) { - LM_ERR("domain at row <%u> is null or not string\n", i); + LM_ERR("did at row <%u> is not null or string\n", i); goto err; } - domain.s = (char *)VAL_STRING(ROW_VALUES(row) + 1); - domain.len = strlen(domain.s); - if (domain.len == 0) { - LM_ERR("domain at row <%u> is empty string\n", i); - goto err; + if (VAL_NULL(ROW_VALUES(row) + 1) == 1) { + did.s = domain.s; + did.len = domain.len; + } else { + did.s = (char *)VAL_STRING(ROW_VALUES(row) + 1); + did.len = strlen(did.s); + if (did.len == 0) { + LM_ERR("did at row <%u> is empty string\n", i); + goto err; + } }
LM_INFO("inserting <did/domain> = <%s/%s> into hash table\n",