aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/tuptoaster.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/heap/tuptoaster.c')
-rw-r--r--src/backend/access/heap/tuptoaster.c76
1 files changed, 33 insertions, 43 deletions
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index 77caf79dd19..5359f24fce2 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.50 2005/07/06 19:02:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.51 2005/08/02 16:11:57 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -268,6 +268,38 @@ toast_raw_datum_size(Datum value)
return result;
}
+/* ----------
+ * toast_datum_size
+ *
+ * Return the physical storage size (possibly compressed) of a varlena datum
+ * ----------
+ */
+Size
+toast_datum_size(Datum value)
+{
+ varattrib *attr = (varattrib *) DatumGetPointer(value);
+ Size result;
+
+ if (VARATT_IS_EXTERNAL(attr))
+ {
+ /*
+ * Attribute is stored externally - return the extsize whether
+ * compressed or not. We do not count the size of the toast
+ * pointer ... should we?
+ */
+ result = attr->va_content.va_external.va_extsize;
+ }
+ else
+ {
+ /*
+ * Attribute is stored inline either compressed or not, just
+ * calculate the size of the datum in either case.
+ */
+ result = VARSIZE(attr);
+ }
+ return result;
+}
+
/* ----------
* toast_delete -
@@ -1436,45 +1468,3 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length)
return result;
}
-
-/* ----------
- * toast_datum_size
- *
- * Show the (possibly compressed) size of a datum
- * ----------
- */
-Size
-toast_datum_size(Datum value)
-{
-
- varattrib *attr = (varattrib *) DatumGetPointer(value);
- Size result;
-
- if (VARATT_IS_EXTERNAL(attr))
- {
- /*
- * Attribute is stored externally - If it is compressed too,
- * then we need to get the external datum and calculate its size,
- * otherwise we just use the external rawsize.
- */
- if (VARATT_IS_COMPRESSED(attr))
- {
- varattrib *attrext = toast_fetch_datum(attr);
- result = VARSIZE(attrext);
- pfree(attrext);
- }
- else
- result = attr->va_content.va_external.va_rawsize;
- }
- else
- {
- /*
- * Attribute is stored inline either compressed or not, just
- * calculate the size of the datum in either case.
- */
- result = VARSIZE(attr);
- }
-
- return result;
-
-}