Conversing with myself ... Reading
http://www.toadworld.com/TWPIPELINEMarch2008/PIPEMarch08MySQL/tabid/308/Default.aspx
Rather than a StoredProcedure which returns a result set, using a
StoredFunction that returns a single value,
DELIMITER //
CREATE FUNCTION `DomainCheckFUNC`(domainName VARCHAR(255))
RETURNS TINYINT
DETERMINISTIC
CONTAINS SQL
BEGIN
DECLARE `result` TINYINT(1) DEFAULT 0;
SELECT 1 INTO `result`
FROM (SELECT `name`
FROM `DOMAIN`
WHERE `enabled` = '1'
UNION DISTINCT
SELECT `name`
FROM `DOMAIN_ALIAS`
WHERE `enabled` = '1'
) AS `X`
WHERE `name` = `domainName`
LIMIT 1;
RETURN(`result`);
END;
//
DELIMITER ;
and in virtual_mailbox_domains.cf
- query = CALL DomainCheck('%s');
+ query = SELECT DomainCheckFUNC('%s');
seems to work. At least valid/invalid domains are getting
passed/rejected early in the transaction, as intended. Need to watch
downstream.
If anyone else has success with this, or has comments why this
approach is wrong, it'd be useful to know.
Rich