summaryrefslogtreecommitdiff
path: root/decode.c
diff options
context:
space:
mode:
authorChristoph Berg2024-06-06 16:11:01 +0000
committerChristoph Berg2024-06-06 16:11:01 +0000
commit8ef53cee02e1db183399dc5aec132304893272e3 (patch)
treec0c16efc8fa052194c96e085b1ce546577627ee9 /decode.c
parente7d52d52e1956298f223361091c2bcbd108f3086 (diff)
Print type of toast when not decoding it
Diffstat (limited to 'decode.c')
-rw-r--r--decode.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/decode.c b/decode.c
index 2bbacb4..7446bd5 100644
--- a/decode.c
+++ b/decode.c
@@ -1102,10 +1102,35 @@ extract_data(const char *buffer, unsigned int buff_size, unsigned int *out_size,
{
result = ReadStringFromToast(buffer, buff_size, out_size, parse_value);
}
- else
+ else if (VARATT_IS_EXTERNAL_ONDISK(buffer))
{
- CopyAppend("(TOASTED)");
+ varatt_external toast_ptr;
+ VARATT_EXTERNAL_GET_POINTER(toast_ptr, buffer);
+ if (VARATT_EXTERNAL_IS_COMPRESSED(toast_ptr))
+ {
+#if PG_VERSION_NUM >= 140000
+ switch (VARATT_EXTERNAL_GET_COMPRESS_METHOD(toast_ptr))
+ {
+ case TOAST_PGLZ_COMPRESSION_ID:
+#endif
+ CopyAppend("(TOASTED,pglz)");
+#if PG_VERSION_NUM >= 140000
+ break;
+ case TOAST_LZ4_COMPRESSION_ID:
+ CopyAppend("(TOASTED,lz4)");
+ break;
+ default:
+ CopyAppend("(TOASTED,unknown)");
+ break;
+ }
+#endif
+ }
+ else
+ CopyAppend("(TOASTED,uncompressed)");
}
+ /* If tag is indirect or expanded, it was stored in memory. */
+ else
+ CopyAppend("(TOASTED IN MEMORY)");
*out_size = padding + len;
return result;
@@ -1199,8 +1224,8 @@ extract_data(const char *buffer, unsigned int buff_size, unsigned int *out_size,
if ((decompress_ret != decompressed_len) || (decompress_ret < 0))
{
- printf("WARNING: Unable to decompress a string. Data is corrupted.\n");
- CopyAppend("(COMPRESSED)");
+ printf("WARNING: Corrupted toast data, unable to decompress.\n");
+ CopyAppend("(inline compressed, corrupted)");
*out_size = padding + len;
free(decompress_tmp_buff);
return 0;
@@ -1374,7 +1399,6 @@ ReadStringFromToast(const char *buffer,
sprintf(toast_relation_filename, "%s/%d",
*toast_relation_path ? toast_relation_path : ".",
toast_ptr.va_toastrelid);
- printf(" Read TOAST relation %s\n", toast_relation_filename);
toast_rel_fp = fopen(toast_relation_filename, "rb");
if (!toast_rel_fp) {
printf("Cannot open TOAST relation %s\n",