DB Class
DB Class
Hello.
I decided to make some maybe small but needed for my next step change to code. I moved all database function to class Database, and create class Database_SQLite3 as implementation to currently used sqlite3. Howewer run into small problem - i need in this class link to ServeMap which is awful... Maybe you are able to patch it further to remove this. But i want to keep current API - functions from class Database takes and returns MapBlock - i want to keep serialization in this class, so i could later use another style of serialization for another db. My next step is to provide MySQL implementation and test if it would behave better for multiplayer servers.
Here is the patch against current 0.4.3 http://para.zonk.pl/patch-db.diff
If you like it maybe include this into mainstream?
I decided to make some maybe small but needed for my next step change to code. I moved all database function to class Database, and create class Database_SQLite3 as implementation to currently used sqlite3. Howewer run into small problem - i need in this class link to ServeMap which is awful... Maybe you are able to patch it further to remove this. But i want to keep current API - functions from class Database takes and returns MapBlock - i want to keep serialization in this class, so i could later use another style of serialization for another db. My next step is to provide MySQL implementation and test if it would behave better for multiplayer servers.
Here is the patch against current 0.4.3 http://para.zonk.pl/patch-db.diff
If you like it maybe include this into mainstream?
-
- Member
- Posts: 844
- Joined: Wed Jul 11, 2012 15:02
Ok, i managed to run server with mysql. Unfortunately now database credentials are hardcoded, so i need to find out how to move them to config files and some similiar stuff. First impressions (as singleplayer) - i have feeleing, that server runs more smoothly: with sqlite i have some short hungups then and then, with mysql there is none. But maybe i need play longer... Anyway, there is some work to do before i realese full patch, and of course i'm not dropping support for sqlite, i plan leave it as default especially for single player - it is much easier to use for enduser.
-
- Member
- Posts: 844
- Joined: Wed Jul 11, 2012 15:02
Ok. Here it is first 'public' version of patch for mysql support:
http://para.zonk.pl/mysql-0.1.1.patch
Server is sqlite3 by default, to use mysql you need to put in minetest.conf values for mysql_server, mysql_user, mysql_password and mysql_database. Database need to be created, tables are created by server, user need to get select, update, insert, delete and create priviliges. Each worlds data is located in table <world_name>_blocks, so better do not use fancy characters in name - it is not checked yet
In few (or more...) days i will announce 24/7 server running on mysql with this patch for multiplayer testing.
TODO:
- maybe move config data to world config not server so user could choose storage at world creation...
- maybe move worlds metadata and players to mysql also
- change serialization for mysql - it would be helpful for next:
- write some external online tools to admin world
http://para.zonk.pl/mysql-0.1.1.patch
Server is sqlite3 by default, to use mysql you need to put in minetest.conf values for mysql_server, mysql_user, mysql_password and mysql_database. Database need to be created, tables are created by server, user need to get select, update, insert, delete and create priviliges. Each worlds data is located in table <world_name>_blocks, so better do not use fancy characters in name - it is not checked yet
In few (or more...) days i will announce 24/7 server running on mysql with this patch for multiplayer testing.
TODO:
- maybe move config data to world config not server so user could choose storage at world creation...
- maybe move worlds metadata and players to mysql also
- change serialization for mysql - it would be helpful for next:
- write some external online tools to admin world
Last edited by wieszak on Mon Sep 24, 2012 19:45, edited 1 time in total.
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Nice.wieszak wrote:Ok. Here it is first 'public' version of patch for mysql support:
http://para.zonk.pl/mysql-0.1.patch
Server is sqlite3 by default, to use mysql you need to put in minetest.conf values for mysql_server, mysql_user, mysql_password and mysql_database. Database need to be created, tables are created by server, user need to get select, update, insert, delete and create priviliges. Each worlds data is located in table <world_name>_blocks, so better do not use fancy characters in name - it is not checked yet
In few (or more...) days i will announce 24/7 server running on mysql with this patch for multiplayer testing.
TODO:
- maybe move config data to world config not server so user could choose storage at world creation...
- maybe move worlds metadata and players to mysql also
- change serialization for mysql - it would be helpful for next:
- write some external online tools to admin world
BTW, line 260 of your patch seems to be wrong
Code: Select all
+ if (mysql_select_db(m_database,"minetest")) {
It works, but I can't determine whether it works faster or not.
Yes, this line is even unnecessary, removed from patch (link edited)
FindMySQL.cmake i've got from mysql package. I know that it is not standart module for cmake, but it is not related witch patch itself. I will provide link to donwload it as soon as i remember from where i exectly got it.
For me is slighty faster but in singleplayer. Will see if it makes any differences in multiplayer when i (or somebody) setup server for people to test...
rubenwardy:
- download sources and patch, unpack sources
- enter mintetest directory
- apply patch with : patch -p1 </somewhere/mysql-0.1.1.patch
- compile minetest as in minetest's readme
If problems i see you sometimes at redcrabs server, ask me there (i'm smoki) or here .
Patch requires at least mysql client libraries and mysql headers to compile, then any mysql server to connect.
FindMySQL.cmake i've got from mysql package. I know that it is not standart module for cmake, but it is not related witch patch itself. I will provide link to donwload it as soon as i remember from where i exectly got it.
For me is slighty faster but in singleplayer. Will see if it makes any differences in multiplayer when i (or somebody) setup server for people to test...
rubenwardy:
- download sources and patch, unpack sources
- enter mintetest directory
- apply patch with : patch -p1 </somewhere/mysql-0.1.1.patch
- compile minetest as in minetest's readme
If problems i see you sometimes at redcrabs server, ask me there (i'm smoki) or here .
Patch requires at least mysql client libraries and mysql headers to compile, then any mysql server to connect.
any hint how to change the backend db in config? just still patched it and the database is still sqlite... no readme nor anything else, could you provide some more infos to it?
also i get the followin error:
any clue?
thanks
also i get the followin error:
Code: Select all
patching file src/CMakeLists.txt
patching file src/client.cpp
patching file src/clientserver.h
patching file src/database-mysql.cpp
patch: **** malformed patch at line 571: diff -ruN celeron55-minetest-9cadaf8/src/database.cpp celeron55-minetest-9cadaf8-mysql/src/database.cpp
thanks
Last edited by fgr on Wed Oct 31, 2012 20:25, edited 1 time in total.
I've already included that patch with two more backends (dummy and leveldb) into my db_backends branchfgr wrote:any hint how to change the backend db in config? just still patched it and the database is still sqlite... no readme nor anything else, could you provide some more infos to it?
also i get the followin error:
any clue?Code: Select all
patch: **** malformed patch at line 571: diff -ruN celeron55-minetest-9cadaf8/src/database.cpp celeron55-minetest-9cadaf8-mysql/src/database.cpp
thanks
ho thats nice, so i need only compile it and create the mysql db, or does it by its own (the db)? because if i run the minetestserver (even in the config i postet the right mysql settings) there will no mysql db be used....???? The server creates the sqlite db as usual....
Code: Select all
Server creating detached inventory "creative"
creative inventory size: 111
21:46:19: INFO[ServerThread]: ServerMap: SQLite3 database structure was createdServerMap: SQLite3 database opened
Last edited by fgr on Wed Oct 31, 2012 20:56, edited 1 time in total.
- Pitriss
- Member
- Posts: 254
- Joined: Mon Aug 05, 2013 17:09
- GitHub: Pitriss
- IRC: pitriss
- In-game: pitriss
- Location: Czech republic, Bohumin
i want to ask, is there any progress in this patch? can be applied on latest client?
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
So it's not fully integrated because of different opinions about mysql. The game will probably have lack of speed when lot of mods loaded. This wont get better with leveldb.xyz wrote:It's merged already. MySQL backend isn't present though.fgr wrote:why isnt this considered anymore? is there any possibility to get short attention to it? thanks a lot!!!!!!
I don't see how this is related to not having MySQL backend.fgr wrote:So it's not fully integrated because of different opinions about mysql. The game will probably have lack of speed when lot of mods loaded. This wont get better with leveldb.xyz wrote:It's merged already. MySQL backend isn't present though.fgr wrote:why isnt this considered anymore? is there any possibility to get short attention to it? thanks a lot!!!!!!
- lightonflux
- Member
- Posts: 384
- Joined: Mon Nov 11, 2013 07:22
- In-game: lof
- Location: Germany
-
- Moderator
- Posts: 4095
- Joined: Wed Aug 24, 2011 09:44
- GitHub: sfan5
- IRC: sfan5
- Location: Germany
You could use lua to communicate between Minetest and MySQL (or any other way of saving things).
1) Compile this branch
2) Use the lua backend in world.mt
3) Make the database_lua_scriptfile setting point at a Lua file that provides the following functions:
1) Compile this branch
2) Use the lua backend in world.mt
3) Make the database_lua_scriptfile setting point at a Lua file that provides the following functions:
Code: Select all
function db_init()
--Initialize database
end
function db_beginSave()
--Is called before multiple transactions take place
end
function db_endSave()
--Is called after multiple transactions have taken place
end
function db_saveBlock(x, y, z, blobdata)
--Save MapBlock
end
function db_loadBlock(x, y, z)
--Load MapBlock (return string)
-- "" means the MapBlock could not be loaded (e.g. Not existant, Error occurred)
end
function db_listAllLoadableBlocks()
--Return list of positions of all existing MapBlocks
end
function db_destroy()
--Close database
end
Last edited by sfan5 on Tue Mar 11, 2014 17:41, edited 1 time in total.
- Johnny Joy
- Member
- Posts: 56
- Joined: Fri Sep 05, 2014 20:26
- GitHub: johnnyjoy
- In-game: jjb
Re: DB Class
This is a great patch. What ever happened to it? Why did it not progress to the next level?
Who is online
Users browsing this forum: No registered users and 3 guests