function return type for triggers in postgresql 8.0 rc2
От | PEDRO LOPEZ |
---|---|
Тема | function return type for triggers in postgresql 8.0 rc2 |
Дата | |
Msg-id | web-1898811@be-2.cluster1.bresnan.net обсуждение исходный текст |
Ответы |
Re: function return type for triggers in postgresql 8.0 rc2
|
Список | pgsql-bugs |
I am porting an existing database to postgresql and am translating some triggers. I have the following objects: A table named 'currentstatus' a function which I orignally defined as: CREATE OR REPLACE FUNCTION "CurrentStatus_DTrigx"() RETURNS opaque AS $BODY$ Begin if (select COUNT(*) FROM deleted, Stations WHERE deleted.CurrentStatusCode = Stations.CurrentStatusCode) > 0 then RAISE EXCEPTION 'RAISERROR(778501, 16, 1)'; ROLLBACK TRANSACTION; end if; END $BODY$ LANGUAGE 'plpgsql' VOLATILE; a trigger I defined as: create trigger csd before delete on currentstatus for each row execute procedure public.CurrentStatus_DTrig() after struggling with 'function not defined errors', and unable to see what was wrong I redefined the function as: CREATE OR REPLACE FUNCTION currentstatus_dtrig() RETURNS opaque AS $BODY$ Begin if (select COUNT(*) FROM deleted, Stations WHERE deleted.CurrentStatusCode = Stations.CurrentStatusCode) > 0 then RAISE EXCEPTION 'RAISERROR(778501, 16, 1)'; ROLLBACK TRANSACTION; end if; END $BODY$ LANGUAGE 'plpgsql' VOLATILE; and got the message to the effect of 'redefining return type as trigger', and the following function was created: -- Function: currentstatus_dtrig() -- DROP FUNCTION currentstatus_dtrig(); CREATE OR REPLACE FUNCTION currentstatus_dtrig() RETURNS "trigger" AS $BODY$ Begin if (select COUNT(*) FROM deleted, Stations WHERE deleted.CurrentStatusCode = Stations.CurrentStatusCode) > 0 then RAISE EXCEPTION 'RAISERROR(778501, 16, 1)'; ROLLBACK TRANSACTION; end if; END $BODY$ LANGUAGE 'plpgsql' VOLATILE; ALTER FUNCTION currentstatus_dtrig() OWNER TO postgres; GRANT EXECUTE ON FUNCTION currentstatus_dtrig() TO public; GRANT EXECUTE ON FUNCTION currentstatus_dtrig() TO postgres; This is strange, AFAICT I followed the documentation setting up the trigger and functions (correct parameter signature and return type). Did I do something wrong or is this a RC2 issue? Thanks, Pedro Lopez
В списке pgsql-bugs по дате отправления: