]> granicus.if.org Git - postgresql/commit
Fix datumSerialize infrastructure to not crash on non-varlena data.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 8 Aug 2017 23:18:12 +0000 (19:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 8 Aug 2017 23:18:23 +0000 (19:18 -0400)
commitfe578cbd4b4262496d44cb5cd110eae3c4aff48c
tree24ac7209ce46f0fc9cc654de4c9dc6d9b6e0b19f
parent1924ef41668773ad62d845eebc11ff35f17446ad
Fix datumSerialize infrastructure to not crash on non-varlena data.

Commit 1efc7e538 did a poor job of emulating existing logic for touching
Datums that might be expanded-object pointers.  It didn't check for typlen
being -1 first, which meant it could crash on fixed-length pass-by-ref
values, and probably on cstring values as well.  It also didn't use
DatumGetPointer before VARATT_IS_EXTERNAL_EXPANDED, which while currently
harmless is not according to documentation nor prevailing style.

I also think the lack of any explanation as to why datumSerialize makes
these particular nonobvious choices is pretty awful, so fix that.

Per report from Jarred Ward.  Back-patch to 9.6 where this code came in.

Discussion: https://postgr.es/m/6F61E6D2-2F5E-4794-9479-A429BE1CEA4B@simple.com
src/backend/utils/adt/datum.c