#794496 postfix-mysql: commands out of sync when calling stored procedure

Package:
postfix-mysql
Source:
postfix
Description:
MySQL map support for Postfix
Submitter:
David Cepelik
Date:
2024-12-22 17:48:01 UTC
Severity:
normal
Tags:
#794496#5
Date:
2015-08-03 18:12:38 UTC
From:
To:
Dear Maintainer,

I attempted to implement all queries that my postfix install
asks the database as stored procedures in MySQL. Unfortunately,
I often get the common "Commands out of sync" error that I believe
comes from Postfix's mysql driver when query results are not
handled appropriately.

The code for the stored procedure is as follows:

SELECT `va`.`dst_email`
FROM `virtual_aliases` AS `va`
WHERE `va`.`src_email` = src_email

And the query is set in mysql-virtual_alias_maps.cf as this:

[...]
query = CALL `get_alias('%s')`

I thoroughly tested the routine, it does not seem to be the
source of the problem.

The log looks like this afterwards:

Aug  3 13:48:08 merlin postfix/smtpd[10872]: warning: mysql query failed: Commands out of sync; you can't run this command now

I was able to implement some routines as functions; but some
need to return result-sets. Then stored procedures need to be
used and problems arise.

Otherwise the package is really great and does its job
perfectly. Thanks for maintenance and development efforts!

#794496#10
Date:
2016-11-11 06:58:04 UTC
From:
To:
http://s.co.tt/2012/01/12/using-postfix-with-mysql-stored-procedures-or-use-functions/ has a reasonable discussion of the issue.  Upstream has said they
aren't going to implement this on their own.  Someone will have to provide a
high quality patch (bad ones have already been provided).

Scott K