[MXS-2521] COM_STMT_EXECUTE maybe return empty result Created: 2019-05-28  Updated: 2020-01-08  Resolved: 2019-06-28

Status: Closed
Project: MariaDB MaxScale
Component/s: readwritesplit
Affects Version/s: 2.2.12
Fix Version/s: 2.2.22, 2.3.9, 2.4.1

Type: Bug Priority: Major
Reporter: xiangzhong Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

linux


Attachments: File test-mxs-2521.c    
Issue Links:
Blocks
is blocked by MXS-2750 COM_STMT_EXECUTE in transaction get u... Closed
Relates
relates to MDEV-19811 Crash with prepared statement Open
Sprint: MXS-SPRINT-85

 Description   

insert into randselect values(1, 'a'),... (10, 'ab');

string sqlstr="select names from randselect where id = ?;"
stmt = mysql_stmt_init(conn);
if(NULL == stmt)

{ cerr << "stmt init failed: " << mysql_error(conn); return 1; }

if (mysql_stmt_prepare(stmt, sql.c_str(), strlen(sql.c_str())) != 0)

{ print_stmt_error(stmt,"stmt prepare fail"); return 1; }

memset(param,0,sizeof(param));
memset(result,0,sizeof(result));

result[0].buffer_type = MYSQL_TYPE_STRING;
result[0].buffer = (char*)&value;
result[0].is_unsigned = 0;
result[0].is_null = 0;
result[0].buffer_length = MAX_SIZE;
result[0].length = &length;

if (mysql_stmt_bind_result(stmt,result) !=0)

{ print_stmt_error(stmt,"bind result error"); return 1; }

param[0].buffer_type = MYSQL_TYPE_LONG;
param[0].buffer = (void *) &id;
param[0].is_unsigned = 1;
param[0].is_null = 0;
param[0].length = 0;

if (mysql_stmt_bind_param(stmt, param) != 0)

{ print_stmt_error(stmt,"bind param error"); return 1; }

int j = 1;
while (j < 10)
{

id = j;
//mysql_stmt_bind_param(stmt, param);
if(mysql_stmt_execute(stmt) !=0)

{ print_stmt_error(stmt,"execute stmt error"); return 1; }

if (mysql_stmt_store_result(stmt) != 0)

{ print_stmt_error(stmt, "Could not buffer result set"); return 1; }

cout << "id" << id << endl;
while (!mysql_stmt_fetch(stmt))

{ cout << " column (string) : " << value << length << endl; }

j++;
}

mysql_stmt_close(stmt);

when multi stmt_exec router to diff db backends,maybe some exec don't get result(empty),only exec first stmt_exec node will reture result, other db backends will return empty result.

maybe because stmt_exec(https://dev.mysql.com/doc/internals/en/com-stmt-execute.html) have new-params-bound-flag,and only set when mysql_stmt_bind_param,otherwise new-params-bound-flag=0 and client not send param type lead to db return empty。



 Comments   
Comment by dapeng huang [ 2019-06-20 ]

test-mxs-2521.c a simple test case to reproduce this problem

Comment by markus makela [ 2019-06-20 ]

dapeng if you can contribute that test according to the MaxScale contribution policy (BSD-3), we can add the test into our test suite.

Comment by dapeng huang [ 2019-06-20 ]

@markus makela ; I am contributing the test test-mxs-2521.c case under the BSD-3
license.

Comment by markus makela [ 2019-06-20 ]

Thanks, we'll add it to the test suite.

Generated at Thu Feb 08 04:14:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.