Index: res/res_config_pgsql.c =================================================================== --- res/res_config_pgsql.c (Revision 280623) +++ res/res_config_pgsql.c (Arbeitskopie) @@ -1056,7 +1056,7 @@ PGresult *result = NULL; long num_rows; struct ast_variable *new_v; - struct ast_category *cur_cat = NULL; + struct ast_category *cur_cat = NULL, *par_cat = NULL; struct ast_str *sql = ast_str_thread_get(&sql_buf, 100); char last[80] = ""; int last_cat_metric = 0; @@ -1069,7 +1069,7 @@ } ast_str_set(&sql, 0, "SELECT category, var_name, var_val, cat_metric FROM %s " - "WHERE filename='%s' and commented=0" + "WHERE filename='%s' and commented=0 " "ORDER BY cat_metric DESC, var_metric ASC, category, var_name ", table, file); ast_debug(1, "PostgreSQL RealTime: Static SQL: %s\n", ast_str_buffer(sql)); @@ -1121,16 +1121,24 @@ } continue; } - + + if (strcmp(last, field_category) || last_cat_metric != atoi(field_cat_metric)) { - cur_cat = ast_category_new(field_category, "", 99999); + /* searching for category in parent configuration, if field_cat_metric == 0 */ + if(strcmp(last, field_category) && atoi(field_cat_metric) <= 0 && (par_cat = ast_category_get(cfg, field_category)) != NULL ){ + cur_cat = par_cat; + ast_debug(1, "using category %s from patent configuration.\n", field_category); + }else{ + cur_cat = ast_category_new(field_category, "", rowIndex + 1); + ast_debug(1, "create new category %s.\n", field_category); + } if (!cur_cat) break; strcpy(last, field_category); last_cat_metric = atoi(field_cat_metric); ast_category_append(cfg, cur_cat); } - new_v = ast_variable_new(field_var_name, field_var_val, ""); + new_v = ast_variable_new(field_var_name, field_var_val, file); ast_variable_append(cur_cat, new_v); } } else {