Thread: Re: backup + restore fails

Re: backup + restore fails

From
Andreas Seltenreich
Date:
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); }


Re: [BUGS] backup + restore fails

From
Tom Lane
Date:
Andreas Seltenreich <andreas+pg@gate450.dyndns.org> writes:
> 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.

Done, thanks.
        regards, tom lane


Re: [BUGS] backup + restore fails

From
Bruce Momjian
Date:
This will be fixed in 8.2 by suppressing %Z on Windows.

---------------------------------------------------------------------------

Andreas Seltenreich wrote:
> 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);
>   }
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

--  Bruce Momjian   bruce@momjian.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +