瀏覽代碼

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.
Juha Heinanen 13 年之前
父節點
當前提交
a12f916596
共有 4 個文件被更改,包括 27 次插入19 次删除
  1. 3 3
      lib/srdb1/schema/domain.xml
  2. 2 1
      modules_k/domain/README
  3. 3 1
      modules_k/domain/doc/domain_admin.xml
  4. 19 14
      modules_k/domain/domain.c

+ 3 - 3
lib/srdb1/schema/domain.xml

@@ -39,9 +39,9 @@
         <name>did</name>
         <name>did</name>
         <type>string</type>
         <type>string</type>
         <size>&domain_len;</size>
         <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>
 
 
     <column>
     <column>

+ 2 - 1
modules_k/domain/README

@@ -174,7 +174,8 @@ modparam("domain", "domain_attrs_table", "local_domain_attributes")
 3.4. did_col (string)
 3.4. did_col (string)
 
 
    Name of column containing domain id (did) of domain in domain and
    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”.
    Default value is “did”.
 
 

+ 3 - 1
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>
 		<title><varname>did_col</varname> (string)</title>
 		<para>
 		<para>
 		Name of column containing domain id (did) of domain in domain
 		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>
 		<para>
 		<para>
 		Default value is <quote>did</quote>.
 		Default value is <quote>did</quote>.

+ 19 - 14
modules_k/domain/domain.c

@@ -414,8 +414,8 @@ int reload_tables ( void )
     domain_dbf.free_result(db_handle, res);
     domain_dbf.free_result(db_handle, res);
     res = NULL;
     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) {
     if (domain_dbf.use_table(db_handle, &domain_table) < 0) {
 	LM_ERR("error while trying to use domain table\n");
 	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) ||
 	if ((VAL_NULL(ROW_VALUES(row)) == 1) ||
 	    (VAL_TYPE(ROW_VALUES(row)) != DB1_STRING)) {
 	    (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;
 	    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;
 	    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)) {
 	    (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;
 	    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",
 	LM_INFO("inserting <did/domain> = <%s/%s> into hash table\n",