summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_checksums/pg_checksums.c17
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c15
-rw-r--r--src/bin/pg_dump/pg_dump.c7
3 files changed, 29 insertions, 10 deletions
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
index f20be82862a..46cb2f36efa 100644
--- a/src/bin/pg_checksums/pg_checksums.c
+++ b/src/bin/pg_checksums/pg_checksums.c
@@ -25,6 +25,7 @@
#include "common/logging.h"
#include "common/relpath.h"
#include "fe_utils/option_utils.h"
+#include "fe_utils/version.h"
#include "getopt_long.h"
#include "pg_getopt.h"
#include "storage/bufpage.h"
@@ -448,6 +449,8 @@ main(int argc, char *argv[])
int c;
int option_index;
bool crc_ok;
+ uint32 major_version;
+ char *version_str;
pg_logging_init(argv[0]);
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_checksums"));
@@ -543,6 +546,20 @@ main(int argc, char *argv[])
exit(1);
}
+ /*
+ * Retrieve the contents of this cluster's PG_VERSION. We require
+ * compatibility with the same major version as the one this tool is
+ * compiled with.
+ */
+ major_version = GET_PG_MAJORVERSION_NUM(get_pg_version(DataDir, &version_str));
+ if (major_version != PG_MAJORVERSION_NUM)
+ {
+ pg_log_error("data directory is of wrong version");
+ pg_log_error_detail("File \"%s\" contains \"%s\", which is not compatible with this program's version \"%s\".",
+ "PG_VERSION", version_str, PG_MAJORVERSION);
+ exit(1);
+ }
+
/* Read the control file and check compatibility */
ControlFile = get_controlfile(DataDir, &crc_ok);
if (!crc_ok)
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index f7c3af56304..2226520dffc 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -624,12 +624,19 @@ _skipData(ArchiveHandle *AH)
lclContext *ctx = (lclContext *) AH->formatData;
size_t blkLen;
char *buf = NULL;
- int buflen = 0;
+ size_t buflen = 0;
blkLen = ReadInt(AH);
while (blkLen != 0)
{
- if (ctx->hasSeek)
+ /*
+ * Seeks of less than stdio's buffer size are less efficient than just
+ * reading the data, at least on common platforms. We don't know the
+ * buffer size for sure, but 4kB is the usual value. (While pg_dump
+ * currently tries to avoid producing such short data blocks, older
+ * dump files often contain them.)
+ */
+ if (ctx->hasSeek && blkLen >= 4 * 1024)
{
if (fseeko(AH->FH, blkLen, SEEK_CUR) != 0)
pg_fatal("error during file seek: %m");
@@ -639,8 +646,8 @@ _skipData(ArchiveHandle *AH)
if (blkLen > buflen)
{
free(buf);
- buf = (char *) pg_malloc(blkLen);
- buflen = blkLen;
+ buflen = Max(blkLen, 4 * 1024);
+ buf = (char *) pg_malloc(buflen);
}
if (fread(buf, 1, blkLen, AH->FH) != blkLen)
{
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4b8cd49df09..47913178a93 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12023,17 +12023,12 @@ dumpExtension(Archive *fout, const ExtensionInfo *extinfo)
.createStmt = q->data,
.dropStmt = delq->data));
- /* Dump Extension Comments and Security Labels */
+ /* Dump Extension Comments */
if (extinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, "EXTENSION", qextname,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
- if (extinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "EXTENSION", qextname,
- NULL, "",
- extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
-
free(qextname);
destroyPQExpBuffer(q);