2020-05-08 22:10:49 +02:00
|
|
|
#pragma once
|
2017-01-08 23:24:09 +01:00
|
|
|
|
|
|
|
#include "db.h"
|
|
|
|
#include <libpq-fe.h>
|
|
|
|
|
|
|
|
class DBPostgreSQL : public DB {
|
|
|
|
public:
|
|
|
|
DBPostgreSQL(const std::string &mapdir);
|
2020-03-27 16:12:26 +01:00
|
|
|
std::vector<BlockPos> getBlockPos(BlockPos min, BlockPos max) override;
|
|
|
|
void getBlocksOnXZ(BlockList &blocks, int16_t x, int16_t z,
|
|
|
|
int16_t min_y, int16_t max_y) override;
|
2020-03-27 21:10:00 +01:00
|
|
|
void getBlocksByPos(BlockList &blocks,
|
|
|
|
const std::vector<BlockPos> &positions) override;
|
2020-03-27 16:12:26 +01:00
|
|
|
~DBPostgreSQL() override;
|
|
|
|
|
2020-03-27 21:10:00 +01:00
|
|
|
bool preferRangeQueries() const override { return true; }
|
|
|
|
|
2017-01-08 23:24:09 +01:00
|
|
|
protected:
|
|
|
|
PGresult *checkResults(PGresult *res, bool clear = true);
|
|
|
|
void prepareStatement(const std::string &name, const std::string &sql);
|
|
|
|
PGresult *execPrepared(
|
|
|
|
const char *stmtName, const int paramsNumber,
|
|
|
|
const void **params,
|
2022-02-09 22:46:07 +01:00
|
|
|
const int *paramsLengths = nullptr, const int *paramsFormats = nullptr,
|
2020-03-27 16:12:26 +01:00
|
|
|
bool clear = true
|
2017-01-08 23:24:09 +01:00
|
|
|
);
|
|
|
|
int pg_binary_to_int(PGresult *res, int row, int col);
|
|
|
|
BlockPos pg_to_blockpos(PGresult *res, int row, int col);
|
2020-03-27 16:12:26 +01:00
|
|
|
|
2017-01-08 23:24:09 +01:00
|
|
|
private:
|
|
|
|
PGconn *db;
|
|
|
|
};
|