Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix UPDATE SET ... RETURNING processing for encrypted tuples
If `get_heap_tuple` is NULL, the core uses `copy_heap_tuple` instead. The former returns a pointer to a tuple in the slot and the latter makes a copy of such a tuple. For UPDATE SET, the core uses the slot for INSERT and later for RETURNING processing. If we copy the tuple the next happens: 1. The core creates a slot with the generic tuple. 2. It passed to `pg_tdeam_tuple_update()` and it gets a copy of the tuple here [https://github.com/Percona-Lab/pg_tde/blob/6d4f7e5b7bd2507ce65deb315ea8d5647f474cf9/src17/access/pg_tdeam_handler.c#L336]. 3. This generic tuple is filled with the proper data and used for the update here [https://github.com/Percona-Lab/pg_tde/blob/6d4f7e5b7bd2507ce65deb315ea8d5647f474cf9/src17/access/pg_tdeam_handler.c#L343]. 4. Later on, RETURNING processing uses the slot's tuple but is still a generic unmodified one because of the copy. 5. That results in wrong RETURNING data. To avoid this, we should return a pointer to the slot's tuple instead of copying it. Fixes PG-1056
- Loading branch information