pg_dumpall to use the same memory allocation functions as the others.
pg_restore: pg_restore.o $(OBJS) $(KEYWRDOBJS) | submake-libpq submake-libpgport
$(CC) $(CFLAGS) pg_restore.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_dumpall: pg_dumpall.o dumputils.o $(KEYWRDOBJS) | submake-libpq submake-libpgport
- $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(KEYWRDOBJS) $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+pg_dumpall: pg_dumpall.o dumputils.o dumpmem.o $(KEYWRDOBJS) | submake-libpq submake-libpgport
+ $(CC) $(CFLAGS) pg_dumpall.o dumputils.o dumpmem.o $(KEYWRDOBJS) $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
$(INSTALL_PROGRAM) pg_dump$(X) '$(DESTDIR)$(bindir)'/pg_dump$(X)
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
-#include "pg_backup.h"
+#include "dumputils.h"
#include "dumpmem.h"
#include <ctype.h>
char *tmp;
if (!string)
- exit_horribly(NULL, NULL, "cannot duplicate null pointer\n");
+ exit_horribly(NULL, "cannot duplicate null pointer\n");
tmp = strdup(string);
if (!tmp)
- exit_horribly(NULL, NULL, "out of memory\n");
+ exit_horribly(NULL, "out of memory\n");
return tmp;
}
tmp = malloc(size);
if (!tmp)
- exit_horribly(NULL, NULL, "out of memory\n");
+ exit_horribly(NULL, "out of memory\n");
return tmp;
}
tmp = calloc(nmemb, size);
if (!tmp)
- exit_horribly(NULL, NULL, _("out of memory\n"));
+ exit_horribly(NULL, _("out of memory\n"));
return tmp;
}
tmp = realloc(ptr, size);
if (!tmp)
- exit_horribly(NULL, NULL, _("out of memory\n"));
+ exit_horribly(NULL, _("out of memory\n"));
return tmp;
}
int quote_all_identifiers = 0;
+const char *progname;
#define supports_grant_options(version) ((version) >= 70400)
appendPQExpBuffer(buffer, ";\n");
}
}
+
+
+void
+write_msg(const char *modulename, const char *fmt,...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ if (modulename)
+ fprintf(stderr, "%s: [%s] ", progname, _(modulename));
+ else
+ fprintf(stderr, "%s: ", progname);
+ vfprintf(stderr, _(fmt), ap);
+ va_end(ap);
+}
+
+
+void
+exit_horribly(const char *modulename, const char *fmt,...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ write_msg(modulename, fmt, ap);
+ va_end(ap);
+
+ exit(1);
+}
+
+
uint32 objectId, PQExpBuffer sql);
extern void emitShSecLabels(PGconn *conn, PGresult *res,
PQExpBuffer buffer, const char *target, const char *objname);
+extern void write_msg(const char *modulename, const char *fmt,...)
+ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
+extern void exit_horribly(const char *modulename, const char *fmt,...)
+ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
#endif /* DUMPUTILS_H */
* Main archiver interface.
*/
-extern void
-exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
-
/* Lets the archive know we have a DB connection to shutdown if it dies */
int gzOut;
} OutputContext;
-const char *progname;
-
static const char *modulename = gettext_noop("archiver");
/* index array created by fix_dependencies -- only used in parallel restore */
static int RestoringToDB(ArchiveHandle *AH);
static void dump_lo_buf(ArchiveHandle *AH);
-static void _write_msg(const char *modulename, const char *fmt, va_list ap) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)));
static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_list ap) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0)));
static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim);
return;
va_start(ap, fmt);
- _write_msg(NULL, fmt, ap);
+ write_msg(NULL, fmt, ap);
va_end(ap);
}
}
}
-/* Common exit code */
-static void
-_write_msg(const char *modulename, const char *fmt, va_list ap)
-{
- if (modulename)
- fprintf(stderr, "%s: [%s] ", progname, _(modulename));
- else
- fprintf(stderr, "%s: ", progname);
- vfprintf(stderr, _(fmt), ap);
-}
-
-void
-write_msg(const char *modulename, const char *fmt,...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- _write_msg(modulename, fmt, ap);
- va_end(ap);
-}
-
static void
_die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_list ap)
{
- _write_msg(modulename, fmt, ap);
+ write_msg(modulename, fmt, ap);
if (AH)
{
exit(1);
}
-/* External use */
-void
-exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- _die_horribly((ArchiveHandle *) AH, modulename, fmt, ap);
- va_end(ap);
-}
-
/* Archiver use (just different arg declaration) */
void
die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...)
_die_horribly(AH, modulename, fmt, ap);
else
{
- _write_msg(modulename, fmt, ap);
+ write_msg(modulename, fmt, ap);
AH->public.n_errors++;
}
va_end(ap);
extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
extern void warn_or_die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
-extern void write_msg(const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
extern void WriteTOC(ArchiveHandle *AH);
extern void ReadTOC(ArchiveHandle *AH);
*/
#include "compress_io.h"
+#include "dumputils.h"
#include "dumpmem.h"
/*--------
*/
#include "pg_backup_archiver.h"
+#include "dumputils.h"
#include "dumpmem.h"
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
*-------------------------------------------------------------------------
*/
#include "pg_backup_archiver.h"
+#include "dumputils.h"
#include "dumpmem.h"
static const char *modulename = gettext_noop("sorter");
obj = objs[i];
j = obj->dumpId;
if (j <= 0 || j > maxDumpId)
- exit_horribly(NULL, modulename, "invalid dumpId %d\n", j);
+ exit_horribly(modulename, "invalid dumpId %d\n", j);
idMap[j] = i;
for (j = 0; j < obj->nDeps; j++)
{
k = obj->dependencies[j];
if (k <= 0 || k > maxDumpId)
- exit_horribly(NULL, modulename, "invalid dependency %d\n", k);
+ exit_horribly(modulename, "invalid dependency %d\n", k);
beforeConstraints[k]++;
}
}
/* We'd better have fixed at least one loop */
if (!fixedloop)
- exit_horribly(NULL, modulename, "could not identify dependency loop\n");
+ exit_horribly(modulename, "could not identify dependency loop\n");
free(workspace);
}
#include "getopt_long.h"
#include "dumputils.h"
+#include "dumpmem.h"
#include "pg_backup.h"
/* version string we expect back from pg_dump */
appendPQExpBufferChar(buf, '"');
#endif /* WIN32 */
}
-
-
-/*
- * Simpler versions of common.c functions.
- */
-
-char *
-pg_strdup(const char *string)
-{
- char *tmp;
-
- if (!string)
- {
- fprintf(stderr, "cannot duplicate null pointer\n");
- exit(1);
- }
- tmp = strdup(string);
- if (!tmp)
- {
- fprintf(stderr, _("%s: out of memory\n"), progname);
- exit(1);
- }
- return tmp;
-}
-
-void *
-pg_malloc(size_t size)
-{
- void *tmp;
-
- tmp = malloc(size);
- if (!tmp)
- {
- fprintf(stderr, _("%s: out of memory\n"), progname);
- exit(1);
- }
- return tmp;
-}
$pgdumpall->AddIncludeDir('src\backend');
$pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c');
$pgdumpall->AddFile('src\bin\pg_dump\dumputils.c');
+ $pgdumpall->AddFile('src\bin\pg_dump\dumpmem.c');
$pgdumpall->AddFile('src\bin\pg_dump\keywords.c');
$pgdumpall->AddFile('src\backend\parser\kwlookup.c');