Skip to content

Commit 9b73210

Browse files
committed
Fix bootstrap so it properly defines alignment of attributes.
1 parent f821eec commit 9b73210

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.48 1998/08/19 02:01:26 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.49 1998/08/24 19:04:02 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -90,7 +90,7 @@ static AttributeTupleForm AllocateAttribute(void);
9090
static bool BootstrapAlreadySeen(Oid id);
9191
static int CompHash(char *str, int len);
9292
static hashnode *FindStr(char *str, int length, hashnode *mderef);
93-
static int gettype(char *type);
93+
static Oid gettype(char *type);
9494
static void cleanup(void);
9595

9696
/* ----------------
@@ -571,15 +571,15 @@ void
571571
DefineAttr(char *name, char *type, int attnum)
572572
{
573573
int attlen;
574-
int t;
574+
Oid typeoid;
575575

576576
if (reldesc != NULL)
577577
{
578578
fputs("Warning: no open relations allowed with 't' command.\n", stderr);
579579
closerel(relname);
580580
}
581581

582-
t = gettype(type);
582+
typeoid = gettype(type);
583583
if (attrtypes[attnum] == (AttributeTupleForm) NULL)
584584
attrtypes[attnum] = AllocateAttribute();
585585
if (Typ != (struct typmap **) NULL)
@@ -591,16 +591,18 @@ DefineAttr(char *name, char *type, int attnum)
591591
attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
592592
attlen = attrtypes[attnum]->attlen = Ap->am_typ.typlen;
593593
attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
594+
attrtypes[attnum]->attalign = Ap->am_typ.typalign;
594595
}
595596
else
596597
{
597-
attrtypes[attnum]->atttypid = Procid[t].oid;
598+
attrtypes[attnum]->atttypid = Procid[typeoid].oid;
598599
namestrcpy(&attrtypes[attnum]->attname, name);
599600
if (!Quiet)
600601
printf("<%s %s> ", attrtypes[attnum]->attname.data, type);
601602
attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
602-
attlen = attrtypes[attnum]->attlen = Procid[t].len;
603-
attrtypes[attnum]->attbyval = (attlen == 1) || (attlen == 2) || (attlen == 4);
603+
attlen = attrtypes[attnum]->attlen = Procid[typeoid].len;
604+
attrtypes[attnum]->attbyval = (attlen == 1) || (attlen == 2) ||(attlen == 4);
605+
attrtypes[attnum]->attalign = 'i';
604606
}
605607
attrtypes[attnum]->attcacheoff = -1;
606608
attrtypes[attnum]->atttypmod = -1;
@@ -784,7 +786,7 @@ cleanup()
784786
* gettype
785787
* ----------------
786788
*/
787-
static int
789+
static Oid
788790
gettype(char *type)
789791
{
790792
int i;

src/backend/catalog/index.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.52 1998/08/21 23:22:34 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.53 1998/08/24 19:04:04 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -279,6 +279,7 @@ BuildFuncTupleDesc(FuncIndexInfo *funcInfo)
279279
funcTupDesc->attrs[0]->attbyval = ((TypeTupleForm) GETSTRUCT(tuple))->typbyval;
280280
funcTupDesc->attrs[0]->attcacheoff = -1;
281281
funcTupDesc->attrs[0]->atttypmod = -1;
282+
funcTupDesc->attrs[0]->attalign = ((TypeTupleForm) GETSTRUCT(tuple))->typalign;
282283

283284
/*
284285
* make the attributes name the same as the functions
@@ -378,7 +379,6 @@ ConstructTupleDescriptor(Oid heapoid,
378379
* here we are indexing on a normal attribute (1...n)
379380
* ----------------
380381
*/
381-
382382
heapTupDesc = RelationGetTupleDescriptor(heapRelation);
383383
atind = AttrNumberGetAttrOffset(atnum);
384384

@@ -400,6 +400,7 @@ ConstructTupleDescriptor(Oid heapoid,
400400
((AttributeTupleForm) to)->atthasdef = false;
401401
((AttributeTupleForm) to)->attcacheoff = -1;
402402
((AttributeTupleForm) to)->atttypmod = -1;
403+
((AttributeTupleForm) to)->attalign = 'i';
403404

404405
/*
405406
* if the keytype is defined, we need to change the tuple form's
@@ -417,11 +418,11 @@ ConstructTupleDescriptor(Oid heapoid,
417418
IndexKeyType->name);
418419
((AttributeTupleForm) to)->atttypid = tup->t_oid;
419420
((AttributeTupleForm) to)->attbyval =
420-
((TypeTupleForm) ((char *) tup + tup->t_hoff))->typbyval;
421-
421+
((TypeTupleForm) GETSTRUCT(tup))->typbyval;
422422
((AttributeTupleForm) to)->attlen =
423-
((TypeTupleForm) ((char *) tup + tup->t_hoff))->typlen;
424-
423+
((TypeTupleForm) GETSTRUCT(tup))->typlen;
424+
((AttributeTupleForm) to)->attalign =
425+
((TypeTupleForm) GETSTRUCT(tup))->typalign;
425426
((AttributeTupleForm) to)->atttypmod = IndexKeyType->typmod;
426427
}
427428

0 commit comments

Comments
 (0)