Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: 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
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: 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
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: 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."
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: 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."
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: 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
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: 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
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: Fri Feb 01, 2008 3:37 am   
 
This thread is now obsolete.

http://forums.zuggsoft.com/forums/viewtopic.php?p=124254

Has workarounds for the problem. Turns out it was caused by 2 copies of the same DLL being loaded.
_________________
The Drake Forestseer
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net