Re: backup + restore fails

From: Andreas Seltenreich <andreas+pg(at)gate450(dot)dyndns(dot)org>
To: pgsql-bugs(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Cc: "Schoenen\, Holger" <holger(dot)schoenen(at)sds-bs(dot)de>
Subject: Re: backup + restore fails
Date: 2006-10-20 19:33:51
Message-ID: 877iyu3hpc.fsf@gate450.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Holger Schoenen writes:

> ERROR: invalid byte sequence for encoding "UTF8": 0xe46973
> Command was: --
[...]
> -- Started on 2006-09-15 14:56:51 Westeuropäische Normalzeit

The same problem was recently reported on the pgsql-de-allgemein list.

Would just avoiding %Z in Win32's strftime be an acceptable solution?
elog.c is already doing this, however because of the length of the
zone names, not the localization problem. The attached patch is
completely untested because I don't have access to a win32 box.

regards,
andreas

Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.137
diff -c -r1.137 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c 14 Oct 2006 23:07:22 -0000 1.137
--- src/bin/pg_dump/pg_backup_archiver.c 20 Oct 2006 18:59:11 -0000
***************
*** 2780,2785 ****
{
char buf[256];

! if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&tim)) != 0)
ahprintf(AH, "-- %s %s\n\n", msg, buf);
}
--- 2780,2793 ----
{
char buf[256];

! if (strftime(buf, 256,
! /* Win32 timezone names are long and localized and
! * can interfere with utf-8 dumps */
! #ifndef WIN32
! "%Y-%m-%d %H:%M:%S %Z",
! #else
! "%Y-%m-%d %H:%M:%S",
! #endif
! localtime(&tim)) != 0)
ahprintf(AH, "-- %s %s\n\n", msg, buf);
}
Index: src/bin/pg_dump/pg_dumpall.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v
retrieving revision 1.84
diff -c -r1.84 pg_dumpall.c
*** src/bin/pg_dump/pg_dumpall.c 7 Oct 2006 20:59:05 -0000 1.84
--- src/bin/pg_dump/pg_dumpall.c 20 Oct 2006 18:59:12 -0000
***************
*** 1320,1325 ****
char buf[256];
time_t now = time(NULL);

! if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
printf("-- %s %s\n\n", msg, buf);
}
--- 1320,1333 ----
char buf[256];
time_t now = time(NULL);

! if (strftime(buf, 256,
! /* Win32 timezone names are long and localized and
! * can interfere with utf-8 dumps */
! #ifndef WIN32
! "%Y-%m-%d %H:%M:%S %Z",
! #else
! "%Y-%m-%d %H:%M:%S",
! #endif
! localtime(&now)) != 0)
printf("-- %s %s\n\n", msg, buf);
}

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message j.random.programmer 2006-10-20 21:51:52 Bug in 8.1.5: cannot add literal timestamp value and a interval.
Previous Message Alvaro Herrera 2006-10-20 13:59:33 Re: Freezing is not WAL-logged

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2006-10-20 19:43:40 Re: misbehaving planer?
Previous Message Martijn van Oosterhout 2006-10-20 19:10:30 Re: [SPAM?] Re: Asynchronous I/O Support