aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-02-23 19:11:55 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-02-23 19:11:55 +0000
commit7b416c8c1a682ea1703d0e1da470a23c95f8124b (patch)
tree800856b890402750617f670d6d7f0e33383709aa /src
parente2f86a5c4591eeaf7cca8742a164aaed364a13a8 (diff)
downloadpostgresql-7b416c8c1a682ea1703d0e1da470a23c95f8124b.tar.gz
postgresql-7b416c8c1a682ea1703d0e1da470a23c95f8124b.zip
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')
-rw-r--r--src/backend/access/heap/tuptoaster.c5
-rw-r--r--src/include/c.h4
-rw-r--r--src/include/utils/inet.h4
3 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index ca49ec9d937..e729e77a54e 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.81 2008/01/01 19:45:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.81.2.1 2008/02/23 19:11:55 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -65,7 +65,8 @@
#define VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr) \
do { \
varattrib_1b_e *attre = (varattrib_1b_e *) (attr); \
- Assert(VARSIZE_ANY_EXHDR(attre) == sizeof(toast_pointer)); \
+ Assert(VARATT_IS_EXTERNAL(attre)); \
+ Assert(VARSIZE_EXTERNAL(attre) == sizeof(toast_pointer) + VARHDRSZ_EXTERNAL); \
memcpy(&(toast_pointer), VARDATA_EXTERNAL(attre), sizeof(toast_pointer)); \
} while (0)
diff --git a/src/include/c.h b/src/include/c.h
index b66006200f8..074411a3ba9 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.222.2.1 2008/02/23 19:11:55 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];
};
diff --git a/src/include/utils/inet.h b/src/include/utils/inet.h
index d102573f05f..5b7b619dc7e 100644
--- a/src/include/utils/inet.h
+++ b/src/include/utils/inet.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/inet.h,v 1.28 2008/01/01 19:45:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/inet.h,v 1.28.2.1 2008/02/23 19:11:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,7 +49,7 @@ typedef struct
*/
typedef struct
{
- int32 vl_len_; /* Do not touch this field directly! */
+ char vl_len_[4]; /* Do not touch this field directly! */
inet_struct inet_data;
} inet;