Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ EXTRA_CLEAN = src/pgactive_init_copy$(X) src/pgactive_init_copy.o include/pgacti
test/regression.diffs test/regression.out \
pgactive_init_copy_postgres.log home tmp_test_* \
pgactive_dump$(X) $(pgactive_DUMP_OBJS) \
src/*.o src/compat/*/pg_dump/*.o

# When in development add -Werror.
PG_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/src/$(pgactive_PGVERCOMPAT_INCDIR) -I$(libpq_srcdir) -Wall -Wmissing-prototypes -Wmissing-declarations $(EXTRA_CFLAGS)
Expand Down
12 changes: 6 additions & 6 deletions src/compat/18/pg_dump.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ index d9041da..4dd06e8 100644
/* various user-settable parameters */
int dumpSections; /* bitmask of chosen sections */
diff --git a/src/compat/18/pg_dump/pg_dump.c b/src/compat/18/pg_dump/pg_dump.c
index 2b70da8..2fd19c6 100644
index 8f6332d..5b024e1 100644
--- a/src/compat/18/pg_dump/pg_dump.c
+++ b/src/compat/18/pg_dump/pg_dump.c
@@ -487,6 +487,7 @@ main(int argc, char **argv)
@@ -488,6 +488,7 @@ main(int argc, char **argv)
*/
{"attribute-inserts", no_argument, &dopt.column_inserts, 1},
{"binary-upgrade", no_argument, &dopt.binary_upgrade, 1},
+ {"pgactive-init-node", no_argument, &dopt.pgactive_init_node, 1},
{"column-inserts", no_argument, &dopt.column_inserts, 1},
{"disable-dollar-quoting", no_argument, &dopt.disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &dopt.disable_triggers, 1},
@@ -9948,6 +9949,8 @@ shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
@@ -9965,6 +9966,8 @@ shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
{
if (dopt->binary_upgrade)
return true;
Expand All @@ -31,7 +31,7 @@ index 2b70da8..2fd19c6 100644
if (tbinfo->attisdropped[colno])
return false;
return (tbinfo->attislocal[colno] || tbinfo->ispartition);
@@ -15957,7 +15960,7 @@ dumpForeignServer(Archive *fout, const ForeignServerInfo *srvinfo)
@@ -15974,7 +15977,7 @@ dumpForeignServer(Archive *fout, const ForeignServerInfo *srvinfo)
res = ExecuteSqlQueryForSingleRow(fout, query->data);
fdwname = PQgetvalue(res, 0, 0);

Expand All @@ -40,7 +40,7 @@ index 2b70da8..2fd19c6 100644
if (srvinfo->srvtype && strlen(srvinfo->srvtype) > 0)
{
appendPQExpBufferStr(q, " TYPE ");
@@ -16085,7 +16088,7 @@ dumpUserMappings(Archive *fout,
@@ -16102,7 +16105,7 @@ dumpUserMappings(Archive *fout,
umoptions = PQgetvalue(res, i, i_umoptions);

resetPQExpBuffer(q);
Expand All @@ -49,7 +49,7 @@ index 2b70da8..2fd19c6 100644
appendPQExpBuffer(q, " SERVER %s", fmtId(servername));

if (umoptions && strlen(umoptions) > 0)
@@ -17593,6 +17596,35 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
@@ -17613,6 +17616,35 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
}
}

Expand Down
48 changes: 38 additions & 10 deletions src/compat/18/pg_dump/compress_gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
#ifdef HAVE_LIBZ
#include <zlib.h>

/*
* We don't use the gzgetc() macro, because zlib's configuration logic is not
* robust enough to guarantee that the macro will have the same ideas about
* struct field layout as the library itself does; see for example
* https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=59711
* Instead, #undef the macro and fall back to the underlying function.
*/
#undef gzgetc

/*----------------------
* Compressor API
*----------------------
Expand Down Expand Up @@ -251,34 +260,53 @@ InitCompressorGzip(CompressorState *cs,
*----------------------
*/

static bool
Gzip_read(void *ptr, size_t size, size_t *rsize, CompressFileHandle *CFH)
static size_t
Gzip_read(void *ptr, size_t size, CompressFileHandle *CFH)
{
gzFile gzfp = (gzFile) CFH->private_data;
int gzret;

/* Reading zero bytes must be a no-op */
if (size == 0)
return 0;

gzret = gzread(gzfp, ptr, size);
if (gzret <= 0 && !gzeof(gzfp))

/*
* gzread returns zero on EOF as well as some error conditions, and less
* than zero on other error conditions, so we need to inspect for EOF on
* zero.
*/
if (gzret <= 0)
{
int errnum;
const char *errmsg = gzerror(gzfp, &errnum);
const char *errmsg;

if (gzret == 0 && gzeof(gzfp))
return 0;

errmsg = gzerror(gzfp, &errnum);

pg_fatal("could not read from input file: %s",
errnum == Z_ERRNO ? strerror(errno) : errmsg);
}

if (rsize)
*rsize = (size_t) gzret;

return true;
return (size_t) gzret;
}

static bool
static void
Gzip_write(const void *ptr, size_t size, CompressFileHandle *CFH)
{
gzFile gzfp = (gzFile) CFH->private_data;
int errnum;
const char *errmsg;

return gzwrite(gzfp, ptr, size) > 0;
if (gzwrite(gzfp, ptr, size) != size)
{
errmsg = gzerror(gzfp, &errnum);
pg_fatal("could not write to file: %s",
errnum == Z_ERRNO ? strerror(errno) : errmsg);
}
}

static int
Expand Down
2 changes: 2 additions & 0 deletions src/compat/18/pg_dump/compress_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ InitDiscoverCompressFileHandle(const char *path, const char *mode)
}

CFH = InitCompressFileHandle(compression_spec);
errno = 0;
if (!CFH->open_func(fname, -1, mode, CFH))
{
free_keep_errno(CFH);
Expand All @@ -289,6 +290,7 @@ EndCompressFileHandle(CompressFileHandle *CFH)
{
bool ret = false;

errno = 0;
if (CFH->private_data)
ret = CFH->close_func(CFH);

Expand Down
15 changes: 8 additions & 7 deletions src/compat/18/pg_dump/compress_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,22 @@ struct CompressFileHandle
CompressFileHandle *CFH);

/*
* Read 'size' bytes of data from the file and store them into 'ptr'.
* Optionally it will store the number of bytes read in 'rsize'.
* Read up to 'size' bytes of data from the file and store them into
* 'ptr'.
*
* Returns true on success and throws an internal error otherwise.
* Returns number of bytes read (this might be less than 'size' if EOF was
* reached). Exits via pg_fatal for all error conditions.
*/
bool (*read_func) (void *ptr, size_t size, size_t *rsize,
size_t (*read_func) (void *ptr, size_t size,
CompressFileHandle *CFH);

/*
* Write 'size' bytes of data into the file from 'ptr'.
*
* Returns true on success and false on error.
* Returns nothing, exits via pg_fatal for all error conditions.
*/
bool (*write_func) (const void *ptr, size_t size,
struct CompressFileHandle *CFH);
void (*write_func) (const void *ptr, size_t size,
CompressFileHandle *CFH);

/*
* Read at most size - 1 characters from the compress file handle into
Expand Down
Loading
Loading