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

source-sqlserver: Detect updates which modify collection key and translate into paired delete/insert #2224

Open
willdonnelly opened this issue Dec 19, 2024 · 0 comments

Comments

@willdonnelly
Copy link
Member

willdonnelly commented Dec 19, 2024

For MySQL and PostgreSQL we have logic which detects CDC update events which modify the collection key of a document and translate that update into a paired delete of the old collection key and insert of the new row-state.

For SQL Server this logic is usually not necessary, because the source database already represents updates which modify the primary key of a table as a paired deletion and insert in the CDC change tables. Except, the collection key is not necessarily the same as the source database primary key, it just usually is because that's what we discover and make easy for users to set up automatically.

In the rare edge case where the user has explicitly set their collection key to something different from the source table's primary key, the behavior of SQL Server will be inconsistent with how MySQL or PostgreSQL captures handle the analogous scenario.

Fixing this would basically just require the same "compare preimage row key and postimage row key" logic that MySQL/PostgreSQL have, except that as of today SQL Server doesn't capture or even process update row preimages. So tackling this issue will require first addressing #2223 and then copying over the appropriate "encode row keys representing the preimage and postimage, then compare them" logic.

We have no plans to do this today, I'm just filing an issue so we have the context if this ever becomes necessary.

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

1 participant