Bug #107694 connector xapi execute long sql statement through mysql router will cause error
Submitted: 29 Jun 3:20 Modified: 30 Jun 15:57
Reporter: bingo yang Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / C++ Severity:S2 (Serious)
Version:8.0.29 OS:Any
Assigned to: CPU Architecture:Any

[29 Jun 3:20] bingo yang
Description:
connector c/c++ 8.0.29 xapi  execute long sql statement through mysql router will cause error;

1.download connector c/c++ 8.0.29 from this page https://dev.mysql.com/downloads/connector/cpp/

2.create a session using mysqlx_get_session_from_options to connect a mysql router

3. execute a long sql statement using mysqlx_sql

4. mysqlx_sql will fail and get error:5000, bad massage

5. recall mysqlx_sql will get other error;

additon:
1. Js mysqlx api do the same operation is ok
2. do not use mysql router is ok;
3. do not use compressing is ok;
4. short sql statement is ok;
5. c version and c++ version has the same issue

How to repeat:
//the below is c version; but c++ version has the same problem

int MysqlApiTest::cTest()
{
std::string MysqlApiTest::mUser = "root";
std::string MysqlApiTest::mPwd = "toot";
std::string MysqlApiTest::mIp = "10.3.68.8";
int MysqlApiTest::mPort = 6448;// router port
std::string MysqlApiTest::mDbName = "db_test";

    mysqlx_session_t  *sess = NULL;
    std::string mCurErrcode;

    mysqlx_session_options_t *opt = NULL;
    mysqlx_error_t *error = NULL;
    opt = mysqlx_session_options_new();

    int optRes = mysqlx_session_option_set(opt,
        OPT_HOST(mIp.c_str()), OPT_PORT(mPort),
        OPT_USER(mUser.c_str()), OPT_PWD(mPwd.c_str()),
        OPT_DB(mDbName.c_str()),
        PARAM_END);

    sess = mysqlx_get_session_from_options(opt, &error);
    mysqlx_free(opt);

    if (sess == NULL)
    {
        mCurErrcode = mysqlx_error_num(error);  //if option error, mCurErrcode = 0
        std::string str(mysqlx_error_message(error));
        mysqlx_free(error);
        return 1;
    }
    printf("\nSession create");
    if (error != NULL) {
        mysqlx_free(error);
        error = NULL;
    }
    mysqlx_result_t* result = NULL;;
    std::string sql;
    sql = "CREATE TABLE IF NOT EXISTS `len_test` (`id` INT NOT NULL,`content` TEXT,PRIMARY KEY (`id`) )ENGINE=INNODB DEFAULT CHARSET=utf8mb4";
        result = mysqlx_sql(sess, sql.c_str(), sql.length()); //this will ok

    if (result != NULL)
    {
        mysqlx_free(result);
        result = NULL;
   }
   else {
       int stop = 0;
   }
   
    sql = "insert into viastorage_test.len_test (id, content) VALUE(2,'content5')";
    result = mysqlx_sql(sess, sql.c_str(), sql.length()); //this will ok

    if (result != NULL)
    {
        mysqlx_free(result);
        result = NULL;
   }
   else {
       int stop = 0;
   }
    
    sql = "insert into len_test (id, content) VALUE(2,'content5')";
    result = mysqlx_sql(sess, sql.c_str(), sql.length()); //this will ok

    if (result != NULL)
    {
        mysqlx_free(result);
        result = NULL;
   }
   else {
       int stop = 0;
   }

    sql = "insert into len_test (id, content) VALUE(13, 'content: aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh aaaa bbbbbb cccccc dddddhhhh')";

    result = mysqlx_sql(sess, sql.c_str(), sql.length()); // will fail

    if (result != NULL)
    {
        mysqlx_free(result);
        result = NULL;
    }
    else {
        mCurErrcode = mysqlx_error_num(sess);  //if option error, mCurErrcode = 0
        std::string str(mysqlx_error_message(sess));
        int stop = 0;
    }

    mysqlx_session_close(sess);

    return 0;
}
[29 Jun 3:21] bingo yang
change severity
[30 Jun 15:57] MySQL Verification Team
Hello,

Thank you for the bug report and feedback.

Regards,
Ashwini Patil