aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/tupmacs.h
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1996-08-21 04:25:49 +0000
committerMarc G. Fournier <scrappy@hub.org>1996-08-21 04:25:49 +0000
commit5e773a4f70dd07d57e07cfbc856e7822dc6defdc (patch)
treec3f48a6caf8e9130a107c84589f9f6c675c2224e /src/backend/access/tupmacs.h
parent93ad36fdc2b7ebe3147cb0003e14d9832ef4543e (diff)
downloadpostgresql-5e773a4f70dd07d57e07cfbc856e7822dc6defdc.tar.gz
postgresql-5e773a4f70dd07d57e07cfbc856e7822dc6defdc.zip
Here's a patch for Versions 1 and 2 that fixes the following bug:
When you try to do any UPDATE of the catalog class pg_class, such as to change ownership of a class, the backend crashes. This is really two serial bugs: 1) there is a hardcoded copy of the schema of pg_class in the postgres program, and it doesn't match the actual class that initdb creates in the database; 2) Parts of postgres determine whether to pass an attribute value by value or by reference based on the attbyval attribute of the attribute in class pg_attribute. Other parts of postgres have it hardcoded. For the relacl[] attribute in class pg_class, attbyval does not match the hardcoded expectation. The fix is to correct the hardcoded schema for pg_attribute and to change the fetchatt macro so it ignores attbyval for all variable length attributes. The fix also adds a bunch of logic documentation and extends genbki.sh so it allows source files to contain such documentation. -- Bryan Henderson Phone 408-227-6803 San Jose, California
Diffstat (limited to 'src/backend/access/tupmacs.h')
-rw-r--r--src/backend/access/tupmacs.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/access/tupmacs.h b/src/backend/access/tupmacs.h
index 9a9bcce3b41..168a4669c3b 100644
--- a/src/backend/access/tupmacs.h
+++ b/src/backend/access/tupmacs.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: tupmacs.h,v 1.1.1.1 1996/07/09 06:21:09 scrappy Exp $
+ * $Id: tupmacs.h,v 1.2 1996/08/21 04:25:37 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,12 @@
* given a AttributeTupleForm and a pointer into a tuple's data
* area, return the correct value or pointer.
*
+ * We return a 4 byte (char *) value in all cases. If the attribute has
+ * "byval" false or has variable length, we return the same pointer
+ * into the tuple data area that we're passed. Otherwise, we return
+ * the 1, 2, or 4 bytes pointed to by it, properly extended to 4
+ * bytes, depending on the length of the attribute.
+ *
* note that T must already be properly LONGALIGN/SHORTALIGN'd for
* this to work correctly.
*
@@ -30,9 +36,15 @@
* sign-extension may get weird if you use an integer type that
* isn't the same size as (char *) for the first cast. (on the other
* hand, it's safe to use another type for the (foo *)(T).)
+ *
+ * attbyval seems to be fairly redundant. We have to return a pointer if
+ * the value is longer than 4 bytes or has variable length; returning the
+ * value would be useless. In fact, for at least the variable length case,
+ * the caller assumes we return a pointer regardless of attbyval.
+ * I would eliminate attbyval altogether, but I don't know how. -BRYANH.
*/
#define fetchatt(A, T) \
- ((*(A))->attbyval \
+ ((*(A))->attbyval && (*(A))->attlen != -1 \
? ((*(A))->attlen > sizeof(int16) \
? (char *) (long) *((int32 *)(T)) \
: ((*(A))->attlen < sizeof(int16) \