gpt4 book ai didi

mysql C API - mysql_stmt_fetch 抛出异常 : access violation write at 0x00000008

转载 作者:行者123 更新时间:2023-11-29 22:30:03 25 4
gpt4 key购买 nike

我收到“node.exe 中 0x0369AF03 (libmysql.dll) 处未处理的异常:0xC0000005:访问冲突写入位置 0x00000008”。在循环中使用 mysql C API 时出现错误消息。

环境:Windows 7 32位,Mysql 5.6

这个错误只发生在Debug模式下,在release模式下,它传递并获取结果,这很奇怪。

我用谷歌搜索,并设置了 STMT_ATTR_CURSOR_TYPE,但它是相同的

请指教,谢谢!

代码:

准备声明

  static const char *sql_odb_read =
"SELECT `type`, `size`, UNCOMPRESS(`data`) FROM GIT_ODB WHERE `repo` = ? AND `oid` = ?;";
mysql->odb_read = mysql_stmt_init(mysql->db);
if (mysql->odb_read == NULL)
return GIT_ERROR;

if (mysql_stmt_prepare(mysql->odb_read, sql_odb_read, strlen(sql_odb_read)) != 0)
return GIT_ERROR;

if (mysql_stmt_attr_set(mysql->odb_read, STMT_ATTR_UPDATE_MAX_LENGTH, &truth) != 0)
return GIT_ERROR;

if (mysql_stmt_attr_set(mysql->odb_read, STMT_ATTR_CURSOR_TYPE, (const void *)&type) != 0)
return GIT_ERROR;

执行语句

 // bind the repo passed to the statement
bind_buffers[0].buffer = &(backend->mysql->repo);
bind_buffers[0].buffer_length = sizeof(backend->mysql->repo);
bind_buffers[0].length = &bind_buffers[0].buffer_length;
bind_buffers[0].buffer_type = MYSQL_TYPE_LONGLONG;

// bind the oid passed to the statement
bind_buffers[1].buffer = (void*)oid->id;
bind_buffers[1].buffer_length = 20;
bind_buffers[1].length = &bind_buffers[1].buffer_length;
bind_buffers[1].buffer_type = MYSQL_TYPE_BLOB;

if (mysql_stmt_bind_param(backend->mysql->odb_read, bind_buffers) != 0)
return GIT_ERROR;

// execute the statement
if (mysql_stmt_execute(backend->mysql->odb_read) != 0)
return GIT_ERROR;

if (mysql_stmt_num_rows(backend->mysql->odb_read) == 1) {
result_buffers[0].buffer_type = MYSQL_TYPE_TINY;
result_buffers[0].buffer = type_p;
result_buffers[0].buffer_length = sizeof(type_p); //sizeof(signed char);
result_buffers[0].is_null = 0;
result_buffers[0].length = &type_len;
memset(type_p, 0, sizeof(type_p));

result_buffers[1].buffer_type = MYSQL_TYPE_LONGLONG;
result_buffers[1].buffer = len_p;
result_buffers[1].buffer_length = sizeof(len_p);
result_buffers[1].is_null = 0;
result_buffers[1].length = &len_len;
memset(len_p, 0, sizeof(len_p));

result_buffers[2].buffer_type = MYSQL_TYPE_LONG_BLOB;
result_buffers[2].buffer = 0;
result_buffers[2].is_null = 0;
result_buffers[2].buffer_length = 0;
result_buffers[2].length = &data_len;

if (mysql_stmt_bind_result(backend->mysql->odb_read, result_buffers) != 0)
return GIT_ERROR;

error = mysql_stmt_fetch(backend->mysql->odb_read);

最佳答案

我下载了libmysql符号和源文件并调试了它mysql_stmt_execute后,结果缓冲区被更改,我不知道为什么,这是libmysql bug?所以我在使用结果缓冲区之前移动了 mem_set,然后一切正常

关于mysql C API - mysql_stmt_fetch 抛出异常 : access violation write at 0x00000008,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29890247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com