Re: [Exim] Re: Access to data yielded by lookup

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Fred Viles
Data:  
Para: exim-users
Assunto: Re: [Exim] Re: Access to data yielded by lookup
On 22 May 2004 at 21:27, Steven Ericsson-Zenith wrote about
    "[Exim] Re: Access to data yielded b":



| Thank you for the responses regarding this question


Did you read mine, in another other thread you started?

| however
| the variable $address_data does not appear to carry the
| data from a lookup.


Per the spec, $address_data yields whatever you set it to.

|...
| To review, the spec suggests that the data from a lookup
| - and the case I am interested in is a PostgreSQL query -
| is cached until after routing.


But that is irrelevant to your question. The internal caching means
that additional duplicate lookups will be satisfied by the cached
answer, so there is little performance penalty. But it does not have
anything to do with how you *access* the value returned by the
lookup.

| I would prefer to limit my authentication queries to one
| transaction per message. The simplified example I gave:

|
|         condition = ${lookup pgsql{select ...
|         header_add = X-Aheader : $value

|
| Clearly, $value does not carry the data but then nor does $0 ...


Quoting again the relevant part of the spec:

> ${lookup{<key>} <search type> {<file>} {<string1>} {<string2>}}
>
> ${lookup <search type> {<query>} {<string1>} {<string2>}}
>
> ...
> If the lookup succeeds, <string1> is expanded and replaces the entire item.
> During its expansion, the variable $value contains the data returned by the
> lookup. Afterwards it reverts to the value it had previously ...

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


If you want to reference the looked-up data later, you need to:

1. Supply $value for <string1>, and

2. Store the result of ${lookup somewhere.

In an ACL you can save it in a $acl_* variable with the "set"
modifier. In a router, you can use the address_data option to save
it in $address_data.

| Perhaps, the spec suggests that the exact same query is guaranteed
| to produce the identical results - if so, I would like to understand
| this behavior.


That's the effect of caching the lookup.

- Fred