pgsql/create_tables.pgsql
branchv0.6.x
changeset 521 75d1c0d6bb8f
parent 518 5ec2068d02af
child 525 3acbff727626
equal deleted inserted replaced
520:a0a27688e616 521:75d1c0d6bb8f
   587     DECLARE
   587     DECLARE
   588         recordc recipient_destination;
   588         recordc recipient_destination;
   589         record recipient_destination;
   589         record recipient_destination;
   590         catchall_cursor refcursor;
   590         catchall_cursor refcursor;
   591         recipient varchar(320) := localpart || '@' || the_domain;
   591         recipient varchar(320) := localpart || '@' || the_domain;
       
   592         idestination varchar(320) :=
       
   593             _interpolate_destination(destination, localpart, the_domain);
   592         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   594         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
   593     BEGIN
   595     BEGIN
   594         FOR record IN
   596         FOR record IN
   595             SELECT recipient,
   597             SELECT recipient, idestination
   596                 _interpolate_destination(destination, localpart, the_domain)
       
   597               FROM alias
   598               FROM alias
   598              WHERE gid = did
   599              WHERE gid = did
   599                AND address = localpart
   600                AND address = localpart
   600             LOOP
   601             LOOP
   601                 RETURN NEXT record;
   602                 RETURN NEXT record;
   609             -- over mailboxes/relocated, which is not what we want. Therefore,
   610             -- over mailboxes/relocated, which is not what we want. Therefore,
   610             -- we must first find out if the query is for an existing mailbox
   611             -- we must first find out if the query is for an existing mailbox
   611             -- or relocated entry and return the identity mapping if that is
   612             -- or relocated entry and return the identity mapping if that is
   612             -- the case
   613             -- the case
   613             OPEN catchall_cursor FOR
   614             OPEN catchall_cursor FOR
   614                 SELECT recipient,
   615                 SELECT recipient, idestination
   615                     _interpolate_destination(destination, localpart, the_domain)
       
   616                   FROM catchall
   616                   FROM catchall
   617                  WHERE gid = did;
   617                  WHERE gid = did;
   618             FETCH NEXT FROM catchall_cursor INTO recordc;
   618             FETCH NEXT FROM catchall_cursor INTO recordc;
   619 
   619 
   620             IF recordc IS NOT NULL THEN
   620             IF recordc IS NOT NULL THEN