Comments (4)
I just found this and seem to have a similar requirement. I detailed it in an issue at arkhipov/temporal_tables#41
I have done as @paolochiodi said and inserted my initial data with the trigger disabled, but I also need to set sys_period
on UPDATEs to backfill my data (and the history table, through the trigger) so I can push multiple in-time snapshots without manually stitching a history table.
As to how the c version handles this currently: it ignores any data passed to the sys_period
column in an INSERT or UPDATE.
(Thanks @MHova for the PR code, I believe I can understand this enough to use as a starting point for a simple hackjob - unlike the c code. 👍 )
from temporal_tables.
Hi, thanks for getting in touch and sorry for the late reply.
I have three thoughts on this issue:
- A quick fix for your use case would be to attached the trigger after you ported the original data. The only thing the trigger versioning function does on inserts is to force the
sys_period
- Do you know what is the behaviour of the original c version in this situation? I'm inclined to respect its behaviour
- I'd prefer for
versioning()
to make sure we have a valid sys_period. If we want to include this functionality I'd haveversioning()
modified so that ifsys_period
is present in the originalinsert
it will check its validity (start should be in the past and end not defined), if not presetversioning()
will create it. This means that we can't support default values forsys_period
, but I don't see a real use case for that (please let me know if you have one)
from temporal_tables.
- That wouldn't work in my case because the original database is live and being continually updated by a live service. My plan is to setup the new database with the triggers, hook up the service to write to both databases, then run my migration to backfill all the old data. This will allow me to migrate the data without any gaps and without downtime.
- I don't know what the behavior of the original extension is. Honestly this is my first time doing any kind of in-depth work with an SQL database.
- Your suggestion makes sense 👍. Let me see if I can modify
versioning()
to do this. I don't see a sane use case for supporting default values either.
from temporal_tables.
I'm going to close this, as I'm not convinced about this feature. The use case described can be achieved through populating the tables before adding the versioning trigger (or by temporarily disabling it).
On the other side, I'm afraid giving the user this option may result in unexpected errors and inconsistencies in the history table. I'd prefer to keep the sys_period
value under the sole control of the versioning function.
(plus, this is super old)
I'm open to revisit this decision if a new valid use case arise and/or the original extension also adds this feature.
from temporal_tables.
Related Issues (20)
- Some updates are not recorded HOT 2
- Execute functioning version procedure script with C# HOT 2
- does not work for table names with CamelCase HOT 2
- Lagging behind HOT 1
- Not working with RDS Postgres 11.5 HOT 1
- PL/pgSQL function public.versioning() line 87 at RAISE HOT 2
- Updates Not Recorded When Long Running Transactions Are Open HOT 6
- Allow user-defined timestamps HOT 1
- Questions: how deal with related table HOT 1
- set_system_time is not supported HOT 6
- Trigger not working if table contains column with non-equality type HOT 6
- Check for rows updated in the same transaction checks for all the transactions in the instance HOT 14
- add release workflow and dependabot HOT 1
- Info - Old extension is alive! HOT 1
- Can we get the old value and new value in the history tables ? HOT 1
- ignore_unchanged_values=false does not work HOT 3
- Generated Columns HOT 1
- Clean-up readme and include list of different cloud providers
- Ignore inserts without actual change
- Add support to add user name HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from temporal_tables.