[英]MySQL C API fails to error on subquery returns more than 1 row
From the mysql terminal:从 mysql 终端:
SELECT 1, (SELECT user_id FROM users);
ERROR 1242 (21000): Subquery returns more than 1 row ERROR 1242 (21000):子查询返回多于 1 行
In C code:在 C 代码中:
ret = mysql_query("SELECT 1, (SELECT user_id FROM users)");
printf("Ret is %d\n", ret); // --> "Ret is 0"
Is this a bug in the mysql C api?这是 mysql C api 中的错误吗? I cannot get any error information from this query.我无法从此查询中获得任何错误信息。 Both mysql_errno()
and mysql_error()
return nothing. mysql_errno()
和mysql_error()
都没有返回任何内容。 As far as the API is concerned the query ran successfully.就 API 而言,查询运行成功。
This error isn't reported until you call mysql_store_result
.在您调用mysql_store_result
之前不会报告此错误。
ret = mysql_query(con, "SELECT 1, (SELECT user_id FROM users)");
printf("Ret is %d\n", ret); // --> "Ret is 0"
MYSQL_RES *result = mysql_store_result(con);
if (result == NULL) {
printf("Error is %s", mysql_error(con); // prints "Subquery returns more than 1 row"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.