Hello team, I'm not very knowledgeable on trigger writing, but follow attached a patch which fixes the trigger rhn_channel_mod_trig updating the field last_modified only when some new package or change are made into channel.
Please, check the complete error description and tests at BZ#753021. Thank you. Best Regards, mmello -- Marcelo Moreira de Mello RHCA RHCSS RHCVA Senior Software Maintenance Engineer/SEG gpg id: 2048R/FDB110E5 gpg fingerprint: 3BE7 EF71 4DD7 6812 D309 8F18 BD42 D095 FDB1 10E5
From: Marcelo Moreira de Mello <mme...@redhat.com> Date: Fri, 11 Nov 2011 14:52:46 -0200 Subject: [PATCH] 753021 - fixed spacewalk-repo-sync updates last_modified even if no new packages to download --- schema/spacewalk/oracle/triggers/rhnChannel.sql | 4 +++- schema/spacewalk/postgres/triggers/rhnChannel.sql | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/schema/spacewalk/oracle/triggers/rhnChannel.sql b/schema/spacewalk/oracle/triggers/rhnChannel.sql index 3a357fa..58ef396 100644 --- a/schema/spacewalk/oracle/triggers/rhnChannel.sql +++ b/schema/spacewalk/oracle/triggers/rhnChannel.sql @@ -21,7 +21,9 @@ rhn_channel_mod_trig before insert or update on rhnChannel for each row begin - :new.last_modified := sysdate; + if inserting then + :new.last_modified := sysdate; + end if; -- this is a really bad way of saying "if all we''re -- changing is the date" if updating then diff --git a/schema/spacewalk/postgres/triggers/rhnChannel.sql b/schema/spacewalk/postgres/triggers/rhnChannel.sql index 4dfe71d..864a1f0 100644 --- a/schema/spacewalk/postgres/triggers/rhnChannel.sql +++ b/schema/spacewalk/postgres/triggers/rhnChannel.sql @@ -21,9 +21,11 @@ create or replace function rhn_channel_mod_trig_fun() returns trigger as $$ begin - new.last_modified := current_timestamp; + if tg_op='INSERT' then + new.last_modified := current_timestamp; + end if; -- this is a really bad way of saying "if all we''re - -- changing is the date" + -- changing is the date" if tg_op='UPDATE' then if (old.id is distinct from new.id) or (old.parent_channel is distinct from new.parent_channel) or -- 1.7.7.1
_______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel