summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian1998-09-07 05:35:48 +0000
committerBruce Momjian1998-09-07 05:35:48 +0000
commit202751921d9a7adb0181bc0afd990a53e6015141 (patch)
tree44b62cb083afebf83339685b388132cce0f87298
parente15807f4103034f42963cef17e39028c1dba58f7 (diff)
Alignment cleanup so no more massive switch statements for alignment,
just two macros.
-rw-r--r--src/backend/access/common/heaptuple.c197
-rw-r--r--src/backend/access/common/indextuple.c79
-rw-r--r--src/backend/access/index/indexam.c8
-rw-r--r--src/backend/access/nbtree/nbtree.c4
-rw-r--r--src/backend/access/nbtree/nbtutils.c5
-rw-r--r--src/backend/catalog/index.c33
-rw-r--r--src/backend/catalog/indexing.c27
-rw-r--r--src/backend/commands/copy.c37
-rw-r--r--src/include/access/tupmacs.h51
-rw-r--r--src/include/utils/memutils.h5
10 files changed, 113 insertions, 333 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 97626420206..f7b53083e42 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.43 1998/09/04 18:21:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.44 1998/09/07 05:35:27 momjian Exp $
*
* NOTES
* The old interface functions have been converted to macros
@@ -68,44 +68,8 @@ ComputeDataSize(TupleDesc tupleDesc,
if (nulls[i] != ' ')
continue;
- switch (att[i]->attlen)
- {
- case -1:
-
- /*
- * This is the size of the disk representation and so must
- * include the additional sizeof long.
- */
- if (att[i]->attalign == 'd')
- {
- data_length = DOUBLEALIGN(data_length)
- + VARSIZE(DatumGetPointer(value[i]));
- }
- else
- {
- data_length = INTALIGN(data_length)
- + VARSIZE(DatumGetPointer(value[i]));
- }
- break;
- case sizeof(char):
- data_length++;
- break;
- case sizeof(short):
- data_length = SHORTALIGN(data_length + sizeof(short));
- break;
- case sizeof(int32):
- data_length = INTALIGN(data_length + sizeof(int32));
- break;
- default:
- if (att[i]->attlen < sizeof(int32))
- elog(ERROR, "ComputeDataSize: attribute %d has len %d",
- i, att[i]->attlen);
- if (att[i]->attalign == 'd')
- data_length = DOUBLEALIGN(data_length) + att[i]->attlen;
- else
- data_length = LONGALIGN(data_length) + att[i]->attlen;
- break;
- }
+ data_length = att_align(data_length, att[i]->attlen, att[i]->attalign);
+ data_length = att_addlength(data_length, att[i]->attlen, value[i]);
}
return data_length;
@@ -160,57 +124,34 @@ DataFill(char *data,
*bitP |= bitmask;
}
+ data = (char *)att_align((long)data, att[i]->attlen, att[i]->attalign);
switch (att[i]->attlen)
{
case -1:
*infomask |= HEAP_HASVARLENA;
- if (att[i]->attalign == 'd')
- data = (char *) DOUBLEALIGN(data);
- else
- data = (char *) INTALIGN(data);
data_length = VARSIZE(DatumGetPointer(value[i]));
memmove(data, DatumGetPointer(value[i]), data_length);
- data += data_length;
break;
case sizeof(char):
*data = att[i]->attbyval ?
DatumGetChar(value[i]) : *((char *) value[i]);
- data += sizeof(char);
break;
case sizeof(int16):
- data = (char *) SHORTALIGN(data);
*(short *) data = (att[i]->attbyval ?
DatumGetInt16(value[i]) :
*((short *) value[i]));
- data += sizeof(short);
break;
case sizeof(int32):
- data = (char *) INTALIGN(data);
*(int32 *) data = (att[i]->attbyval ?
DatumGetInt32(value[i]) :
*((int32 *) value[i]));
- data += sizeof(int32);
break;
default:
- if (att[i]->attlen < sizeof(int32))
- elog(ERROR, "DataFill: attribute %d has len %d",
- i, att[i]->attlen);
- if (att[i]->attalign == 'd')
- {
- data = (char *) DOUBLEALIGN(data);
- memmove(data, DatumGetPointer(value[i]),
- att[i]->attlen);
- data += att[i]->attlen;
- }
- else
- {
- data = (char *) LONGALIGN(data);
- memmove(data, DatumGetPointer(value[i]),
- att[i]->attlen);
- data += att[i]->attlen;
- }
+ memmove(data, DatumGetPointer(value[i]),
+ att[i]->attlen);
break;
}
+ data = (char *)att_addlength((long)data, att[i]->attlen, value[i]);
}
}
@@ -557,53 +498,11 @@ nocachegetattr(HeapTuple tup,
* Fix me when going to a machine with more than a four-byte
* word!
*/
-
- switch (att[j]->attlen)
- {
- case -1:
- off = (att[j]->attalign == 'd') ?
- DOUBLEALIGN(off) : INTALIGN(off);
- break;
- case sizeof(char):
- break;
- case sizeof(short):
- off = SHORTALIGN(off);
- break;
- case sizeof(int32):
- off = INTALIGN(off);
- break;
- default:
- if (att[j]->attlen > sizeof(int32))
- off = (att[j]->attalign == 'd') ?
- DOUBLEALIGN(off) : LONGALIGN(off);
- else
- elog(ERROR, "nocache_index_getattr: attribute %d has len %d",
- j, att[j]->attlen);
- break;
- }
+ off = att_align(off, att[j]->attlen, att[j]->attalign);
att[j]->attcacheoff = off;
- switch (att[j]->attlen)
- {
- case sizeof(char):
- off++;
- break;
- case sizeof(short):
- off += sizeof(short);
- break;
- case sizeof(int32):
- off += sizeof(int32);
- break;
- case -1:
- Assert(!VARLENA_FIXED_SIZE(att[j]) ||
- att[j]->atttypmod == VARSIZE(tp + off));
- off += VARSIZE(tp + off);
- break;
- default:
- off += att[j]->attlen;
- break;
- }
+ off = att_addlength(off, att[j]->attlen, tp + off);
}
return (Datum) fetchatt(&(att[attnum]), tp + att[attnum]->attcacheoff);
@@ -640,84 +539,20 @@ nocachegetattr(HeapTuple tup,
off = att[i]->attcacheoff;
else
{
- switch (att[i]->attlen)
- {
- case -1:
- off = (att[i]->attalign == 'd') ?
- DOUBLEALIGN(off) : INTALIGN(off);
- break;
- case sizeof(char):
- break;
- case sizeof(short):
- off = SHORTALIGN(off);
- break;
- case sizeof(int32):
- off = INTALIGN(off);
- break;
- default:
- if (att[i]->attlen < sizeof(int32))
- elog(ERROR,
- "nocachegetattr2: attribute %d has len %d",
- i, att[i]->attlen);
- if (att[i]->attalign == 'd')
- off = DOUBLEALIGN(off);
- else
- off = LONGALIGN(off);
- break;
- }
+ off = att_align(off, att[i]->attlen, att[i]->attalign);
+
if (usecache)
att[i]->attcacheoff = off;
}
- switch (att[i]->attlen)
- {
- case sizeof(char):
- off++;
- break;
- case sizeof(short):
- off += sizeof(short);
- break;
- case sizeof(int32):
- off += sizeof(int32);
- break;
- case -1:
- Assert(!VARLENA_FIXED_SIZE(att[i]) ||
- att[i]->atttypmod == VARSIZE(tp + off));
- off += VARSIZE(tp + off);
- if (!VARLENA_FIXED_SIZE(att[i]))
- usecache = false;
- break;
- default:
- off += att[i]->attlen;
- break;
- }
- }
+ off = att_addlength(off, att[i]->attlen, tp + off);
- switch (att[attnum]->attlen)
- {
- case -1:
- off = (att[attnum]->attalign == 'd') ?
- DOUBLEALIGN(off) : INTALIGN(off);
- break;
- case sizeof(char):
- break;
- case sizeof(short):
- off = SHORTALIGN(off);
- break;
- case sizeof(int32):
- off = INTALIGN(off);
- break;
- default:
- if (att[attnum]->attlen < sizeof(int32))
- elog(ERROR, "nocachegetattr3: attribute %d has len %d",
- attnum, att[attnum]->attlen);
- if (att[attnum]->attalign == 'd')
- off = DOUBLEALIGN(off);
- else
- off = LONGALIGN(off);
- break;
+ if (att[i]->attlen == -1 && !VARLENA_FIXED_SIZE(att[i]))
+ usecache = false;
}
+ off = att_align(off, att[attnum]->attlen, att[attnum]->attalign);
+
return (Datum) fetchatt(&(att[attnum]), tp + off);
}
}
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
index 370294a0bb4..e6154ba8cdd 100644
--- a/src/backend/access/common/indextuple.c
+++ b/src/backend/access/common/indextuple.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.31 1998/09/01 03:20:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.32 1998/09/07 05:35:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -300,30 +300,7 @@ nocache_index_getattr(IndexTuple tup,
* word!
*/
- switch (att[j]->attlen)
- {
- case -1:
- off = (att[j]->attalign == 'd') ?
- DOUBLEALIGN(off) : INTALIGN(off);
- break;
- case sizeof(char):
- break;
- case sizeof(short):
- off = SHORTALIGN(off);
- break;
- case sizeof(int32):
- off = INTALIGN(off);
- break;
- default:
- if (att[j]->attlen > sizeof(int32))
- off = (att[j]->attalign == 'd') ?
- DOUBLEALIGN(off) : LONGALIGN(off);
- else
- elog(ERROR, "nocache_index_getattr: attribute %d has len %d",
- j, att[j]->attlen);
- break;
-
- }
+ off = att_align(off, att[j]->attlen, att[j]->attalign);
att[j]->attcacheoff = off;
@@ -365,31 +342,8 @@ nocache_index_getattr(IndexTuple tup,
off = att[i]->attcacheoff;
else
{
- switch (att[i]->attlen)
- {
- case -1:
- off = (att[i]->attalign == 'd') ?
- DOUBLEALIGN(off) : INTALIGN(off);
- break;
- case sizeof(char):
- break;
- case sizeof(short):
- off = SHORTALIGN(off);
- break;
- case sizeof(int32):
- off = INTALIGN(off);
- break;
- default:
- if (att[i]->attlen < sizeof(int32))
- elog(ERROR,
- "nocachegetiattr2: attribute %d has len %d",
- i, att[i]->attlen);
- if (att[i]->attalign == 'd')
- off = DOUBLEALIGN(off);
- else
- off = LONGALIGN(off);
- break;
- }
+ off = att_align(off, att[i]->attlen, att[i]->attalign);
+
if (usecache)
att[i]->attcacheoff = off;
}
@@ -418,30 +372,7 @@ nocache_index_getattr(IndexTuple tup,
}
}
- switch (att[attnum]->attlen)
- {
- case -1:
- off = (att[attnum]->attalign == 'd') ?
- DOUBLEALIGN(off) : INTALIGN(off);
- break;
- case sizeof(char):
- break;
- case sizeof(short):
- off = SHORTALIGN(off);
- break;
- case sizeof(int32):
- off = INTALIGN(off);
- break;
- default:
- if (att[attnum]->attlen < sizeof(int32))
- elog(ERROR, "nocache_index_getattr: attribute %d has len %d",
- attnum, att[attnum]->attlen);
- if (att[attnum]->attalign == 'd')
- off = DOUBLEALIGN(off);
- else
- off = LONGALIGN(off);
- break;
- }
+ off = att_align(off, att[attnum]->attlen, att[attnum]->attalign);
return (Datum) fetchatt(&att[attnum], tp + off);
}
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 04445f14dd0..f695d71107e 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.26 1998/09/02 23:05:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.27 1998/09/07 05:35:30 momjian Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -384,9 +384,7 @@ GetIndexValue(HeapTuple tuple,
*attNull = FALSE;
}
else
- {
- returnVal = heap_getattr(tuple, attrNums[attOff],
- hTupDesc, attNull);
- }
+ returnVal = heap_getattr(tuple, attrNums[attOff], hTupDesc, attNull);
+
return returnVal;
}
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index d486bb432da..f32502fbda6 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.32 1998/09/01 04:27:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.33 1998/09/07 05:35:33 momjian Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -367,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
btitem = _bt_formitem(itup);
res = _bt_doinsert(rel, btitem,
- IndexIsUnique(RelationGetRelid(rel)), heapRel);
+ IndexIsUnique(RelationGetRelid(rel)), heapRel);
pfree(btitem);
pfree(itup);
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 30baab1e9f5..bffdf53dc00 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.22 1998/09/01 03:21:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.23 1998/09/07 05:35:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -297,8 +297,7 @@ _bt_formitem(IndexTuple itup)
/* make a copy of the index tuple with room for the sequence number */
tuplen = IndexTupleSize(itup);
- nbytes_btitem = tuplen +
- (sizeof(BTItemData) - sizeof(IndexTupleData));
+ nbytes_btitem = tuplen + (sizeof(BTItemData) - sizeof(IndexTupleData));
btitem = (BTItem) palloc(nbytes_btitem);
memmove((char *) &(btitem->bti_itup), (char *) itup, tuplen);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 7d98a51bc5c..e56deb90664 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.60 1998/09/01 04:27:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.61 1998/09/07 05:35:37 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -64,8 +64,7 @@
#define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
/* non-export function prototypes */
-static Oid
- RelationNameGetObjectId(char *relationName, Relation pg_class);
+static Oid RelationNameGetObjectId(char *relationName, Relation pg_class);
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
@@ -73,12 +72,11 @@ static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
int numatts, AttrNumber *attNums);
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
-static Oid UpdateRelationRelation(Relation indexRelation);
+static Oid UpdateRelationRelation(Relation indexRelation);
static void InitializeAttributeOids(Relation indexRelation,
int numatts,
Oid indexoid);
-static void
- AppendAttributeTuples(Relation indexRelation, int numatts);
+static void AppendAttributeTuples(Relation indexRelation, int numatts);
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
FuncIndexInfo *funcInfo, int natts,
AttrNumber *attNums, Oid *classOids, Node *predicate,
@@ -552,11 +550,9 @@ UpdateRelationRelation(Relation indexRelation)
sizeof(*indexRelation->rd_rel),
(char *) indexRelation->rd_rel);
- /* ----------------
- * the new tuple must have the same oid as the relcache entry for the
- * index. sure would be embarassing to do this sort of thing in polite
- * company.
- * ----------------
+ /*
+ * The new tuple must have the same oid as the heap_create() we just
+ * did.
*/
tuple->t_oid = RelationGetRelid(indexRelation);
heap_insert(pg_class, tuple);
@@ -1078,7 +1074,7 @@ index_create(char *heapRelationName,
/* ----------------
* add index to catalogs
- * (append RELATION tuple)
+ * (INSERT pg_class tuple)
* ----------------
*/
indexoid = UpdateRelationRelation(indexRelation);
@@ -1264,8 +1260,7 @@ FormIndexDatum(int numberOfAttributes,
char *nullv,
FuncIndexInfoPtr fInfo)
{
- AttrNumber i;
- int offset;
+ AttrNumber attOff;
bool isNull;
/* ----------------
@@ -1275,18 +1270,16 @@ FormIndexDatum(int numberOfAttributes,
* ----------------
*/
- for (i = 1; i <= numberOfAttributes; i++)
+ for (attOff = 0; attOff < numberOfAttributes; attOff++)
{
- offset = AttrNumberGetAttrOffset(i);
-
- datum[offset] = PointerGetDatum(GetIndexValue(heapTuple,
+ datum[attOff] = PointerGetDatum(GetIndexValue(heapTuple,
heapDescriptor,
- offset,
+ attOff,
attributeNumber,
fInfo,
&isNull));
- nullv[offset] = (isNull) ? 'n' : ' ';
+ nullv[attOff] = (isNull) ? 'n' : ' ';
}
}
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index ad31265f501..2fae3979000 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.30 1998/09/02 23:05:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.31 1998/09/07 05:35:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -129,25 +129,29 @@ CatalogIndexInsert(Relation *idescs,
Assert(index_tup);
index_form = (Form_pg_index) GETSTRUCT(index_tup);
- /*
- * Compute the number of attributes we are indexing upon.
- */
- for (attnumP = index_form->indkey, natts = 0;
- *attnumP != InvalidAttrNumber;
- attnumP++, natts++)
- ;
-
if (index_form->indproc != InvalidOid)
{
- FIgetnArgs(&finfo) = natts;
+ int fatts;
+
+ /*
+ * Compute the number of attributes we are indexing upon.
+ */
+ for (attnumP = index_form->indkey, fatts = 0;
+ *attnumP != InvalidAttrNumber && fatts < INDEX_MAX_KEYS;
+ attnumP++, fatts++)
+ ;
+ FIgetnArgs(&finfo) = fatts;
natts = 1;
FIgetProcOid(&finfo) = index_form->indproc;
*(FIgetname(&finfo)) = '\0';
finfoP = &finfo;
}
else
+ {
+ natts = RelationGetDescr(idescs[i])->natts;
finfoP = (FuncIndexInfo *) NULL;
-
+ }
+
FormIndexDatum(natts,
(AttrNumber *) index_form->indkey,
heapTuple,
@@ -160,6 +164,7 @@ CatalogIndexInsert(Relation *idescs,
&heapTuple->t_ctid, heapRelation);
if (indexRes)
pfree(indexRes);
+
pfree(index_tup);
}
}
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 2f0b6d2833c..c293762f0cd 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.59 1998/09/01 04:27:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.60 1998/09/07 05:35:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -661,38 +661,9 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
}
else if (nulls[i] != 'n')
{
- switch (attr[i]->attlen)
- {
- case -1:
- if (attr[i]->attalign == 'd')
- ptr = (char *) DOUBLEALIGN(ptr);
- else
- ptr = (char *) INTALIGN(ptr);
- values[i] = (Datum) ptr;
- ptr += *(uint32 *) ptr;
- break;
- case sizeof(char):
- values[i] = (Datum) ptr;
- ptr += attr[i]->attlen;
- break;
- case sizeof(short):
- ptr = (char *) SHORTALIGN(ptr);
- values[i] = (Datum) ptr;
- ptr += attr[i]->attlen;
- break;
- case sizeof(int32):
- ptr = (char *) INTALIGN(ptr);
- values[i] = (Datum) ptr;
- ptr += attr[i]->attlen;
- break;
- default:
- if (attr[i]->attalign == 'd')
- ptr = (char *) DOUBLEALIGN(ptr);
- else
- ptr = (char *) LONGALIGN(ptr);
- values[i] = (Datum) ptr;
- ptr += attr[i]->attlen;
- }
+ ptr = att_align(ptr, attr[i]->attlen, attr[i]->attalign);
+ values[i] = (Datum) ptr;
+ ptr = att_addlength(ptr, attr[i]->attlen, ptr);
}
}
}
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index f81987f3823..df2b9ded3c1 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: tupmacs.h,v 1.5 1998/09/01 03:27:37 momjian Exp $
+ * $Id: tupmacs.h,v 1.6 1998/09/07 05:35:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -62,4 +62,53 @@
(char *) (T) \
)
+#define att_align(cur_offset, attlen, attalign) \
+( \
+ ((attlen) < sizeof(int32)) ? \
+ ( \
+ ((attlen) == -1) ? \
+ ( \
+ ((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \
+ INTALIGN(cur_offset) \
+ ) \
+ : \
+ ( \
+ ((attlen) == sizeof(char)) ? \
+ ( \
+ (cur_offset) \
+ ) \
+ : \
+ ( \
+ AssertMacro((attlen) == sizeof(short)), \
+ SHORTALIGN(cur_offset) \
+ ) \
+ ) \
+ ) \
+ : \
+ ( \
+ ((attlen) == sizeof(int32)) ? \
+ ( \
+ INTALIGN(cur_offset) \
+ ) \
+ : \
+ ( \
+ AssertMacro((attlen) > sizeof(int32)), \
+ ((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \
+ LONGALIGN(cur_offset) \
+ ) \
+ ) \
+)
+
+#define att_addlength(cur_offset, attlen, attval) \
+( \
+ ((attlen) != -1) ? \
+ ( \
+ (cur_offset) + (attlen) \
+ ) \
+ : \
+ ( \
+ (cur_offset) + VARSIZE(DatumGetPointer(attval)) \
+ ) \
+)
+
#endif
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index cfe7cdd626e..381dd226850 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -15,7 +15,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: memutils.h,v 1.17 1998/09/01 04:39:20 momjian Exp $
+ * $Id: memutils.h,v 1.18 1998/09/07 05:35:48 momjian Exp $
*
* NOTES
* some of the information in this file will be moved to
@@ -37,8 +37,7 @@ tending
GCC (at least v2.5.8 and up) has an __alignof__ keyword.
However, we cannot use it here since on some architectures it reports
just a _recommended_ alignment instead of the actual alignment used in
- padding structures (or at least, this is how I understand gcc's
-s...)
+ padding structures (or at least, this is how I understand gcc).
So define a macro that gives us the _actual_ alignment inside a struct.
{{note: assumes that alignment size is always a power of 2.}}
*/