sql/m_sql_stmt.c
/*! Perform actual execution in a loop if there are multiple bound rows while
 *  the prior grouping was successful and there are more rows remaining
 */
Perform actual execution in a loop if there are multiple bound rows while
the prior grouping was successful and there are more rows remaining
Perform actual execution in a loop if there are multiple bound rows while the prior grouping was successful and there are more rows remaining
static M_sql_error_t M_sql_conn_execute_rows(M_sql_conn_t *conn, M_sql_stmt_t *stmt)
{
	size_t                rows_executed; 
	const M_sql_driver_t *driver = M_sql_conn_get_driver(conn);
	M_sql_error_t         err    = M_SQL_ERROR_SUCCESS;
	stmt->bind_row_offset = 0;
	do {
		M_free(stmt->query_prepared);
		stmt->query_prepared = driver->cb_queryformat(conn, stmt->query_user, stmt->query_param_cnt, M_sql_driver_stmt_bind_rows(stmt), stmt->error_msg, sizeof(stmt->error_msg));
		if (stmt->query_prepared == NULL) {
			err = M_SQL_ERROR_QUERY_PREPARE;
			goto done;
		}
		stmt->dstmt = M_sql_conn_get_stmt_cache(conn, stmt->query_prepared);
		err = driver->cb_prepare(&stmt->dstmt, conn, stmt, stmt->error_msg, sizeof(stmt->error_msg));
		M_sql_conn_set_stmt_cache(conn, stmt->query_prepared, stmt->dstmt);
		if (err != M_SQL_ERROR_SUCCESS)
			goto done;
		rows_executed = 1; 
		err = driver->cb_execute(conn, stmt, &rows_executed, stmt->error_msg, sizeof(stmt->error_msg));
		if (err != M_SQL_ERROR_SUCCESS && err != M_SQL_ERROR_SUCCESS_ROW) {
			if (err == M_SQL_ERROR_QUERY_FAILURE) {
				M_sql_conn_set_stmt_cache(conn, stmt->query_prepared, NULL);
			}
			goto done;
		}
		stmt->bind_row_offset += rows_executed;
	} while (M_sql_driver_stmt_bind_rows(stmt));
done:
	return err;
}
static M_sql_error_t M_sql_conn_execute_rows ( M_sql_conn_t * conn , M_sql_stmt_t * stmt ) { size_t rows_executed ; const M_sql_driver_t * driver = M_sql_conn_get_driver ( conn ) ; M_sql_error_t err = M_SQL_ERROR_SUCCESS ; stmt -> bind_row_offset = 0 ; do { M_free ( stmt -> query_prepared ) ; stmt -> query_prepared = driver -> cb_queryformat ( conn , stmt -> query_user , stmt -> query_param_cnt , M_sql_driver_stmt_bind_rows ( stmt ) , stmt -> error_msg , sizeof ( stmt -> error_msg ) ) ; if ( stmt -> query_prepared == NULL ) { err = M_SQL_ERROR_QUERY_PREPARE ; goto done ; } stmt -> dstmt = M_sql_conn_get_stmt_cache ( conn , stmt -> query_prepared ) ; err = driver -> cb_prepare ( & stmt -> dstmt , conn , stmt , stmt -> error_msg , sizeof ( stmt -> error_msg ) ) ; M_sql_conn_set_stmt_cache ( conn , stmt -> query_prepared , stmt -> dstmt ) ; if ( err != M_SQL_ERROR_SUCCESS ) goto done ; rows_executed = 1 ; err = driver -> cb_execute ( conn , stmt , & rows_executed , stmt -> error_msg , sizeof ( stmt -> error_msg ) ) ; if ( err != M_SQL_ERROR_SUCCESS && err != M_SQL_ERROR_SUCCESS_ROW ) { if ( err == M_SQL_ERROR_QUERY_FAILURE ) { M_sql_conn_set_stmt_cache ( conn , stmt -> query_prepared , NULL ) ; } goto done ; } stmt -> bind_row_offset += rows_executed ; } while ( M_sql_driver_stmt_bind_rows ( stmt ) ) ; done : return err ; }
Perform actual execution in a loop if there are multiple bound rows while
  the prior grouping was successful and there are more rows remaining
Perform actual execution in a loop if there are multiple bound rows while the prior grouping was successful and there are more rows remaining
/*! For multiple-insert queries, this may be a value > 1 */ /* Make sure we start at offset 0 */ /* Number of rows might be 0 if there are no bound parameters, so we want
	 * to account for this possibility by making it a do { } while */ /* Call query format callback (clear existing format *first* as it may be invalid) */ /* Lookup existing driver statement handle for formatted query from connection */ /* Call the sql driver's prepare callback, passing in existing statement handle if any.
		 * Add returned handle to cache (even if NULL, which will clear the cached handle). */ /* Execute the query */ /* Assume, driver may update */ /* If there is a generic failure, invalidate the prepared statement handle as it could
			 * be invalid to reuse */ /* Update offset */