$final_c_attr_test = 'EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source AND vis_attr_vector @@ c_attr.vis_test)';
if (!$pc_vis_test) { # staff search
- $final_c_attr_test = '(' . $final_c_attr_test . ' OR NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source))';
+ $final_c_attr_test = '(' . $final_c_attr_test . " OR (" .
+ "NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source) " .
+ "AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))".
+ "))";
}
}
# These are magic numbers... see: search.calculate_visibility_attribute() UDF
$final_b_attr_test = '(b_attr.vis_test IS NULL OR bre.vis_attr_vector @@ b_attr.vis_test)';
- if (!$pb_vis_test) { # staff search
- $final_b_attr_test .= " OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) )";
- }
}
if ($final_c_attr_test or $final_b_attr_test) { # something...
RETURN NEW;
ELSIF TG_OP = 'DELETE' THEN
DELETE FROM asset.copy_vis_attr_cache
- WHERE record = NEW.peer_record AND target_copy = NEW.target_copy;
+ WHERE record = OLD.peer_record AND target_copy = OLD.target_copy;
RETURN OLD;
END IF;