Improved error reporting
This commit is contained in:
parent
6cf7b52453
commit
457b09f15c
12 changed files with 110 additions and 94 deletions
|
|
@ -115,19 +115,21 @@ Result Connection::queryParam(const QString &command, const Params ¶ms)
|
|||
}
|
||||
|
||||
|
||||
bool Connection::sendQuery(const char *query)
|
||||
void Connection::sendQuery(const char *query)
|
||||
{
|
||||
int res = PQsendQuery(conn, query);
|
||||
return res == 1;
|
||||
if (res == 0)
|
||||
throw PgConnectionError(PQerrorMessage(conn));
|
||||
}
|
||||
|
||||
bool Connection::sendQueryParams(const char * command, const Params ¶ms)
|
||||
void Connection::sendQueryParams(const char * command, const Params ¶ms)
|
||||
{
|
||||
int res = PQsendQueryParams(conn, command, params.size(), params.types(),
|
||||
params.values(), params.lengths(), params.formats(),
|
||||
0); // text format
|
||||
|
||||
return res == 1;
|
||||
if (res == 0)
|
||||
throw PgConnectionError(PQerrorMessage(conn));
|
||||
}
|
||||
|
||||
std::shared_ptr<Result> Connection::getResult()
|
||||
|
|
|
|||
|
|
@ -85,17 +85,17 @@ namespace Pgsql {
|
|||
Result queryParam(const char * command, const Params ¶ms);
|
||||
Result queryParam(const QString &command, const Params ¶ms);
|
||||
|
||||
bool sendQuery(const char * query);
|
||||
bool sendQuery(const std::string &command)
|
||||
void sendQuery(const char * query);
|
||||
void sendQuery(const std::string &command)
|
||||
{
|
||||
return sendQuery(command.c_str());
|
||||
sendQuery(command.c_str());
|
||||
}
|
||||
bool sendQuery(const QString &command)
|
||||
void sendQuery(const QString &command)
|
||||
{
|
||||
return sendQuery(command.toUtf8().data());
|
||||
sendQuery(command.toUtf8().data());
|
||||
}
|
||||
|
||||
bool sendQueryParams(const char * command, const Params ¶ms);
|
||||
void sendQueryParams(const char * command, const Params ¶ms);
|
||||
|
||||
std::shared_ptr<Result> getResult();
|
||||
std::shared_ptr<Result> getResultNoThrow();
|
||||
|
|
|
|||
|
|
@ -84,32 +84,32 @@ namespace Pgsql {
|
|||
return m_conn->queryParam(command, params);
|
||||
}
|
||||
|
||||
bool Transaction::sendQuery(const char * query)
|
||||
void Transaction::sendQuery(const char * query)
|
||||
{
|
||||
BOOST_ASSERT(m_conn != nullptr);
|
||||
BOOST_ASSERT(m_committed == false);
|
||||
BOOST_ASSERT(m_rolledback == false);
|
||||
|
||||
return m_conn->sendQuery(query);
|
||||
m_conn->sendQuery(query);
|
||||
}
|
||||
|
||||
bool Transaction::sendQuery(const std::string &command)
|
||||
void Transaction::sendQuery(const std::string &command)
|
||||
{
|
||||
return sendQuery(command.c_str());
|
||||
sendQuery(command.c_str());
|
||||
}
|
||||
|
||||
bool Transaction::sendQuery(const QString &command)
|
||||
void Transaction::sendQuery(const QString &command)
|
||||
{
|
||||
return sendQuery(command.toUtf8().data());
|
||||
sendQuery(command.toUtf8().data());
|
||||
}
|
||||
|
||||
bool Transaction::sendQueryParams(const char * command, const Params ¶ms)
|
||||
void Transaction::sendQueryParams(const char * command, const Params ¶ms)
|
||||
{
|
||||
BOOST_ASSERT(m_conn != nullptr);
|
||||
BOOST_ASSERT(m_committed == false);
|
||||
BOOST_ASSERT(m_rolledback == false);
|
||||
|
||||
return m_conn->sendQueryParams(command, params);
|
||||
m_conn->sendQueryParams(command, params);
|
||||
}
|
||||
|
||||
std::shared_ptr<Result> Transaction::getResult()
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ namespace Pgsql {
|
|||
Result query(const QString &command);
|
||||
Result queryParam(const char * command, const Params ¶ms);
|
||||
Result queryParam(const QString &command, const Params ¶ms);
|
||||
bool sendQuery(const char * query);
|
||||
bool sendQuery(const std::string &command);
|
||||
bool sendQuery(const QString &command);
|
||||
bool sendQueryParams(const char * command, const Params ¶ms);
|
||||
void sendQuery(const char * query);
|
||||
void sendQuery(const std::string &command);
|
||||
void sendQuery(const QString &command);
|
||||
void sendQueryParams(const char * command, const Params ¶ms);
|
||||
std::shared_ptr<Result> getResult();
|
||||
bool consumeInput();
|
||||
bool isBusy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue