Browse Source

Merge pull request #9636 from hggq/master

[Paozhu] update ORM
Mike Smith 5 months ago
parent
commit
8ad55f909a

+ 4 - 0
frameworks/C++/paozhu/paozhu_benchmark/common/cost_define.h

@@ -9,4 +9,8 @@
 #define CONST_HTTP_BODY_POST_SIZE 33554432
 #define CONST_HTTP_JSON_POST_SIZE 2097152
 
+#define CONST_ORM_CLEAR_TIME 7200
+#define CONST_ORM_CLEAR_NUMBER 1024
+#define CONST_ORM_QUERY_CONNECT_TIMEOUT 30
+
 #endif

+ 399 - 103
frameworks/C++/paozhu/paozhu_benchmark/orm/include/fortune_mysql.h

@@ -28,6 +28,7 @@
 #include "mysql_conn.h"
 #include "mysql_conn_pool.h"
 #include "orm_cache.hpp"
+#include "mysql_connect_mar.h"
 /*baseincludefile*/
 namespace orm
 {
@@ -168,10 +169,21 @@ namespace orm
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -371,10 +383,20 @@ namespace orm
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -601,7 +623,11 @@ namespace orm
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -730,7 +756,10 @@ namespace orm
 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -848,7 +877,11 @@ namespace orm
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -5067,10 +5100,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return temprecord;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return temprecord;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5282,10 +5326,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5455,26 +5510,33 @@ M_MODEL& or_leMessage(T val)
                     return *mod;
                 }
                 auto conn = conn_obj->get_select_conn();
+                
+                std::size_t n = conn->write_sql(sqlstring);
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return *mod;
+                }
 
-                unsigned int querysql_len = sqlstring.length() + 1;
+                //unsigned int querysql_len = sqlstring.length() + 1;
 
-                conn->send_data.clear();
+                // conn->send_data.clear();
 
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
 
-                std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
+                // std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
                 
-                if(conn->ec)
-                {
-                    error_msg = conn->ec.message();
-                    iserror   = true;
-                    return *mod;
-                }
+                // if(conn->ec)
+                // {
+                //     error_msg = conn->ec.message();
+                //     iserror   = true;
+                //     return *mod;
+                // }
                 
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
@@ -5492,10 +5554,22 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        iserror = true;
+                        error_msg = conn->error_msg;
+                        return *mod;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return *mod;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5646,18 +5720,26 @@ M_MODEL& or_leMessage(T val)
                 }
                 auto conn = co_await conn_obj->async_get_select_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
+                std::size_t n = co_await conn->async_write_sql(sqlstring);
+                
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    co_return 0;
+                }
 
-                conn->send_data.clear();
+                // unsigned int querysql_len = sqlstring.length() + 1;
 
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
+                // conn->send_data.clear();
 
-                std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
 
                 
                 pack_info_t temp_pack_data;
@@ -5676,10 +5758,20 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5865,10 +5957,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6056,10 +6159,20 @@ M_MODEL& or_leMessage(T val)
                     // n      = co_await conn->socket->async_read_some(asio::buffer(result_data), asio::use_awaitable);
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6208,25 +6321,32 @@ M_MODEL& or_leMessage(T val)
                 }
                 auto conn = conn_obj->get_select_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
-
-                conn->send_data.clear();
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
-
-                std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
-                
-                if(conn->ec)
+                std::size_t n = conn->write_sql(sqlstring);
+                if(n==0)
                 {
-                    error_msg = conn->ec.message();
-                    iserror   = true;
+                    error_msg = conn->error_msg;
                     return 0;
                 }
 
+                // unsigned int querysql_len = sqlstring.length() + 1;
+
+                // conn->send_data.clear();
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
+                
+                // if(conn->ec)
+                // {
+                //     error_msg = conn->ec.message();
+                //     iserror   = true;
+                //     return 0;
+                // }
+
                 
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
@@ -6242,10 +6362,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6412,17 +6543,25 @@ M_MODEL& or_leMessage(T val)
                 }
                 auto conn = co_await conn_obj->async_get_select_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
+                std::size_t n = co_await conn->async_write_sql(sqlstring);
+                
+                if (n==0)
+                {
+                    error_msg = conn->error_msg;
+                    co_return 0;
+                }
 
-                conn->send_data.clear();
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
+                // unsigned int querysql_len = sqlstring.length() + 1;
 
-                std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
+                // conn->send_data.clear();
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
 
                 
                 pack_info_t temp_pack_data;
@@ -6443,10 +6582,20 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6753,10 +6902,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6923,10 +7083,20 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return valuetemp;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -7093,10 +7263,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -7260,10 +7441,20 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -7434,7 +7625,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }    
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7533,28 +7728,39 @@ M_MODEL& or_leMessage(T val)
                 }
                 auto conn = conn_obj->get_edit_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
-
-                conn->send_data.clear();
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
-
-                std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
-                
-                if(conn->ec)
+                std::size_t n = conn->write_sql(sqlstring);
+                if(n==0)
                 {
-                    error_msg = conn->ec.message();
-                    iserror   = true;
+                    error_msg = conn->error_msg;
                     return 0;
                 }
 
+                // unsigned int querysql_len = sqlstring.length() + 1;
+
+                // conn->send_data.clear();
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
+                
+                // if(conn->ec)
+                // {
+                //     error_msg = conn->ec.message();
+                //     iserror   = true;
+                //     return 0;
+                // }
+
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7668,7 +7874,10 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7783,7 +7992,10 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7871,7 +8083,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7992,7 +8208,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8107,7 +8327,10 @@ M_MODEL& or_leMessage(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8194,7 +8417,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8274,7 +8501,10 @@ M_MODEL& or_leMessage(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8399,7 +8629,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8531,7 +8765,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8610,7 +8848,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8683,7 +8925,10 @@ M_MODEL& or_leMessage(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8763,7 +9008,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8836,7 +9085,10 @@ M_MODEL& or_leMessage(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8916,7 +9168,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8988,7 +9244,10 @@ M_MODEL& or_leMessage(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9099,7 +9358,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9149,7 +9412,11 @@ M_MODEL& or_leMessage(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9244,7 +9511,10 @@ M_MODEL& or_leMessage(T val)
 
                     unsigned int offset = 0;
                     n                   = co_await conn->async_read_loop();
-
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     pack_info_t temp_pack_data;
                     temp_pack_data.seq_id = 1;
                     conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9306,7 +9576,10 @@ M_MODEL& or_leMessage(T val)
                     
                     unsigned int offset = 0;
                     n                   = co_await conn->async_read_loop();
-
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     pack_info_t temp_pack_data;
                     temp_pack_data.seq_id = 1;
                     conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9429,10 +9702,21 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -9594,10 +9878,20 @@ M_MODEL& or_leMessage(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -9781,6 +10075,8 @@ M_MODEL& or_leMessage(T val)
 
         M_MODEL *mod;
 
+        std::shared_ptr<mysql_conn_base> select_conn;
+        std::shared_ptr<mysql_conn_base> edit_conn;
         std::shared_ptr<orm_conn_pool> conn_obj;
     };
 //} /*tagnamespace_replace*/

+ 1 - 1
frameworks/C++/paozhu/paozhu_benchmark/orm/include/fortunebase.h

@@ -2,7 +2,7 @@
 #define ORM_DEFAULT_FORTUNEBASEMATA_H
 /*
 *This file is auto create from cli
-*本文件为自动生成 Sun, 02 Mar 2025 10:54:30 GMT
+*本文件为自动生成 Mon, 10 Mar 2025 03:03:50 GMT
 ***/
 #include <iostream>
 #include <cstdio>

+ 399 - 103
frameworks/C++/paozhu/paozhu_benchmark/orm/include/world_mysql.h

@@ -28,6 +28,7 @@
 #include "mysql_conn.h"
 #include "mysql_conn_pool.h"
 #include "orm_cache.hpp"
+#include "mysql_connect_mar.h"
 /*baseincludefile*/
 namespace orm
 {
@@ -168,10 +169,21 @@ namespace orm
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -371,10 +383,20 @@ namespace orm
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -601,7 +623,11 @@ namespace orm
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -730,7 +756,10 @@ namespace orm
 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -848,7 +877,11 @@ namespace orm
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -4907,10 +4940,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return temprecord;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return temprecord;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5122,10 +5166,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5295,26 +5350,33 @@ M_MODEL& or_leRandomnumber(T val)
                     return *mod;
                 }
                 auto conn = conn_obj->get_select_conn();
+                
+                std::size_t n = conn->write_sql(sqlstring);
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return *mod;
+                }
 
-                unsigned int querysql_len = sqlstring.length() + 1;
+                //unsigned int querysql_len = sqlstring.length() + 1;
 
-                conn->send_data.clear();
+                // conn->send_data.clear();
 
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
 
-                std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
+                // std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
                 
-                if(conn->ec)
-                {
-                    error_msg = conn->ec.message();
-                    iserror   = true;
-                    return *mod;
-                }
+                // if(conn->ec)
+                // {
+                //     error_msg = conn->ec.message();
+                //     iserror   = true;
+                //     return *mod;
+                // }
                 
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
@@ -5332,10 +5394,22 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        iserror = true;
+                        error_msg = conn->error_msg;
+                        return *mod;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return *mod;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5486,18 +5560,26 @@ M_MODEL& or_leRandomnumber(T val)
                 }
                 auto conn = co_await conn_obj->async_get_select_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
+                std::size_t n = co_await conn->async_write_sql(sqlstring);
+                
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    co_return 0;
+                }
 
-                conn->send_data.clear();
+                // unsigned int querysql_len = sqlstring.length() + 1;
 
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
+                // conn->send_data.clear();
 
-                std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
 
                 
                 pack_info_t temp_pack_data;
@@ -5516,10 +5598,20 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5705,10 +5797,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -5896,10 +5999,20 @@ M_MODEL& or_leRandomnumber(T val)
                     // n      = co_await conn->socket->async_read_some(asio::buffer(result_data), asio::use_awaitable);
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6048,25 +6161,32 @@ M_MODEL& or_leRandomnumber(T val)
                 }
                 auto conn = conn_obj->get_select_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
-
-                conn->send_data.clear();
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
-
-                std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
-                
-                if(conn->ec)
+                std::size_t n = conn->write_sql(sqlstring);
+                if(n==0)
                 {
-                    error_msg = conn->ec.message();
-                    iserror   = true;
+                    error_msg = conn->error_msg;
                     return 0;
                 }
 
+                // unsigned int querysql_len = sqlstring.length() + 1;
+
+                // conn->send_data.clear();
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
+                
+                // if(conn->ec)
+                // {
+                //     error_msg = conn->ec.message();
+                //     iserror   = true;
+                //     return 0;
+                // }
+
                 
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
@@ -6082,10 +6202,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6252,17 +6383,25 @@ M_MODEL& or_leRandomnumber(T val)
                 }
                 auto conn = co_await conn_obj->async_get_select_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
+                std::size_t n = co_await conn->async_write_sql(sqlstring);
+                
+                if (n==0)
+                {
+                    error_msg = conn->error_msg;
+                    co_return 0;
+                }
 
-                conn->send_data.clear();
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
+                // unsigned int querysql_len = sqlstring.length() + 1;
 
-                std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
+                // conn->send_data.clear();
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = co_await asio::async_write(*conn->socket, asio::buffer(conn->send_data), asio::use_awaitable);
 
                 
                 pack_info_t temp_pack_data;
@@ -6283,10 +6422,20 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6593,10 +6742,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6763,10 +6923,20 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return valuetemp;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -6933,10 +7103,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -7100,10 +7281,20 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return 0;
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -7274,7 +7465,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }    
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7373,28 +7568,39 @@ M_MODEL& or_leRandomnumber(T val)
                 }
                 auto conn = conn_obj->get_edit_conn();
 
-                unsigned int querysql_len = sqlstring.length() + 1;
-
-                conn->send_data.clear();
-                conn->send_data.push_back((querysql_len & 0xFF));
-                conn->send_data.push_back((querysql_len >> 8 & 0xFF));
-                conn->send_data.push_back((querysql_len >> 16 & 0xFF));
-                conn->send_data.push_back(0x00);
-                conn->send_data.push_back(0x03);
-                conn->send_data.append(sqlstring);
-
-                std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
-                
-                if(conn->ec)
+                std::size_t n = conn->write_sql(sqlstring);
+                if(n==0)
                 {
-                    error_msg = conn->ec.message();
-                    iserror   = true;
+                    error_msg = conn->error_msg;
                     return 0;
                 }
 
+                // unsigned int querysql_len = sqlstring.length() + 1;
+
+                // conn->send_data.clear();
+                // conn->send_data.push_back((querysql_len & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 8 & 0xFF));
+                // conn->send_data.push_back((querysql_len >> 16 & 0xFF));
+                // conn->send_data.push_back(0x00);
+                // conn->send_data.push_back(0x03);
+                // conn->send_data.append(sqlstring);
+
+                // std::size_t n = asio::write(*conn->socket, asio::buffer(conn->send_data), conn->ec);
+                
+                // if(conn->ec)
+                // {
+                //     error_msg = conn->ec.message();
+                //     iserror   = true;
+                //     return 0;
+                // }
+
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7508,7 +7714,10 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7623,7 +7832,10 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7711,7 +7923,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7832,7 +8048,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -7947,7 +8167,10 @@ M_MODEL& or_leRandomnumber(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8034,7 +8257,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8114,7 +8341,10 @@ M_MODEL& or_leRandomnumber(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8239,7 +8469,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8371,7 +8605,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8450,7 +8688,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8523,7 +8765,10 @@ M_MODEL& or_leRandomnumber(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8603,7 +8848,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8676,7 +8925,10 @@ M_MODEL& or_leRandomnumber(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8756,7 +9008,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8828,7 +9084,10 @@ M_MODEL& or_leRandomnumber(T val)
                 
                 unsigned int offset = 0;
                 n                   = co_await conn->async_read_loop();
-
+                if (n==0)
+                {
+                    co_return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8939,7 +9198,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -8989,7 +9252,11 @@ M_MODEL& or_leRandomnumber(T val)
 
                 unsigned int offset = 0;
                 n                   = conn->read_loop();
-
+                if(n==0)
+                {
+                    error_msg = conn->error_msg;
+                    return 0;
+                }
                 pack_info_t temp_pack_data;
                 temp_pack_data.seq_id = 1;
                 conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9084,7 +9351,10 @@ M_MODEL& or_leRandomnumber(T val)
 
                     unsigned int offset = 0;
                     n                   = co_await conn->async_read_loop();
-
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     pack_info_t temp_pack_data;
                     temp_pack_data.seq_id = 1;
                     conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9146,7 +9416,10 @@ M_MODEL& or_leRandomnumber(T val)
                     
                     unsigned int offset = 0;
                     n                   = co_await conn->async_read_loop();
-
+                    if (n==0)
+                    {
+                        co_return 0;
+                    }
                     pack_info_t temp_pack_data;
                     temp_pack_data.seq_id = 1;
                     conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
@@ -9269,10 +9542,21 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = conn->read_loop();
                     offset = 0;
+                    if(n==0)
+                    {
+                        error_msg = conn->error_msg;
+                        return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -9434,10 +9718,20 @@ M_MODEL& or_leRandomnumber(T val)
                 {
                     n      = co_await conn->async_read_loop();
                     offset = 0;
+                    if (n==0)
+                    {
+                        co_return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                    }
                     for (; offset < n;)
                     {
                         conn->read_field_pack(conn->_cache_data, n, offset, temp_pack_data);
-                        if (temp_pack_data.length == temp_pack_data.current_length)
+                        if(temp_pack_data.error > 0)
+                        {
+                            iserror = true;
+                            error_msg =temp_pack_data.data;
+                            co_return std::make_tuple(table_fieldname, table_fieldmap, temprecord);
+                        }
+                        if (temp_pack_data.length == temp_pack_data.current_length && temp_pack_data.current_length > 0)
                         {
                             if (conn->pack_eof_check(temp_pack_data))
                             {
@@ -9621,6 +9915,8 @@ M_MODEL& or_leRandomnumber(T val)
 
         M_MODEL *mod;
 
+        std::shared_ptr<mysql_conn_base> select_conn;
+        std::shared_ptr<mysql_conn_base> edit_conn;
         std::shared_ptr<orm_conn_pool> conn_obj;
     };
 //} /*tagnamespace_replace*/

+ 1 - 1
frameworks/C++/paozhu/paozhu_benchmark/orm/include/worldbase.h

@@ -2,7 +2,7 @@
 #define ORM_DEFAULT_WORLDBASEMATA_H
 /*
 *This file is auto create from cli
-*本文件为自动生成 Sun, 02 Mar 2025 10:54:30 GMT
+*本文件为自动生成 Mon, 10 Mar 2025 03:03:50 GMT
 ***/
 #include <iostream>
 #include <cstdio>