FS-7187 add switch_cache_db_create_schema() to test for SCF_AUTO_SCHEMAS flag
This commit is contained in:
parent
608d3e2425
commit
01dcb74f33
|
@ -26,6 +26,7 @@
|
|||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC)
|
||||
* Joseph Sullivan <jossulli@amazon.com>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
*
|
||||
* switch_core.h -- Core Library
|
||||
*
|
||||
|
@ -2437,6 +2438,13 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_
|
|||
const char *file, const char *func, int line);
|
||||
#define switch_cache_db_get_db_handle_dsn(_a, _b) _switch_cache_db_get_db_handle_dsn(_a, _b, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||
|
||||
/*!
|
||||
\brief Executes the create schema sql
|
||||
\param [in] dbh The handle
|
||||
\param [in] sql - sql to run
|
||||
\param [out] err - Error if it exists
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err);
|
||||
/*!
|
||||
\brief Executes the sql and returns the result as a string
|
||||
\param [in] dbh The handle
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
* Mathieu Rene <mathieu.rene@gmail.com>
|
||||
* Bret McDanel <trixter AT 0xdecafbad.com>
|
||||
* Rupa Schomaker <rupa@rupa.com>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
*
|
||||
* mod_db.c -- Implements simple db API, group support, and limit db backend
|
||||
*
|
||||
|
@ -325,7 +326,7 @@ static switch_status_t do_config()
|
|||
switch_cache_db_test_reactive(dbh, "select * from group_data", NULL, group_sql);
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_cache_db_execute_sql(dbh, indexes[x], NULL);
|
||||
switch_cache_db_create_schema(dbh, indexes[x], NULL);
|
||||
}
|
||||
|
||||
switch_cache_db_release_db_handle(&dbh);
|
||||
|
|
|
@ -782,7 +782,7 @@ static vm_profile_t *load_profile(const char *profile_name)
|
|||
|
||||
for (x = 0; vm_index_list[x]; x++) {
|
||||
errmsg = NULL;
|
||||
switch_cache_db_execute_sql(dbh, vm_index_list[x], &errmsg);
|
||||
switch_cache_db_create_schema(dbh, vm_index_list[x], &errmsg);
|
||||
switch_safe_free(errmsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -2271,7 +2271,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
free(test_sql);
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_cache_db_execute_sql(dbh, indexes[x], NULL);
|
||||
switch_cache_db_create_schema(dbh, indexes[x], NULL);
|
||||
}
|
||||
|
||||
switch_cache_db_release_db_handle(&dbh);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Michael Jerris <mike@jerris.com>
|
||||
* Paul D. Tinsley <pdt at jackhammer.org>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
*
|
||||
*
|
||||
* switch_core_sqldb.c -- Main Core Library (statistics tracker)
|
||||
|
@ -1267,6 +1268,19 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback_err(switch_
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err)
|
||||
{
|
||||
switch_status_t r = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
switch_assert(sql != NULL);
|
||||
|
||||
if (switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) {
|
||||
r = switch_cache_db_execute_sql(dbh, sql, err);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Performs test_sql and if it fails performs drop_sql and reactive_sql.
|
||||
*
|
||||
|
@ -3399,10 +3413,10 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
|||
|
||||
|
||||
switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from recovery", "DROP TABLE recovery", recovery_sql);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery1 on recovery(technology)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery2 on recovery(profile_name)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery3 on recovery(uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery3 on recovery(runtime_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery1 on recovery(technology)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery2 on recovery(profile_name)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery3 on recovery(uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery3 on recovery(runtime_uuid)", NULL);
|
||||
|
||||
|
||||
|
||||
|
@ -3536,30 +3550,30 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
|||
switch_cache_db_execute_sql(sql_manager.dbh, sql, NULL);
|
||||
}
|
||||
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index alias1 on aliases (alias)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index tasks1 on tasks (hostname,task_id)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete1 on complete (a1,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete2 on complete (a2,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete3 on complete (a3,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete4 on complete (a4,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete5 on complete (a5,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete6 on complete (a6,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete7 on complete (a7,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete8 on complete (a8,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete9 on complete (a9,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete10 on complete (a10,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete11 on complete (a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index nat_map_port_proto on nat (port,proto,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index channels1 on channels(hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index calls1 on calls(hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index chidx1 on channels (hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index uuindex on channels (uuid, hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index uuindex2 on channels (call_uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index callsidx1 on calls (hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index eruuindex on calls (caller_uuid, hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index eeuuindex on calls (callee_uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index eeuuindex2 on calls (call_uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index regindex1 on registrations (reg_user,realm,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index alias1 on aliases (alias)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index tasks1 on tasks (hostname,task_id)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete1 on complete (a1,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete2 on complete (a2,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete3 on complete (a3,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete4 on complete (a4,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete5 on complete (a5,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete6 on complete (a6,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete7 on complete (a7,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete8 on complete (a8,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete9 on complete (a9,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete10 on complete (a10,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete11 on complete (a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index nat_map_port_proto on nat (port,proto,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index channels1 on channels(hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index calls1 on calls(hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index chidx1 on channels (hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index uuindex on channels (uuid, hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index uuindex2 on channels (call_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index callsidx1 on calls (hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index eruuindex on calls (caller_uuid, hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index eeuuindex on calls (callee_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index eeuuindex2 on calls (call_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index regindex1 on registrations (reg_user,realm,hostname)", NULL);
|
||||
|
||||
|
||||
skip:
|
||||
|
|
Loading…
Reference in New Issue