diff options
author | Bruce Momjian <bruce@momjian.us> | 2007-05-15 17:39:54 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2007-05-15 17:39:54 +0000 |
commit | 178214d2ae46b1b1a67b168b510a224881f60efd (patch) | |
tree | 7356fbab0f5623187d26e182f95b8aeb30333f76 /src/include/postgres.h | |
parent | 39712d1184f184ee348e701ca794fdf8d6a51510 (diff) | |
download | postgresql-178214d2ae46b1b1a67b168b510a224881f60efd.tar.gz postgresql-178214d2ae46b1b1a67b168b510a224881f60efd.zip |
Update comments for PG_DETOAST_PACKED and VARDATA_ANY on a structures
that require alignment.
Add a paragraph to the "User-Defined Types" chapter on using these
macros since it seems like they're a hit.
Gregory Stark
Diffstat (limited to 'src/include/postgres.h')
-rw-r--r-- | src/include/postgres.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/include/postgres.h b/src/include/postgres.h index 27c21e2bcc8..3f65d646312 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1995, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/postgres.h,v 1.80 2007/05/04 02:01:02 tgl Exp $ + * $PostgreSQL: pgsql/src/include/postgres.h,v 1.81 2007/05/15 17:39:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -235,6 +235,12 @@ typedef struct * use VARSIZE_ANY/VARSIZE_ANY_EXHDR/VARDATA_ANY. The other macros here * should usually be used only by tuple assembly/disassembly code and * code that specifically wants to work with still-toasted Datums. + * + * WARNING: It is only safe to use VARDATA_ANY() -- typically with + * PG_DETOAST_DATUM_UNPACKED() -- if you really don't care about the alignment. + * Either because you're working with something like text where the alignment + * doesn't matter or because you're not going to access its constituent parts + * and just use things like memcpy on it anyways. */ #define VARDATA(PTR) VARDATA_4B(PTR) #define VARSIZE(PTR) VARSIZE_4B(PTR) @@ -265,6 +271,7 @@ typedef struct VARSIZE_4B(PTR)-4)) /* caution: this will not work on an external or compressed-in-line Datum */ +/* caution: this will return a possibly unaligned pointer */ #define VARDATA_ANY(PTR) \ (VARATT_IS_1B(PTR) ? VARDATA_1B(PTR) : VARDATA_4B(PTR)) |