mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
postgres_fdw: Clean up handling of system columns.
Previously, querying the xmin column of a single postgres_fdw foreign table fetched the tuple length, xmax the typmod, and cmin or cmax the composite type OID of the tuple. However, when you queried several such tables and the join got shipped to the remote side, these columns ended up containing the remote values of the corresponding columns. Both behaviors are rather unprincipled, the former for obvious reasons and the latter because the remote values of these columns don't have any local significance; our transaction IDs are in a different space than those of the remote machine. Clean this up by setting all of these fields to 0 in both cases. Also fix the handling of tableoid to be sane. Robert Haas and Ashutosh Bapat, reviewed by Etsuro Fujita.
This commit is contained in:
@ -4410,6 +4410,18 @@ make_tuple_from_result_row(PGresult *res,
|
||||
if (ctid)
|
||||
tuple->t_self = tuple->t_data->t_ctid = *ctid;
|
||||
|
||||
/*
|
||||
* Stomp on the xmin, xmax, and cmin fields from the tuple created by
|
||||
* heap_form_tuple. heap_form_tuple actually creates the tuple with
|
||||
* DatumTupleFields, not HeapTupleFields, but the executor expects
|
||||
* HeapTupleFields and will happily extract system columns on that
|
||||
* assumption. If we don't do this then, for example, the tuple length
|
||||
* ends up in the xmin field, which isn't what we want.
|
||||
*/
|
||||
HeapTupleHeaderSetXmax(tuple->t_data, InvalidTransactionId);
|
||||
HeapTupleHeaderSetXmin(tuple->t_data, InvalidTransactionId);
|
||||
HeapTupleHeaderSetCmin(tuple->t_data, InvalidTransactionId);
|
||||
|
||||
/* Clean up */
|
||||
MemoryContextReset(temp_context);
|
||||
|
||||
|
Reference in New Issue
Block a user