Hi there, I'm a Postfix newb playing with Postfix-current under FreeBSD
and am now trying to store mydestination in mysql:
/usr/local/etc/postfix/main.cf:
mydestination = mysql:/usr/local/etc/postfix/mysql-mydestination.conf
/user/local/etc/postfix/mysql-mydestination.conf:
host = localhost
username = postfix
password = none
dbname = mail
expansion_limit = 1
query = SELECT v FROM mydestination WHERE k='%s'
table mail.mydestination:
mysql> show create table mydestination;
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
|
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| mydestination | CREATE TABLE `mydestination` (
`k` varchar(255) NOT NULL,
`v` varchar(255) DEFAULT NULL,
PRIMARY KEY (`k`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> select * from mydestination;
+-------------+------+
| k | v |
+-------------+------+
| $myhostname | NULL |
+-------------+------+
1 row in set (0.01 sec)
mysql>
Rationale (taken from mysql_table(5)):
LIST MEMBERSHIP
When using SQL to store lists such as $mynetworks, $mydestination,
$relay_domains, $local_recipient_maps, etc., it is important to under-
stand that the table must store each list member as a separate key. The
table lookup verifies the *existence* of the key. See "Postfix lists
versus tables" in the DATABASE_README document for a discussion.
Do NOT create tables that return the full list of domains in $mydesti-
nation or $relay_domains etc., or IP addresses in $mynetworks.
DO create tables with each matching item as a key and with an arbitrary
value.
Alas, restarting Postfix shows no queries being tried in MySQL query
log, and "postconf mydestination" simply greps whatever's in main.cf:
$ postconf mydestination
mydestination = mysql:/usr/local/etc/postfix/mysql-mydestination.conf
$
What's going on? How is Postfix supposed to learn the whole
mydestination list if there's no such SQL template? I thought Postfix
would deduce a "select k from mydestination" query or similar on its
own. The manpage is ambiguous in this regard.
Thanks.