According to me update logs, somewhere between zlib versions 1.2.3.4 and 1.2.6, the definition of the gzFile type was changed from void * to struct gzFile_s *, an opaque struct. Note that gzFile is already the pointer in either case. Our code has assumed, however, that you use gzFile like FILE, namely that the APIs take a pointer to the type, but that is not the case. So code like
gzFile *handle = gzopen(...) is wrong. This used to pass silently because you can assign a void* to a void**, but with the newer definition you get a bunch of warnings like pg_backup_files.c: In function ‘_StartData’: pg_backup_files.c:256:11: warning: assignment from incompatible pointer type [enabled by default] pg_backup_files.c: In function ‘_WriteData’: pg_backup_files.c:271:2: warning: passing argument 1 of ‘gzwrite’ from incompatible pointer type [enabled by default] /usr/include/zlib.h:1318:12: note: expected ‘gzFile’ but argument is of type ‘struct gzFile_s **’ Affected are pg_dump and pg_basebackup. Fixing most of this is not difficult, see attached patch. The only ugliness is in pg_backup_archiver.h FILE *FH; /* General purpose file handle */ which is used throughout pg_dump as sometimes a real FILE* and sometimes a gzFile handle. There are also some fileno() calls on this, so just replacing this with an #ifdef isn't going to work. This might need some more restructuring to make the code truly type-safe. My quick patch replaces the type with void*, thus sort of restoring the original situation that allowed this to work. Note that these are only warnings, so we probably don't need to worry about backpatching this in a hurry.
*** i/src/bin/pg_basebackup/pg_basebackup.c --- w/src/bin/pg_basebackup/pg_basebackup.c *************** *** 82,88 **** static bool segment_callback(XLogRecPtr segendpos, uint32 timeline); #ifdef HAVE_LIBZ static const char * ! get_gz_error(gzFile *gzf) { int errnum; const char *errmsg; --- 82,88 ---- #ifdef HAVE_LIBZ static const char * ! get_gz_error(gzFile gzf) { int errnum; const char *errmsg; *************** *** 450,456 **** ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) FILE *tarfile = NULL; #ifdef HAVE_LIBZ ! gzFile *ztarfile = NULL; #endif if (PQgetisnull(res, rownum, 0)) --- 450,456 ---- FILE *tarfile = NULL; #ifdef HAVE_LIBZ ! gzFile ztarfile = NULL; #endif if (PQgetisnull(res, rownum, 0)) *** i/src/bin/pg_dump/pg_backup_archiver.h --- w/src/bin/pg_dump/pg_backup_archiver.h *************** *** 247,253 **** typedef struct _archiveHandle int blobCount; /* # of blobs restored */ char *fSpec; /* Archive File Spec */ ! FILE *FH; /* General purpose file handle */ void *OF; int gzOut; /* Output file */ --- 247,253 ---- int blobCount; /* # of blobs restored */ char *fSpec; /* Archive File Spec */ ! void *FH; /* General purpose file handle */ void *OF; int gzOut; /* Output file */ *** i/src/bin/pg_dump/pg_backup_files.c --- w/src/bin/pg_dump/pg_backup_files.c *************** *** 60,66 **** typedef struct typedef struct { #ifdef HAVE_LIBZ ! gzFile *FH; #else FILE *FH; #endif --- 60,66 ---- typedef struct { #ifdef HAVE_LIBZ ! gzFile FH; #else FILE *FH; #endif *** i/src/bin/pg_dump/pg_backup_tar.c --- w/src/bin/pg_dump/pg_backup_tar.c *************** *** 58,73 **** static void _EndBlobs(ArchiveHandle *AH, TocEntry *te); #define K_STD_BUF_SIZE 1024 #ifdef HAVE_LIBZ ! /* typedef gzFile ThingFile; */ ! typedef FILE ThingFile; #else ! typedef FILE ThingFile; #endif - - typedef struct - { - ThingFile *zFH; FILE *nFH; FILE *tarFH; FILE *tmpFH; --- 58,70 ---- #define K_STD_BUF_SIZE 1024 + typedef struct + { #ifdef HAVE_LIBZ ! gzFile zFH; #else ! FILE *zFH; #endif FILE *nFH; FILE *tarFH; FILE *tmpFH;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers