pgsql/update_tables_0.5.x-0.6.pgsql
branchv0.6.x
changeset 521 75d1c0d6bb8f
parent 518 5ec2068d02af
child 525 3acbff727626
equal deleted inserted replaced
520:a0a27688e616 521:75d1c0d6bb8f
   485     DECLARE
   485     DECLARE
   486         recordc recipient_destination;
   486         recordc recipient_destination;
   487         record recipient_destination;
   487         record recipient_destination;
   488         catchall_cursor refcursor;
   488         catchall_cursor refcursor;
   489         recipient varchar(320) := localpart || '@' || the_domain;
   489         recipient varchar(320) := localpart || '@' || the_domain;
       
   490         idestination varchar(320) :=
       
   491             _interpolate_destination(destination, localpart, the_domain);
   490         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   492         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   491     BEGIN
   493     BEGIN
   492         FOR record IN
   494         FOR record IN
   493             SELECT recipient,
   495             SELECT recipient, idestination
   494                 _interpolate_destination(destination, localpart, the_domain)
       
   495               FROM alias
   496               FROM alias
   496              WHERE gid = did
   497              WHERE gid = did
   497                AND address = localpart
   498                AND address = localpart
   498             LOOP
   499             LOOP
   499                 RETURN NEXT record;
   500                 RETURN NEXT record;
   507             -- over mailboxes/relocated, which is not what we want. Therefore,
   508             -- over mailboxes/relocated, which is not what we want. Therefore,
   508             -- we must first find out if the query is for an existing mailbox
   509             -- we must first find out if the query is for an existing mailbox
   509             -- or relocated entry and return the identity mapping if that is
   510             -- or relocated entry and return the identity mapping if that is
   510             -- the case
   511             -- the case
   511             OPEN catchall_cursor FOR
   512             OPEN catchall_cursor FOR
   512                 SELECT recipient,
   513                 SELECT recipient, idestination
   513                     _interpolate_destination(destination, localpart, the_domain)
       
   514                   FROM catchall
   514                   FROM catchall
   515                  WHERE gid = did;
   515                  WHERE gid = did;
   516             FETCH NEXT FROM catchall_cursor INTO recordc;
   516             FETCH NEXT FROM catchall_cursor INTO recordc;
   517 
   517 
   518             IF recordc IS NOT NULL THEN
   518             IF recordc IS NOT NULL THEN