Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include-pk can't work with identity full? #273

Closed
yichao-figma opened this issue Oct 31, 2023 · 2 comments
Closed

include-pk can't work with identity full? #273

yichao-figma opened this issue Oct 31, 2023 · 2 comments

Comments

@yichao-figma
Copy link

Context:

  • We need replica identity = full because we need to get the full record value (all columns) even for partial update
  • We also would like to use include-pk option to get the primary key

However we noticed that these two does NOT work together starting from wal2json v2.5 (It was working on v2.3). Looking at the history, I noticed this commit made the behavioral change: 8139a6d From this change it seems that include-pk only works when identity = default. Though it's not very clear from the commit description regarding why this limitation was added.

cc @eulerto please let me know if my understanding is incorrect and / or if there are ways to have both "identity = full" and primary key.

@eulerto
Copy link
Owner

eulerto commented Dec 8, 2023

@yichao-figma Sorry about the late reaction. Are you using format 1, right? I can reproduce it with the following test case.

 INSERT INTO w2j_rename_ri (g, b, c, f, e) VALUES(790, '2020-04-04 10:34:55', 'Myrmecophaga tridactyla', false, 1.8);
 UPDATE w2j_rename_ri SET e = 3.1415 WHERE g = 456;
 COMMIT;
+ALTER TABLE w2j_rename_pk REPLICA IDENTITY FULL;
+INSERT INTO w2j_rename_pk (g, b, c, f, e) VALUES(890, '2023-10-31 03:06:00', 'Crypturellus parvirostris', true, 8.90);
+UPDATE w2j_rename_pk SET e = 8.91 WHERE g = 890;
+DELETE FROM w2j_rename_pk WHERE g = 890;
 SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0', 'include-pk', '1');

@yichao-figma
Copy link
Author

yichao-figma commented Apr 12, 2024

Sorry for the slow reply.

Yes the original format.

I looked into the implementation by searching include_pk in the code, almost all of them come with && relation->rd_rel->relreplident == REPLICA_IDENTITY_DEFAULT (example), which aligns with our observation (that include_pk only works with RI=Default)

In the repro you had above, it doesn't seem there's evidence that it's producing the pk info, but just whether the option is enabled? Correct me if I misread.

Also I saw you mentioned a potential fix for this thread - do you mind elaborate what fix are you thinking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants