39 #define SWITCH_SQL_QUEUE_LEN 100000
40 #define SWITCH_SQL_QUEUE_PAUSE_LEN 90000
122 for (dbh_ptr =
sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->
next) {
123 if (dbh_ptr == dbh) {
141 unsigned long hash = 0, thread_hash = 0;
149 for (dbh_ptr =
sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->
next) {
157 for (dbh_ptr =
sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->
next) {
208 #define SQL_CACHE_TIMEOUT 30
209 #define SQL_REG_TIMEOUT 15
225 if (prune > 0 && prune > dbh->
last_used) {
277 if (sanity) sanity--;
301 switch((*dbh)->type) {
314 (*dbh)->io_mutex = NULL;
316 if ((*dbh)->use_count) {
317 if (--(*dbh)->use_count == 0) {
318 (*dbh)->thread_hash = 1;
336 const
char *file, const
char *func,
int line)
345 if (!strncasecmp(dsn,
"pgsql://", 8)) {
348 }
else if (!strncasecmp(dsn,
"sqlite://", 9)) {
351 }
else if ((!(i = strncasecmp(dsn,
"odbc://", 7))) || strchr(dsn+2,
':')) {
362 if ((p = strchr(tmp,
':'))) {
387 const
char *file, const
char *func,
int line)
395 uint32_t yield_len = 100000, total_yield = 0;
397 const char *db_name = NULL;
398 const char *odbc_user = NULL;
399 const char *odbc_pass = NULL;
400 const char *db_type = NULL;
409 total_yield += yield_len;
421 db_name = connection_options->pgsql_options.dsn;
428 db_name = connection_options->odbc_options.dsn;
429 odbc_user = connection_options->odbc_options.user;
430 odbc_pass = connection_options->odbc_options.pass;
436 db_name = connection_options->core_db_options.db_path;
448 if (odbc_user || odbc_pass) {
449 snprintf(db_str,
sizeof(db_str) - 1,
"db=\"%s\";type=\"%s\"user=\"%s\";pass=\"%s\"", db_name, db_type, odbc_user, odbc_pass);
451 snprintf(db_str,
sizeof(db_str) - 1,
"db=\"%s\",type=\"%s\"", db_name, db_type);
453 snprintf(db_callsite_str,
sizeof(db_callsite_str) - 1,
"%s:%d", file, line);
454 snprintf(thread_str,
sizeof(thread_str) - 1,
"thread=\"%lu\"", (
unsigned long) (intptr_t)
self);
456 if ((new_dbh =
get_handle(db_str, db_callsite_str, thread_str))) {
488 connection_options->odbc_options.user, connection_options->odbc_options.pass))) {
507 if (!db && !odbc_dbh && !pgsql_dbh) {
519 }
else if (odbc_dbh) {
525 add_handle(new_dbh, db_str, db_callsite_str, thread_str);
619 if (chunk_size > len) {
623 if (!(chunk_count = strlen(sql) / chunk_size)) {
638 if (*p ==
'\n' && *(p - 1) ==
';') {
755 while (running < 5000) {
757 const unsigned char *txt;
813 while (retries > 0) {
825 if (retries == 0 && forever) {
840 char *sql, uint32_t retries,
841 const
char *pre_trans_execute,
842 const
char *post_trans_execute,
843 const
char *inner_pre_trans_execute,
844 const
char *inner_post_trans_execute)
849 unsigned begin_retries = 100;
860 if (!
zstr(pre_trans_execute)) {
870 while (begin_retries > 0) {
885 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to Set AutoCommit Off", result);
886 errmsg = strdup(tmp);
896 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to Set AutoCommit Off", result);
897 errmsg = strdup(tmp);
905 if (strstr(errmsg,
"cannot start a transaction within a transaction")) {
939 if (begin_retries == 0) {
950 if (!
zstr(inner_pre_trans_execute)) {
958 while (retries > 0) {
968 if (retries == 0 && forever) {
978 if (!
zstr(inner_post_trans_execute)) {
1009 if (!
zstr(post_trans_execute)) {
1046 char *errmsg = NULL;
1060 switch (dbh->type) {
1081 if (!strstr(errmsg,
"query abort")) {
1098 void *
pdata,
char **err)
1101 char *errmsg = NULL;
1115 switch (dbh->type) {
1120 (*err_callback)(
pdata, (
const char*)*err);
1128 (*err_callback)(
pdata, (
const char*)*err);
1142 if (!strstr(errmsg,
"query abort")) {
1147 (*err_callback)(
pdata, errmsg);
1165 char *errmsg = NULL;
1175 switch (dbh->type) {
1188 int ret =
switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, callback, pdata, &errmsg);
1196 if (!strstr(errmsg,
"query abort")) {
1215 char *errmsg = NULL;
1225 switch (dbh->type) {
1230 (*err_callback)(
pdata, (
const char*)*err);
1238 (*err_callback)(
pdata, (
const char*)*err);
1244 int ret =
switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, callback, pdata, &errmsg);
1252 if (!strstr(errmsg,
"query abort")) {
1257 (*err_callback)(
pdata, errmsg);
1300 const
char *test_sql, const
char *drop_sql, const
char *reactive_sql)
1320 switch (dbh->type) {
1343 char *errmsg = NULL;
1381 int sec = 0, reg_sec = 0;;
1461 for (i = 0; i < qm->
numq; i++) {
1541 }
else if (event_callback) {
1558 if ((td =
new_job(qm, sql, callback, NULL, NULL, NULL, pdata))) {
1569 if ((td =
new_job(qm, sql, callback, err_callback, NULL, NULL, pdata))) {
1579 if ((td =
new_job(qm, sql, NULL, NULL, callback, NULL, pdata))) {
1591 if ((td =
new_job(qm, sql, NULL, NULL, callback, err_callback, pdata))) {
1635 for(i = 0; i < qm->numq; i++) {
1647 if (index < qm->numq) {
1658 uint32_t i, sanity = 100;
1660 if (qm->thread_running == 1) {
1661 qm->thread_running = -1;
1663 while(--sanity && qm->thread_running == -1) {
1664 for(i = 0; i < qm->numq; i++) {
1670 if (qm->thread_running == -1) {
1692 if (!qm->thread_running) {
1721 for(i = 0; i < qm->
numq; i++) {
1733 char *sqlptr = NULL;
1737 if (
sql_manager.paused || qm->thread_running != 1) {
1739 if (!dup) free((
char *)sql);
1744 if (qm->thread_running != 1) {
1745 if (!dup) free((
char *)sql);
1749 if (pos > qm->numq - 1) {
1753 sqlptr = dup ? strdup(sql) : (
char *)sql;
1779 if (
sql_manager.paused || qm->thread_running != 1) {
1781 if (!dup) free((
char *)sql);
1791 if (!dup) free((
char *)sql);
1795 int size, x = 0, sanity = 0;
1796 uint32_t written, want;
1799 if (!dup) free((
char *)sql);
1804 if (qm->thread_running != 1) {
1805 if (!dup) free((
char *)sql);
1809 if (pos > qm->numq - 1) {
1816 written = qm->pre_written[pos];
1818 want = written + size;
1823 while((qm->written[pos] < want) || (qm->written[pos] >= written && want < written && qm->written[pos] > want)) {
1829 if (++sanity == 20) {
1849 uint32_t numq, const
char *dsn, uint32_t max_trans,
1850 const
char *pre_trans_execute,
1851 const
char *post_trans_execute,
1852 const
char *inner_pre_trans_execute,
1853 const
char *inner_post_trans_execute)
1859 if (!numq) numq = 1;
1879 for (i = 0; i < qm->
numq; i++) {
1883 if (pre_trans_execute) {
1886 if (post_trans_execute) {
1889 if (inner_pre_trans_execute) {
1892 if (inner_post_trans_execute) {
1904 char *errmsg = NULL;
1933 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to Set AutoCommit Off", result);
1934 errmsg = strdup(tmp);
1944 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to Set AutoCommit Off", result);
1945 errmsg = strdup(tmp);
1967 while(qm->
max_trans == 0 || ttl <= qm->max_trans) {
2034 for (i = 0; i < qm->
numq; i++) {
2048 uint32_t sanity = 120;
2087 uint32_t written = 0, iterations = 0;
2094 for (i = 0; i < qm->
numq; i++) {
2105 iterations += written;
2109 char line[128] =
"";
2114 for (i = 0; i < qm->
numq; i++) {
2128 if ((lc =
qm_ttl(qm)) == 0) {
2136 while (--i > 0 && (lc =
qm_ttl(qm)) < 500) {
2145 for(i = 0; i < qm->
numq; i++) {
2159 char *cols[128] = { 0 };
2165 char col_name[128] =
"";
2172 data_copy = strdup(data);
2178 for (i = 0; i < col_count; i++) {
2179 const char *val = NULL;
2190 r = (
char *) stream.
data;
2204 #define new_sql() switch_assert(sql_idx+1 < MAX_SQL); if (exists) sql[sql_idx++]
2205 #define new_sql_a() switch_assert(sql_idx+1 < MAX_SQL); sql[sql_idx++]
2249 new_sql() =
switch_mprintf(
"insert into tasks (task_id, task_desc, task_group, task_runtime, task_sql_manager, hostname) "
2250 "values(%q,'%q','%q',%q,%q,'%q')",
2255 manager ? manager :
"0",
2272 new_sql() =
switch_mprintf(
"update tasks set task_desc='%q',task_group='%q', task_runtime=%q, task_sql_manager=%q where task_id=%q and hostname='%q'",
2276 manager ? manager :
"0",
2311 new_sql() =
switch_mprintf(
"insert into channels (uuid,direction,created,created_epoch, name,state,callstate,dialplan,context,hostname,initial_cid_name,initial_cid_num,initial_ip_addr,initial_dest,initial_dialplan,initial_context) "
2312 "values('%q','%q','%q','%ld','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
2335 (
"update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q'",
2349 "presence_id='%q',presence_data='%q' where uuid='%q'",
2364 "presence_id='%q',presence_data='%q', call_uuid='%q',%s where uuid='%q'",
2373 "presence_id='%q',presence_data='%q', call_uuid='%q' where uuid='%q'",
2385 new_sql() =
switch_mprintf(
"update channels set callee_name='%q',callee_num='%q',sent_callee_name='%q',sent_callee_num='%q',callee_direction='%q',"
2386 "cid_name='%q',cid_num='%q' where uuid='%s'",
2404 callstate = atoi(num);
2429 state_i = atoi(state);
2436 #ifndef SWITCH_DEPRECATED_CORE_DB
2441 #ifdef SWITCH_DEPRECATED_CORE_DB
2464 new_sql() =
switch_mprintf(
"update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
2465 "sent_callee_name='%q',sent_callee_num='%q',"
2466 "ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q',%s "
2485 new_sql() =
switch_mprintf(
"update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
2486 "sent_callee_name='%q',sent_callee_num='%q',"
2487 "ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q' "
2518 const char *a_uuid, *b_uuid, *uuid;
2524 if (
zstr(a_uuid) ||
zstr(b_uuid)) {
2539 "caller_uuid,callee_uuid,hostname) "
2540 "values ('%s','%s','%ld','%q','%q','%q')",
2569 "delete from interfaces where hostname='%q';"
2570 "delete from calls where hostname='%q'",
2587 (
"insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')", type, name,
2599 new_sql() =
switch_mprintf(
"delete from interfaces where type='%q' and name='%q' and hostname='%q'", type, name,
2620 if (!strcmp(
"add", op)) {
2621 new_sql() =
switch_mprintf(
"insert into nat (port, proto, sticky, hostname) values (%s, %s, %d,'%q')",
2625 }
else if (!strcmp(
"del", op)) {
2629 }
else if (!strcmp(
"status", op)) {
2631 }
else if (!strcmp(
"status_response", op)) {
2646 for (i = 0; i < sql_idx; i++) {
2659 "CREATE TABLE complete (\n"
2660 " sticky INTEGER,\n"
2661 " a1 VARCHAR(128),\n"
2662 " a2 VARCHAR(128),\n"
2663 " a3 VARCHAR(128),\n"
2664 " a4 VARCHAR(128),\n"
2665 " a5 VARCHAR(128),\n"
2666 " a6 VARCHAR(128),\n"
2667 " a7 VARCHAR(128),\n"
2668 " a8 VARCHAR(128),\n"
2669 " a9 VARCHAR(128),\n"
2670 " a10 VARCHAR(128),\n"
2671 " hostname VARCHAR(256)\n"
2675 "CREATE TABLE aliases (\n"
2676 " sticky INTEGER,\n"
2677 " alias VARCHAR(128),\n"
2678 " command VARCHAR(4096),\n"
2679 " hostname VARCHAR(256)\n"
2683 "CREATE TABLE channels (\n"
2684 " uuid VARCHAR(256),\n"
2685 " direction VARCHAR(32),\n"
2686 " created VARCHAR(128),\n"
2687 " created_epoch INTEGER,\n"
2688 " name VARCHAR(1024),\n"
2689 " state VARCHAR(64),\n"
2690 " cid_name VARCHAR(1024),\n"
2691 " cid_num VARCHAR(256),\n"
2692 " ip_addr VARCHAR(256),\n"
2693 " dest VARCHAR(1024),\n"
2694 " application VARCHAR(128),\n"
2695 " application_data VARCHAR(4096),\n"
2696 " dialplan VARCHAR(128),\n"
2697 " context VARCHAR(128),\n"
2698 " read_codec VARCHAR(128),\n"
2699 " read_rate VARCHAR(32),\n"
2700 " read_bit_rate VARCHAR(32),\n"
2701 " write_codec VARCHAR(128),\n"
2702 " write_rate VARCHAR(32),\n"
2703 " write_bit_rate VARCHAR(32),\n"
2704 " secure VARCHAR(64),\n"
2705 " hostname VARCHAR(256),\n"
2706 " presence_id VARCHAR(4096),\n"
2707 " presence_data VARCHAR(4096),\n"
2708 " callstate VARCHAR(64),\n"
2709 " callee_name VARCHAR(1024),\n"
2710 " callee_num VARCHAR(256),\n"
2711 " callee_direction VARCHAR(5),\n"
2712 " call_uuid VARCHAR(256),\n"
2713 " sent_callee_name VARCHAR(1024),\n"
2714 " sent_callee_num VARCHAR(256),\n"
2715 " initial_cid_name VARCHAR(1024),\n"
2716 " initial_cid_num VARCHAR(256),\n"
2717 " initial_ip_addr VARCHAR(256),\n"
2718 " initial_dest VARCHAR(1024),\n"
2719 " initial_dialplan VARCHAR(128),\n"
2720 " initial_context VARCHAR(128)\n"
2724 "CREATE TABLE calls (\n"
2725 " call_uuid VARCHAR(255),\n"
2726 " call_created VARCHAR(128),\n"
2727 " call_created_epoch INTEGER,\n"
2728 " caller_uuid VARCHAR(256),\n"
2729 " callee_uuid VARCHAR(256),\n"
2730 " hostname VARCHAR(256)\n"
2734 "CREATE TABLE interfaces (\n"
2735 " type VARCHAR(128),\n"
2736 " name VARCHAR(1024),\n"
2737 " description VARCHAR(4096),\n"
2738 " ikey VARCHAR(1024),\n"
2739 " filename VARCHAR(4096),\n"
2740 " syntax VARCHAR(4096),\n"
2741 " hostname VARCHAR(256)\n"
2745 "CREATE TABLE tasks (\n"
2746 " task_id INTEGER,\n"
2747 " task_desc VARCHAR(4096),\n"
2748 " task_group VARCHAR(1024),\n"
2749 " task_runtime BIGINT,\n"
2750 " task_sql_manager INTEGER,\n"
2751 " hostname VARCHAR(256)\n"
2755 "CREATE TABLE nat (\n"
2756 " sticky INTEGER,\n"
2759 " hostname VARCHAR(256)\n"
2764 "CREATE TABLE registrations (\n"
2765 " reg_user VARCHAR(256),\n"
2766 " realm VARCHAR(256),\n"
2767 " token VARCHAR(256),\n"
2770 " expires INTEGER,\n"
2771 " network_ip VARCHAR(256),\n"
2772 " network_port VARCHAR(256),\n"
2773 " network_proto VARCHAR(256),\n"
2774 " hostname VARCHAR(256),\n"
2775 " metadata VARCHAR(256)\n"
2782 "create view detailed_calls as select "
2784 "a.direction as direction,"
2785 "a.created as created,"
2786 "a.created_epoch as created_epoch,"
2789 "a.cid_name as cid_name,"
2790 "a.cid_num as cid_num,"
2791 "a.ip_addr as ip_addr,"
2793 "a.application as application,"
2794 "a.application_data as application_data,"
2795 "a.dialplan as dialplan,"
2796 "a.context as context,"
2797 "a.read_codec as read_codec,"
2798 "a.read_rate as read_rate,"
2799 "a.read_bit_rate as read_bit_rate,"
2800 "a.write_codec as write_codec,"
2801 "a.write_rate as write_rate,"
2802 "a.write_bit_rate as write_bit_rate,"
2803 "a.secure as secure,"
2804 "a.hostname as hostname,"
2805 "a.presence_id as presence_id,"
2806 "a.presence_data as presence_data,"
2807 "a.callstate as callstate,"
2808 "a.callee_name as callee_name,"
2809 "a.callee_num as callee_num,"
2810 "a.callee_direction as callee_direction,"
2811 "a.call_uuid as call_uuid,"
2812 "a.sent_callee_name as sent_callee_name,"
2813 "a.sent_callee_num as sent_callee_num,"
2815 "b.direction as b_direction,"
2816 "b.created as b_created,"
2817 "b.created_epoch as b_created_epoch,"
2819 "b.state as b_state,"
2820 "b.cid_name as b_cid_name,"
2821 "b.cid_num as b_cid_num,"
2822 "b.ip_addr as b_ip_addr,"
2824 "b.application as b_application,"
2825 "b.application_data as b_application_data,"
2826 "b.dialplan as b_dialplan,"
2827 "b.context as b_context,"
2828 "b.read_codec as b_read_codec,"
2829 "b.read_rate as b_read_rate,"
2830 "b.read_bit_rate as b_read_bit_rate,"
2831 "b.write_codec as b_write_codec,"
2832 "b.write_rate as b_write_rate,"
2833 "b.write_bit_rate as b_write_bit_rate,"
2834 "b.secure as b_secure,"
2835 "b.hostname as b_hostname,"
2836 "b.presence_id as b_presence_id,"
2837 "b.presence_data as b_presence_data,"
2838 "b.callstate as b_callstate,"
2839 "b.callee_name as b_callee_name,"
2840 "b.callee_num as b_callee_num,"
2841 "b.callee_direction as b_callee_direction,"
2842 "b.call_uuid as b_call_uuid,"
2843 "b.sent_callee_name as b_sent_callee_name,"
2844 "b.sent_callee_num as b_sent_callee_num,"
2845 "c.call_created_epoch as call_created_epoch "
2847 "left join calls c on a.uuid = c.caller_uuid and a.hostname = c.hostname "
2848 "left join channels b on b.uuid = c.callee_uuid and b.hostname = c.hostname "
2849 "where a.uuid = c.caller_uuid or a.uuid not in (select callee_uuid from calls)";
2853 "CREATE TABLE recovery (\n"
2854 " runtime_uuid VARCHAR(255),\n"
2855 " technology VARCHAR(255),\n"
2856 " profile_name VARCHAR(255),\n"
2857 " hostname VARCHAR(255),\n"
2858 " uuid VARCHAR(255),\n"
2863 "create view basic_calls as select "
2865 "a.direction as direction,"
2866 "a.created as created,"
2867 "a.created_epoch as created_epoch,"
2870 "a.cid_name as cid_name,"
2871 "a.cid_num as cid_num,"
2872 "a.ip_addr as ip_addr,"
2875 "a.presence_id as presence_id,"
2876 "a.presence_data as presence_data,"
2877 "a.callstate as callstate,"
2878 "a.callee_name as callee_name,"
2879 "a.callee_num as callee_num,"
2880 "a.callee_direction as callee_direction,"
2881 "a.call_uuid as call_uuid,"
2882 "a.hostname as hostname,"
2883 "a.sent_callee_name as sent_callee_name,"
2884 "a.sent_callee_num as sent_callee_num,"
2888 "b.direction as b_direction,"
2889 "b.created as b_created,"
2890 "b.created_epoch as b_created_epoch,"
2892 "b.state as b_state,"
2893 "b.cid_name as b_cid_name,"
2894 "b.cid_num as b_cid_num,"
2895 "b.ip_addr as b_ip_addr,"
2898 "b.presence_id as b_presence_id,"
2899 "b.presence_data as b_presence_data,"
2900 "b.callstate as b_callstate,"
2901 "b.callee_name as b_callee_name,"
2902 "b.callee_num as b_callee_num,"
2903 "b.callee_direction as b_callee_direction,"
2904 "b.sent_callee_name as b_sent_callee_name,"
2905 "b.sent_callee_num as b_sent_callee_num,"
2906 "c.call_created_epoch as call_created_epoch "
2909 "left join calls c on a.uuid = c.caller_uuid and a.hostname = c.hostname "
2910 "left join channels b on b.uuid = c.callee_uuid and b.hostname = c.hostname "
2911 "where a.uuid = c.caller_uuid or a.uuid not in (select callee_uuid from calls)";
2925 if (
zstr(technology)) {
2927 if (
zstr(profile_name)) {
2934 if (
zstr(profile_name)) {
2935 sql =
switch_mprintf(
"delete from recovery where technology='%q' ", technology);
2937 sql =
switch_mprintf(
"delete from recovery where technology='%q' and profile_name='%q'", technology, profile_name);
2952 int *rp = (
int *) pArg;
3017 if (strcasecmp(var,
"speak") && strcasecmp(var,
"playback") && strcasecmp(var,
"gentones") && strcasecmp(var,
"say")) {
3053 char *errmsg = NULL;
3067 if (
zstr(technology)) {
3069 if (
zstr(profile_name)) {
3070 sql =
switch_mprintf(
"select technology, profile_name, hostname, uuid, metadata "
3071 "from recovery where runtime_uuid!='%q'",
3074 sql =
switch_mprintf(
"select technology, profile_name, hostname, uuid, metadata "
3075 "from recovery where runtime_uuid!='%q' and profile_name='%q'",
3081 if (
zstr(profile_name)) {
3082 sql =
switch_mprintf(
"select technology, profile_name, hostname, uuid, metadata "
3083 "from recovery where technology='%q' and runtime_uuid!='%q'",
3086 sql =
switch_mprintf(
"select technology, profile_name, hostname, uuid, metadata "
3087 "from recovery where technology='%q' and runtime_uuid!='%q' and profile_name='%q'",
3102 if (
zstr(technology)) {
3103 if (
zstr(profile_name)) {
3104 sql =
switch_mprintf(
"delete from recovery where runtime_uuid!='%q'",
3107 sql =
switch_mprintf(
"delete from recovery where runtime_uuid!='%q' and profile_name='%q'",
3111 if (
zstr(profile_name)) {
3112 sql =
switch_mprintf(
"delete from recovery where runtime_uuid!='%q' and technology='%q' ",
3115 sql =
switch_mprintf(
"delete from recovery where runtime_uuid!='%q' and technology='%q' and profile_name='%q'",
3183 sql =
switch_mprintf(
"delete from recovery where runtime_uuid='%q' and uuid='%q'",
3197 char *xml_cdr_text = NULL;
3200 const char *profile_name;
3201 const char *technology;
3216 technology = session->endpoint_interface->interface_name;
3227 sql =
switch_mprintf(
"insert into recovery (runtime_uuid, technology, profile_name, hostname, uuid, metadata) "
3228 "values ('%q','%q','%q','%q','%q','%q')",
3245 const
char *network_ip, const
char *network_port, const
char *network_proto,
3246 const
char *metadata)
3255 sql =
switch_mprintf(
"delete from registrations where hostname='%q' and (url='%q' or token='%q')",
3258 sql =
switch_mprintf(
"delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'",
3264 if ( !
zstr(metadata) ) {
3265 sql =
switch_mprintf(
"insert into registrations (reg_user,realm,token,url,expires,network_ip,network_port,network_proto,hostname,metadata) "
3266 "values ('%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%q')",
3279 sql =
switch_mprintf(
"insert into registrations (reg_user,realm,token,url,expires,network_ip,network_port,network_proto,hostname) "
3280 "values ('%q','%q','%q','%q',%ld,'%q','%q','%q','%q')",
3388 char *tables[] = {
"channels",
"calls",
"tasks", NULL };
3392 for (i = 0; tables[i]; i++) {
3393 switch_snprintfv(sql,
sizeof(sql),
"delete from %q where hostname='%q'", tables[i], hostname);
3440 switch_cache_db_test_reactive(
sql_manager.dbh,
"select call_uuid, read_bit_rate, sent_callee_name, initial_cid_name, initial_cid_num, initial_ip_addr, initial_dest, initial_dialplan, initial_context from channels",
"DROP TABLE channels",
create_channels_sql);
3450 "DROP TABLE registrations", tmp);
3470 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to Set AutoCommit Off", result);
3481 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to Set AutoCommit Off", result);
3503 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to commit transaction.", result);
3514 switch_snprintfv(tmp,
sizeof(tmp),
"%q-%i",
"Unable to commit transaction.", result);
3550 char *tables[] = {
"complete",
"aliases",
"nat", NULL };
3554 for (i = 0; tables[i]; i++) {
3555 switch_snprintfv(sql,
sizeof(sql),
"delete from %q where sticky=0 and hostname='%q'", tables[i], hostname);
3559 switch_snprintfv(sql,
sizeof(sql),
"delete from interfaces where hostname='%q'", hostname);
3575 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);
3592 #ifdef SWITCH_SQL_BIND_EVERY_EVENT
3725 int count = 0, used = 0;
3734 needles[0] =
"pass=\"";
3735 needles[1] =
"password=";
3736 needles[2] =
"password='";
3748 memset(cleankey_str, 0,
sizeof(cleankey_str));
3749 for (i = 0; i < 3; i++) {
3750 if((pos1 = strstr(dbh->
name, needles[i]))) {
3751 pos1 += strlen(needles[i]);
3753 if (!(pos2 = strstr(pos1,
"\""))) {
3754 if (!(pos2 = strstr(pos1,
"'"))) {
3755 if (!(pos2 = strstr(pos1,
" "))) {
3756 pos2 = pos1 + strlen(pos1);
3760 strncpy(cleankey_str, dbh->
name, pos1 - dbh->
name);
3761 strcpy(&cleankey_str[pos1 - dbh->
name], pos2);
3766 strncpy(cleankey_str, dbh->
name, strlen(dbh->
name));
3775 stream->write_function(stream,
"%s\n\tType: %s\n\tLast used: %d\n\tTotal used: %ld\n\tFlags: %s, %s(%d)\n"
3776 "\tCreator: %s\n\tLast User: %s\n",
3781 locked ?
"Locked" :
"Unlocked",
3785 stream->write_function(stream,
"%d total. %d in use.\n", count, used);
struct apr_queue_t switch_queue_t
#define SWITCH_SQL_QUEUE_LEN
#define switch_event_get_header_nil(e, h)
switch_status_t switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err)
Executes the create schema sql.
const char * switch_core_get_switchname(void)
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
switch_mutex_t * cond2_mutex
unsigned int switch_queue_size(switch_queue_t *queue)
#define switch_strdup(ptr, s)
switch_event_types_t event_id
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
char * core_db_inner_post_trans_execute
switch_cache_db_native_handle_t native_handle
char * switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err)
Executes the sql and returns the result as a string.
const char * switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr)
returns the value of the requested tag attribute, or "" if not found
switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_t manage)
switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
switch_odbc_status_t switch_odbc_handle_exec_string(switch_odbc_handle_t *handle, const char *sql, char *resbuf, size_t len, char **err)
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_mutex_t * io_mutex
An Abstract Representation of a dialplan extension.
switch_bool_t switch_pgsql_available(void)
#define SWITCH_CHANNEL_LOG
switch_xml_t switch_xml_parse_str_dynamic(_In_z_ char *s, _In_ switch_bool_t dup)
Parses a string into a switch_xml_t, ensuring the memory will be freed with switch_xml_free.
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
switch_cache_db_handle_t * event_db
static char create_interfaces_sql[]
struct switch_odbc_handle switch_odbc_handle_t
static switch_cache_db_handle_t * create_handle(switch_cache_db_handle_type_t type)
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
char * inner_pre_trans_execute
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_status_t _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
Open the default system database.
static void del_handle(switch_cache_db_handle_t *dbh)
char * core_db_post_trans_execute
switch_cache_db_handle_type_t type
switch_cache_db_core_db_options_t core_db_options
int switch_odbc_handle_affected_rows(switch_odbc_handle_t *handle)
switch_status_t switch_cache_db_persistant_execute_trans_full(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries, const char *pre_trans_execute, const char *post_trans_execute, const char *inner_pre_trans_execute, const char *inner_post_trans_execute)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
switch_core_db_event_callback_func_t callback
struct switch_pgsql_handle switch_pgsql_handle_t
#define switch_split(_data, _delim, _array)
void switch_odbc_handle_destroy(switch_odbc_handle_t **handlep)
switch_mutex_t * cond_mutex
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
switch_pgsql_status_t switch_pgsql_SQLEndTran(switch_pgsql_handle_t *handle, switch_bool_t commit)
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
#define SWITCH_EVENT_SUBCLASS_ANY
switch_memory_pool_t * pool
Representation of an event.
#define SQL_CACHE_TIMEOUT
switch_core_session_t * switch_core_session_request_xml(switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool, switch_xml_t xml)
char * inner_post_trans_execute
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
static char create_tasks_sql[]
switch_odbc_status_t switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err)
void switch_sql_queue_manager_pause(switch_sql_queue_manager_t *qm, switch_bool_t flush)
static const char * switch_cache_db_type_name(switch_cache_db_handle_type_t type)
unsigned int switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
void switch_sql_queue_manager_resume(switch_sql_queue_manager_t *qm)
switch_status_t switch_cache_db_execute_sql_event_callback(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_event_callback_func_t callback, void *pdata, char **err)
int switch_core_db_close(switch_core_db_t *db)
A representation of an XML tree.
#define switch_cache_db_get_db_handle_dsn(_a, _b)
const char * switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx)
Retrieve a variable from a given channel.
switch_status_t switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex)
switch_status_t switch_core_del_registration(const char *user, const char *realm, const char *token)
Delete user registration.
switch_pgsql_status_t switch_pgsql_SQLSetAutoCommitAttr(switch_pgsql_handle_t *handle, switch_bool_t on)
void switch_cache_db_dismiss_db_handle(switch_cache_db_handle_t **dbh)
Returns the handle to the pool, immediately available for other threads to use.
switch_memory_pool_t * pool
char creator[CACHE_DB_LEN]
switch_memory_pool_t * memory_pool
#define SWITCH_CORE_DB_BUSY
switch_status_t switch_sql_queue_manager_stop(switch_sql_queue_manager_t *qm)
void switch_core_recovery_track(switch_core_session_t *session)
int switch_core_recovery_recover(const char *technology, const char *profile_name)
int(* switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames)
static switch_thread_t * thread
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
int switch_core_db_finalize(switch_core_db_stmt_t *pStmt)
void switch_core_recovery_flush(const char *technology, const char *profile_name)
struct switch_runtime runtime
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
switch_status_t switch_sql_queue_manager_push_confirm(switch_sql_queue_manager_t *qm, const char *sql, uint32_t pos, switch_bool_t dup)
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
char last_user[CACHE_DB_LEN]
switch_sql_queue_manager_t * qm
static void switch_core_sqldb_start_thread(void)
struct apr_thread_cond_t switch_thread_cond_t
int(* switch_core_db_event_callback_func_t)(void *pArg, switch_event_t *event)
int switch_core_db_step(switch_core_db_stmt_t *stmt)
switch_mutex_t * dbh_mutex
int switch_core_db_exec(switch_core_db_t *db, const char *sql, switch_core_db_callback_func_t callback, void *data, char **errmsg)
int(* switch_core_db_err_callback_func_t)(void *pArg, const char *errmsg)
#define SWITCH_CORE_DB_OK
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries)
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
static void add_handle(switch_cache_db_handle_t *dbh, const char *db_str, const char *db_callsite_str, const char *thread_str)
struct switch_cache_db_handle * next
#define UNPROTECT_INTERFACE(_it)
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
#define SWITCH_MUTEX_NESTED
int switch_sql_queue_manager_size(switch_sql_queue_manager_t *qm, uint32_t index)
void switch_cache_db_flush_handles(void)
switch_status_t _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn, const char *file, const char *func, int line)
static char recovery_sql[]
static char * parse_presence_data_cols(switch_event_t *event)
switch_status_t switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data)
Bind an event callback to a specific event.
switch_dbtype_t odbc_dbtype
void switch_core_sqldb_stop(void)
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
switch_cache_db_handle_type_t switch_cache_db_get_type(switch_cache_db_handle_t *dbh)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
switch_channel_t * channel
static switch_thread_data_t * new_job(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, switch_core_db_event_callback_func_t event_callback, switch_core_db_err_callback_func_t event_err_callback, void *pdata)
static uint32_t do_trans(switch_sql_queue_manager_t *qm)
switch_queue_t ** sql_queue
char * switch_core_get_uuid(void)
Retrieve the unique identifier from the core.
switch_core_db_err_callback_func_t event_err_callback
static char create_channels_sql[]
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
int switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh)
Get the affected rows of the last performed query.
switch_cache_db_handle_type_t
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
#define switch_channel_get_variable(_c, _v)
#define SWITCH_THREAD_STACKSIZE
uint64_t total_used_count
int switch_core_db_load_extension(switch_core_db_t *db, const char *extension)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
static char create_nat_sql[]
switch_thread_start_t func
#define switch_pgsql_finish_results(handle)
switch_core_db_err_callback_func_t err_callback
switch_memory_pool_t * pool
static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread, void *obj)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
void switch_core_sqldb_resume(void)
switch_sql_queue_manager_t * qm
#define switch_pgsql_handle_exec_string(handle, sql, resbuf, len, err)
switch_bool_t switch_odbc_available(void)
void switch_core_sql_exec(const char *sql)
void switch_sql_queue_manager_execute_sql_event_callback_err(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_event_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata)
char * switch_snprintfv(char *zBuf, int n, const char *zFormat,...)
void switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
Assign a caller extension to a given channel.
switch_pgsql_status_t switch_pgsql_flush(switch_pgsql_handle_t *handle)
#define switch_pgsql_handle_exec(handle, sql, err)
int switch_cache_db_load_extension(switch_cache_db_handle_t *dbh, const char *extension)
load an external extension to db
uint32_t db_handle_timeout
void switch_caller_extension_add_application(_In_ switch_core_session_t *session, _In_ switch_caller_extension_t *caller_extension, _In_z_ const char *application_name, _In_z_ const char *extra_data)
Add an application (instruction) to the given extension.
static char create_calls_sql[]
pthread_t switch_thread_id_t
void switch_cond_next(void)
switch_status_t switch_cache_db_execute_sql_event_callback_err(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_event_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata, char **err)
static char detailed_calls_sql[]
void switch_cache_db_status(switch_stream_handle_t *stream)
Provides some feedback as to the status of the db connection pool.
#define SWITCH_STANDARD_STREAM(s)
switch_odbc_handle_t * odbc_dbh
switch_channel_callstate_t
char * switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size)
#define switch_odbc_handle_callback_exec(handle,sql,callback, pdata, err)
Execute the sql query and issue a callback for each row returned.
switch_cache_db_odbc_options_t odbc_options
switch_caller_extension_t * switch_caller_extension_new(_In_ switch_core_session_t *session, _In_z_ const char *extension_name, _In_z_ const char *extension_number)
Create a new extension with desired parameters.
switch_cache_db_handle_t * handle_pool
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_cache_db_handle_t * dbh
#define switch_core_db_handle(_a)
#define switch_pgsql_handle_callback_exec(handle,sql,callback, pdata, err)
Execute the sql query and issue a callback for each row returned.
#define switch_str_nil(s)
Make a null string a blank string instead.
void switch_core_sqldb_pause(void)
switch_memory_pool_t * pool
switch_status_t switch_thread_cond_signal(switch_thread_cond_t *cond)
void switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh)
Returns the handle to the pool, handle is NOT available to other threads until the allocating thread ...
void switch_core_recovery_untrack(switch_core_session_t *session, switch_bool_t force)
switch_core_recover_callback_t recover_callback
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
static switch_cache_db_handle_t * get_handle(const char *db_str, const char *user_str, const char *thread_str)
uint32_t total_used_handles
switch_core_db_t * core_db_dbh
switch_stream_handle_write_function_t write_function
struct apr_thread_mutex_t switch_mutex_t
switch_status_t
Common return values.
static char basic_calls_sql[]
switch_pgsql_handle_t * pgsql_dbh
char * switch_string_replace(const char *string, const char *search, const char *replace)
static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t *dbh, const char *sql, char **err)
switch_status_t switch_sql_queue_manager_init_name(const char *name, switch_sql_queue_manager_t **qmp, uint32_t numq, const char *dsn, uint32_t max_trans, const char *pre_trans_execute, const char *post_trans_execute, const char *inner_pre_trans_execute, const char *inner_post_trans_execute)
switch_endpoint_interface_t * switch_loadable_module_get_endpoint_interface(const char *name)
Retrieve the endpoint interface by it's registered name.
void switch_sql_queue_manager_execute_sql_callback(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_callback_func_t callback, void *pdata)
static void *SWITCH_THREAD_FUNC switch_core_sql_db_thread(switch_thread_t *thread, void *obj)
const char * switch_core_get_hostname(void)
switch_status_t switch_core_expire_registration(int force)
Expire user registrations.
static int helper_callback(void *pArg, int argc, char **argv, char **columnNames)
unsigned long thread_hash
struct sqlite3 switch_core_db_t
switch_status_t switch_queue_interrupt_all(switch_queue_t *queue)
struct apr_thread_t switch_thread_t
switch_cache_db_pgsql_options_t pgsql_options
switch_odbc_status_t switch_odbc_handle_connect(switch_odbc_handle_t *handle)
static int recover_callback(void *pArg, int argc, char **argv, char **columnNames)
switch_core_db_callback_func_t callback
int switch_pgsql_handle_affected_rows(switch_pgsql_handle_t *handle)
#define switch_event_get_header(_e, _h)
switch_odbc_status_t switch_odbc_SQLEndTran(switch_odbc_handle_t *handle, switch_bool_t commit)
#define switch_channel_set_flag(_c, _f)
char * switch_xml_toxml_nolock(switch_xml_t xml, _In_ switch_bool_t prn_header)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
switch_bool_t switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh, const char *test_sql, const char *drop_sql, const char *reactive_sql)
Performs test_sql and if it fails performs drop_sql and reactive_sql.
#define SWITCH_CORE_DB_ABORT
switch_pgsql_handle_t * switch_pgsql_handle_new(const char *dsn)
Create a new handle for the PGSQL connection.
static char create_registrations_sql[]
static int qm_wake(switch_sql_queue_manager_t *qm)
#define switch_set_string(_dst, _src)
switch_thread_cond_t * cond
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
switch_status_t switch_event_create_array_pair(switch_event_t **event, char **names, char **vals, int len)
char * core_db_pre_trans_execute
static void switch_core_sqldb_stop_thread(void)
static const char * skip(const char *in)
void switch_core_db_free(char *z)
int(* switch_core_recover_callback_t)(switch_core_session_t *session)
struct sqlite3_stmt switch_core_db_stmt_t
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
switch_status_t switch_sql_queue_manager_destroy(switch_sql_queue_manager_t **qmp)
#define SWITCH_CORE_DB_ROW
switch_core_recover_callback_t switch_core_get_secondary_recover_callback(const char *key)
switch_status_t switch_sql_queue_manager_start(switch_sql_queue_manager_t *qm)
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
struct apr_pool_t switch_memory_pool_t
switch_status_t switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err)
Executes the sql and uses callback for row-by-row processing.
switch_status_t switch_event_unbind_callback(switch_event_callback_t callback)
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
const char * switch_stristr(const char *instr, const char *str)
int switch_core_db_changes(switch_core_db_t *db)
switch_status_t switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
switch_status_t switch_sql_queue_manager_push(switch_sql_queue_manager_t *qm, const char *sql, uint32_t pos, switch_bool_t dup)
int switch_core_db_column_count(switch_core_db_stmt_t *pStmt)
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
static uint32_t qm_ttl(switch_sql_queue_manager_t *qm)
switch_thread_id_t switch_thread_self(void)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
char * switch_sql_concat(void)
switch_mutex_t * ctl_mutex
switch_status_t switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err)
Executes the sql.
switch_core_db_event_callback_func_t event_callback
const unsigned char * switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol)
static char create_complete_sql[]
void switch_sql_queue_manager_execute_sql_event_callback(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_event_callback_func_t callback, void *pdata)
void switch_pgsql_handle_destroy(switch_pgsql_handle_t **handlep)
static void core_event_handler(switch_event_t *event)
char * core_db_inner_pre_trans_execute
int multiple_registrations
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
void switch_sql_queue_manager_execute_sql_callback_err(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata)
switch_odbc_handle_t * switch_odbc_handle_new(const char *dsn, const char *username, const char *password)
switch_mutex_t * io_mutex
static void sql_close(time_t prune)
switch_thread_t * db_thread
switch_status_t switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr)
Generate an XML CDR report.
switch_core_db_t * switch_core_db_open_file(const char *filename)
Open a core db (SQLite) file.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
switch_status_t switch_cache_db_execute_sql_callback_err(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata, char **err)
Executes the sql and uses callback for row-by-row processing.
switch_pgsql_status_t switch_pgsql_handle_connect(switch_pgsql_handle_t *handle)
Connect to the database specified by the DSN passed to the switch_pgsql_handle_new() call which initi...
static void *SWITCH_THREAD_FUNC sql_in_thread(switch_thread_t *thread, void *obj)
switch_odbc_status_t switch_odbc_SQLSetAutoCommitAttr(switch_odbc_handle_t *handle, switch_bool_t on)
int switch_core_db_prepare(switch_core_db_t *db, const char *zSql, int nBytes, switch_core_db_stmt_t **ppStmt, const char **pzTail)
static void do_flush(switch_sql_queue_manager_t *qm, int i, switch_cache_db_handle_t *dbh)
char * post_trans_execute
static char create_alias_sql[]
static struct @3 sql_manager
switch_status_t switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires, const char *network_ip, const char *network_port, const char *network_proto, const char *metadata)
Add user registration.
switch_status_t _switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t *connection_options, const char *file, const char *func, int line)
Gets a new cached handle from the pool, potentially creating a new connection. The connection is boun...
switch_status_t switch_core_session_thread_launch(_In_ switch_core_session_t *session)
Launch the session thread (state machine) on a given session.
switch_status_t switch_thread_pool_launch_thread(switch_thread_data_t **tdp)
static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handle_t *dbh, char *sql, uint32_t chunk_size, char **err)
switch_cache_db_handle_type_t switch_core_dbtype(void)
switch_status_t switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority)