# HG changeset patch
# User martin f. krafft <madduck@madduck.net>
# Date 1334504186 -7200
# Node ID 44a808af6cf40508a5e1d4e37454feebf3274188
# Parent  92ef34f07da3862592a608dc2583de7dcf32988b
Revert caching of destination interpolation

Since 'destination' comes from the table in the query, it cannot be cached
across queries! Doh!

diff -r 92ef34f07da3 -r 44a808af6cf4 pgsql/create_tables-dovecot-1.2.x.pgsql
--- a/pgsql/create_tables-dovecot-1.2.x.pgsql	Sun Apr 15 15:30:16 2012 +0000
+++ b/pgsql/create_tables-dovecot-1.2.x.pgsql	Sun Apr 15 17:36:26 2012 +0200
@@ -631,12 +631,11 @@
         record recipient_destination;
         catchall_cursor refcursor;
         recipient varchar(320) := localpart || '@' || the_domain;
-        idestination varchar(320) :=
-            _interpolate_destination(destination, localpart, the_domain);
         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
     BEGIN
         FOR record IN
-            SELECT recipient, idestination
+            SELECT recipient,
+                _interpolate_destination(destination, localpart, the_domain)
               FROM alias
              WHERE gid = did
                AND address = localpart
@@ -654,7 +653,8 @@
             -- or relocated entry and return the identity mapping if that is
             -- the case
             OPEN catchall_cursor FOR
-                SELECT recipient, idestination
+                SELECT recipient,
+                    _interpolate_destination(destination, localpart, the_domain)
                   FROM catchall
                  WHERE gid = did;
             FETCH NEXT FROM catchall_cursor INTO recordc;
diff -r 92ef34f07da3 -r 44a808af6cf4 pgsql/create_tables.pgsql
--- a/pgsql/create_tables.pgsql	Sun Apr 15 15:30:16 2012 +0000
+++ b/pgsql/create_tables.pgsql	Sun Apr 15 17:36:26 2012 +0200
@@ -609,12 +609,11 @@
         record recipient_destination;
         catchall_cursor refcursor;
         recipient varchar(320) := localpart || '@' || the_domain;
-        idestination varchar(320) :=
-            _interpolate_destination(destination, localpart, the_domain);
         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
     BEGIN
         FOR record IN
-            SELECT recipient, idestination
+            SELECT recipient,
+                _interpolate_destination(destination, localpart, the_domain)
               FROM alias
              WHERE gid = did
                AND address = localpart
@@ -632,7 +631,8 @@
             -- or relocated entry and return the identity mapping if that is
             -- the case
             OPEN catchall_cursor FOR
-                SELECT recipient, idestination
+                SELECT recipient,
+                    _interpolate_destination(destination, localpart, the_domain)
                   FROM catchall
                  WHERE gid = did;
             FETCH NEXT FROM catchall_cursor INTO recordc;
diff -r 92ef34f07da3 -r 44a808af6cf4 pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql
--- a/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql	Sun Apr 15 15:30:16 2012 +0000
+++ b/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql	Sun Apr 15 17:36:26 2012 +0200
@@ -551,12 +551,11 @@
         record recipient_destination;
         catchall_cursor refcursor;
         recipient varchar(320) := localpart || '@' || the_domain;
-        idestination varchar(320) :=
-            _interpolate_destination(destination, localpart, the_domain);
         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
     BEGIN
         FOR record IN
-            SELECT recipient, idestination
+            SELECT recipient,
+                _interpolate_destination(destination, localpart, the_domain)
               FROM alias
              WHERE gid = did
                AND address = localpart
@@ -574,7 +573,8 @@
             -- or relocated entry and return the identity mapping if that is
             -- the case
             OPEN catchall_cursor FOR
-                SELECT recipient, idestination
+                SELECT recipient,
+                    _interpolate_destination(destination, localpart, the_domain)
                   FROM catchall
                  WHERE gid = did;
             FETCH NEXT FROM catchall_cursor INTO recordc;
diff -r 92ef34f07da3 -r 44a808af6cf4 pgsql/update_tables_0.5.x-0.6.pgsql
--- a/pgsql/update_tables_0.5.x-0.6.pgsql	Sun Apr 15 15:30:16 2012 +0000
+++ b/pgsql/update_tables_0.5.x-0.6.pgsql	Sun Apr 15 17:36:26 2012 +0200
@@ -530,12 +530,11 @@
         record recipient_destination;
         catchall_cursor refcursor;
         recipient varchar(320) := localpart || '@' || the_domain;
-        idestination varchar(320) :=
-            _interpolate_destination(destination, localpart, the_domain);
         did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
     BEGIN
         FOR record IN
-            SELECT recipient, idestination
+            SELECT recipient,
+                _interpolate_destination(destination, localpart, the_domain)
               FROM alias
              WHERE gid = did
                AND address = localpart
@@ -553,7 +552,8 @@
             -- or relocated entry and return the identity mapping if that is
             -- the case
             OPEN catchall_cursor FOR
-                SELECT recipient, idestination
+                SELECT recipient,
+                    _interpolate_destination(destination, localpart, the_domain)
                   FROM catchall
                  WHERE gid = did;
             FETCH NEXT FROM catchall_cursor INTO recordc;