From 39ee7ef2afece74fb93114dd16c2733ed19d6a99 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 8 Dec 2009 16:37:48 +0000 Subject: [PATCH] change name of 'key' field due to reserved name in sql git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15842 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/applications/mod_commands/mod_commands.c | 16 ++++++++-------- src/switch_core_sqldb.c | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index e1fd149eb5..a8dd24c20e 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -3012,24 +3012,24 @@ SWITCH_STANDARD_API(show_function) if (end_of(command) == 's') { end_of(command) = '\0'; } - sprintf(sql, "select type, name, key from interfaces where type = '%s' order by type,name", command); + sprintf(sql, "select type, name, ikey from interfaces where type = '%s' order by type,name", command); } else if (!strncasecmp(command, "module", 6)) { if (argv[1]) { - sprintf(sql, "select distinct type, name, key, filename from interfaces where key = '%s' order by type,name", argv[1]); + sprintf(sql, "select distinct type, name, ikey, filename from interfaces where key = '%s' order by type,name", argv[1]); } else { - sprintf(sql, "select distinct type, name, key, filename from interfaces order by type,name"); + sprintf(sql, "select distinct type, name, ikey, filename from interfaces order by type,name"); } } else if (!strcasecmp(command, "interfaces")) { - sprintf(sql, "select type, name, key from interfaces order by type,name"); + sprintf(sql, "select type, name, ikey from interfaces order by type,name"); } else if (!strcasecmp(command, "interface_types")) { sprintf(sql, "select type,count(type) as total from interfaces group by type order by type"); } else if (!strcasecmp(command, "tasks")) { sprintf(sql, "select * from %s", command); } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) { if (argv[1] && strcasecmp(argv[1], "as")) { - sprintf(sql, "select name, description, syntax, key from interfaces where type = '%s' and description != '' and name = '%s' order by type,name", command, argv[1]); + sprintf(sql, "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name", command, argv[1]); } else { - sprintf(sql, "select name, description, syntax, key from interfaces where type = '%s' and description != '' order by type,name", command); + sprintf(sql, "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' order by type,name", command); } } else if (!strcasecmp(command, "calls")) { sprintf(sql, "select * from calls order by call_created_epoch"); @@ -3087,10 +3087,10 @@ SWITCH_STANDARD_API(show_function) holder.print_title = 0; if ((cmdname = strchr(command, ' ')) && strcasecmp(cmdname, "as")) { *cmdname++ = '\0'; - switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, key from interfaces where type = 'api' and name = '%s' order by name", + switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name", cmdname); } else { - switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, key from interfaces where type = 'api' order by name"); + switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where type = 'api' order by name"); } } else if (!strcasecmp(command, "nat_map")) { switch_snprintf(sql, sizeof(sql) - 1, diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 7646a9d412..b82235519e 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -1067,7 +1067,7 @@ static void core_event_handler(switch_event_t *event) const char *filename = switch_event_get_header_nil(event, "filename"); if (!zstr(type) && !zstr(name)) { sql = - switch_mprintf("insert into interfaces (type,name,description,syntax,key,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')", + switch_mprintf("insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')", type, name, switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename), switch_core_get_variable("hostname") ); @@ -1211,7 +1211,7 @@ static char create_interfaces_sql[] = " type VARCHAR(4096),\n" " name VARCHAR(4096),\n" " description VARCHAR(4096),\n" - " key VARCHAR(4096),\n" + " ikey VARCHAR(4096),\n" " filename VARCHAR(4096),\n" " syntax VARCHAR(4096),\n" " hostname VARCHAR(4096)\n" @@ -1307,7 +1307,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_ char *err; switch_cache_db_test_reactive(dbh, "select hostname from channels", "DROP TABLE channels", create_channels_sql); switch_cache_db_test_reactive(dbh, "select hostname from calls", "DROP TABLE calls", create_calls_sql); - switch_cache_db_test_reactive(dbh, "select hostname from interfaces", "DROP TABLE interfaces", create_interfaces_sql); + switch_cache_db_test_reactive(dbh, "select ikey from interfaces", "DROP TABLE interfaces", create_interfaces_sql); switch_cache_db_test_reactive(dbh, "select hostname from tasks", "DROP TABLE tasks", create_tasks_sql); switch_cache_db_execute_sql(dbh, "begin;delete from channels where hostname='';delete from channels where hostname='';commit;", &err);