#if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID<32224
#define mysql_field_count mysql_num_fields
#endif

void
process_query (MYSQL *conn, char *query)
{
MYSQL_RES *res_set;
unsigned int field_count;

	if (mysql_query (conn, query) != 0)	/* the query failed */
	{
		print_error (conn, "process_query() failed");
		return;
	}

	/* the query succeeded; determine whether or not it returns data */

	res_set = mysql_store_result (conn);
	if (res_set == NULL)	/* no result set was returned */
	{
		/*
		 * does the lack of a result set mean that an error
		 * occurred or that no result set was returned?
		 */
		if (mysql_field_count (conn) > 0)
		{
			/*
			 * a result set was expected, but mysql_store_result()
			 * did not return one; this means an error occurred
			 */
			print_error (conn, "Problem processing result set");
		}
		else
		{
			/*
			 * no result set was returned; query returned no data
			 * (it was not a SELECT, SHOW, DESCRIBE, or EXPLAIN),
			 * so just report number of rows affected by query
			 */
			printf ("%lu rows affected\n",
						(unsigned long) mysql_affected_rows (conn));
		}
	}
	else	/* a result set was returned */
	{
		/* process rows, then free the result set */
		process_result_set (conn, res_set);
		mysql_free_result (res_set);
	}
}
