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

UPDATE statement broken after PR67 #68

Closed
codeforall opened this issue Nov 13, 2023 · 0 comments · Fixed by #69
Closed

UPDATE statement broken after PR67 #68

codeforall opened this issue Nov 13, 2023 · 0 comments · Fixed by #69
Labels
bug Something isn't working

Comments

@codeforall
Copy link
Collaborator

After 67, UPDATE statement adds new rows instead of updating the previous ones


DROP TABLE IF EXISTS test_update;
CREATE TABLE test_update ( a int) using pg_tde;
INSERT INTO test_update VALUES (1), (2),(3), (4);
SELECT * from test_update;
UPDATE test_update SET a = a + 1;
--Expecting 4 rows
SELECT * from test_update;
 a 
---
 1
 2
 3
 4
 2
 3
 4
 5
(8 rows)

@codeforall codeforall added the bug Something isn't working label Nov 13, 2023
dutow added a commit to dutow/postgres-tde-ext that referenced this issue Nov 13, 2023
Issue: with the fix in Percona-Lab#67, pgtde decrypts tuples during update into
a new memory region, and changes the t_data pointer to this new region.

Because of this, later updates to tuple flags also happen in the new
data, and the original persisted tuple flags are never updated.

Fix: after the update statement is done with the decrypted data,
restore the t_data pointer to the original. This way, flag changes
happen where they should.

Fixes Percona-Lab#68
dutow added a commit to dutow/postgres-tde-ext that referenced this issue Nov 13, 2023
Issue: with the fix in Percona-Lab#67, pgtde decrypts tuples during update into
a new memory region, and changes the t_data pointer to this new region.

Because of this, later updates to tuple flags also happen in the new
data, and the original persisted tuple flags are never updated.

Fix: after the update statement is done with the decrypted data,
restore the t_data pointer to the original. This way, flag changes
happen where they should.

Fixes Percona-Lab#68
@dutow dutow closed this as completed in #69 Nov 15, 2023
dutow added a commit that referenced this issue Nov 15, 2023
Issue: with the fix in #67, pgtde decrypts tuples during update into
a new memory region, and changes the t_data pointer to this new region.

Because of this, later updates to tuple flags also happen in the new
data, and the original persisted tuple flags are never updated.

Fix: after the update statement is done with the decrypted data,
restore the t_data pointer to the original. This way, flag changes
happen where they should.

Fixes #68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant