1997
1997
COMMENT ON FUNCTION message_copy_owner_to_bugmessage() IS
1998
'Copies the message owner into bugmessage whenmessage changes.';
1998
'Copies the message owner into bugmessage when message changes.';
2001
CREATE OR REPLACE FUNCTION questionmessage_copy_owner_from_message()
2002
RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path TO public AS
2005
IF TG_OP = 'INSERT' THEN
2006
IF NEW.owner is NULL THEN
2007
UPDATE QuestionMessage
2008
SET owner = Message.owner FROM
2010
Message.id = NEW.message AND
2011
QuestionMessage.id = NEW.id;
2013
ELSIF NEW.message != OLD.message THEN
2014
UPDATE QuestionMessage
2015
SET owner = Message.owner FROM
2017
Message.id = NEW.message AND
2018
QuestionMessage.id = NEW.id;
2020
RETURN NULL; -- Ignored - this is an AFTER trigger
2024
COMMENT ON FUNCTION questionmessage_copy_owner_from_message() IS
2025
'Copies the message owner into QuestionMessage when QuestionMessage changes.';
2027
CREATE OR REPLACE FUNCTION message_copy_owner_to_questionmessage()
2028
RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path TO public AS
2031
IF NEW.owner != OLD.owner THEN
2032
UPDATE QuestionMessage
2033
SET owner = NEW.owner
2035
QuestionMessage.message = NEW.id;
2037
RETURN NULL; -- Ignored - this is an AFTER trigger
2041
COMMENT ON FUNCTION message_copy_owner_to_questionmessage() IS
2042
'Copies the message owner into questionmessage when message changes.';
2001
2045
CREATE OR REPLACE FUNCTION bug_update_heat_copy_to_bugtask()