aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2014-12-25 20:46:14 +0900
committerFujii Masao <fujii@postgresql.org>2014-12-25 20:46:14 +0900
commit60838df922345b26a616e49ac9fab808a35d1f85 (patch)
tree9f924e2b9558b80cd523305aa76d697b35da6fb7 /src/backend/access
parent5b89473d870dc2a9fec0926c5afccf53042dbb0a (diff)
downloadpostgresql-60838df922345b26a616e49ac9fab808a35d1f85.tar.gz
postgresql-60838df922345b26a616e49ac9fab808a35d1f85.zip
Move pg_lzcompress.c to src/common.
Exposing compression and decompression APIs of pglz makes possible its use by extensions and contrib modules. pglz_decompress contained a call to elog to emit an error message in case of corrupted data. This function is changed to return a status code to let its callers return an error instead. This commit is required for upcoming WAL compression feature so that the WAL reader facility can decompress the WAL data by using pglz_decompress. Michael Paquier
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/tuptoaster.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index d230387c859..c91bdc0d3f5 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -37,7 +37,7 @@
#include "catalog/catalog.h"
#include "miscadmin.h"
#include "utils/fmgroids.h"
-#include "utils/pg_lzcompress.h"
+#include "common/pg_lzcompress.h"
#include "utils/rel.h"
#include "utils/typcache.h"
#include "utils/tqual.h"
@@ -142,7 +142,8 @@ heap_tuple_untoast_attr(struct varlena * attr)
attr = (struct varlena *) palloc(PGLZ_RAW_SIZE(tmp) + VARHDRSZ);
SET_VARSIZE(attr, PGLZ_RAW_SIZE(tmp) + VARHDRSZ);
- pglz_decompress(tmp, VARDATA(attr));
+ if (!pglz_decompress(tmp, VARDATA(attr)))
+ elog(ERROR, "compressed data is corrupted");
pfree(tmp);
}
}
@@ -167,7 +168,8 @@ heap_tuple_untoast_attr(struct varlena * attr)
attr = (struct varlena *) palloc(PGLZ_RAW_SIZE(tmp) + VARHDRSZ);
SET_VARSIZE(attr, PGLZ_RAW_SIZE(tmp) + VARHDRSZ);
- pglz_decompress(tmp, VARDATA(attr));
+ if (!pglz_decompress(tmp, VARDATA(attr)))
+ elog(ERROR, "compressed data is corrupted");
}
else if (VARATT_IS_SHORT(attr))
{
@@ -239,7 +241,8 @@ heap_tuple_untoast_attr_slice(struct varlena * attr,
preslice = (struct varlena *) palloc(size);
SET_VARSIZE(preslice, size);
- pglz_decompress(tmp, VARDATA(preslice));
+ if (!pglz_decompress(tmp, VARDATA(preslice)))
+ elog(ERROR, "compressed data is corrupted");
if (tmp != (PGLZ_Header *) attr)
pfree(tmp);