Well, Brian, you may be right.
I was trying to figure out how it worked and figured it probably stored the values in the FS database. So I opened that up and saw the tables and noticed both the complete and aliases database has a "sticky" integer field. So I tried the stickyadd sub-command for complete in fs_cli and it worked and created a record in the complete table with the sticky field set to 1. Great. Then I shut down FS and all the values (even those with sticky = 0) were still in the table. Then I started FS and everything was wiped out. I compared this to the aliases table where only the sticky=0 records got wiped out.
So, I'm a bit hazy on C but I tried to hunt down how it works.. It looks like in mod_commands.c the complete and alias commands get registered as console command and that points back to the function switch_console_set_complete/alias in switch_console.c. In that function the code for "stickyadd" is already there for complete.
So, the final culprit seems to be switch_core_sqldb.c where it clears/rebuilds the db when FS is started. There's a line in there for the alias table to delete all non-sticky records but the complete table seems to be totally different. There's a section around line 3484 that makes an array of complete, interfaces, and NULL then walks that array and deletes everything in the tables. I think the NULL just causes the for loop to exit out. So, all that code is just for two tables it seems.
So, I don't know if there's a reason for that block of code at all. I would think the safest is to just remove complete from the array and replicate a similar line below like the alias table has. But I'm more curious if just taking that whole block out and then creating a line for complete and interfaces below would be even better and more consistent with everything else. Or at the least, remove all the array/loop business since it's a lot of code to loop over 1 item (once complete is removed) :)
So, on the safe side, from a fresh git clone here's me learning C Brian. Of course I don't really know if any of this is right and I just starting using freeswitch last week and I haven't actually ran freeswitch with this code... So, well.. try at your own risk I guess, but it looks pretty straight forward to me.
diff -u orig-switch_core_sqldb.c switch_core_sqldb.c
--- orig-switch_core_sqldb.c 2014-04-05 08:38:09.547441223 -0500
+++ switch_core_sqldb.c 2014-04-05 09:45:58.916440649 -0500
@@ -3483,7 +3483,7 @@
if (switch_test_flag((&runtime), SCF_CLEAR_SQL)) {
char sql[512] = "";
- char *tables[] = { "complete", "interfaces", NULL };
+ char *tables[] = { "interfaces", NULL };
int i;
const char *hostname = switch_core_get_hostname();
@@ -3494,6 +3494,7 @@
}
switch_cache_db_execute_sql(sql_manager.dbh, "delete from aliases where sticky=0", NULL);
+ switch_cache_db_execute_sql(sql_manager.dbh, "delete from complete where sticky=0", NULL);
switch_cache_db_execute_sql(sql_manager.dbh, "delete from nat where sticky=0", 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);
Though, again.. I would question the need for that whole block at the top.
------ Original Message ------
Sent: 4/4/2014 9:03:08 AM
Subject: Re: [Freeswitch-users] Configure aliases and auto-complete on start up.
This is a perfect project for someone to learn a little C on, We all have to start somewhere. :P
--
Brian West
FreeSWITCH Solutions, LLC
PO BOX 2531
Brookfield, WI 53008-2531
Twitter: @FreeSWITCH , @briankwest
T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST
iNUM: +883 5100 1420 9001
ISN: 410*543
Skype:briankwest
Thank you very much Steven! I hadn't seen any message you sent previously! That's perfect and will work great.
Thanks everybody for all the hand holding :)
------ Original Message ------
Sent: 4/3/2014 1:52:37 PM
Subject: Re: Re[2]: [Freeswitch-users] Configure aliases and auto-complete on start up.
I sent a mail with that - in case you didn't see it:
Check the first link.