On Sunday 14 May 2006 12:58, Casey Allen Shobe wrote:
> I have the following hostlist:
>
> hostlist known_mailhosts = pgsql;select coalesce ((select true
> from "mail_servers" where "ip_address" = '${quote_pgsql:$sender_host_addres
> s}'), ${if def:sender_host_name {(select true from "exempt_domains"
> where '${quote_pgsql:$sender_host_name}' like '%' || "domain"), }}false);
>
> The SQL works as expected as demonstrated below, returning a true or false
> result. I don't think the SQL has anything to do with the actual
> problem...
In fact the SQL was the problem. As it turns out a ANY return value is
counted. Taking ', false' out of the coalesce still returned a null value so
it was always true still. Thus, I have split it up into two hostlists as
follows:
hostlist known_mailhosts = pgsql;select true from "mail_servers"
where "ip_address" = '${quote_pgsql:$sender_host_address}';
hostlist exempt_domains = pgsql;${if def:sender_host_name {select true
from "exempt_domains" where '${quote_pgsql:$sender_host_name}'
like '%' || "domain"}{select true where true = false}};
I don't really like that it runs the latter query on the db all the time when
it's not needed, but I don't know any way to only execute the query if
$sender_host_name is defined...
> ...what actually gets logged is not the expected:
> [...]
> ...but instead:
> [...]
> (note the missing ').' at the end). Why is this?
I guess the logger didn't like the newline and stopped there. So I just
changed the newline to some spaces instead.
--
Casey Allen Shobe | cshobe@??? | 206-381-2800
SeattleServer.com, Inc. |
http://www.seattleserver.com