On Mon, 25 Oct 2004, Marilyn Davis wrote:
> 9.18. Special MySQL features
>
> [skipped some]
>
> If a MySQL query is issued that does not request any
> data (an insert, update, or delete command), the
> result of the lookup is the number of rows affected.
>
> I'm running exim 4.43 on the test machine, where this is happening.
I'm not an MySQL expert at all, and therefore I can't easily set up a
test to check this out. However, I've made a note about this and if I
have some time I'll see if I can run a local test.
The code in Exim that implements this is very simple. It is in the
src/lookups/mysql.c file, and reads thus:
/* Pick up the result. If the query was not of the type that returns data,
namely INSERT, UPDATE, or DELETE, an error occurs here. However, this situation
can be detected by calling mysql_field_count(). If its result is zero, no data
was expected (this is all explained clearly in the MySQL manual). In this case,
we return the number of rows affected by the command. In this event, we do NOT
want to cache the result; also the whole cache for the handle must be cleaned
up. Setting do_cache FALSE requests this. */
if ((mysql_result = mysql_use_result(mysql_handle)) == NULL)
{
if ( mysql_field_count(mysql_handle) == 0 )
{
DEBUG(D_lookup) debug_printf("MYSQL: query was not one that returns data\n")
result = string_sprintf("%d", mysql_affected_rows(mysql_handle));
*do_cache = FALSE;
goto MYSQL_EXIT;
}
So all that Exim is doing is returning the value that MySQL is giving it.
I suppose to double-check one could insert an extra
debug_printf("result=%s\n", result);
just after setting result, just to make sure, but I suspect it won't
show anything different.
Just for the record, which release of MySQL?
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book: http://www.uit.co.uk/exim-book