Skip site navigation (1) Skip section navigation (2)

pgsql: Change the declaration of struct varlena so that the length word

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Change the declaration of struct varlena so that the length word
Date: 2008-02-23 19:11:55
Message-ID: 20080223191155.3511D754108@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
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.

Tags:
----
REL8_3_STABLE

Modified Files:
--------------
    pgsql/doc/src/sgml:
        xtypes.sgml (r1.29 -> r1.29.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/xtypes.sgml?r1=1.29&r2=1.29.2.1)
    pgsql/src/backend/access/heap:
        tuptoaster.c (r1.81 -> r1.81.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/heap/tuptoaster.c?r1=1.81&r2=1.81.2.1)
    pgsql/src/include:
        c.h (r1.222 -> r1.222.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/c.h?r1=1.222&r2=1.222.2.1)
    pgsql/src/include/utils:
        inet.h (r1.28 -> r1.28.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/inet.h?r1=1.28&r2=1.28.2.1)

pgsql-committers by date

Next:From: Tom LaneDate: 2008-02-23 19:23:33
Subject: pgsql: Avoid trying to print a NULL char pointer in --describe-config.
Previous:From: Tom LaneDate: 2008-02-23 19:11:45
Subject: pgsql: Change the declaration of struct varlena so that the length word

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group