From: David Rowley Date: Thu, 2 Apr 2026 01:11:17 +0000 (+1300) Subject: Fix nocachegetattr() so it again supports deforming cstrings X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=331d829e62dbb08112bb3a2c5770cd10ba0ffccb;p=thirdparty%2Fpostgresql.git Fix nocachegetattr() so it again supports deforming cstrings c456e3911 added various optimizations to the tuple deformation routines. One optimization assumed that heap tuples would never contain cstrings. That optimization also made its way into nocachegetattr(), which isn't correct as ROW() types get formed into HeapTuples by ExecEvalRow() and those can contain cstring Datums. nocachegetattr() gets used to extract Datums from those tuples. Here we remove the pg_assume(), which was there to instruct the compiler to omit the attlen == -2 related code in att_addlength_pointer(). Author: David Rowley Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/80aeac57-8f50-4732-a5b4-c2373c3f8149@gmail.com --- diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index dce97a162a5..f30346469ed 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -589,14 +589,6 @@ nocachegetattr(HeapTuple tup, cattr = TupleDescCompactAttr(tupleDesc, i); 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 - * att_addlength_pointer(). - */ - pg_assume(attlen > 0 || attlen == -1); - off = att_pointer_alignby(off, cattr->attalignby, attlen, @@ -613,10 +605,6 @@ nocachegetattr(HeapTuple tup, cattr = TupleDescCompactAttr(tupleDesc, i); attlen = cattr->attlen; - - /* As above, heaptuples have no cstrings */ - pg_assume(attlen > 0 || attlen == -1); - off = att_pointer_alignby(off, cattr->attalignby, attlen, tp + off); off = att_addlength_pointer(off, attlen, tp + off);