Skip to content

Commit 27f56dd

Browse files
committed
This patch for Versions 1 and 2 corrects the following bug:
In a catalog class that has a "name" type attribute, UPDATEing of an instance of that class may destroy all of the attributes of that instance that are stored as or after the "name" attribute. This is caused by the alignment value of the "name" type being set to "double" in Class pg_type, but "integer" in Class pg_attribute. Postgres constructs a tuple using double alignment, but interprets it using integer alignment. The fix is to change the alignment to integer in pg_type. Note that this corrects the problem for new Postgres systems. Existing databases already contain the error and it can't easily be repaired because this very bug prevents updating the class that contains it. -- Bryan Henderson Phone 408-227-6803 San Jose, California
1 parent d390886 commit 27f56dd

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/backend/catalog/pg_attribute.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_attribute.h,v 1.1.1.1.2.1 1996/08/21 04:23:32 scrappy Exp $
10+
* $Id: pg_attribute.h,v 1.1.1.1.2.2 1996/08/24 20:56:42 scrappy Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -44,13 +44,19 @@ CATALOG(pg_attribute) BOOTSTRAP {
4444
Oid attrelid;
4545
NameData attname;
4646
Oid atttypid;
47+
/* atttypid is the OID of the instance in Catalog Class pg_type that
48+
defines the data type of this attribute (e.g. int4). Information in
49+
that instance is redundant with the attlen, attbyval, and attalign
50+
attributes of this instance, so they had better match or Postgres
51+
will fail.
52+
*/
4753
Oid attdefrel;
4854
int4 attnvals;
4955
Oid atttyparg; /* type arg for arrays/spquel/procs */
5056
int2 attlen;
51-
/* attlen is the number of bytes we use to represent the value
52-
of this attribute, e.g. 4 for an int4. But for a variable length
53-
attribute, attlen is -1.
57+
/* attlen is a copy of the typlen field from pg_type for this
58+
attribute. See atttypid above. See struct TypeTupleFormData for
59+
definition.
5460
*/
5561
int2 attnum;
5662
/* attnum is the "attribute number" for the attribute: A
@@ -68,6 +74,10 @@ CATALOG(pg_attribute) BOOTSTRAP {
6874
*/
6975
int2 attbound;
7076
bool attbyval;
77+
/* attbyval is a copy of the typbyval field from pg_type for this
78+
attribute. See atttypid above. See struct TypeTupleFormData for
79+
definition.
80+
*/
7181
bool attcanindex;
7282
Oid attproc; /* spquel? */
7383
int4 attnelems;
@@ -80,7 +90,11 @@ CATALOG(pg_attribute) BOOTSTRAP {
8090
walking process.
8191
*/
8292
bool attisset;
83-
char attalign; /* alignment (c=char, s=short, i=int, d=double) */
93+
char attalign;
94+
/* attalign is a copy of the typalign field from pg_type for this
95+
attribute. See atttypid above. See struct TypeTupleFormData for
96+
definition.
97+
*/
8498
} FormData_pg_attribute;
8599

86100
/*

0 commit comments

Comments
 (0)