summaryrefslogtreecommitdiff
path: root/src/include/c.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-02-23 19:11:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-02-23 19:11:45 +0000
commit9713c063191099a29b6e1762b2b8e24ad4a95a83 (patch)
treee71087e67f97dd668b3c6136e09a78af4756e4b2 /src/include/c.h
parent870993e8717f928437dfb466901a135c63686905 (diff)
downloadpostgresql-9713c063191099a29b6e1762b2b8e24ad4a95a83.tar.gz
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.
Diffstat (limited to 'src/include/c.h')
-rw-r--r--src/include/c.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/c.h b/src/include/c.h
index b66006200f..07a29d9cdf 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/c.h,v 1.222 2008/01/01 19:45:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.223 2008/02/23 19:11:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -410,7 +410,7 @@ typedef struct
*/
struct varlena
{
- int32 vl_len_; /* Do not touch this field directly! */
+ char vl_len_[4]; /* Do not touch this field directly! */
char vl_dat[1];
};