Re: [Exim] slightly baffled (postgresql query question)

Top Pagina
Delete this message
Reply to this message
Auteur: Philip Hazel
Datum:  
Aan: Richard Welty
CC: exim-users
Onderwerp: Re: [Exim] slightly baffled (postgresql query question)
On Tue, 5 Aug 2003, Richard Welty wrote:

> my plan was that it could then be used in a lookup like this:
>
> hostlist relay_hosts                    = pgsql;select test_relay_ip( \
>                                                 '${quote_pgsql:$sender_host_address}');

>
> however, what i'm seeing is that any return value (t or f) from the query
> is being treated by exim as success in the lookup.


Yup. That's the way that kind of lookup works. It uses the question
"does the lookup succeed?" as way of getting the answer to "is this host
in this list?". (This goes back to the original single-key type of
lookups like lsearch and cdb.)

If you can make your lookup return "*" and "" instead of "t" and "f",
you can use something simple like this:

hostlist relay_hosts = ${lookup pgsql{select ....}}

If you can't change what is returned, then you have to wrap it in some
more stuff to do a conversion:

hostlist relay_hosts = ${if eq {${lookup....}}{t}{*}}

In other words, get the expanded string to be "*" when you want it to
match, and "" otherwise.

--
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