static TupleDesc ExecTypeFromTLInternal(List *targetList,
bool skipjunk);
static pg_attribute_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
- int reqnatts);
+ int reqnatts, bool support_cstring);
static inline void tts_buffer_heap_store_tuple(TupleTableSlot *slot,
HeapTuple tuple,
Buffer buffer,
Assert(!TTS_EMPTY(slot));
- slot_deform_heap_tuple(slot, hslot->tuple, &hslot->off, natts);
+ slot_deform_heap_tuple(slot, hslot->tuple, &hslot->off, natts, false);
}
static Datum
Assert(!TTS_EMPTY(slot));
- slot_deform_heap_tuple(slot, mslot->tuple, &mslot->off, natts);
+ slot_deform_heap_tuple(slot, mslot->tuple, &mslot->off, natts, true);
}
/*
Assert(!TTS_EMPTY(slot));
- slot_deform_heap_tuple(slot, bslot->base.tuple, &bslot->base.off, natts);
+ slot_deform_heap_tuple(slot, bslot->base.tuple, &bslot->base.off, natts, false);
}
static Datum
*
* This is marked as always inline, so the different offp for different types
* of slots gets optimized away.
+ *
+ * support_cstring should be passed as a const to allow the compiler only
+ * emit code during inlining for cstring deforming when it's required.
+ * cstrings can exist in MinimalTuples, but not in HeapTuples.
*/
static pg_attribute_always_inline void
slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
- int reqnatts)
+ int reqnatts, bool support_cstring)
{
CompactAttribute *cattrs;
CompactAttribute *cattr;
attlen = cattr->attlen;
/*
- * cstrings don't exist in heap tuples. Use pg_assume to instruct the
- * compiler not to emit the cstring-related code in
- * align_fetch_then_add().
+ * Only emit the cstring-related code in align_fetch_then_add() when
+ * cstring support is needed. We assume support_cstring will be
+ * passed as a const to allow the compiler to eliminate this branch.
*/
- pg_assume(attlen > 0 || attlen == -1);
+ if (!support_cstring)
+ pg_assume(attlen > 0 || attlen == -1);
/* align 'off', fetch the datum, and increment off beyond the datum */
values[attnum] = align_fetch_then_add(tp,
cattr = &cattrs[attnum];
attlen = cattr->attlen;
- /* As above, we don't expect cstrings */
- pg_assume(attlen > 0 || attlen == -1);
+ /* As above, only emit cstring code when needed. */
+ if (!support_cstring)
+ pg_assume(attlen > 0 || attlen == -1);
/* align 'off', fetch the datum, and increment off beyond the datum */
values[attnum] = align_fetch_then_add(tp,