<div dir="ltr">Just a guess, maybe you have a null value (for either var_name or var_value) and your mycount becomes unreliable, didn&#39;t check lately how freeswitch.Dbh handles null values.<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 8, 2016 at 2:14 PM, Юрий Насида <span dir="ltr">&lt;<a href="mailto:ynasida@gmail.com" target="_blank">ynasida@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Wow! Nice trick, thanks a lot :)</div>It works great but I am still a bit wonder why my script worked fine with old version of FS.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-03-08 21:29 GMT+03:00 Abaci B <span dir="ltr">&lt;<a href="mailto:abaci64@gmail.com" target="_blank">abaci64@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I shortened and changed your function a little, can you try it and se if it makes a difference?</div><div>BTW you can also shorten the set to a single execution by using &quot;multiset&quot;</div><div><br></div><div><span>local dbh = freeswitch.Dbh(&quot;name&quot;, &quot;root&quot;, &quot;passwd&quot;)<br> <br>function get_global_vars()<br></span> local res = {}<span><br> my_query = &quot;select var_name, var_value from directory_global_vars where domain_id=&#39;1&#39;&quot;<br> assert(dbh:query(my_query, function(qrow)<br></span>  if qrow[&quot;var_name&quot;] and qrow[&quot;var_value&quot;] then<br>   table.insert(row, qrow[&quot;var_name&quot;] .. &quot;=&quot; .. qrow[&quot;var_value&quot;]);<br>  end))<br> return res<br>end</div><div><br></div><div>local row = get_global_vars()</div><div><br></div><div>for i in ipairs(row) do<br> session:execute(&quot;set&quot;, &quot;&quot;.. row[i] ..&quot;&quot;)<br> freeswitch.consoleLog(&quot;NOTICE&quot;,&quot;row[i]   is &#39;&quot; .. row[i] .. &quot;&#39;\n&quot;)<br>end</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, Mar 8, 2016 at 12:57 PM, Юрий Насида <span dir="ltr">&lt;<a href="mailto:ynasida@gmail.com" target="_blank">ynasida@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hi list,<br></div><div><br></div><div>I noted that my old lua script which I used a lot of years from FS 1.2 works very strange with FS 1.6</div><div><br></div><div>The script is quite simple. I am using it for getting the list of variables from mysql and set as channel variables. Please look below.</div><div><br></div><div><div>local dbh = freeswitch.Dbh(&quot;name&quot;, &quot;root&quot;, &quot;passwd&quot;)</div><div><br></div><div><span style="white-space:pre-wrap">        </span>function get_global_vars()</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>local row = {}</div><div><span style="white-space:pre-wrap">        </span>local i = 1</div><div><span style="white-space:pre-wrap">        </span>local mycount = 1</div><div><br></div><div><span style="white-space:pre-wrap">        </span>my_query = &quot;select var_name, var_value from directory_global_vars where domain_id=&#39;1&#39;&quot;</div><div><br></div><div><span style="white-space:pre-wrap">                </span>assert(dbh:query(my_query, function(qrow)</div><div><br></div><div><span style="white-space:pre-wrap">                </span>for key, val in pairs(qrow) do</div><div><span style="white-space:pre-wrap">                </span>   if mycount == 1 then</div><div><span style="white-space:pre-wrap">                </span>   abc = val</div><div><span style="white-space:pre-wrap">                </span>   mycount = 2</div><div><span style="white-space:pre-wrap">                </span>   elseif mycount == 2 then</div><div><span style="white-space:pre-wrap">                </span>   row[i] = abc..&quot;=&quot;..val</div><div><span style="white-space:pre-wrap">                </span>   mycount =1</div><div><span style="white-space:pre-wrap">                </span>   i = i+1</div><div><span style="white-space:pre-wrap">                </span>   end<span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">                </span>end</div><div><br></div><div><span style="white-space:pre-wrap">                </span>end))</div><div><br></div><div><span style="white-space:pre-wrap">        </span>return row</div><div><br></div><div><span style="white-space:pre-wrap">        </span>end</div><div><br></div><div><br></div><div>local row = get_global_vars()</div><div><span style="white-space:pre-wrap">        </span></div><div>for k in pairs(row) do</div><div><span style="white-space:pre-wrap">        </span>session:execute(&quot;set&quot;, &quot;&quot;.. row[k] ..&quot;&quot;)</div><div><span style="white-space:pre-wrap">        </span>freeswitch.consoleLog(&quot;NOTICE&quot;,&quot;row[k]   is &#39;&quot; .. row[k] .. &quot;&#39;\n&quot;)</div><div>end</div></div><div><br></div><div><br></div><div>The result in fs_cli should looks like</div><div><div> switch_cpp.cpp:1356  simplescript start </div><div> switch_cpp.cpp:1356 row[k]   is <b>&#39;user_context=default</b>&#39;</div><div> switch_cpp.cpp:1356 row[k]   is &#39;<b>numbering_plan=USCAN</b>&#39;</div></div><div><br></div><div>BUT sometimes it looks like backwards!</div><div><div> switch_cpp.cpp:1356  simplescript start </div><div> switch_cpp.cpp:1356 row[k]   is &#39;<b>default=user_context</b>&#39;</div><div> switch_cpp.cpp:1356 row[k]   is &#39;<b>USCAN=numbering_plan</b>&#39;</div></div><div><br></div><div>Please keep in mind that I do exactly same call without any changes but I have different results (its ~ 50%/50%)</div><div><br></div><div>I am not sure but it looks like bug.</div><div><br></div><div>Please advice.</div><div>Thanks.</div></div>
<br></div></div>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank" rel="noreferrer">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank" rel="noreferrer">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank" rel="noreferrer">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank" rel="noreferrer">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank" rel="noreferrer">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank" rel="noreferrer">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank" rel="noreferrer">http://www.freeswitch.org</a><br></blockquote></div><br></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank" rel="noreferrer">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank" rel="noreferrer">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank" rel="noreferrer">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank" rel="noreferrer">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank" rel="noreferrer">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank" rel="noreferrer">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank" rel="noreferrer">http://www.freeswitch.org</a><br></blockquote></div><br></div>
</div></div><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank" rel="noreferrer">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank" rel="noreferrer">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank" rel="noreferrer">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank" rel="noreferrer">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank" rel="noreferrer">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank" rel="noreferrer">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank" rel="noreferrer">http://www.freeswitch.org</a><br></blockquote></div><br></div></div>