Skip to content

Commit

Permalink
adding some friendly comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranswhite committed Nov 1, 2024
1 parent 1683286 commit afd1230
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions versioning_function.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ BEGIN
HINT = 'history relation must contain system period column with the same name and data type as the versioned one';
END IF;

-- If we are not including the current version in the history, we need to check if the current version is valid
IF include_current_version_in_history <> 'true' THEN
EXECUTE format('SELECT $1.%I', sys_period) USING OLD INTO existing_range;

Expand Down Expand Up @@ -198,6 +199,7 @@ BEGIN
RETURN NEW;
END IF;
END IF;
-- If we are including the current version in the history and the operation is an update or delete, we need to update the previous version in the history table
IF include_current_version_in_history = 'true' THEN
IF TG_OP = 'UPDATE' OR TG_OP = 'DELETE' THEN
EXECUTE (
Expand All @@ -217,6 +219,7 @@ BEGIN
)
USING OLD, range_lower, time_stamp_to_use;
END IF;
-- If we are including the current version in the history and the operation is an insert or update, we need to insert the current version in the history table
IF TG_OP = 'UPDATE' OR TG_OP = 'INSERT' THEN
EXECUTE ('INSERT INTO ' ||
history_table ||
Expand Down

0 comments on commit afd1230

Please sign in to comment.