-- Check the contents.jsgo field points to a valid URL.
-- This is triggered on rows inserted or updated in contents.
--- $Id: contents_jsgo_check_tg.sql,v 1.1 2006/07/26 11:07:06 rich Exp $
+-- $Id: contents_jsgo_check_tg.sql,v 1.2 2006/07/26 13:41:34 rich Exp $
create or replace function contents_jsgo_check_tg() returns trigger as '
select into my_count count(p.*)
from pages p
where p.hostid = my_hostid
- and p.url = new.jsgo;
+ and p.url is not null
+ and p.url = new.jsgo
+ and p.redirect is null;
if my_count < 1 then
raise exception ''contents.jsgo points to non-existent page (%, %)'',
my_hostid, new.jsgo;