Add support for the official postgresql backend implementation
The connection strings and database structure of the previous unofficial versions (by Shadowninja and johhnyjoy) are also still supported, but support will be removed in a future version of minetestmapper.
This commit is contained in:
parent
3ffda4ab57
commit
ba9166fd79
@ -1,7 +1,9 @@
|
|||||||
[]
|
[]
|
||||||
Features:
|
Features:
|
||||||
- Support for postgresql backend added
|
- Support for postgresql backend added
|
||||||
Compatible with both ShadowNinja's and johnnyjoy's implementation
|
Compatible with two previous unofficial implementations, by
|
||||||
|
ShadowNinja and johnnyjoy. Support for these will be removed
|
||||||
|
in a future version of Minetestmapper.
|
||||||
Enhancements:
|
Enhancements:
|
||||||
- Updated the included colors file with colors for the new tiles that
|
- Updated the included colors file with colors for the new tiles that
|
||||||
were recently added to the default minetest game.
|
were recently added to the default minetest game.
|
||||||
|
@ -5,9 +5,12 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define BLOCKPOSLIST_QUERY "SELECT x, y, z FROM blocks"
|
#define BLOCKPOSLIST_QUERY_COMPAT "SELECT x, y, z FROM blocks"
|
||||||
#define BLOCKPOSLISTBOUNDED_QUERY "SELECT x, y, z FROM blocks WHERE x BETWEEN $1 AND $2 AND y BETWEEN $3 AND $4 AND z BETWEEN $5 AND $6"
|
#define BLOCKPOSLISTBOUNDED_QUERY_COMPAT "SELECT x, y, z FROM blocks WHERE x BETWEEN $1 AND $2 AND y BETWEEN $3 AND $4 AND z BETWEEN $5 AND $6"
|
||||||
#define BLOCK_QUERY "SELECT data FROM blocks WHERE x = $1 AND y = $2 AND z = $3"
|
#define BLOCK_QUERY_COMPAT "SELECT data FROM blocks WHERE x = $1 AND y = $2 AND z = $3"
|
||||||
|
#define BLOCKPOSLIST_QUERY "SELECT posX, posY, posZ FROM blocks"
|
||||||
|
#define BLOCKPOSLISTBOUNDED_QUERY "SELECT posX, posY, posZ FROM blocks WHERE posX BETWEEN $1 AND $2 AND posY BETWEEN $3 AND $4 AND posZ BETWEEN $5 AND $6"
|
||||||
|
#define BLOCK_QUERY "SELECT data FROM blocks WHERE posX = $1 AND posY = $2 AND posZ = $3"
|
||||||
|
|
||||||
// From pg_type.h
|
// From pg_type.h
|
||||||
#define PG_INT4OID 23
|
#define PG_INT4OID 23
|
||||||
@ -20,16 +23,22 @@ DBPostgreSQL::DBPostgreSQL(const std::string &mapdir) :
|
|||||||
std::string connection_info;
|
std::string connection_info;
|
||||||
|
|
||||||
bool info_found = false;
|
bool info_found = false;
|
||||||
// ShadowNinja's implementation
|
bool compat_mode = false;
|
||||||
info_found = world_mt.check("postgresql_connection_info", connection_info);
|
|
||||||
// johnnyjoy's implementation
|
// Official postgresql connection info string
|
||||||
// The default value is not used here as it seems to me it has a serious issue:
|
info_found = world_mt.check("pgsql_connection", connection_info);
|
||||||
// creating two worlds without specifying pg_connection_info will result in both
|
compat_mode = !info_found;
|
||||||
// worlds using the same database.
|
|
||||||
|
// ShadowNinja's implementation (historical)
|
||||||
|
if (!info_found)
|
||||||
|
info_found = world_mt.check("postgresql_connection_info", connection_info);
|
||||||
|
|
||||||
|
// johnnyjoy's implementation (historical)
|
||||||
if (!info_found)
|
if (!info_found)
|
||||||
info_found = world_mt.check("pg_connection_info", connection_info);
|
info_found = world_mt.check("pg_connection_info", connection_info);
|
||||||
|
|
||||||
if (!info_found)
|
if (!info_found)
|
||||||
throw std::runtime_error("Set postgresql_connection_info or pg_connection_info in world.mt to use the postgresql backend");
|
throw std::runtime_error("Set pgsql_connection in world.mt to use the postgresql backend");
|
||||||
|
|
||||||
connection_info += "fallback_application_name=minetestmapper " + connection_info;
|
connection_info += "fallback_application_name=minetestmapper " + connection_info;
|
||||||
|
|
||||||
@ -39,21 +48,30 @@ DBPostgreSQL::DBPostgreSQL(const std::string &mapdir) :
|
|||||||
+ PQerrorMessage(m_connection));
|
+ PQerrorMessage(m_connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *blockposlist_query = BLOCKPOSLIST_QUERY;
|
||||||
|
const char *blockposlistbounded_query = BLOCKPOSLISTBOUNDED_QUERY;
|
||||||
|
const char *block_query = BLOCK_QUERY;
|
||||||
|
if (compat_mode) {
|
||||||
|
blockposlist_query = BLOCKPOSLIST_QUERY_COMPAT;
|
||||||
|
blockposlistbounded_query = BLOCKPOSLISTBOUNDED_QUERY_COMPAT;
|
||||||
|
block_query = BLOCK_QUERY_COMPAT;
|
||||||
|
}
|
||||||
|
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
|
|
||||||
result = PQprepare(m_connection, "GetBlockPosList", BLOCKPOSLIST_QUERY, 0, NULL);
|
result = PQprepare(m_connection, "GetBlockPosList", blockposlist_query, 0, NULL);
|
||||||
if (!result || PQresultStatus(result) != PGRES_COMMAND_OK)
|
if (!result || PQresultStatus(result) != PGRES_COMMAND_OK)
|
||||||
throw std::runtime_error(std::string("Failed to prepare PostgreSQL statement (GetBlockPosList): ")
|
throw std::runtime_error(std::string("Failed to prepare PostgreSQL statement (GetBlockPosList): ")
|
||||||
+ (result ? PQresultErrorMessage(result) : "(result was NULL)"));
|
+ (result ? PQresultErrorMessage(result) : "(result was NULL)"));
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
|
||||||
result = PQprepare(m_connection, "GetBlockPosListBounded", BLOCKPOSLISTBOUNDED_QUERY, 0, NULL);
|
result = PQprepare(m_connection, "GetBlockPosListBounded", blockposlistbounded_query, 0, NULL);
|
||||||
if (!result || PQresultStatus(result) != PGRES_COMMAND_OK)
|
if (!result || PQresultStatus(result) != PGRES_COMMAND_OK)
|
||||||
throw std::runtime_error(std::string("Failed to prepare PostgreSQL statement (GetBlockPosListBounded): ")
|
throw std::runtime_error(std::string("Failed to prepare PostgreSQL statement (GetBlockPosListBounded): ")
|
||||||
+ (result ? PQresultErrorMessage(result) : "(result was NULL)"));
|
+ (result ? PQresultErrorMessage(result) : "(result was NULL)"));
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
|
||||||
result = PQprepare(m_connection, "GetBlock", BLOCK_QUERY, 0, NULL);
|
result = PQprepare(m_connection, "GetBlock", block_query, 0, NULL);
|
||||||
if (!result || PQresultStatus(result) != PGRES_COMMAND_OK)
|
if (!result || PQresultStatus(result) != PGRES_COMMAND_OK)
|
||||||
throw std::runtime_error(std::string("Failed to prepare PostgreSQL statement (GetBlock): ")
|
throw std::runtime_error(std::string("Failed to prepare PostgreSQL statement (GetBlock): ")
|
||||||
+ (result ? PQresultErrorMessage(result) : "(result was NULL)"));
|
+ (result ? PQresultErrorMessage(result) : "(result was NULL)"));
|
||||||
|
@ -6,7 +6,7 @@ Minetestmapper generates maps of minetest and freeminer worlds.
|
|||||||
Major Features
|
Major Features
|
||||||
==============
|
==============
|
||||||
* Support for both minetest and freeminer
|
* Support for both minetest and freeminer
|
||||||
* Support for sqlite3, postsgresql, leveldb and redis map databases
|
* Support for sqlite3, postgresql, leveldb and redis map databases
|
||||||
* Generate a subsection of the map, or a full map
|
* Generate a subsection of the map, or a full map
|
||||||
(but the size of generated images is limited - see
|
(but the size of generated images is limited - see
|
||||||
'Known Problems' below)
|
'Known Problems' below)
|
||||||
|
@ -350,18 +350,11 @@ Detailed Description of Options
|
|||||||
By default (``auto``), the database is obtained from the world configuration,
|
By default (``auto``), the database is obtained from the world configuration,
|
||||||
and there is no need to set it,
|
and there is no need to set it,
|
||||||
|
|
||||||
PostgreSQL support is currently (january 2016) not officially available
|
For backward compatibility, besides supporting the official implementation,
|
||||||
in minetest. Two different unofficial patches exist: one by ShadowNinja, and
|
minetestmapper still supports two previous unofficial implementations of
|
||||||
one by johnnyjoy. Minetestmapper supports both implementations.
|
postgresql support for minetest. These are ShadowNinja's, and johnnyjoy's.
|
||||||
|
Support for these two versions will be removed in a future version of
|
||||||
Git tree for ShadowNinja's version:
|
minetestmapper.
|
||||||
|
|
||||||
https://github.com/ShadowNinja/minetest/tree/PostgreSQL
|
|
||||||
|
|
||||||
Pull request for johnnyjoy's version:
|
|
||||||
|
|
||||||
https://github.com/minetest/minetest/pull/2912
|
|
||||||
|
|
||||||
|
|
||||||
``--bgcolor <color>``
|
``--bgcolor <color>``
|
||||||
.....................
|
.....................
|
||||||
|
Loading…
x
Reference in New Issue
Block a user