]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Change the declaration of struct varlena so that the length word is
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 Feb 2008 19:11:55 +0000 (19:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 Feb 2008 19:11:55 +0000 (19:11 +0000)
commit7b416c8c1a682ea1703d0e1da470a23c95f8124b
tree800856b890402750617f670d6d7f0e33383709aa
parente2f86a5c4591eeaf7cca8742a164aaed364a13a8
Change the declaration of struct varlena so that the length word is
represented as "char ...[4]" not "int32".  Since the length word is never
supposed to be accessed via this struct member anyway, this won't break
any existing code that is following the rules.  The advantage is that C
compilers will no longer assume that a pointer to struct varlena is
word-aligned, which prevents incorrect optimizations in TOAST-pointer
access and perhaps other places.  gcc doesn't seem to do this (at least
not at -O2), but the problem is demonstrable on some other compilers.

I changed struct inet as well, but didn't bother to touch a lot of other
struct definitions in which it wouldn't make any difference because there
were other fields forcing int alignment anyway.  Hopefully none of those
struct definitions are used for accessing unaligned Datums.
doc/src/sgml/xtypes.sgml
src/backend/access/heap/tuptoaster.c
src/include/c.h
src/include/utils/inet.h