[Dovecot] Bug in driver-mysql.c + fix

Alain Williams addw at phcomp.co.uk
Wed Mar 10 17:57:28 EET 2010


On Wed, Mar 10, 2010 at 04:23:23PM +0200, Timo Sirainen wrote:
> On Wed, 2010-03-10 at 16:18 +0200, Timo Sirainen wrote:
> > > 	password_query = CALL user_pass_check('%n', '%d', '%w')
> > > 
> > > 	user_query = CALL user_info('%n', '%d')
> > > 
> > > This failed with the message:
> > > 	User query failed: PROCEDURE imap.user_info can't return a result set in the given context
> > 
> > I thought it was possible to avoid that error by implementing the MySQL
> > procedure in a specific way?..
> 
> "Statements that return a result set can be used within a stored
> procedcure but not within a stored function. This prohibition includes
> SELECT statements that do not have an INTO var_list clause and other
> statements such as SHOW, EXPLAIN, and CHECK TABLE."
> 
> Sounds like if you used SELECT .. INTO and returned those variables, it
> would work?

I tried that just now, with my patch not implemented and get the error about 'context' above
Unfortunately that does not seem to work.

The SQL that I am using is below, if someone can make it work without my patch
I would be grateful.

DROP PROCEDURE IF EXISTS user_pass_check_t !!

CREATE PROCEDURE user_pass_check_t(local_part TEXT, in_domain TEXT, test_pass TEXT)
    NOT DETERMINISTIC  -- login state of the user may change
    COMMENT "Return user information as needed by dovecot"
BEGIN
    DECLARE usr_addr   VARCHAR(128);
    DECLARE usr_pass   VARCHAR(64);
    DECLARE usr_home   VARCHAR(256);
    DECLARE usr_uid    INTEGER;
    DECLARE usr_gid    INTEGER;

    SELECT CONCAT(userid, '@', domain), CONCAT('{DIGEST-MD5}', password), home, uid, gid \
      INTO usr_addr, usr_pass, usr_home, usr_uid, usr_gid
      FROM imap.users WHERE userid = local_part AND domain = in_domain;

    SELECT usr_addr AS user, usr_pass AS password, usr_home AS userdb_home, usr_uid AS userdb_uid, usr_gid AS userdb_gid;
END !!




-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Past chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>


More information about the dovecot mailing list