Re: [PATCHES] pg_restore ignore error patch v2

2004-04-19 Thread Bruce Momjian

[ Newest version.]

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---


Fabien COELHO wrote:
 
 Dear patchers,
 
 please find attached a small patch so that pg_restore ignores some sql
 errors. This is the second submission, which integrates Tom comments about
 localisation and exit code. I also added some comments about one sql
 command which is not ignored.
 
 I tested it.
 
 Have a nice day,
 
 -- 
 Fabien Coelho - [EMAIL PROTECTED]

Content-Description: 

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 6: Have you searched our list archives?
 
http://archives.postgresql.org

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(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


Re: [PATCHES] pg_restore ignore error patch v2

2004-04-19 Thread Bruce Momjian

Ah, this v2 version has the proper exit code.  Great.

---

Fabien COELHO wrote:
 
 Dear patchers,
 
 please find attached a small patch so that pg_restore ignores some sql
 errors. This is the second submission, which integrates Tom comments about
 localisation and exit code. I also added some comments about one sql
 command which is not ignored.
 
 I tested it.
 
 Have a nice day,
 
 -- 
 Fabien Coelho - [EMAIL PROTECTED]

Content-Description: 

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 6: Have you searched our list archives?
 
http://archives.postgresql.org

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


[PATCHES] pg_restore ignore error patch v2

2004-04-10 Thread Fabien COELHO

Dear patchers,

please find attached a small patch so that pg_restore ignores some sql
errors. This is the second submission, which integrates Tom comments about
localisation and exit code. I also added some comments about one sql
command which is not ignored.

I tested it.

Have a nice day,

-- 
Fabien Coelho - [EMAIL PROTECTED]*** ./src/bin/pg_dump/pg_backup.h.orig  Wed Mar 24 17:19:43 2004
--- ./src/bin/pg_dump/pg_backup.h   Sat Apr 10 13:04:21 2004
***
*** 57,62 
--- 57,67 
int remoteVersion;
int minRemoteVersion;
int maxRemoteVersion;
+ 
+   /* error handling */
+ bool  die_on_errors;  /* whether to die on sql errors... */
+   int n_errors;   /* number of errors (if no 
die) */
+ 
/* The rest is private */
  } Archive;
  
*** ./src/bin/pg_dump/pg_backup_archiver.c.orig Wed Mar 24 17:19:43 2004
--- ./src/bin/pg_dump/pg_backup_archiver.c  Sat Apr 10 13:09:55 2004
***
*** 1197,1202 
--- 1197,1220 
va_end(ap);
  }
  
+ /* on some error, we may decide to go on... */
+ void
+ warn_or_die_horribly(ArchiveHandle *AH, 
+const char *modulename, const char *fmt, ...)
+ {
+   va_list ap;
+   va_start(ap, fmt);
+   if (AH-public.die_on_errors)
+   {
+   _die_horribly(AH, modulename, fmt, ap);
+   }
+   else
+   {
+   _write_msg(modulename, fmt, ap);
+   AH-public.n_errors++;
+   }
+   va_end(ap);
+ }
  
  static void
  _moveAfter(ArchiveHandle *AH, TocEntry *pos, TocEntry *te)
***
*** 1651,1656 
--- 1669,1678 
die_horribly(AH, modulename, unrecognized file format 
\%d\\n, fmt);
}
  
+   /* sql error handling */
+   AH-public.die_on_errors = true;
+   AH-public.n_errors = 0;
+ 
return AH;
  }
  
***
*** 2011,2016 
--- 2033,2039 
res = PQexec(AH-connection, cmd-data);
  
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+   /* NOT warn_or_die_horribly... use -O instead to skip this. */
die_horribly(AH, modulename, could not set session user to 
\%s\: %s,
 user, PQerrorMessage(AH-connection));
  
***
*** 2042,2049 
res = PQexec(AH-connection, cmd-data);
  
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
!   die_horribly(AH, modulename, could not set default_with_oids: 
%s,
!PQerrorMessage(AH-connection));
  
PQclear(res);
}
--- 2065,2073 
res = PQexec(AH-connection, cmd-data);
  
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
!   warn_or_die_horribly(AH, modulename, 
!could not set 
default_with_oids: %s,
!
PQerrorMessage(AH-connection));
  
PQclear(res);
}
***
*** 2181,2188 
res = PQexec(AH-connection, qry-data);
  
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
!   die_horribly(AH, modulename, could not set search_path to 
\%s\: %s,
!schemaName, 
PQerrorMessage(AH-connection));
  
PQclear(res);
}
--- 2205,2213 
res = PQexec(AH-connection, qry-data);
  
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
!   warn_or_die_horribly(AH, modulename, 
!could not set 
search_path to \%s\: %s,
!schemaName, 
PQerrorMessage(AH-connection));
  
PQclear(res);
}
*** ./src/bin/pg_dump/pg_backup_archiver.h.orig Wed Mar 24 17:19:43 2004
--- ./src/bin/pg_dump/pg_backup_archiver.h  Sat Apr 10 13:04:21 2004
***
*** 281,286 
--- 281,287 
  extern const char *progname;
  
  extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char 
*fmt,...) __attribute__((format(printf, 3, 4)));
+ extern void warn_or_die_horribly(ArchiveHandle *AH, const char *modulename, const 
char *fmt,...) __attribute__((format(printf, 3, 4)));
  extern void write_msg(const char *modulename, const char *fmt,...) 
__attribute__((format(printf, 2, 3)));
  
  extern void WriteTOC(ArchiveHandle *AH);
*** ./src/bin/pg_dump/pg_backup_db.c.orig   Wed Mar  3 22:28:54 2004
--- ./src/bin/pg_dump/pg_backup_db.cSat Apr 10 13:04:21 2004
***
*** 316,323