static int conc_new_issue(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
MYSQL_BIND bind[2];
bind[0].buffer_type = MYSQL_TYPE_LONG;
bind[0].buffer = (void *)&id;
bind[0].buffer_length = 4;
bind[0].is_null = &is_null[0];
bind[0].length = NULL;// &length[0];
bind[0].error = &error[0];
mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count);
check_stmt_rc(mysql_stmt_bind_param(stmt, bind), stmt);
check_stmt_rc(mariadb_stmt_execute_direct(stmt, "SELECT ?", -1), stmt);
check_stmt_rc(mysql_stmt_store_result(stmt), stmt);
check_stmt_rc(mysql_stmt_free_result(stmt), stmt);
//mysql_stmt_close(stmt);
//stmt= mysql_stmt_init(mysql);
param_count= 1;
mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count);
check_stmt_rc(mysql_stmt_bind_param(stmt, bind), stmt);
check_stmt_rc(mariadb_stmt_execute_direct(stmt, "SELECT ?", -1), stmt);
mysql_stmt_close(stmt);
return OK;
}
Yes, if close stmt between 2 calls, everything will work fine.
Reusing statement might lead to unexpected behavior - mariadb_stmt_execute_direct().
If we want to allow reusing we need to reset statement in mysql_stmt_attr_set when setting number of prebind parameters.