--- a/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Sun Apr 15 17:36:26 2012 +0200
+++ b/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Sun Apr 15 17:51:00 2012 +0200
@@ -496,9 +496,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