> Am 06.08.2012 22:54, schrieb email builder:
>> I read in http://www.postfix.org/mysql_table.5.html for the %d substitution
>> in the query if the lookup is not a full email address with domain, the
>> entire
>> query is not even executed? Is this right?
>>
>> If that's the case, you can't do complex queries like:
>>
>> select IF('%d' = 'example.com', .....
>>
>> Even though a query like that might account for the case where %d is null,
>> postfix won't execute it?
>
> how do you come to that conclusion?
By reading.
"%d When the input key is an address of the form user@domain, %d is replaced
by the SQL quoted domain part of the address. Otherwise, the query is
suppressed and returns no results."
And by testing a query using %d against an alias with only a local part.
> below a grep of a since 2009 working config
Any local part only aliases? It looks to me like your queries all assume input
key in format "u...@example.com"
> [root@srv-rhsoft:~]$ cat /etc/postfix/mysql* | grep '%d'
> query = select deliver_to from dbmail_aliases where alias='%u@%d' and
> (select count(*) from dbmail_aliases where
> alias='%u@%d' and (round(deliver_to)<>0))=0;
> query = select target from dbma_rewrite_domains where source='%d' and
> ((select count(*) from dbmail_aliases
> where alias=(select concat('%u', (select target from
> dbma_rewrite_domains where source='%d' limit 1)) from
> dbma_rewrite_domains limit 1))>0 or (select count(*) from dbmail_aliases
> where alias='%u@' limit 1)>0) limit 1;
> query = select userid from dbmail_users where ((select count(*) from
> dbma_mta
> where mydestination='%d') > 0 or
> (select count(*) from dbma_sender_relay where email='%s') > 0) and
> user_idnr>3;
> query = select filter from dbma_spamfilter where domain='%d';
> query = select transport from dbma_transports where
> mydestination='%s' or mydestination='%d' order by transport
> desc limit 1;