pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql
branchv0.6.x
changeset 549 44a808af6cf4
parent 548 92ef34f07da3
child 550 867d950ce7b7
equal deleted inserted replaced
548:92ef34f07da3 549:44a808af6cf4
   549     DECLARE
   549     DECLARE
   550         recordc recipient_destination;
   550         recordc recipient_destination;
   551         record recipient_destination;
   551         record recipient_destination;
   552         catchall_cursor refcursor;
   552         catchall_cursor refcursor;
   553         recipient varchar(320) := localpart || '@' || the_domain;
   553         recipient varchar(320) := localpart || '@' || the_domain;
   554         idestination varchar(320) :=
       
   555             _interpolate_destination(destination, localpart, the_domain);
       
   556         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   554         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   557     BEGIN
   555     BEGIN
   558         FOR record IN
   556         FOR record IN
   559             SELECT recipient, idestination
   557             SELECT recipient,
       
   558                 _interpolate_destination(destination, localpart, the_domain)
   560               FROM alias
   559               FROM alias
   561              WHERE gid = did
   560              WHERE gid = did
   562                AND address = localpart
   561                AND address = localpart
   563             LOOP
   562             LOOP
   564                 RETURN NEXT record;
   563                 RETURN NEXT record;
   572             -- over mailboxes/relocated, which is not what we want. Therefore,
   571             -- over mailboxes/relocated, which is not what we want. Therefore,
   573             -- we must first find out if the query is for an existing mailbox
   572             -- we must first find out if the query is for an existing mailbox
   574             -- or relocated entry and return the identity mapping if that is
   573             -- or relocated entry and return the identity mapping if that is
   575             -- the case
   574             -- the case
   576             OPEN catchall_cursor FOR
   575             OPEN catchall_cursor FOR
   577                 SELECT recipient, idestination
   576                 SELECT recipient,
       
   577                     _interpolate_destination(destination, localpart, the_domain)
   578                   FROM catchall
   578                   FROM catchall
   579                  WHERE gid = did;
   579                  WHERE gid = did;
   580             FETCH NEXT FROM catchall_cursor INTO recordc;
   580             FETCH NEXT FROM catchall_cursor INTO recordc;
   581 
   581 
   582             IF recordc IS NOT NULL THEN
   582             IF recordc IS NOT NULL THEN