Skip to content

Commit 5e495d6

Browse files
Andy Fanhackorum
authored andcommitted
Using more specific code when detoasting an expanded datum.
In the detoast_attr function, VARATT_IS_EXTERNAL_ONDISK and VARATT_IS_EXTERNAL_INDIRECT are checked first, and then VARATT_IS_EXTERNAL_EXPANDED is checked, However it is true, detoast_external_attr is called which would check the two cases again. The attached patch uses a more specific code to handle this.
1 parent feb1536 commit 5e495d6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/backend/access/common/detoast.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,15 @@ detoast_attr(varlena *attr)
161161
/*
162162
* This is an expanded-object pointer --- get flat format
163163
*/
164-
attr = detoast_external_attr(attr);
165-
/* flatteners are not allowed to produce compressed/short output */
166-
Assert(!VARATT_IS_EXTENDED(attr));
164+
ExpandedObjectHeader *eoh;
165+
Size resultsize;
166+
struct varlena *result;
167+
168+
eoh = DatumGetEOHP(PointerGetDatum(attr));
169+
resultsize = EOH_get_flat_size(eoh);
170+
result = (struct varlena *) palloc(resultsize);
171+
EOH_flatten_into(eoh, (void *) result, resultsize);
172+
attr = result;
167173
}
168174
else if (VARATT_IS_COMPRESSED(attr))
169175
{

0 commit comments

Comments
 (0)