29 inline int pg_to_int(PGresult *res,
int row,
int col)
31 return atoi(PQgetvalue(res, row, col));
36 return (u32) atoi(PQgetvalue(res, row, col));
41 return (
float) atof(PQgetvalue(res, row, col));
55 return std::string(PQgetvalue(res, row, col), PQgetlength(res, row, col));
58 inline PGresult *
execPrepared(
const char *stmtName,
const int paramsNumber,
60 const int *paramsLengths = NULL,
const int *paramsFormats = NULL,
61 bool clear =
true,
bool nobinary =
true)
64 (
const char*
const*) params, paramsLengths, paramsFormats,
65 nobinary ? 1 : 0), clear);
68 inline PGresult *
execPrepared(
const char *stmtName,
const int paramsNumber,
69 const char **params,
bool clear =
true,
bool nobinary =
true)
72 (
const void **)params, NULL, NULL, clear, nobinary);
170 void getModKeys(
const std::string &modname, std::vector<std::string> *storage);
171 bool getModEntry(
const std::string &modname,
const std::string &key, std::string *value);
172 bool hasModEntry(
const std::string &modname,
const std::string &key);
174 const std::string &key, std::string_view value);
Definition database-postgresql.h:141
virtual void writePrivileges(const AuthEntry &authEntry)
virtual bool saveAuth(const AuthEntry &authEntry)
virtual bool getAuth(const std::string &name, AuthEntry &res)
virtual void createDatabase()
virtual void verifyDatabase()
Definition database-postgresql.h:146
virtual ~AuthDatabasePostgreSQL()=default
virtual bool deleteAuth(const std::string &name)
virtual bool createAuth(AuthEntry &authEntry)
virtual void listNames(std::vector< std::string > &res)
virtual void initStatements()
AuthDatabasePostgreSQL(const std::string &connect_string)
Definition database-postgresql.h:15
v3s16 pg_to_v3s16(PGresult *res, int row, int col)
Definition database-postgresql.h:44
std::string pg_to_string(PGresult *res, int row, int col)
Definition database-postgresql.h:53
std::string m_connect_string
Definition database-postgresql.h:97
u32 pg_to_uint(PGresult *res, int row, int col)
Definition database-postgresql.h:34
int m_pgversion
Definition database-postgresql.h:99
int getPGVersion() const
Definition database-postgresql.h:87
float pg_to_float(PGresult *res, int row, int col)
Definition database-postgresql.h:39
void createTableIfNotExists(const std::string &table_name, const std::string &definition)
PGconn * m_conn
Definition database-postgresql.h:98
PGresult * execPrepared(const char *stmtName, const int paramsNumber, const char **params, bool clear=true, bool nobinary=true)
Definition database-postgresql.h:68
void prepareStatement(const std::string &name, const std::string &sql)
Definition database-postgresql.h:82
PGresult * checkResults(PGresult *res, bool clear=true)
Database_PostgreSQL(const std::string &connect_string, const char *type)
int pg_to_int(PGresult *res, int row, int col)
Definition database-postgresql.h:29
PGresult * execPrepared(const char *stmtName, const int paramsNumber, const void **params, const int *paramsLengths=NULL, const int *paramsFormats=NULL, bool clear=true, bool nobinary=true)
Definition database-postgresql.h:58
virtual void initStatements()=0
virtual void createDatabase()=0
Definition database-postgresql.h:103
void listAllLoadableBlocks(std::vector< v3s16 > &dst)
virtual void createDatabase()
bool saveBlock(const v3s16 &pos, std::string_view data)
MapDatabasePostgreSQL(const std::string &connect_string)
void endSave()
Definition database-postgresql.h:114
virtual void initStatements()
void beginSave()
Definition database-postgresql.h:113
bool deleteBlock(const v3s16 &pos)
virtual ~MapDatabasePostgreSQL()=default
void loadBlock(const v3s16 &pos, std::string *block)
Definition database-postgresql.h:164
bool setModEntry(const std::string &modname, const std::string &key, std::string_view value)
bool removeModEntry(const std::string &modname, const std::string &key)
bool hasModEntry(const std::string &modname, const std::string &key)
bool removeModEntries(const std::string &modname)
ModStorageDatabasePostgreSQL(const std::string &connect_string)
void beginSave()
Definition database-postgresql.h:179
~ModStorageDatabasePostgreSQL()=default
void getModKeys(const std::string &modname, std::vector< std::string > *storage)
void endSave()
Definition database-postgresql.h:180
bool getModEntry(const std::string &modname, const std::string &key, std::string *value)
virtual void initStatements()
void getModEntries(const std::string &modname, StringMap *storage)
virtual void createDatabase()
void listMods(std::vector< std::string > *res)
Definition database-postgresql.h:122
virtual void initStatements()
void savePlayer(RemotePlayer *player)
void listPlayers(std::vector< std::string > &res)
PlayerDatabasePostgreSQL(const std::string &connect_string)
bool playerDataExists(const std::string &playername)
virtual void createDatabase()
bool loadPlayer(RemotePlayer *player, PlayerSAO *sao)
bool removePlayer(const std::string &name)
virtual ~PlayerDatabasePostgreSQL()=default
Definition player_sao.h:56
Definition remoteplayer.h:26
Definition settings.h:109
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
std::unordered_map< std::string, std::string > StringMap
Definition string.h:65