diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-04-15 11:58:56 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-04-15 12:08:14 -0400 |
commit | da7d44b627ba839de32c9409aca659f60324de76 (patch) | |
tree | de848f1342a4a69ac08f70fa0df83d50892352a6 /contrib/postgres_fdw/postgres_fdw.c | |
parent | 5702277ca97396384eaf5c58d582b79b9984ce73 (diff) | |
download | postgresql-da7d44b627ba839de32c9409aca659f60324de76.tar.gz postgresql-da7d44b627ba839de32c9409aca659f60324de76.zip |
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.
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.c')
-rw-r--r-- | contrib/postgres_fdw/postgres_fdw.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index ee0220a7f70..066cffba955 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -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); |