Skip to content

Commit d81550a

Browse files
committed
Improve todo notes
1 parent cbfc2c4 commit d81550a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

todo.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,16 @@ This section summarizes potential improvements and features adapted from the `pe
7777
### From `periods` extension:
7878

7979
- [ ] **Implement System Versioning (with C triggers):** `periods` contains a complete implementation of `SYSTEM VERSIONING`, including history tables, C-based triggers (`generated_always_as_row_start_end`, `write_history`) for populating them, and helper functions (`_as_of`, `_between`, etc.). This is a major feature that `sql_saga` currently has commented-out stubs for.
80+
- **Comparison to Audit Frameworks (`pgaudit`):** System Versioning (as implemented in `periods`) and audit logging (`pgaudit`) are complementary, can be used together without conflict, and solve different problems.
81+
- **System Versioning** tracks the *state of the data* over time. It creates a complete, queryable history of every row, answering the question: "What did this record look like last year?" Its purpose is historical data analysis and reconstruction.
82+
- **Audit Frameworks (`pgaudit`)** track the *actions performed on the data*. They log the `INSERT`, `UPDATE`, `DELETE` statements themselves, answering the question: "Who deleted a record from this table yesterday?" Their purpose is security, compliance, and forensics.
83+
- **Combined Use Case:** For NSOs, using both provides a complete picture: `pgaudit` supplies the mandatory, unalterable log of *who made a change*, while System Versioning provides the queryable history of *what the data looked like* as a result of that change.
8084
- **Action:** Port the entire system versioning feature from `periods`. This includes:
8185
1. The `system_versioning` and `system_time_periods` metadata tables.
8286
2. The `add_system_versioning` and `drop_system_versioning` API functions.
8387
3. The C trigger functions from `periods.c` for high-performance history tracking.
88+
- **Design Constraints to Preserve:**
89+
- **History Tables are Not Temporal:** The `periods` implementation correctly prevents a history table from being a temporal table itself. This is a critical design choice that separates concerns: the main table handles "application time," while the history table tracks "system time" (the audit trail). This prevents circular dependencies and preserves the integrity of the history log.
8490

8591
- [x] **Enhance Event Trigger Logic:** `periods` has robust `drop_protection` and `rename_following` event triggers.
8692
- **Action:** Compared logic in `periods` with `sql_saga`'s event triggers. `sql_saga`'s logic is a correct subset of `periods`, and includes a performance optimization for `rename_following` that `periods` lacks. No further changes needed.

0 commit comments

Comments
 (0)