diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-24 15:00:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-24 15:00:47 +0000 |
commit | 976246cc7e4d8b673fc62fe6daa61c76d94af1af (patch) | |
tree | b61ea3f5bbd8fa025587754bc90c3fd43889337c /src/include/access/tupmacs.h | |
parent | cf4d885c67744637d82f6fec657e8205578c5905 (diff) | |
download | postgresql-976246cc7e4d8b673fc62fe6daa61c76d94af1af.tar.gz postgresql-976246cc7e4d8b673fc62fe6daa61c76d94af1af.zip |
The cstring datatype can now be copied, passed around, etc. The typlen
value '-2' is used to indicate a variable-width type whose width is
computed as strlen(datum)+1. Everything that looks at typlen is updated
except for array support, which Joe Conway is working on; at the moment
it wouldn't work to try to create an array of cstring.
Diffstat (limited to 'src/include/access/tupmacs.h')
-rw-r--r-- | src/include/access/tupmacs.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h index 02c5f261580..b2bab69b810 100644 --- a/src/include/access/tupmacs.h +++ b/src/include/access/tupmacs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tupmacs.h,v 1.21 2002/06/20 20:29:43 momjian Exp $ + * $Id: tupmacs.h,v 1.22 2002/08/24 15:00:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -93,12 +93,11 @@ #endif /* SIZEOF_DATUM == 8 */ /* - * att_align aligns the given offset as needed for a datum of length attlen - * and alignment requirement attalign. In practice we don't need the length. - * The attalign cases are tested in what is hopefully something like their - * frequency of occurrence. + * att_align aligns the given offset as needed for a datum of alignment + * requirement attalign. The cases are tested in what is hopefully something + * like their frequency of occurrence. */ -#define att_align(cur_offset, attlen, attalign) \ +#define att_align(cur_offset, attalign) \ ( \ ((attalign) == 'i') ? INTALIGN(cur_offset) : \ (((attalign) == 'c') ? ((long)(cur_offset)) : \ @@ -111,18 +110,23 @@ /* * att_addlength increments the given offset by the length of the attribute. - * attval is only accessed if we are dealing with a varlena attribute. + * attval is only accessed if we are dealing with a variable-length attribute. */ #define att_addlength(cur_offset, attlen, attval) \ ( \ - ((attlen) != -1) ? \ + ((attlen) > 0) ? \ ( \ (cur_offset) + (attlen) \ ) \ - : \ + : (((attlen) == -1) ? \ ( \ (cur_offset) + VARATT_SIZE(DatumGetPointer(attval)) \ ) \ + : \ + ( \ + AssertMacro((attlen) == -2), \ + (cur_offset) + (strlen(DatumGetCString(attval)) + 1) \ + )) \ ) /* |