pgsql/create_tables-dovecot-1.2.x.pgsql
branchv0.6.x
changeset 521 75d1c0d6bb8f
parent 518 5ec2068d02af
child 525 3acbff727626
equal deleted inserted replaced
520:a0a27688e616 521:75d1c0d6bb8f
   610     DECLARE
   610     DECLARE
   611         recordc recipient_destination;
   611         recordc recipient_destination;
   612         record recipient_destination;
   612         record recipient_destination;
   613         catchall_cursor refcursor;
   613         catchall_cursor refcursor;
   614         recipient varchar(320) := localpart || '@' || the_domain;
   614         recipient varchar(320) := localpart || '@' || the_domain;
       
   615         idestination varchar(320) :=
       
   616             _interpolate_destination(destination, localpart, the_domain);
   615         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   617         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   616     BEGIN
   618     BEGIN
   617         FOR record IN
   619         FOR record IN
   618             SELECT recipient,
   620             SELECT recipient, idestination
   619                 _interpolate_destination(destination, localpart, the_domain)
       
   620               FROM alias
   621               FROM alias
   621              WHERE gid = did
   622              WHERE gid = did
   622                AND address = localpart
   623                AND address = localpart
   623             LOOP
   624             LOOP
   624                 RETURN NEXT record;
   625                 RETURN NEXT record;
   632             -- over mailboxes/relocated, which is not what we want. Therefore,
   633             -- over mailboxes/relocated, which is not what we want. Therefore,
   633             -- we must first find out if the query is for an existing mailbox
   634             -- we must first find out if the query is for an existing mailbox
   634             -- or relocated entry and return the identity mapping if that is
   635             -- or relocated entry and return the identity mapping if that is
   635             -- the case
   636             -- the case
   636             OPEN catchall_cursor FOR
   637             OPEN catchall_cursor FOR
   637                 SELECT recipient,
   638                 SELECT recipient, idestination
   638                     _interpolate_destination(destination, localpart, the_domain)
       
   639                   FROM catchall
   639                   FROM catchall
   640                  WHERE gid = did;
   640                  WHERE gid = did;
   641             FETCH NEXT FROM catchall_cursor INTO recordc;
   641             FETCH NEXT FROM catchall_cursor INTO recordc;
   642 
   642 
   643             IF recordc IS NOT NULL THEN
   643             IF recordc IS NOT NULL THEN