[Freeswitch-users] Strange error message
Chris
c_cav_01 at yahoo.com
Wed Feb 11 07:23:01 PST 2009
In that particular instance, no, it's not needed. It's assigned a numeric value and is just a variable that will disappear when it goes out of scope. You could deallocate or release the variable if you wished to be tidy.
In the case of a recordset being returned by the server (an SQL "SELECT") then it will be a recordset object and would need to be closed.
If you look at your error, your trying to index a number. e.g curs assigned numeric by the UPDATE returning the number of rows affected, then your trying to look for a :close method or property on a numeric var which isn't going to work and the compiler is interpreting that as an attempt to index it.
In general, on most SQL servers, SQL insert, update and delete calls return numerics, only select returns recordsets.
--- On Tue, 2/10/09, Nik Middleton <nik.middleton at noblesolutions.co.uk> wrote:
From: Nik Middleton <nik.middleton at noblesolutions.co.uk>
Subject: Re: [Freeswitch-users] Strange error message
To: freeswitch-users at lists.freeswitch.org
Date: Tuesday, February 10, 2009, 4:22 PM
So what you’re saying is that I can comment out curs:close() as it’s not needed?
Regards,
From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Chris
Sent: 10 February 2009 21:19
To: freeswitch-users at lists.freeswitch.org
Subject: Re: [Freeswitch-users] Strange error message
Closing the connection will force the server to close any open transactions, as well as release recordsets in local memory that reference the connection.
However curs is not a recordset. An SQL update is going to return an integer (rows affected) or boolean depending on the which server you use since no recordset is actually requested.
--- On Tue, 2/10/09, Nik Middleton <nik.middleton at noblesolutions.co.uk> wrote:
From: Nik Middleton <nik.middleton at noblesolutions.co.uk>
Subject: [Freeswitch-users] Strange error message
To: freeswitch-users at lists.freeswitch.org
Date: Tuesday, February 10, 2009, 2:04 PM
Hi Guys,
I’m baffled by this error. I’m updating the db on call hang-up If I comment out curs:close() no error, but I’m concerned about memory leaks. Can anyone tell me what FS is complaining about?
The db gets updated in both cases
Regards
require "luasql.mysql"
function myHangupHook(s, status, arg)
freeswitch.consoleLog("info", " : They hung up on US!!!\n");
env = assert (luasql.mysql())
con = assert (env:connect("xxxxl","xxxxxxxxx","pass","192.168.3.205"))
curs = assert (con:execute"UPDATE callers SET lastcall = 'BOB' WHERE id = 33292")
curs:close()
con:close()
env:close()
freeswitch.consoleLog("NOTICE", "myHangupHook: " .. status .. "\n");
--error()
end
2009-02-10 20:53:20 [INFO] switch_cpp.cpp:1086 console_log() : They hung up on US!!!
2009-02-10 20:53:20 [ERR] mod_lua.cpp:176 lua_parse_and_execute() /usr/local/freeswitch/scripts/helloworld.lua:50: attempt to index global 'curs' (a number value)
stack traceback:
/usr/local/freeswitch/scripts/helloworld.lua:50: in function </usr/local/freeswitch/scripts/helloworld.lua:45>
[C]: in function 'hangup'
/usr/local/freeswitch/scripts/helloworld.lua:70: in main chunk
2009-02-10 20:53:20 [NOTICE] switch_core_session.c:957 switch_core_session_thread() Session 63 (sofia/internal/1001 at 192.168.3.206) Ended_______________________________________________Freeswitch-users mailing listFreeswitch-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-usersUNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
_______________________________________________
Freeswitch-users mailing list
Freeswitch-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090211/5773e5fb/attachment-0002.html
More information about the FreeSWITCH-users
mailing list