aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-30 18:38:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-30 18:38:47 +0000
commit1f5cc8c78aa3e600f3857f39e1b92bb9d019e68b (patch)
tree993c67d3b94ec50a46a200285d2c9d629af7d7f9 /src/backend/utils/cache/relcache.c
parent59a9735fc814f66aa4b7a685557e790eb176f96c (diff)
downloadpostgresql-1f5cc8c78aa3e600f3857f39e1b92bb9d019e68b.tar.gz
postgresql-1f5cc8c78aa3e600f3857f39e1b92bb9d019e68b.zip
Remove VARLENA_FIXED_SIZE hack, which is irreversibly broken now that
both MULTIBYTE and TOAST prevent char(n) from being truly fixed-size. Simplify and speed up fastgetattr() and index_getattr() macros by eliminating special cases for attnum=1. It's just as fast to handle the first attribute by presetting its attcacheoff to zero; so do that instead when loading the tupledesc in relcache.c.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 2f4697a39b8..e4551d4c604 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.117 2000/11/30 08:46:24 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.118 2000/11/30 18:38:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -630,6 +630,32 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
heap_endscan(pg_attribute_scan);
heap_close(pg_attribute_desc, AccessShareLock);
+ /* ----------------
+ * The attcacheoff values we read from pg_attribute should all be -1
+ * ("unknown"). Verify this if assert checking is on. They will be
+ * computed when and if needed during tuple access.
+ * ----------------
+ */
+#ifdef USE_ASSERT_CHECKING
+ {
+ int i;
+
+ for (i = 0; i < relation->rd_rel->relnatts; i++)
+ {
+ Assert(relation->rd_att->attrs[i]->attcacheoff == -1);
+ }
+ }
+#endif
+
+ /* ----------------
+ * However, we can easily set the attcacheoff value for the first
+ * attribute: it must be zero. This eliminates the need for special
+ * cases for attnum=1 that used to exist in fastgetattr() and
+ * index_getattr().
+ * ----------------
+ */
+ relation->rd_att->attrs[0]->attcacheoff = 0;
+
SetConstrOfRelation(relation, constr, ndef, attrdef);
}
@@ -715,6 +741,28 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
heap_close(attrel, AccessShareLock);
+ /* ----------------
+ * The attcacheoff values we read from pg_attribute should all be -1
+ * ("unknown"). Verify this if assert checking is on. They will be
+ * computed when and if needed during tuple access.
+ * ----------------
+ */
+#ifdef USE_ASSERT_CHECKING
+ for (i = 0; i < relation->rd_rel->relnatts; i++)
+ {
+ Assert(relation->rd_att->attrs[i]->attcacheoff == -1);
+ }
+#endif
+
+ /* ----------------
+ * However, we can easily set the attcacheoff value for the first
+ * attribute: it must be zero. This eliminates the need for special
+ * cases for attnum=1 that used to exist in fastgetattr() and
+ * index_getattr().
+ * ----------------
+ */
+ relation->rd_att->attrs[0]->attcacheoff = 0;
+
SetConstrOfRelation(relation, constr, ndef, attrdef);
}