When there is nonsense in the database, we may stop fetching the
authornbk <nbk>
Fri, 20 Jul 2007 15:42:56 +0000 (15:42 +0000)
committernbk <nbk>
Fri, 20 Jul 2007 15:42:56 +0000 (15:42 +0000)
rows before reaching the last result of a multiple results set.
Therefore we need to fetch the possibly pending results from the
function sql_finish_select_query().

Problem spotted by Jean Deram <jderam@nordnet.fr>

src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c

index 03e61c1..db683d6 100644 (file)
@@ -455,8 +455,23 @@ skip_next_result:
  *************************************************************************/
 static int sql_finish_select_query(SQLSOCK * sqlsocket, SQL_CONFIG *config)
 {
+#if (MYSQL_VERSION_ID >= 40100)
+       int status;
+       rlm_sql_mysql_sock *mysql_sock = sqlsocket->conn;
+#endif
        sql_free_result(sqlsocket, config);
-
+#if (MYSQL_VERSION_ID >= 40100)
+       status = mysql_next_result(mysql_sock->sock);
+       if (status == 0) {
+               /* there are more results */
+               sql_finish_query(sqlsocket, config);
+       }  else if (status > 0) {
+               radlog(L_ERR, "rlm_sql_mysql: Cannot get next result");
+               radlog(L_ERR, "rlm_sql_mysql: MySQL error '%s'",
+                      mysql_error(mysql_sock->sock));
+               return sql_check_error(status);
+       }
+#endif
        return 0;
 }