diff --git a/modules/dialplan/dialplan.c b/modules/dialplan/dialplan.c index 6140b2ea063..29c9a0d5980 100644 --- a/modules/dialplan/dialplan.c +++ b/modules/dialplan/dialplan.c @@ -268,6 +268,14 @@ static int dp_create_head(const str *in) if (!params) goto bad_input; + /* support for the "default: my_part" syntax */ + if (!props->next && !params->next && !ZSTR(params->s)) { + dp_df_part = params->s; + LM_DBG("changing the default partition to '%.*s'\n", + dp_df_part.len, dp_df_part.s); + return 0; + } + if (str_match(¶ms->s, _str(PARAM_URL))) { have_db_url = 1; dp_head_insert(DP_TYPE_URL, ¶ms->next->s, &partition); @@ -358,7 +366,7 @@ static int mod_init(void) timerec_column.len = strlen(timerec_column.s); disabled_column.len = strlen(disabled_column.s); - if (!dp_df_head) { + if (!dp_df_head && str_match(&dp_df_part, _str(DEFAULT_PARTITION))) { if (default_dp_db_url.s) dp_head_insert(DP_TYPE_URL, &default_dp_db_url, &dp_df_part); diff --git a/modules/dialplan/doc/dialplan_admin.xml b/modules/dialplan/doc/dialplan_admin.xml index 556c1bd5c8a..7e0f19109bd 100644 --- a/modules/dialplan/doc/dialplan_admin.xml +++ b/modules/dialplan/doc/dialplan_admin.xml @@ -346,15 +346,16 @@ modparam("dialplan", "partition", " - The 'default' partition inherits its URL from <varname>'db_default_url'</varname> + Define the 'pstn' partition and make it the 'default' partition, so we avoid loading the 'dialplan' table ... db_default_url = "mysql://opensips:opensipsrw@localhost/opensips" loadmodule "dialplan.so" modparam("dialplan", "partition", " - default: - table_name = dialplan") + pstn: + table_name = dialplan_pstn") +modparam("dialplan", "partition", "default: pstn") ... diff --git a/modules/dialplan/dp_db.c b/modules/dialplan/dp_db.c index af64b6c883a..76931d8da1e 100644 --- a/modules/dialplan/dp_db.c +++ b/modules/dialplan/dp_db.c @@ -169,6 +169,7 @@ void dp_disconnect_db(dp_connection_list_p dp_conn) int init_data(void) { dp_head_p start, tmp; + int found_df_part = 0; start = dp_hlist; if (!start) { @@ -179,6 +180,10 @@ int init_data(void) while (start) { LM_DBG("Adding partition with name [%.*s]\n", start->partition.len, start->partition.s); + + if (str_match(&start->partition, &dp_df_part)) + found_df_part = 1; + if (!dp_add_connection(start)) { LM_ERR("failed to initialize partition '%.*s'\n", start->partition.len, start->partition.s); @@ -190,6 +195,12 @@ int init_data(void) pkg_free(tmp); } + if (!found_df_part) { + LM_ERR("partition '%.*s' is not defined\n", + dp_df_part.len, dp_df_part.s); + return -1; + } + dp_hlist = NULL; return 0; }