Re: [exim] query lookups with multiple rows as result

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Stephen Gran
Fecha:  
A: exim-users
Asunto: Re: [exim] query lookups with multiple rows as result
On Sun, Dec 05, 2004 at 11:25:17PM +0100, Marco Herrn said:
> Hi,
>
> I have a problem in understanding the query style lookups in Exim 4.
> I need a lookup to get a list of local parts. A I understand the FAQ
> in question Q0080, this should be no problem. I have the following
> router:
>
> hosteduser:
>   driver= accept
>   domains= +hosted_domains
> #  local_parts= ${lookup pgsql{\
> #                     SELECT localpart FROM mailbox WHERE domainname='$domain'}\
> #                     {$value}\
> #                fail}
>   local_parts= pgsql;SELECT localpart FROM mailbox WHERE domainname='$domain'
>   transport= hosted_delivery
>   cannot_route_message= Unknown mailbox

>
> A you can see, I have tried two versions of the lookup. Neither of
> which does what I want. The version currently active in the above
> example always results in success. I have only two local parts defined
> for this domain, with the names 'erwin' and 'spam', but sending a mail
> to 'wbe' succeeds. Here is the appropriate debug output:


The problem with the lookups is something I just learned myself -
lookup pgsql returns a list, which never matches a single item (as is -
you could rewrite your query to only return one item, e.g add AND
localpart = $localpart). Using pgsql; returns true if anything is
returned, so it returns true for all localparts.

You can do one of two things, essentially - have your query return only
one row, or use sg to transform the \n seperated fields into : seperated
fields. Using pgsql; is not what you want though.
--
--------------------------------------------------------------------------
|  Stephen Gran                  | "You can have my Unix system when you   |
|  steve@???             | pry it from my cold, dead fingers." --  |
|  http://www.lobefin.net/~steve | Cal Keegan                              |

--------------------------------------------------------------------------