wal2json icon indicating copy to clipboard operation
wal2json copied to clipboard

Documentation on oldkeys

Open mijoharas opened this issue 3 years ago • 2 comments

Hey, Happy to provide a PR, just want to check it's wanted.

I couldn't find any description of what "oldkeys" was. Now I traced the code, and my understanding is that it's a description of the replica identity for the tuple that's the subject of the action (for updates and deletes). The replica identity should be the primary key in most cases (it gets slightly weird if pkeys change, which is why you have the pointer to the old tuple for that weird edge case).

This all makes sense, but can we document that that's what this means?

Let me know if you'd like this and if I have understood correctly and I'll happily raise a PR to add it to the readme.

(also, there's at least one place online that seems to use this plugin and have a different explanation of what this data means.)

mijoharas avatar Nov 25 '20 17:11 mijoharas

I tried to explain when old tuple is available here. Maybe it would be a good idea to clarify this behavior in the README. If I were to write this explanation, I would add a new section that explains what a replica identity is and provide details about each change (INSERT, UPDATE, DELETE) when you use different replica identity. I would also add a paragraph that explain the unchanged TOAST columns.

Feel free to submit a PR.

eulerto avatar Nov 25 '20 23:11 eulerto

I found that link useful to help understand what was going on in the code, that only told me when the oldtuple was available, but not really what oldkeys meant in the general case, (I wanted to be absolutely sure that it was always the replica identity, and had to trace more of the code than I'd care to admit to figure that out, I'm sure it's mostly just my unfamiliarity with this library).

I'll write the PR, but I'm not actually aware of the unchanged TOAST column stuff (I saw a couple of bools about that in the code, but I didn't actually follow them), so would appreciate a hand with that bit? in the meantime I'll put a small stub with a TODO for that.

Thanks again!

mijoharas avatar Nov 26 '20 10:11 mijoharas