<HTML><HEAD>
<STYLE id=eMClientCss>BLOCKQUOTE.cite {
        BORDER-LEFT: #cccccc 1px solid; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px
}
BLOCKQUOTE.cite2 {
        BORDER-LEFT: #cccccc 1px solid; MARGIN-TOP: 3px; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-TOP: 0px
}
.plain PRE {
        FONT-STYLE: normal; FONT-FAMILY: monospace; FONT-SIZE: 100%; FONT-WEIGHT: normal
}
.plain TT {
        FONT-STYLE: normal; FONT-FAMILY: monospace; FONT-SIZE: 100%; FONT-WEIGHT: normal
}
.plain PRE {
        FONT-FAMILY: Tahoma; FONT-SIZE: 12pt
}
.plain TT {
        FONT-FAMILY: Tahoma; FONT-SIZE: 12pt
}
BODY {
        FONT-FAMILY: Tahoma; FONT-SIZE: 12pt
}
</STYLE>
<STYLE></STYLE>
<META content=text/html;charset=utf-8 http-equiv=Content-Type></HEAD>
<BODY scroll=auto class>
<DIV>Well, Brian, you may be right.</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>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. </DIV>
<DIV> </DIV>
<DIV>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. </DIV>
<DIV> </DIV>
<DIV>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) :)</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>diff -u orig-switch_core_sqldb.c switch_core_sqldb.c</DIV>
<DIV><BR>--- orig-switch_core_sqldb.c 2014-04-05 08:38:09.547441223 -0500<BR>+++ switch_core_sqldb.c 2014-04-05 09:45:58.916440649 -0500<BR>@@ -3483,7 +3483,7 @@</DIV>
<DIV> </DIV>
<DIV> if (switch_test_flag((&runtime), SCF_CLEAR_SQL)) {<BR> char sql[512] = "";<BR>- char *tables[] = { "complete", "interfaces", NULL };<BR>+ char *tables[] = { "interfaces", NULL };<BR> int i;<BR> const char *hostname = switch_core_get_hostname();</DIV>
<DIV> </DIV>
<DIV>@@ -3494,6 +3494,7 @@<BR> }</DIV>
<DIV> </DIV>
<DIV> switch_cache_db_execute_sql(sql_manager.dbh, "delete from aliases where sticky=0", NULL);<BR>+ switch_cache_db_execute_sql(sql_manager.dbh, "delete from complete where sticky=0", NULL);<BR> switch_cache_db_execute_sql(sql_manager.dbh, "delete from nat where sticky=0", NULL);<BR> switch_cache_db_execute_sql(sql_manager.dbh, "create index alias1 on aliases (alias)", NULL);<BR> switch_cache_db_execute_sql(sql_manager.dbh, "create index tasks1 on tasks (hostname,task_id)", NULL);<BR></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><SPAN id=bbd83660c08747ec9c3d32c9abd99f64>Though, again.. I would question the need for that whole block at the top. </SPAN></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>------ Original Message ------</DIV>
<DIV>From: "Brian West" <<A href="mailto:brian@freeswitch.org">brian@freeswitch.org</A>></DIV>
<DIV>To: "FreeSWITCH Users Help" <<A href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</A>></DIV>
<DIV>Sent: 4/4/2014 9:03:08 AM</DIV>
<DIV>Subject: Re: [Freeswitch-users] Configure aliases and auto-complete on start up.</DIV>
<DIV> </DIV>
<DIV id=9a6860f667f645ec8dcdda80b808184b class=plain>
<BLOCKQUOTE class=cite2 cite=CBFEFE37-6378-4435-8578-19FEE338EEB2@freeswitch.org type="cite"><TT style="WORD-WRAP: break-word">
<DIV>This is a perfect project for someone to learn a little C on, We all have to start somewhere. :P </DIV>
<DIV>-- </DIV>
<DIV>Brian West </DIV>
<DIV><A href="mailto:brian@freeswitch.org">brian@freeswitch.org</A> </DIV>
<DIV>FreeSWITCH Solutions, LLC </DIV>
<DIV>PO BOX 2531 </DIV>
<DIV>Brookfield, WI 53008-2531 </DIV>
<DIV>Twitter: @FreeSWITCH , @briankwest </DIV>
<DIV><A href="http://www.freeswitchbook.com/">http://www.freeswitchbook.com</A> </DIV>
<DIV><A href="http://www.freeswitchcookbook.com/">http://www.freeswitchcookbook.com</A> </DIV>
<DIV> </DIV>
<DIV>T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST </DIV>
<DIV>iNUM: +883 5100 1420 9001 </DIV>
<DIV>ISN: 410*543 </DIV>
<DIV>Skype:briankwest </DIV>
<DIV>PGP Key: <A href="http://www.bkw.org/key.txt">http://www.bkw.org/key.txt</A> (AB93356707C76CED) </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>On Apr 3, 2014, at 2:18 PM, <A href="mailto:bruce@sqls.net">bruce@sqls.net</A> wrote: </DIV>
<DIV> </DIV>
<BLOCKQUOTE class=cite2 type="cite">
<DIV> </DIV>
<DIV> Thank you very much Steven! I hadn't seen any message you sent previously! That's perfect and will work great. </DIV>
<DIV> </DIV>
<DIV> Thanks everybody for all the hand holding :) </DIV>
<DIV> </DIV>
<DIV> ------ Original Message ------ </DIV>
<DIV> From: "Steven Ayre" <<A href="mailto:steveayre@gmail.com">steveayre@gmail.com</A>> </DIV>
<DIV> To: <A href="mailto:bruce@sqls.net">bruce@sqls.net</A> </DIV>
<DIV> Cc: "FreeSWITCH Users Help" <<A href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</A>> </DIV>
<DIV> Sent: 4/3/2014 1:52:37 PM </DIV>
<DIV> Subject: Re: Re[2]: [Freeswitch-users] Configure aliases and auto-complete on start up. </DIV>
<DIV> </DIV>
<BLOCKQUOTE class=cite type="cite">
<DIV> I sent a mail with that - in case you didn't see it: </DIV>
<DIV> </DIV>
<DIV> <A href="https://wiki.freeswitch.org/wiki/Mod_lua#Lua_scripts_at_startup">https://wiki.freeswitch.org/wiki/Mod_lua#Lua_scripts_at_startup</A> </DIV>
<DIV> <A href="https://wiki.freeswitch.org/wiki/Mod_lua#Make_API_calls_directly_from_Lua_code">https://wiki.freeswitch.org/wiki/Mod_lua#Make_API_calls_directly_from_Lua_code</A> </DIV>
<DIV> </DIV>
<DIV> Check the first link. </DIV>
<DIV> </DIV>
<DIV> </DIV></BLOCKQUOTE></BLOCKQUOTE>
<DIV> </DIV></TT></BLOCKQUOTE></DIV></BODY></HTML>