I think though that one distinction is that immutability in this case requires cooperation from the client, a commitment not to modify existing records. As compare to the database enforcing it.
I think though that one distinction is that immutability in this case requires cooperation from the client, a commitment not to modify existing records. As compare to the database enforcing it.
The timestamp for a tuple was returned by reads, so when a client wanted to update/delete a tuple, the service functions all required the client to provide the timestamp from the client read. If that timestamp argument wasn't the most recent, the client had to deal with that. But the actual database insert would fail.
Importantly, this particular service had only a few internal clients who almost 100% "owned" the tuples the client worked with. So there wasn't a lot of contention for any specific tuple by multiple clients.
Oh! I haven't seen this pattern in a long time - not since I worked on Oracle Application Express apps. In a cousin comment I noted that the bulk of app developers don't think about how to use the database to their advantage.
EDIT: Oracle has append-only tables, and can also use "blockchain" to verify integrity. See the IMMUTABLE option on CREATE TABLE[0]. PostgreSQL doesn't appear to have append-only tables, so using security and/or triggers seems to be the only option there.
[0] https://docs.oracle.com/en/database/oracle/oracle-database/2...
I'm not sure if any ORMs actually support this though.
And without the ORM layer there's this extension for Postgres: https://github.com/hettie-d/pg_bitemporal
https://github.com/codr7/hostr/blob/532295b40dcad6c54082e1d3...
SELECT ... AS OF <timestamp or logical clock time>
So you can query the database as of any point in the past, making manual work to implement the same feature with custom columns redundant.Oracle can also show you a record of transactions made and what SQL to run to undo them, including dependency tracking between transactions.