Can use the parameter list in the query window now.
Still requires extensive testing for all possible types.
This commit is contained in:
parent
aefc9eb7ba
commit
3af26d915e
14 changed files with 461 additions and 242 deletions
|
|
@ -51,6 +51,16 @@ bool ASyncDBConnection::send(const std::string &command, on_result_callback on_r
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ASyncDBConnection::send(const std::string &command, Pgsql::Params params, on_result_callback on_result)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
||||
m_threadData.m_commandQueue.m_queue.emplace(command, std::move(params), on_result);
|
||||
m_threadData.m_commandQueue.m_newEvent.set();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ASyncDBConnection::cancel()
|
||||
{
|
||||
return m_threadData.cancel();
|
||||
|
|
@ -243,21 +253,29 @@ void ASyncDBConnection::Thread::doNewCommand()
|
|||
{
|
||||
// todo: send command
|
||||
// get command from top of queue (but leave it in the queue, we need the callback)
|
||||
std::string command;
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(m_commandQueue.m_mutex);
|
||||
if (! m_commandQueue.m_queue.empty()) {
|
||||
command = m_commandQueue.m_queue.front().command;
|
||||
const Command &command = m_commandQueue.m_queue.front();
|
||||
if (!command.command.empty()) {
|
||||
bool query_send = false;
|
||||
if (command.params.empty())
|
||||
query_send = m_connection.sendQuery(command.command.c_str());
|
||||
else
|
||||
query_send = m_connection.sendQueryParams(command.command.c_str(), command.params);
|
||||
|
||||
if (query_send) {
|
||||
m_timer.start();
|
||||
doStateCallback(State::QuerySend);
|
||||
}
|
||||
else {
|
||||
std::string error = m_connection.getErrorMessage();
|
||||
// todo: need to report the error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!command.empty() && m_connection.sendQuery(command)) {
|
||||
m_timer.start();
|
||||
doStateCallback(State::QuerySend);
|
||||
}
|
||||
else {
|
||||
std::string error = m_connection.getErrorMessage();
|
||||
// todo: need to report the error
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ASyncDBConnection::Thread::waitForResult()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue