postgresql/src/backend
Tom Lane 3f902354b0 Clean up after insufficiently-researched optimization of tuple conversions.
tupconvert.c's functions formerly considered that an explicit tuple
conversion was necessary if the input and output tupdescs contained
different type OIDs.  The point of that was to make sure that a composite
datum resulting from the conversion would contain the destination rowtype
OID in its composite-datum header.  However, commit 3838074f8 entirely
misunderstood what that check was for, thinking that it had something to do
with presence or absence of an OID column within the tuple.  Removal of the
check broke the no-op conversion path in ExecEvalConvertRowtype, as
reported by Ashutosh Bapat.

It turns out that of the dozen or so call sites for tupconvert.c functions,
ExecEvalConvertRowtype is the only one that cares about the composite-datum
header fields in the output tuple.  In all the rest, we'd much rather avoid
an unnecessary conversion whenever the tuples are physically compatible.
Moreover, the comments in tupconvert.c only promise physical compatibility
not a metadata match.  So, let's accept the removal of the guarantee about
the output tuple's rowtype marking, recognizing that this is a API change
that could conceivably break third-party callers of tupconvert.c.  (So,
let's remember to mention it in the v10 release notes.)

However, commit 3838074f8 did have a bit of a point here, in that two
tuples mustn't be considered physically compatible if one has HEAP_HASOID
set and the other doesn't.  (Some of the callers of tupconvert.c might not
really care about that, but we can't assume it in general.)  The previous
check accidentally covered that issue, because no RECORD types ever have
OIDs, while if two tupdescs have the same named composite type OID then,
a fortiori, they have the same tdhasoid setting.  If we're removing the
type OID match check then we'd better include tdhasoid match as part of
the physical compatibility check.

Without that hack in tupconvert.c, we need ExecEvalConvertRowtype to take
responsibility for inserting the correct rowtype OID label whenever
tupconvert.c decides it need not do anything.  This is easily done with
heap_copy_tuple_as_datum, which will be considerably faster than a tuple
disassembly and reassembly anyway; so from a performance standpoint this
change is a win all around compared to what happened in earlier branches.
It just means a couple more lines of code in ExecEvalConvertRowtype.

Ashutosh Bapat and Tom Lane

Discussion: https://postgr.es/m/CAFjFpRfvHABV6+oVvGcshF8rHn+1LfRUhj7Jz1CDZ4gPUwehBg@mail.gmail.com
2017-04-06 21:10:20 -04:00
..
access Clean up after insufficiently-researched optimization of tuple conversions. 2017-04-06 21:10:20 -04:00
bootstrap Cast result of copyObject() to correct type 2017-03-28 21:59:23 -04:00
catalog Mark immutable functions in information schema as parallel safe 2017-04-06 14:30:13 -04:00
commands Fix compiler warning and add some more comments 2017-04-06 11:18:13 -04:00
executor Clean up after insufficiently-researched optimization of tuple conversions. 2017-04-06 21:10:20 -04:00
foreign Abstract logic to allow for multiple kinds of child rels. 2017-04-03 22:41:31 -04:00
lib Support hashed aggregation with grouping sets. 2017-03-27 04:20:54 +01:00
libpq Remove bogus SCRAM_ITERATION_LEN constant. 2017-04-06 17:41:48 +03:00
main Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
nodes Identity columns 2017-04-06 08:41:37 -04:00
optimizer Reset API of clause_selectivity() 2017-04-06 19:10:51 -04:00
parser Fix the RTE_NAMEDTUPLESTORE case in get_rte_attribute_is_dropped(). 2017-04-06 17:32:53 -05:00
po Translation updates 2016-08-08 11:08:00 -04:00
port Fix WaitEventSetWait() to handle write-ready waits properly on Windows. 2017-03-17 14:58:06 -04:00
postmaster BRIN auto-summarization 2017-04-01 14:00:53 -03:00
regex ICU support 2017-03-23 15:28:48 -04:00
replication Fix logical replication between different encodings 2017-04-06 14:41:09 -04:00
rewrite Identity columns 2017-04-06 08:41:37 -04:00
snowball Add ICU_FLAGS to one more place 2017-03-23 16:53:10 -04:00
statistics Reset API of clause_selectivity() 2017-04-06 19:10:51 -04:00
storage Update comment. 2017-04-03 23:07:31 -04:00
tcop Remove dead code and fix comments in fast-path function handling. 2017-04-06 09:09:39 +03:00
tsearch Full Text Search support for json and jsonb 2017-03-31 14:26:03 -04:00
utils Reset API of clause_selectivity() 2017-04-06 19:10:51 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk ICU support 2017-03-23 15:28:48 -04:00
Makefile Implement multivariate n-distinct coefficients 2017-03-24 14:06:10 -03:00
nls.mk Remove trailing slashes from directories in find command 2015-09-18 22:06:54 -04:00