-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RHINENG-9028: fix comparison of yum_updates
digest can't be used because the json contains map which doesn't remain sorted in DB add yum_checksum which is calculated from marshaled json (marshaling maintains the same key order for structs and maps)
- Loading branch information
Showing
5 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE OR REPLACE FUNCTION check_unchanged() | ||
RETURNS TRIGGER AS | ||
$check_unchanged$ | ||
BEGIN | ||
IF (TG_OP = 'INSERT') AND | ||
NEW.unchanged_since IS NULL THEN | ||
NEW.unchanged_since := CURRENT_TIMESTAMP; | ||
END IF; | ||
IF (TG_OP = 'UPDATE') AND | ||
(NEW.json_checksum <> OLD.json_checksum OR NEW.yum_updates <> OLD.yum_updates) THEN | ||
NEW.unchanged_since := CURRENT_TIMESTAMP; | ||
END IF; | ||
RETURN NEW; | ||
END; | ||
$check_unchanged$ | ||
LANGUAGE 'plpgsql'; | ||
|
||
|
||
ALTER TABLE system_platform DROP COLUMN IF EXISTS yum_checksum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ALTER TABLE system_platform ADD COLUMN IF NOT EXISTS yum_checksum TEXT CHECK (NOT empty(yum_checksum)); | ||
|
||
CREATE OR REPLACE FUNCTION check_unchanged() | ||
RETURNS TRIGGER AS | ||
$check_unchanged$ | ||
BEGIN | ||
IF (TG_OP = 'INSERT') AND | ||
NEW.unchanged_since IS NULL THEN | ||
NEW.unchanged_since := CURRENT_TIMESTAMP; | ||
END IF; | ||
IF (TG_OP = 'UPDATE') AND | ||
(NEW.json_checksum <> OLD.json_checksum OR NEW.yum_checksum <> OLD.yum_checksum) THEN | ||
NEW.unchanged_since := CURRENT_TIMESTAMP; | ||
END IF; | ||
RETURN NEW; | ||
END; | ||
$check_unchanged$ | ||
LANGUAGE 'plpgsql'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters