1
This commit is contained in:
parent
e90d758f5e
commit
943b528893
@ -30,7 +30,7 @@ struct AsyncQueryRequest
|
|||||||
std::string sql;
|
std::string sql;
|
||||||
#if 1
|
#if 1
|
||||||
std::string _sql_fmt;
|
std::string _sql_fmt;
|
||||||
std::initializer_list<a8::XValue> _sql_params;
|
std::vector<a8::XValue> _sql_params;
|
||||||
a8::XObject conn_info;
|
a8::XObject conn_info;
|
||||||
#endif
|
#endif
|
||||||
a8::XParams param;
|
a8::XParams param;
|
||||||
@ -48,7 +48,7 @@ struct AsyncQueryNode
|
|||||||
std::string sql;
|
std::string sql;
|
||||||
#if 1
|
#if 1
|
||||||
std::string _sql_fmt;
|
std::string _sql_fmt;
|
||||||
std::initializer_list<a8::XValue> _sql_params;
|
std::vector<a8::XValue> _sql_params;
|
||||||
a8::XObject conn_info;
|
a8::XObject conn_info;
|
||||||
#endif
|
#endif
|
||||||
AsyncQueryNode* nextnode = nullptr;
|
AsyncQueryNode* nextnode = nullptr;
|
||||||
@ -224,7 +224,7 @@ private:
|
|||||||
switch (node->query_type) {
|
switch (node->query_type) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
int ret = last_query_->ExecQuery(node->sql.c_str(), {});
|
int ret = last_query_->ExecQuery(node->_sql_fmt.c_str(), node->_sql_params);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid,
|
MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
@ -253,7 +253,7 @@ private:
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
bool ret = last_query_->ExecScript(node->sql.c_str(), {});
|
bool ret = last_query_->ExecScript(node->_sql_fmt.c_str(), node->_sql_params);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid,
|
MsgQueue::Instance()->PostMsg_r(exec_async_query_msgid,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
@ -360,7 +360,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InternalExecAsyncSql(int exec_type,
|
void InternalExecAsyncSql(int exec_type,
|
||||||
a8::XObject& conn_info, const char* querystr, std::initializer_list<a8::XValue>& args,
|
a8::XObject& conn_info, const char* querystr, std::vector<a8::XValue>& args,
|
||||||
a8::XParams& param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code)
|
a8::XParams& param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code)
|
||||||
{
|
{
|
||||||
AsyncQueryRequest* p = new AsyncQueryRequest();
|
AsyncQueryRequest* p = new AsyncQueryRequest();
|
||||||
@ -453,13 +453,13 @@ void DBPool::SetThreadNum(int thread_num)
|
|||||||
impl_->SetThreadNum(thread_num);
|
impl_->SetThreadNum(thread_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPool::ExecAsyncQuery(a8::XObject conn_info, const char* querystr, std::initializer_list<a8::XValue> args,
|
void DBPool::ExecAsyncQuery(a8::XObject conn_info, const char* querystr, std::vector<a8::XValue> args,
|
||||||
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code)
|
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code)
|
||||||
{
|
{
|
||||||
impl_->InternalExecAsyncSql(0, conn_info, querystr, args, param, on_ok, on_error, hash_code);
|
impl_->InternalExecAsyncSql(0, conn_info, querystr, args, param, on_ok, on_error, hash_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPool::ExecAsyncScript(a8::XObject conn_info, const char* querystr, std::initializer_list<a8::XValue> args,
|
void DBPool::ExecAsyncScript(a8::XObject conn_info, const char* querystr, std::vector<a8::XValue> args,
|
||||||
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code)
|
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code)
|
||||||
{
|
{
|
||||||
impl_->InternalExecAsyncSql(1, conn_info, querystr, args, param, on_ok, on_error, hash_code);
|
impl_->InternalExecAsyncSql(1, conn_info, querystr, args, param, on_ok, on_error, hash_code);
|
||||||
|
@ -17,10 +17,10 @@ class DBPool : public a8::Singleton<DBPool>
|
|||||||
void SetThreadNum(int thread_num);
|
void SetThreadNum(int thread_num);
|
||||||
|
|
||||||
//执行异步并行查询
|
//执行异步并行查询
|
||||||
void ExecAsyncQuery(a8::XObject conn_info, const char* querystr, std::initializer_list<a8::XValue> args,
|
void ExecAsyncQuery(a8::XObject conn_info, const char* querystr, std::vector<a8::XValue> args,
|
||||||
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code);
|
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code);
|
||||||
//执行异步并行sql
|
//执行异步并行sql
|
||||||
void ExecAsyncScript(a8::XObject conn_info, const char* querystr, std::initializer_list<a8::XValue> args,
|
void ExecAsyncScript(a8::XObject conn_info, const char* querystr, std::vector<a8::XValue> args,
|
||||||
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code);
|
a8::XParams param, AsyncDBOnOkFunc on_ok, AsyncDBOnErrorFunc on_error, long long hash_code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user