summaryrefslogtreecommitdiff
path: root/src/include/access
diff options
context:
space:
mode:
authorTom Lane2000-08-04 04:16:17 +0000
committerTom Lane2000-08-04 04:16:17 +0000
commitdd8ad6411846f8ca609a824f3b515260be1f0ca1 (patch)
treef538d86b9b91cb91534ab6085878b03cbe914869 /src/include/access
parented9ca687582caa88f31c4b273b9fd4eb5743cf41 (diff)
Fix tuptoaster bugs induced by making bytea toastable. Durn thing was
trying to toast tuples inserted into toast tables! Fix is two-pronged: first, ensure all columns of a toast table are marked attstorage='p', and second, alter the target chunk size so that it's less than the threshold for trying to toast a tuple. (Code tried to do that but the expression was wrong.) A few cosmetic cleanups in tuptoaster too. NOTE: initdb forced due to change in toaster chunk-size.
Diffstat (limited to 'src/include/access')
-rw-r--r--src/include/access/tuptoaster.h52
1 files changed, 42 insertions, 10 deletions
diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h
index 91149f5f836..23f31aec522 100644
--- a/src/include/access/tuptoaster.h
+++ b/src/include/access/tuptoaster.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 2000, PostgreSQL Development Team
*
- * $Id: tuptoaster.h,v 1.7 2000/07/22 11:18:47 wieck Exp $
+ * $Id: tuptoaster.h,v 1.8 2000/08/04 04:16:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,25 +20,57 @@
#include "access/tupmacs.h"
#include "utils/rel.h"
+
+/*
+ * This enables de-toasting of index entries. Needed until VACUUM is
+ * smart enough to rebuild indexes from scratch.
+ */
#define TOAST_INDEX_HACK
-#define TOAST_MAX_CHUNK_SIZE ((MaxTupleSize - \
- MAXALIGN( \
- MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + \
- MAXALIGN(sizeof(Oid)) + \
- MAXALIGN(sizeof(int32)) + \
- MAXALIGN(VARHDRSZ))) / 4)
+/*
+ * These symbols control toaster activation. If a tuple is larger than
+ * TOAST_TUPLE_THRESHOLD, we will try to toast it down to no more than
+ * TOAST_TUPLE_TARGET bytes. Both numbers include all tuple header and
+ * alignment-padding overhead.
+ *
+ * The numbers need not be the same, though they currently are.
+ */
+#define TOAST_TUPLE_THRESHOLD (MaxTupleSize / 4)
+
+#define TOAST_TUPLE_TARGET (MaxTupleSize / 4)
+
+
+/*
+ * When we store an oversize datum externally, we divide it into chunks
+ * containing at most TOAST_MAX_CHUNK_SIZE data bytes. This number *must*
+ * be small enough that the completed toast-table tuple (including the
+ * ID and sequence fields and all overhead) is no more than MaxTupleSize
+ * bytes. It *should* be small enough to make toast-table tuples no more
+ * than TOAST_TUPLE_THRESHOLD bytes, else heapam.c will uselessly invoke
+ * the toaster on toast-table tuples.
+ *
+ * NB: you cannot change this value without forcing initdb, at least not
+ * if your DB contains any multi-chunk toasted values.
+ */
+#define TOAST_MAX_CHUNK_SIZE (TOAST_TUPLE_THRESHOLD - \
+ MAXALIGN( \
+ MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + \
+ sizeof(Oid) + \
+ sizeof(int32) + \
+ VARHDRSZ))
/* ----------
* heap_tuple_toast_attrs() -
*
* Called by heap_insert(), heap_update() and heap_delete().
- * Outdates not any longer needed toast entries referenced
- * by oldtup and creates new ones until newtup is smaller
- * that ~2K (or running out of toastable values).
+ * Outdates any no-longer-needed toast entries referenced
+ * by oldtup and creates new ones until newtup is no more than
+ * TOAST_TUPLE_TARGET (or we run out of toastable values).
* Possibly modifies newtup by replacing the t_data part!
+ *
+ * oldtup is NULL if insert, newtup is NULL if delete.
* ----------
*/
extern void heap_tuple_toast_attrs(Relation rel,