pgsql/create_tables.pgsql
branchv0.6.x
changeset 549 44a808af6cf4
parent 547 5020c56f9388
child 550 867d950ce7b7
equal deleted inserted replaced
548:92ef34f07da3 549:44a808af6cf4
   607     DECLARE
   607     DECLARE
   608         recordc recipient_destination;
   608         recordc recipient_destination;
   609         record recipient_destination;
   609         record recipient_destination;
   610         catchall_cursor refcursor;
   610         catchall_cursor refcursor;
   611         recipient varchar(320) := localpart || '@' || the_domain;
   611         recipient varchar(320) := localpart || '@' || the_domain;
   612         idestination varchar(320) :=
       
   613             _interpolate_destination(destination, localpart, the_domain);
       
   614         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   612         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   615     BEGIN
   613     BEGIN
   616         FOR record IN
   614         FOR record IN
   617             SELECT recipient, idestination
   615             SELECT recipient,
       
   616                 _interpolate_destination(destination, localpart, the_domain)
   618               FROM alias
   617               FROM alias
   619              WHERE gid = did
   618              WHERE gid = did
   620                AND address = localpart
   619                AND address = localpart
   621             LOOP
   620             LOOP
   622                 RETURN NEXT record;
   621                 RETURN NEXT record;
   630             -- over mailboxes/relocated, which is not what we want. Therefore,
   629             -- over mailboxes/relocated, which is not what we want. Therefore,
   631             -- we must first find out if the query is for an existing mailbox
   630             -- we must first find out if the query is for an existing mailbox
   632             -- or relocated entry and return the identity mapping if that is
   631             -- or relocated entry and return the identity mapping if that is
   633             -- the case
   632             -- the case
   634             OPEN catchall_cursor FOR
   633             OPEN catchall_cursor FOR
   635                 SELECT recipient, idestination
   634                 SELECT recipient,
       
   635                     _interpolate_destination(destination, localpart, the_domain)
   636                   FROM catchall
   636                   FROM catchall
   637                  WHERE gid = did;
   637                  WHERE gid = did;
   638             FETCH NEXT FROM catchall_cursor INTO recordc;
   638             FETCH NEXT FROM catchall_cursor INTO recordc;
   639 
   639 
   640             IF recordc IS NOT NULL THEN
   640             IF recordc IS NOT NULL THEN