 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Thu Jan 31, 2008 11:33 am
[Bug 2.18] LUASQL - More Info |
I filed a bug report, but i thought i'd provide a little more info here too.
The code that causes the bug is this:
| Code: |
--Include The LUASQL DLL
require("luasql.mysql")
--Reference A LUASQL MYSQL Object
env = assert(luasql.mysql())
--Connect To The Database
con = assert(env:connect("soem_baal", "root", "f117anh", "localhost"))
--Insert A Row
--res = assert (con:execute"INSERT INTO `users` VALUES ('test', 'pwd', 'email', 8, 1, 0)")
--Execute A Select Query - Note: ATM, I'm Only Able To Retrieve The First Column Into The Cursor Variable
cur = assert(con:execute("SELECT `username`, `password` FROM `users`"))
--Fetch The Results
row = cur:fetch(row, "a")
--Print The Number Of Results
print(cur:numrows())
--Print The Column Names
print(cur:getcolnames())
--Loop Through The Results
while row do
--Display The Results
print(row)
--Fetch The Results
row = cur:fetch(row, "a")
end
--Close Our Cursor
cur:close()
--Close The Connection
con:close()
--Close The MYSQL Object
env:close()
|
Just run that once, then close cmud, and it throws the error filed in the bug report.
However, the exact part causing it is:
| Code: |
--Fetch The Results
row = cur:fetch(row, "a")
--Print The Number Of Results
print(cur:numrows())
--Print The Column Names
print(cur:getcolnames())
--Loop Through The Results
while row do
--Display The Results
print(row)
--Fetch The Results
row = cur:fetch(row, "a")
end
|
It is possible it is only the while loop causing the bug. I can't remember if i checked a single fetch or not. #thread only shows a single thread. I guess i'll put a few more safety checks in (zs.aborted) for example |
|
_________________ The Drake Forestseer |
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Thu Jan 31, 2008 11:39 am |
I just tried adding a zs.aborted check and pressing both esc and ctrl-esc before exiting cmud. Bug still occured
|
|
_________________ The Drake Forestseer |
|
|
 |
Dharkael Enchanter

Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Jan 31, 2008 2:28 pm |
As I said in the other thread change the first
| Code: |
--Fetch The Results
row = cur:fetch(row, "a") |
So that it reads
| Code: |
--Fetch The Results
row = cur:fetch({}, "a") |
then change the print function call in the while loop to something like this
| Code: |
| print(row.username,row.password) |
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Jan 31, 2008 5:05 pm |
Printing a table should actually work fine in zScript Lua, because the print function's been changed - it'll print tables in a format quite similar to how you'd write them in Lua. But of course, that'll print the whole contents of the table.
|
|
|
|
 |
Dharkael Enchanter

Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Jan 31, 2008 5:51 pm |
Nifty!
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Thu Jan 31, 2008 11:46 pm |
As i responded in the other thread, error in luasql dll, yada yada, check the other one, this was (i think) a different bug, causing a crash when cmud closed.
|
|
_________________ The Drake Forestseer |
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Fri Feb 01, 2008 1:45 am |
http://forums.zuggsoft.com/forums/viewtopic.php?p=124254
Has a work around for a different bug related to lua itself that seems to fix this problem, so the bug itself seems to be caused by cmud not being able to handle included libraries bugging out gracefully.
I guess what i'm trying to say is, luasql stuffed up, and cmud only realised when it was closing. |
|
_________________ The Drake Forestseer |
|
|
 |
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
|
_________________ The Drake Forestseer |
|
|
 |
|
|
|