pgsql/create_tables-dovecot-1.2.x.pgsql
branchv0.6.x
changeset 549 44a808af6cf4
parent 547 5020c56f9388
child 550 867d950ce7b7
equal deleted inserted replaced
548:92ef34f07da3 549:44a808af6cf4
   629     DECLARE
   629     DECLARE
   630         recordc recipient_destination;
   630         recordc recipient_destination;
   631         record recipient_destination;
   631         record recipient_destination;
   632         catchall_cursor refcursor;
   632         catchall_cursor refcursor;
   633         recipient varchar(320) := localpart || '@' || the_domain;
   633         recipient varchar(320) := localpart || '@' || the_domain;
   634         idestination varchar(320) :=
       
   635             _interpolate_destination(destination, localpart, the_domain);
       
   636         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   634         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   637     BEGIN
   635     BEGIN
   638         FOR record IN
   636         FOR record IN
   639             SELECT recipient, idestination
   637             SELECT recipient,
       
   638                 _interpolate_destination(destination, localpart, the_domain)
   640               FROM alias
   639               FROM alias
   641              WHERE gid = did
   640              WHERE gid = did
   642                AND address = localpart
   641                AND address = localpart
   643             LOOP
   642             LOOP
   644                 RETURN NEXT record;
   643                 RETURN NEXT record;
   652             -- over mailboxes/relocated, which is not what we want. Therefore,
   651             -- over mailboxes/relocated, which is not what we want. Therefore,
   653             -- we must first find out if the query is for an existing mailbox
   652             -- we must first find out if the query is for an existing mailbox
   654             -- or relocated entry and return the identity mapping if that is
   653             -- or relocated entry and return the identity mapping if that is
   655             -- the case
   654             -- the case
   656             OPEN catchall_cursor FOR
   655             OPEN catchall_cursor FOR
   657                 SELECT recipient, idestination
   656                 SELECT recipient,
       
   657                     _interpolate_destination(destination, localpart, the_domain)
   658                   FROM catchall
   658                   FROM catchall
   659                  WHERE gid = did;
   659                  WHERE gid = did;
   660             FETCH NEXT FROM catchall_cursor INTO recordc;
   660             FETCH NEXT FROM catchall_cursor INTO recordc;
   661 
   661 
   662             IF recordc IS NOT NULL THEN
   662             IF recordc IS NOT NULL THEN