mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-08-20 15:40:50 +00:00
Remove query_void() methods. query() is just fine.
This commit is contained in:
parent
43bec4711e
commit
9bb5689d48
4 changed files with 13 additions and 22 deletions
|
@ -154,7 +154,7 @@ namespace pq {
|
|||
oss << "Unable to connect to database " << m_address << ':' << m_port << " as user \"" << m_username << '"';
|
||||
throw DatabaseException(oss.str(), std::move(err), __FILE__, __LINE__);
|
||||
}
|
||||
query_void("SET NAMES 'utf8'");
|
||||
this->query("SET NAMES 'utf8'");
|
||||
|
||||
PQinitTypes(m_localData->connection); //Init libpqtypes
|
||||
}
|
||||
|
@ -184,16 +184,6 @@ namespace pq {
|
|||
return ResultSet(std::move(info));
|
||||
}
|
||||
|
||||
void Connection::query_void (const std::string& parQuery) {
|
||||
ResultInfo info(PQexec(m_localData->connection, parQuery.c_str()));
|
||||
if (not info.result)
|
||||
throw DatabaseException("Error running query", "Error allocating result object", __FILE__, __LINE__);
|
||||
const int ress = PQresultStatus(info.result.get());
|
||||
if (ress != PGRES_TUPLES_OK && ress != PGRES_COMMAND_OK) {
|
||||
throw DatabaseException("Error running query", error_message(), __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Connection::escaped_literal (const std::string& parString) {
|
||||
return this->escaped_literal(boost::string_ref(parString));
|
||||
}
|
||||
|
@ -205,7 +195,7 @@ namespace pq {
|
|||
return std::string(clean_str.get());
|
||||
}
|
||||
|
||||
void Connection::query_void_params (const std::string& parQuery, PGParams& parParams) {
|
||||
ResultSet Connection::query_params (const std::string& parQuery, PGParams& parParams) {
|
||||
int result_format = 1;
|
||||
assert(parParams.get());
|
||||
ResultInfo info(
|
||||
|
@ -225,6 +215,8 @@ namespace pq {
|
|||
if (ress != PGRES_TUPLES_OK && ress != PGRES_COMMAND_OK) {
|
||||
throw DatabaseException("Error running query", error_message(), __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
return ResultSet(std::move(info));
|
||||
}
|
||||
|
||||
auto Connection::make_params (const std::string* parTypes, ...) -> PGParams {
|
||||
|
|
|
@ -39,20 +39,19 @@ namespace pq {
|
|||
bool is_connected ( void ) const noexcept;
|
||||
void connect ( void );
|
||||
void disconnect ( void );
|
||||
void query_void ( const std::string& parQuery );
|
||||
ResultSet query ( const std::string& parQuery );
|
||||
|
||||
std::string escaped_literal ( const std::string& parString );
|
||||
std::string escaped_literal ( boost::string_ref parString );
|
||||
|
||||
template <typename... Args>
|
||||
void query_void ( const std::string& parQuery, Args&&... parArgs );
|
||||
ResultSet query ( const std::string& parQuery, Args&&... parArgs );
|
||||
|
||||
private:
|
||||
struct LocalData;
|
||||
using PGParams = std::unique_ptr<::PGparam, void(*)(::PGparam*)>;
|
||||
|
||||
void query_void_params ( const std::string& parQuery, PGParams& parParams );
|
||||
ResultSet query_params ( const std::string& parQuery, PGParams& parParams );
|
||||
PGParams make_params ( const std::string* parTypes, ... );
|
||||
|
||||
const std::string m_username;
|
||||
|
@ -108,7 +107,7 @@ namespace pq {
|
|||
} //namespace implem
|
||||
|
||||
template <typename... Args>
|
||||
void Connection::query_void (const std::string& parQuery, Args&&... parArgs) {
|
||||
ResultSet Connection::query (const std::string& parQuery, Args&&... parArgs) {
|
||||
using std::remove_cv;
|
||||
using std::remove_reference;
|
||||
|
||||
|
@ -126,7 +125,7 @@ namespace pq {
|
|||
};
|
||||
PGParams pgparams = make_pgparams();
|
||||
|
||||
this->query_void_params(parQuery, pgparams);
|
||||
return this->query_params(parQuery, pgparams);
|
||||
}
|
||||
} //namespace pq
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue