[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  Bug in mapper database interaction

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Bug in mapper database interaction
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1  2 

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Tue 25 Oct 2011 05:29 AM (UTC)  quote  ]
Message
Ah. Fixed.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 24 Oct 2011 02:20 AM (UTC)  quote  ]
Message
Really? Try running a vacuum or something.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Mon 24 Oct 2011 12:34 AM (UTC)  quote  ]
Message
Is it just me or does this make dbs with numeric room ids suddenly almost double in size? :\

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 18 Oct 2011 05:01 AM (UTC)  quote  ]
Message
As a follow-up, I posted this bug to the SQLite3 mailing list, and got a fix within a day:

http://www.sqlite.org/src/ci/59bb999c8b?sbs=0


I'll incorporate that into the next release of MUSHclient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 08:32 PM (UTC)  quote  ]
Message
Fiendish said:

Odd bug, though I have to wonder why your mud is sending such enormous room ids. Surely there aren't actually 2.29354263 × 10^29 unique rooms.


It's not sending them, that's the problem.

For MUDs that don't have room numbers/IDs the mapper is a bit of a problem. I worked around it by using the room description/minimap as a unique identifier, and then hashed that to make it a workable size (10 characters of hash rather than a whole room name/description).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Mon 17 Oct 2011 06:12 PM (UTC)  quote  ]
Message
If I where to guess.. I would say that "string" and "text" are handled differently on the basis that some applications may *need* to store big numbers in strings, so it gets funneled through a conversion function some place (it might be treated as a sort of 'variant' type), where "text" really is literally, "as is, don't do anything else to it". But, that is just guessing. Good thing to know to watch out for.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Mon 17 Oct 2011 05:56 PM (UTC)  quote  ]

Amended on Mon 17 Oct 2011 06:01 PM (UTC) by Fiendish

Message
Odd bug, though I have to wonder why your mud is sending such enormous room ids. Surely there aren't actually 2.29354263 × 10^29 unique rooms.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Horath   United Kingdom  (5 posts)  [Biography] bio
Date Mon 17 Oct 2011 01:22 PM (UTC)  quote  ]
Message
Thanks guys,

This has been driving me crazy over the last few days, just updated my mapper module to make uids Text rather than String and this has solved the problem.

I had wondered if it was something to do with the first few chars in the uid. However checking my database I found plenty starting 2E##### so was a bit stuck. Of course looking back now all the other uid starting like this were along the lines of 2E25F#### and calculating 2E25 doesnt take anywhere near as long as 2E515665758.

Anyway all sorted now :)

Just need to iron out the other creases in my shadowdale mapper now :P

Horath
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 09:59 AM (UTC)  quote  ]

Amended on Mon 17 Oct 2011 10:00 AM (UTC) by Nick Gammon

Message
Uploaded amended mapper, changes here:

https://github.com/nickgammon/plugins/commit/9c3ff98811dc8f92cdbf3b06a5c851acfa39a6b7#Materia_Magica_Mapper.xml

Thanks, Twisol!

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 09:50 AM (UTC)  quote  ]
Message
However it looks like you are right. Changing it to TEXT rather than STRING fixes it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 09:47 AM (UTC)  quote  ]

Amended on Mon 17 Oct 2011 09:48 AM (UTC) by Nick Gammon

Message
This reproduces it:


DROP TABLE IF EXISTS rooms;
 DROP TABLE IF EXISTS exits;

 CREATE TABLE IF NOT EXISTS rooms (
     roomid        INTEGER PRIMARY KEY AUTOINCREMENT,
     uid           TEXT NOT NULL  -- unique room ID
   );

 CREATE TABLE IF NOT EXISTS exits (
     exitid      INTEGER PRIMARY KEY AUTOINCREMENT,
     fromuid     STRING  NOT NULL -- exit from which room (in rooms table)
   );

 CREATE INDEX IF NOT EXISTS fromuid_index ON exits (fromuid);

 SELECT * FROM exits WHERE fromuid = '2E515665758C87202B281C7FC';


The column type is string.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Mon 17 Oct 2011 09:43 AM (UTC)  quote  ]
Message
Relevant question on StackOverflow: http://stackoverflow.com/questions/5348935/string-column-in-android-sqlite-db-being-converted-to-exponential-value

Basically, I think you need to change the affinity for that column to TEXT.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 08:42 AM (UTC)  quote  ]
Message
As a work-around, try changing the code that calculates the room hash, from:


 -- generate a "room ID" by hashing the room name, description and exits
  uid = utils.tohex (utils.md5 (roomname .. roomdesc .. exits_str .. map_str))


to:


 -- generate a "room ID" by hashing the room name, description and exits
  uid = utils.tohex ("x" .. utils.md5 (roomname .. roomdesc .. exits_str .. map_str))


Of course this will invalidate the current rooms, but if it fixes the speed problems it should be worth it, until I can work out why this is a problem in the first place.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 08:27 AM (UTC)  quote  ]
Message
If you type this into sqlite3.exe:


SELECT * FROM exits WHERE fromuid = '2E515665758';


That takes about 2 seconds to execute. Despite it being a quoted match string, and fromuid being a string type.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 17 Oct 2011 08:11 AM (UTC)  quote  ]

Amended on Mon 17 Oct 2011 08:12 AM (UTC) by Nick Gammon

Message
Right, well some light at the end of the tunnel ...

This alias reproduces the problem:


<alias
   enabled="y"
   match="^mapper bugtest3$" regexp="y"
   send_to="12">
  <send>
   t=os.time()
  
   for exitrow in db:nrows("SELECT * FROM exits WHERE fromuid = '2E515665758C87202B281C7FC'") do
   end -- for each exit
  
   print("Time taken to load bugged exit", os.time()-t, "s")
   </send>
 </alias>


Now this rules out problems with loading an exit after loading a room. And since that room doesn't have any exits on the database, I concentrated on the room ID 2E515665758C87202B281C7FC.

Strangely, changing it by removing stuff from the end didn't have any effect. But *this* did:


2F515665758C87202B281C7FC


So what is happening?

Well somewhere something is interpreting the ID as a large number, ie.


2e515665758


It must be taking around 3 seconds to find 2 times 10 to the power 515665758.

But why is it doing that? And why doesn't the Sqlite3.exe program do the same? At least this narrows it down.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


2,736 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]