pgsql/create_tables-dovecot-1.2.x.pgsql
branchv0.6.x
changeset 550 867d950ce7b7
parent 549 44a808af6cf4
--- a/pgsql/create_tables-dovecot-1.2.x.pgsql	Sun Apr 15 17:36:26 2012 +0200
+++ b/pgsql/create_tables-dovecot-1.2.x.pgsql	Sun Apr 15 17:51:00 2012 +0200
@@ -571,9 +571,16 @@
         record recipient_transport;
         recipient varchar(320) := localpart || '@' || the_domain;
         did bigint := (SELECT gid FROM domain_name WHERE domainname = the_domain);
-        transport_id bigint := (SELECT tid FROM users
-                                  WHERE gid = did AND local_part = localpart);
+        transport_id bigint;
     BEGIN
+        IF did IS NULL THEN
+            RETURN;
+        END IF;
+
+        SELECT tid INTO transport_id
+          FROM users
+         WHERE gid = did AND local_part = localpart;
+
         IF transport_id IS NULL THEN
             SELECT tid INTO STRICT transport_id
               FROM domain_data