[BUGS] BUG #1279: pg_dump/resore has trouble with implicit sequences of renamed tables

2004-10-05 Thread PostgreSQL Bugs List

The following bug has been logged online:

Bug reference:  1279
Logged by:  adrian kierman

Email address:  [EMAIL PROTECTED]

PostgreSQL version: 7.4.1

Operating system:   fedora2

Description:pg_dump/resore has trouble with implicit sequences of 
renamed tables 

Details: 

Thanks for a brilliant database - pg_dump/restore succesfully handled my 2 
gig database transfer except for an issue with implicit sequences. 

Steps to recreate the bug
1. create a table with a serial data type and implicit sequence
2. rename the table to something else
3. select nextval a couple of times on the sequence to advace it
4. dump and restore it to a different db

you'll notice that the sequence of the restored table is set to zero (or 
rather is_called=false). Thus the value of the sequence has not been loaded. 
In addition stored procedures making use of the original sequence will not 
work as the implicit sequence created on resore had a different name based 
on the now modified table name.  

potential solution: have pg_dump dump out the sequences explicitly instead 
of implicitly. -or- create an alter sequence name and use it to set the name 
back to the old db's sequence name before calling setval I dont know the 
backend well enough to know the potential issues with these aproaches. 

once again thanks for postgres


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [BUGS] BUG #1279: pg_dump/resore has trouble with implicit sequences of renamed tables

2004-10-05 Thread Tom Lane
"PostgreSQL Bugs List" <[EMAIL PROTECTED]> writes:
> Description:pg_dump/resore has trouble with implicit sequences of 
> renamed tables 

Yeah, this is addressed in 8.0's pg_dump, but the solution isn't
portable back to existing releases (it needs a new backend function).

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


[BUGS] pg_dumpall bug in PG 8.0b3 Win32 port

2004-10-05 Thread Luiz K. Matsumura
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")