postfix 3.1.0-3 fails on mysql table lookup

Bug #1598508 reported by Joel Linn
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
postfix
New
Undecided
Unassigned
postfix (Debian)
Fix Released
Unknown

Bug Description

what I get in the log:
Jul 3 01:21:40 postfix/cleanup[10334]: warning: mysql query failed: Commands out of sync; you can't run this command now
Jul 3 01:21:40 postfix/cleanup[10334]: warning: mysql:/etc/postfix/sql/aliases.cf lookup error for "<email address hidden>"
Jul 3 01:21:40 postfix/cleanup[10334]: warning: EF7AE1C0FCE: virtual_alias_maps map lookup problem for <email address hidden> -- message n$

Configuration:
virtual_alias_maps = mysql:/etc/postfix/sql/aliases.cf

and the query in that file:
query = CALL get_aliases_destinations('%u', '%d')

the stored procedure in the database could be as simple as
CREATE PROCEDURE `get_aliases_destinations`(IN user VARCHAR(64), IN domain VARCHAR(255))
BEGIN
 SELECT CONCAT(destination_username, '@', destination_domain) AS destinations FROM aliases WHERE source_username = user AND source_domain = domain AND enabled = true;
END

The bare select itself as query does work fine.
The crucial thing is that <email address hidden> already is the alias destination, so the first query worked fine. In fact postalias -q .... returns valid results.
I believe this occurs because of the mysql library returning an second empty result set which is not removed/cleared by postfix.
See this discussion which describes a similar issue:
http://stackoverflow.com/questions/6583020/mysql-stored-procedure-caused-commands-out-of-sync
I'm not familiar with the postfix sources but I think a possible fix could be inserted into the plmysql_query function in dict_mysql.c similar to what is discussed in the link and a dozen similar mysql api issues on the web.

Changed in postfix (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.