Notices and errors are as before switch might need still some work.
This commit is contained in:
parent
a36bf5f7f4
commit
2502aea9e5
4 changed files with 49 additions and 33 deletions
|
|
@ -40,6 +40,12 @@ void ASyncDBConnection::setStateCallback(on_state_callback state_callback)
|
|||
m_threadData.m_stateCallback.m_func = state_callback;
|
||||
}
|
||||
|
||||
void ASyncDBConnection::setNoticeCallback(on_notice_callback notice_callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(m_threadData.m_noticeCallback.m_mutex);
|
||||
m_threadData.m_noticeCallback.m_func = notice_callback;
|
||||
}
|
||||
|
||||
ASyncDBConnection::Thread::Thread()
|
||||
: m_stopEvent(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
||||
{}
|
||||
|
|
@ -51,6 +57,8 @@ void ASyncDBConnection::Thread::run()
|
|||
|
||||
// make or recover connection
|
||||
if (makeConnection()) {
|
||||
m_connection.setNoticeReceiver(
|
||||
[this](const PGresult *result) { processNotice(result); });
|
||||
m_canceller = m_connection.getCancel();
|
||||
|
||||
|
||||
|
|
@ -278,3 +286,12 @@ void ASyncDBConnection::Thread::waitForResult()
|
|||
// When last result received, remove command from queue
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::processNotice(const PGresult *result)
|
||||
{
|
||||
// Pgsql::Result res(result);
|
||||
std::lock_guard<std::mutex> lg(m_noticeCallback.m_mutex);
|
||||
if (m_noticeCallback.m_func) {
|
||||
Pgsql::ErrorDetails details = Pgsql::ErrorDetails::createErrorDetailsFromPGresult(result);
|
||||
m_noticeCallback.m_func(details);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue