Hi,
I tried to use pg_dumpall in Win32 and receive a error message like this:
pg_dump.exe: [archiver (db)] connection to database "test" failed:
FATAL: user "'postgres'" does not exist
Well, the word "'postgres'" is the word is between simple quotations
marks and later between double quotations marks.
Then, I assume that the error must be in string that pg_dumpall mounts
to execute pg_dump
I modified pg_dumpall.c lines between 160 and 270 to add a #ifndef
WIN32... #endif clause to pgdumpopts to store
the parameters with double quotations intead simple quotation marks in
case of WIN32 ports
But, I don't have how to test it.
Please, somebody can test and fix the pg_dumpall.c of oficial source ?
Thanks in advance
Luiz
/*-
*
* pg_dumpall
*
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql-server/src/bin/pg_dump/pg_dumpall.c,v 1.51 2004/08/29 05:06:53
momjian Exp $
*
*-
*/
#include "postgres_fe.h"
#include
#ifdef ENABLE_NLS
#include
#endif
#ifndef HAVE_STRDUP
#include "strdup.h"
#endif
#include
#include
#include "getopt_long.h"
#ifndef HAVE_OPTRESET
int optreset;
#endif
#include "dumputils.h"
#include "libpq-fe.h"
#include "pg_backup.h"
#include "pqexpbuffer.h"
#define _(x) gettext((x))
/* version string we expect back from postgres */
#define PG_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
static const char *progname;
static void help(void);
static void dumpUsers(PGconn *conn, bool initdbonly);
static void dumpGroups(PGconn *conn);
static void dumpTablespaces(PGconn *conn);
static void dumpCreateDB(PGconn *conn);
static void dumpDatabaseConfig(PGconn *conn, const char *dbname);
static void dumpUserConfig(PGconn *conn, const char *username);
static void makeAlterConfigCommand(const char *arrayitem, const char *type, const char
*name);
static void dumpDatabases(PGconn *conn);
static void dumpTimestamp(char *msg);
static int runPgDump(const char *dbname);
static PGconn *connectDatabase(const char *dbname, const char *pghost, const char
*pgport,
const char *pguser, bool require_password);
static PGresult *executeQuery(PGconn *conn, const char *query);
charpg_dump_bin[MAXPGPATH];
PQExpBuffer pgdumpopts;
booloutput_clean = false;
boolskip_acls = false;
boolverbose = false;
int server_version;
/* flags for -X long options */
int disable_dollar_quoting = 0;
int disable_triggers = 0;
int use_setsessauth = 0;
int
main(int argc, char *argv[])
{
char *pghost = NULL;
char *pgport = NULL;
char *pguser = NULL;
boolforce_password = false;
booldata_only = false;
boolglobals_only = false;
boolschema_only = false;
PGconn *conn;
int c,
ret;
static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"clean", no_argument, NULL, 'c'},
{"inserts", no_argument, NULL, 'd'},
{"attribute-inserts", no_argument, NULL, 'D'},
{"column-inserts", no_argument, NULL, 'D'},
{"globals-only", no_argument, NULL, 'g'},
{"host", required_argument, NULL, 'h'},
{"ignore-version", no_argument, NULL, 'i'},
{"oids", no_argument, NULL, 'o'},
{"no-owner", no_argument, NULL, 'O'},
{"port", required_argument, NULL, 'p'},
{"password", no_argument, NULL, 'W'},
{"schema-only", no_argument, NULL, 's'},
{"superuser", required_argument, NULL, 'S'},
{"username", required_argument, NULL, 'U'},
{"verbose", no_argument, NULL, 'v'},
{"no-privileges", no_argument, NULL, 'x'},
{"no-acl", no_argument, NULL, 'x'},
/*
* the following options don't have an equivalent short option
* letter, but are available as '-X long-name'
*/
{"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &disable_triggers, 1},
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
{NULL, 0, NULL, 0}
};
int optindex;
set_pglocale_pgservice(argv[0], "pg_dump");
progname = get_progname(argv[0]);
if (argc > 1)
{
if (strcmp(argv[1], "--help")