pgsql/update_tables_0.5.x-0.6.pgsql
branchv0.6.x
changeset 549 44a808af6cf4
parent 548 92ef34f07da3
child 550 867d950ce7b7
equal deleted inserted replaced
548:92ef34f07da3 549:44a808af6cf4
   528     DECLARE
   528     DECLARE
   529         recordc recipient_destination;
   529         recordc recipient_destination;
   530         record recipient_destination;
   530         record recipient_destination;
   531         catchall_cursor refcursor;
   531         catchall_cursor refcursor;
   532         recipient varchar(320) := localpart || '@' || the_domain;
   532         recipient varchar(320) := localpart || '@' || the_domain;
   533         idestination varchar(320) :=
       
   534             _interpolate_destination(destination, localpart, the_domain);
       
   535         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   533         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   536     BEGIN
   534     BEGIN
   537         FOR record IN
   535         FOR record IN
   538             SELECT recipient, idestination
   536             SELECT recipient,
       
   537                 _interpolate_destination(destination, localpart, the_domain)
   539               FROM alias
   538               FROM alias
   540              WHERE gid = did
   539              WHERE gid = did
   541                AND address = localpart
   540                AND address = localpart
   542             LOOP
   541             LOOP
   543                 RETURN NEXT record;
   542                 RETURN NEXT record;
   551             -- over mailboxes/relocated, which is not what we want. Therefore,
   550             -- over mailboxes/relocated, which is not what we want. Therefore,
   552             -- we must first find out if the query is for an existing mailbox
   551             -- we must first find out if the query is for an existing mailbox
   553             -- or relocated entry and return the identity mapping if that is
   552             -- or relocated entry and return the identity mapping if that is
   554             -- the case
   553             -- the case
   555             OPEN catchall_cursor FOR
   554             OPEN catchall_cursor FOR
   556                 SELECT recipient, idestination
   555                 SELECT recipient,
       
   556                     _interpolate_destination(destination, localpart, the_domain)
   557                   FROM catchall
   557                   FROM catchall
   558                  WHERE gid = did;
   558                  WHERE gid = did;
   559             FETCH NEXT FROM catchall_cursor INTO recordc;
   559             FETCH NEXT FROM catchall_cursor INTO recordc;
   560 
   560 
   561             IF recordc IS NOT NULL THEN
   561             IF recordc IS NOT NULL THEN