Commit 6faf8024 authored by Peter Eisentraut's avatar Peter Eisentraut

Enable large file support.

Use off_t and size_t in pg_dump to handle file offset arithmetic correctly.
parent 0d6f6138
...@@ -858,6 +858,7 @@ Optional Features: ...@@ -858,6 +858,7 @@ Optional Features:
--enable-depend turn on automatic dependency tracking --enable-depend turn on automatic dependency tracking
--enable-cassert enable assertion checks (for debugging) --enable-cassert enable assertion checks (for debugging)
--enable-odbc build the ODBC driver package --enable-odbc build the ODBC driver package
--disable-largefile omit support for large files
Optional Packages: Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
...@@ -12147,6 +12148,157 @@ fi ...@@ -12147,6 +12148,157 @@ fi
done done
echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5
echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6
if test "${ac_cv_sys_largefile_source+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
while :; do
ac_cv_sys_largefile_source=no
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <stdio.h>
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
return !fseeko;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#define _LARGEFILE_SOURCE 1
#include <stdio.h>
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
return !fseeko;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sys_largefile_source=1; break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
break
done
fi
echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5
echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6
if test "$ac_cv_sys_largefile_source" != no; then
cat >>confdefs.h <<_ACEOF
#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
_ACEOF
fi
rm -f conftest*
# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
# in glibc 2.1.3, but that breaks too many other things.
# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
echo "$as_me:$LINENO: checking for fseeko" >&5
echo $ECHO_N "checking for fseeko... $ECHO_C" >&6
if test "${ac_cv_func_fseeko+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <stdio.h>
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
return fseeko && fseeko (stdin, 0, 0);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_fseeko=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_fseeko=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_func_fseeko" >&5
echo "${ECHO_T}$ac_cv_func_fseeko" >&6
if test $ac_cv_func_fseeko = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_FSEEKO 1
_ACEOF
fi
# This test makes sure that run tests work at all. Sometimes a shared # This test makes sure that run tests work at all. Sometimes a shared
# library is found by the linker, but the runtime linker can't find it. # library is found by the linker, but the runtime linker can't find it.
...@@ -15127,6 +15279,321 @@ _ACEOF ...@@ -15127,6 +15279,321 @@ _ACEOF
fi fi
HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
if test $ac_cv_func_fseeko = yes; then
# Check whether --enable-largefile or --disable-largefile was given.
if test "${enable_largefile+set}" = set; then
enableval="$enable_largefile"
fi;
if test "$enable_largefile" != no; then
echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6
if test "${ac_cv_sys_largefile_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_sys_largefile_CC=no
if test "$GCC" != yes; then
ac_save_CC=$CC
while :; do
# IRIX 6.2 and later do not support large files by default,
# so use the C compiler's -n32 option if that helps.
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext
CC="$CC -n32"
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sys_largefile_CC=' -n32'; break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext
break
done
CC=$ac_save_CC
rm -f conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6
if test "$ac_cv_sys_largefile_CC" != no; then
CC=$CC$ac_cv_sys_largefile_CC
fi
echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6
if test "${ac_cv_sys_file_offset_bits+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
while :; do
ac_cv_sys_file_offset_bits=no
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sys_file_offset_bits=64; break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
break
done
fi
echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6
if test "$ac_cv_sys_file_offset_bits" != no; then
cat >>confdefs.h <<_ACEOF
#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
_ACEOF
fi
rm -f conftest*
echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6
if test "${ac_cv_sys_large_files+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
while :; do
ac_cv_sys_large_files=no
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#define _LARGE_FILES 1
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sys_large_files=1; break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
break
done
fi
echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
echo "${ECHO_T}$ac_cv_sys_large_files" >&6
if test "$ac_cv_sys_large_files" != no; then
cat >>confdefs.h <<_ACEOF
#define _LARGE_FILES $ac_cv_sys_large_files
_ACEOF
fi
rm -f conftest*
fi
fi
# Select semaphore implementation type. # Select semaphore implementation type.
......
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.194 2002/07/27 20:10:03 petere Exp $ dnl $Header: /cvsroot/pgsql/configure.in,v 1.195 2002/08/20 17:54:43 petere Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [], ...@@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [],
[AC_CHECK_FUNCS(on_exit, [], [AC_CHECK_FUNCS(on_exit, [],
[AC_MSG_ERROR([neither atexit() nor on_exit() found])])]) [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
AC_FUNC_FSEEKO
# This test makes sure that run tests work at all. Sometimes a shared # This test makes sure that run tests work at all. Sometimes a shared
# library is found by the linker, but the runtime linker can't find it. # library is found by the linker, but the runtime linker can't find it.
...@@ -1159,6 +1161,9 @@ AC_CHECK_TYPES([sig_atomic_t], [], [], [#include <signal.h>]) ...@@ -1159,6 +1161,9 @@ AC_CHECK_TYPES([sig_atomic_t], [], [], [#include <signal.h>])
PGAC_FUNC_POSIX_SIGNALS PGAC_FUNC_POSIX_SIGNALS
if test $ac_cv_func_fseeko = yes; then
AC_SYS_LARGEFILE
fi
# Select semaphore implementation type. # Select semaphore implementation type.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.148 2002/08/19 19:33:34 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.149 2002/08/20 17:54:44 petere Exp $
--> -->
<appendix id="release"> <appendix id="release">
...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without ...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters. worries about funny characters.
--> -->
<literallayout><![CDATA[ <literallayout><![CDATA[
Files larger than 2 GB are now supported (if supported by the operating system)
SERIAL no longer implies UNIQUE; specify explicitly if index is wanted SERIAL no longer implies UNIQUE; specify explicitly if index is wanted
pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words. pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words.
CLUSTER is no longer hazardous to your schema CLUSTER is no longer hazardous to your schema
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.21 2002/08/18 09:36:25 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.22 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -144,7 +144,7 @@ extern void ArchiveEntry(Archive *AHX, const char *oid, const char *tag, ...@@ -144,7 +144,7 @@ extern void ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
DataDumperPtr dumpFn, void *dumpArg); DataDumperPtr dumpFn, void *dumpArg);
/* Called to write *data* to the archive */ /* Called to write *data* to the archive */
extern int WriteData(Archive *AH, const void *data, int dLen); extern size_t WriteData(Archive *AH, const void *data, size_t dLen);
/* /*
extern int StartBlobs(Archive* AH); extern int StartBlobs(Archive* AH);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.54 2002/08/18 09:36:25 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.55 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -581,8 +581,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt ...@@ -581,8 +581,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt
*/ */
/* Public */ /* Public */
int size_t
WriteData(Archive *AHX, const void *data, int dLen) WriteData(Archive *AHX, const void *data, size_t dLen)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
...@@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag, ...@@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
(*AH->ArchiveEntryPtr) (AH, newToc); (*AH->ArchiveEntryPtr) (AH, newToc);
/* /*
* printf("New toc owned by '%s', oid %d\n", newToc->owner, * printf("New toc owned by '%s', oid %u\n", newToc->owner,
* newToc->oidVal); * newToc->oidVal);
*/ */
} }
...@@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid) ...@@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
if (AH->lo_buf_used > 0) if (AH->lo_buf_used > 0)
{ {
/* Write remaining bytes from the LO buffer */ /* Write remaining bytes from the LO buffer */
int res; size_t res;
res = lo_write(AH->connection, AH->loFd, (void *) AH->lo_buf, AH->lo_buf_used); res = lo_write(AH->connection, AH->loFd, (void *) AH->lo_buf, AH->lo_buf_used);
ahlog(AH, 5, "wrote remaining %d bytes of large object data (result = %d)\n", ahlog(AH, 5, "wrote remaining %lu bytes of large object data (result = %lu)\n",
(int)AH->lo_buf_used, res); (unsigned long) AH->lo_buf_used, (unsigned long) res);
if (res != AH->lo_buf_used) if (res != AH->lo_buf_used)
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n", die_horribly(AH, modulename, "could not write to large object (result: %lu, expected: %lu)\n",
res, AH->lo_buf_used); (unsigned long) res, (unsigned long) AH->lo_buf_used);
AH->lo_buf_used = 0; AH->lo_buf_used = 0;
} }
...@@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH) ...@@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH)
int int
ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{ {
int res; size_t res;
if (AH->writingBlob) if (AH->writingBlob)
{ {
if(AH->lo_buf_used + size * nmemb > AH->lo_buf_size) { if (AH->lo_buf_used + size * nmemb > AH->lo_buf_size)
/* Split LO buffer */ {
int remaining = AH->lo_buf_size - AH->lo_buf_used; /* Split LO buffer */
int slack = nmemb * size - remaining; size_t remaining = AH->lo_buf_size - AH->lo_buf_used;
size_t slack = nmemb * size - remaining;
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, remaining);
res = lo_write(AH->connection, AH->loFd, AH->lo_buf, AH->lo_buf_size); memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, remaining);
ahlog(AH, 5, "wrote %d bytes of large object data (result = %d)\n", res = lo_write(AH->connection, AH->loFd, AH->lo_buf, AH->lo_buf_size);
AH->lo_buf_size, res); ahlog(AH, 5, "wrote %lu bytes of large object data (result = %lu)\n",
if (res != AH->lo_buf_size) (unsigned long) AH->lo_buf_size, (unsigned long) res);
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n", if (res != AH->lo_buf_size)
res, AH->lo_buf_size); die_horribly(AH, modulename,
memcpy(AH->lo_buf, (char *)ptr + remaining, slack); "could not write to large object (result: %lu, expected: %lu)\n",
AH->lo_buf_used = slack; (unsigned long) res, (unsigned long) AH->lo_buf_size);
} else { memcpy(AH->lo_buf, (char *)ptr + remaining, slack);
/* LO Buffer is still large enough, buffer it */ AH->lo_buf_used = slack;
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb); }
AH->lo_buf_used += size * nmemb; else
} {
/* LO Buffer is still large enough, buffer it */
return size * nmemb; memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb);
AH->lo_buf_used += size * nmemb;
}
return size * nmemb;
} }
else if (AH->gzOut) else if (AH->gzOut)
{ {
...@@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{ {
res = fwrite((void *) ptr, size, nmemb, AH->OF); res = fwrite((void *) ptr, size, nmemb, AH->OF);
if (res != nmemb) if (res != nmemb)
die_horribly(AH, modulename, "could not write to output file (%d != %d)\n", die_horribly(AH, modulename, "could not write to output file (%lu != %lu)\n",
res, (int) nmemb); (unsigned long) res, (unsigned long) nmemb);
return res; return res;
} }
} }
...@@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt) ...@@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt)
return _tocEntryRequired(te, ropt); return _tocEntryRequired(te, ropt);
} }
int size_t
WriteInt(ArchiveHandle *AH, int i) WriteInt(ArchiveHandle *AH, int i)
{ {
int b; int b;
...@@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH) ...@@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH)
return res; return res;
} }
int size_t
WriteStr(ArchiveHandle *AH, const char *c) WriteStr(ArchiveHandle *AH, const char *c)
{ {
int res; size_t res;
if (c) if (c)
{ {
...@@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
{ {
FILE *fh; FILE *fh;
char sig[6]; /* More than enough */ char sig[6]; /* More than enough */
int cnt; size_t cnt;
int wantClose = 0; int wantClose = 0;
#if 0 #if 0
...@@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
if (ferror(fh)) if (ferror(fh))
die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno)); die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno));
else else
die_horribly(AH, modulename, "input file is too short (read %d, expected 5)\n", cnt); die_horribly(AH, modulename, "input file is too short (read %lu, expected 5)\n",
(unsigned long) cnt);
} }
/* Save it, just in case we need it later */ /* Save it, just in case we need it later */
...@@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
} }
/* If we can't seek, then mark the header as read */ /* If we can't seek, then mark the header as read */
if (fseek(fh, 0, SEEK_SET) != 0) if (fseeko(fh, 0, SEEK_SET) != 0)
{ {
/* /*
* NOTE: Formats that use the looahead buffer can unset this in * NOTE: Formats that use the looahead buffer can unset this in
...@@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
AH->lookaheadLen = 0; /* Don't bother since we've reset the file */ AH->lookaheadLen = 0; /* Don't bother since we've reset the file */
#if 0 #if 0
write_msg(modulename, "read %d bytes into lookahead buffer\n", AH->lookaheadLen); write_msg(modulename, "read %lu bytes into lookahead buffer\n",
(unsigned long) AH->lookaheadLen);
#endif #endif
/* Close the file */ /* Close the file */
...@@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH) ...@@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH)
AH->intSize = (*AH->ReadBytePtr) (AH); AH->intSize = (*AH->ReadBytePtr) (AH);
if (AH->intSize > 32) if (AH->intSize > 32)
die_horribly(AH, modulename, "sanity check on integer size (%d) failed\n", AH->intSize); die_horribly(AH, modulename, "sanity check on integer size (%lu) failed\n",
(unsigned long) AH->intSize);
if (AH->intSize > sizeof(int)) if (AH->intSize > sizeof(int))
write_msg(modulename, "WARNING: archive was made on a machine with larger integers, some operations may fail\n"); write_msg(modulename, "WARNING: archive was made on a machine with larger integers, some operations may fail\n");
...@@ -2368,7 +2375,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn) ...@@ -2368,7 +2375,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
for (i = 0; i <= AH->tocCount + 1; i++) for (i = 0; i <= AH->tocCount + 1; i++)
{ {
/* /*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next, * printf("%d: %x (%x, %x) - %u\n", i, te, te->prev, te->next,
* te->oidVal); * te->oidVal);
*/ */
tea[i] = te; tea[i] = te;
...@@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn) ...@@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
for (i = 0; i <= AH->tocCount + 1; i++) for (i = 0; i <= AH->tocCount + 1; i++)
{ {
/* /*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next, * printf("%d: %x (%x, %x) - %u\n", i, te, te->prev, te->next,
* te->oidVal); * te->oidVal);
*/ */
te = te->next; te = te->next;
...@@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2) ...@@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2)
Oid id2 = te2->maxOidVal; Oid id2 = te2->maxOidVal;
int cmpval; int cmpval;
/* printf("Comparing %d to %d\n", id1, id2); */ /* printf("Comparing %u to %u\n", id1, id2); */
cmpval = oidcmp(id1, id2); cmpval = oidcmp(id1, id2);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.45 2002/08/10 16:57:31 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.46 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,8 +48,8 @@ typedef struct _z_stream ...@@ -48,8 +48,8 @@ typedef struct _z_stream
{ {
void *next_in; void *next_in;
void *next_out; void *next_out;
int avail_in; size_t avail_in;
int avail_out; size_t avail_out;
} z_stream; } z_stream;
typedef z_stream *z_streamp; typedef z_stream *z_streamp;
#endif #endif
...@@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH); ...@@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef int (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, int dLen); typedef size_t (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, size_t dLen);
typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
...@@ -96,15 +96,15 @@ typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te); ...@@ -96,15 +96,15 @@ typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i); typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i);
typedef int (*ReadBytePtr) (struct _archiveHandle * AH); typedef int (*ReadBytePtr) (struct _archiveHandle * AH);
typedef int (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, int len); typedef size_t (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
typedef int (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, int len); typedef size_t (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
typedef void (*SaveArchivePtr) (struct _archiveHandle * AH); typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt); typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt);
typedef int (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, int len); typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
typedef int (*TocSortCompareFn) (const void *te1, const void *te2); typedef int (*TocSortCompareFn) (const void *te1, const void *te2);
...@@ -147,7 +147,7 @@ typedef struct _archiveHandle ...@@ -147,7 +147,7 @@ typedef struct _archiveHandle
int debugLevel; /* Used for logging (currently only by int debugLevel; /* Used for logging (currently only by
* --verbose) */ * --verbose) */
int intSize; /* Size of an integer in the archive */ size_t intSize; /* Size of an integer in the archive */
ArchiveFormat format; /* Archive format */ ArchiveFormat format; /* Archive format */
sqlparseInfo sqlparse; sqlparseInfo sqlparse;
...@@ -163,9 +163,9 @@ typedef struct _archiveHandle ...@@ -163,9 +163,9 @@ typedef struct _archiveHandle
* already */ * already */
char *lookahead; /* Buffer used when reading header to char *lookahead; /* Buffer used when reading header to
* discover format */ * discover format */
int lookaheadSize; /* Size of allocated buffer */ size_t lookaheadSize; /* Size of allocated buffer */
int lookaheadLen; /* Length of data in lookahead */ size_t lookaheadLen; /* Length of data in lookahead */
int lookaheadPos; /* Current read position in lookahead off_t lookaheadPos; /* Current read position in lookahead
* buffer */ * buffer */
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */ ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
...@@ -230,8 +230,8 @@ typedef struct _archiveHandle ...@@ -230,8 +230,8 @@ typedef struct _archiveHandle
RestoreOptions *ropt; /* Used to check restore options in RestoreOptions *ropt; /* Used to check restore options in
* ahwrite etc */ * ahwrite etc */
void *lo_buf; void *lo_buf;
int lo_buf_used; size_t lo_buf_used;
int lo_buf_size; size_t lo_buf_size;
} ArchiveHandle; } ArchiveHandle;
typedef struct _tocEntry typedef struct _tocEntry
...@@ -282,10 +282,10 @@ extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt); ...@@ -282,10 +282,10 @@ extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt);
* Mandatory routines for each supported format * Mandatory routines for each supported format
*/ */
extern int WriteInt(ArchiveHandle *AH, int i); extern size_t WriteInt(ArchiveHandle *AH, int i);
extern int ReadInt(ArchiveHandle *AH); extern int ReadInt(ArchiveHandle *AH);
extern char *ReadStr(ArchiveHandle *AH); extern char *ReadStr(ArchiveHandle *AH);
extern int WriteStr(ArchiveHandle *AH, const char *s); extern size_t WriteStr(ArchiveHandle *AH, const char *s);
extern void StartRestoreBlobs(ArchiveHandle *AH); extern void StartRestoreBlobs(ArchiveHandle *AH);
extern void StartRestoreBlob(ArchiveHandle *AH, Oid oid); extern void StartRestoreBlob(ArchiveHandle *AH, Oid oid);
......
...@@ -19,15 +19,7 @@ ...@@ -19,15 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.19 2002/05/29 01:38:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.20 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,12 +36,12 @@ ...@@ -44,12 +36,12 @@
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te);
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len); static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
...@@ -79,16 +71,16 @@ typedef struct ...@@ -79,16 +71,16 @@ typedef struct
z_streamp zp; z_streamp zp;
char *zlibOut; char *zlibOut;
char *zlibIn; char *zlibIn;
int inSize; size_t inSize;
int hasSeek; int hasSeek;
int filePos; off_t filePos;
int dataStart; off_t dataStart;
} lclContext; } lclContext;
typedef struct typedef struct
{ {
int dataPos; off_t dataPos;
int dataLen; size_t dataLen;
} lclTocEntry; } lclTocEntry;
...@@ -99,7 +91,7 @@ typedef struct ...@@ -99,7 +91,7 @@ typedef struct
static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id); static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id);
static void _StartDataCompressor(ArchiveHandle *AH, TocEntry *te); static void _StartDataCompressor(ArchiveHandle *AH, TocEntry *te);
static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te); static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te);
static int _getFilePos(ArchiveHandle *AH, lclContext *ctx); static off_t _getFilePos(ArchiveHandle *AH, lclContext *ctx);
static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush); static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush);
static char *modulename = gettext_noop("custom archiver"); static char *modulename = gettext_noop("custom archiver");
...@@ -156,8 +148,8 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -156,8 +148,8 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
/* Initialize LO buffering */ /* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE; AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE); AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL) if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n"); die_horribly(AH, modulename, "out of memory\n");
/* /*
* zlibOutSize is the buffer size we tell zlib it can output to. We * zlibOutSize is the buffer size we tell zlib it can output to. We
...@@ -188,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -188,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (!AH->FH) if (!AH->FH)
die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno)); die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
} }
else else
...@@ -201,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -201,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (!AH->FH) if (!AH->FH)
die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno)); die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
ReadHead(AH); ReadHead(AH);
ReadToc(AH); ReadToc(AH);
...@@ -285,7 +277,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te) ...@@ -285,7 +277,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
{ {
lclTocEntry *ctx = (lclTocEntry *) te->formatData; lclTocEntry *ctx = (lclTocEntry *) te->formatData;
ahprintf(AH, "-- Data Pos: %d (Length %d)\n", ctx->dataPos, ctx->dataLen); ahprintf(AH, "-- Data Pos: " INT64_FORMAT " (Length %lu)\n",
(int64) ctx->dataPos, (unsigned long) ctx->dataLen);
} }
/* /*
...@@ -323,8 +316,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te) ...@@ -323,8 +316,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
* Mandatory. * Mandatory.
* *
*/ */
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
z_streamp zp = ctx->zp; z_streamp zp = ctx->zp;
...@@ -334,7 +327,7 @@ _WriteData(ArchiveHandle *AH, const void *data, int dLen) ...@@ -334,7 +327,7 @@ _WriteData(ArchiveHandle *AH, const void *data, int dLen)
while (zp->avail_in != 0) while (zp->avail_in != 0)
{ {
/* printf("Deflating %d bytes\n", dLen); */ /* printf("Deflating %lu bytes\n", (unsigned long) dLen); */
_DoDeflate(AH, ctx, 0); _DoDeflate(AH, ctx, 0);
} }
return dLen; return dLen;
...@@ -486,7 +479,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -486,7 +479,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
/* Grab it */ /* Grab it */
if (fseek(AH->FH, tctx->dataPos, SEEK_SET) != 0) if (fseeko(AH->FH, tctx->dataPos, SEEK_SET) != 0)
die_horribly(AH, modulename, "error during file seek: %s\n", strerror(errno)); die_horribly(AH, modulename, "error during file seek: %s\n", strerror(errno));
_readBlockHeader(AH, &blkType, &id); _readBlockHeader(AH, &blkType, &id);
...@@ -532,9 +525,9 @@ _PrintData(ArchiveHandle *AH) ...@@ -532,9 +525,9 @@ _PrintData(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
z_streamp zp = ctx->zp; z_streamp zp = ctx->zp;
int blkLen; size_t blkLen;
char *in = ctx->zlibIn; char *in = ctx->zlibIn;
int cnt; size_t cnt;
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
int res; int res;
...@@ -573,7 +566,9 @@ _PrintData(ArchiveHandle *AH) ...@@ -573,7 +566,9 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH); cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen) if (cnt != blkLen)
die_horribly(AH, modulename, "could not read data block - expected %d, got %d\n", blkLen, cnt); die_horribly(AH, modulename,
"could not read data block - expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen; ctx->filePos += blkLen;
...@@ -683,9 +678,9 @@ static void ...@@ -683,9 +678,9 @@ static void
_skipData(ArchiveHandle *AH) _skipData(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int blkLen; size_t blkLen;
char *in = ctx->zlibIn; char *in = ctx->zlibIn;
int cnt; size_t cnt;
blkLen = ReadInt(AH); blkLen = ReadInt(AH);
while (blkLen != 0) while (blkLen != 0)
...@@ -699,7 +694,9 @@ _skipData(ArchiveHandle *AH) ...@@ -699,7 +694,9 @@ _skipData(ArchiveHandle *AH)
} }
cnt = fread(in, 1, blkLen, AH->FH); cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen) if (cnt != blkLen)
die_horribly(AH, modulename, "could not read data block - expected %d, got %d\n", blkLen, cnt); die_horribly(AH, modulename,
"could not read data block - expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen; ctx->filePos += blkLen;
...@@ -761,16 +758,18 @@ _ReadByte(ArchiveHandle *AH) ...@@ -761,16 +758,18 @@ _ReadByte(ArchiveHandle *AH)
* These routines are only used to read & write headers & TOC. * These routines are only used to read & write headers & TOC.
* *
*/ */
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fwrite(buf, 1, len, AH->FH); res = fwrite(buf, 1, len, AH->FH);
if (res != len) if (res != len)
die_horribly(AH, modulename, "write error in _WriteBuf (%d != %d)\n", res, len); die_horribly(AH, modulename,
"write error in _WriteBuf (%lu != %lu)\n",
(unsigned long) res, (unsigned long) len);
ctx->filePos += res; ctx->filePos += res;
return res; return res;
...@@ -785,11 +784,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len) ...@@ -785,11 +784,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
* These routines are only used to read & write headers & TOC. * These routines are only used to read & write headers & TOC.
* *
*/ */
static int static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, int len) _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fread(buf, 1, len, AH->FH); res = fread(buf, 1, len, AH->FH);
ctx->filePos += res; ctx->filePos += res;
...@@ -816,12 +815,12 @@ static void ...@@ -816,12 +815,12 @@ static void
_CloseArchive(ArchiveHandle *AH) _CloseArchive(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int tpos; off_t tpos;
if (AH->mode == archModeWrite) if (AH->mode == archModeWrite)
{ {
WriteHead(AH); WriteHead(AH);
tpos = ftell(AH->FH); tpos = ftello(AH->FH);
WriteToc(AH); WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx); ctx->dataStart = _getFilePos(AH, ctx);
WriteDataChunks(AH); WriteDataChunks(AH);
...@@ -834,7 +833,7 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -834,7 +833,7 @@ _CloseArchive(ArchiveHandle *AH)
*/ */
if (ctx->hasSeek) if (ctx->hasSeek)
{ {
fseek(AH->FH, tpos, SEEK_SET); fseeko(AH->FH, tpos, SEEK_SET);
WriteToc(AH); WriteToc(AH);
} }
} }
...@@ -853,14 +852,14 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -853,14 +852,14 @@ _CloseArchive(ArchiveHandle *AH)
/* /*
* Get the current position in the archive file. * Get the current position in the archive file.
*/ */
static int static off_t
_getFilePos(ArchiveHandle *AH, lclContext *ctx) _getFilePos(ArchiveHandle *AH, lclContext *ctx)
{ {
int pos; off_t pos;
if (ctx->hasSeek) if (ctx->hasSeek)
{ {
pos = ftell(AH->FH); pos = ftello(AH->FH);
if (pos != ctx->filePos) if (pos != ctx->filePos)
{ {
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell ignored\n"); write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell ignored\n");
...@@ -957,8 +956,8 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) ...@@ -957,8 +956,8 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
if (zp->avail_out < zlibOutSize) if (zp->avail_out < zlibOutSize)
{ {
/* /*
* printf("Wrote %d byte deflated chunk\n", zlibOutSize - * printf("Wrote %lu byte deflated chunk\n", (unsigned long) (zlibOutSize -
* zp->avail_out); * zp->avail_out));
*/ */
WriteInt(AH, zlibOutSize - zp->avail_out); WriteInt(AH, zlibOutSize - zp->avail_out);
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out)) if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver. * Implements the basic DB functions used by the archiver.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.37 2002/08/18 09:36:25 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.38 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include "pg_backup_db.h" #include "pg_backup_db.h"
#include <unistd.h> /* for getopt() */ #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
...@@ -347,7 +347,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc) ...@@ -347,7 +347,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
static char * static char *
_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos) _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos)
{ {
int loc; /* Location of next newline */ size_t loc; /* Location of next newline */
int pos = 0; /* Current position */ int pos = 0; /* Current position */
int sPos = 0; /* Last pos of a slash char */ int sPos = 0; /* Last pos of a slash char */
int isEnd = 0; int isEnd = 0;
...@@ -549,7 +549,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) ...@@ -549,7 +549,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
/* Convenience function to send one or more queries. Monitors result to handle COPY statements */ /* Convenience function to send one or more queries. Monitors result to handle COPY statements */
int int
ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen) ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen)
{ {
char *qry = (char *) qryv; char *qry = (char *) qryv;
char *eos = qry + bufLen; char *eos = qry + bufLen;
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
* Definitions for pg_backup_db.c * Definitions for pg_backup_db.c
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.7 2002/05/29 01:38:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.8 2002/08/20 17:54:44 petere Exp $
*/ */
#define BLOB_XREF_TABLE "pg_dump_blob_xref" /* MUST be lower case */ #define BLOB_XREF_TABLE "pg_dump_blob_xref" /* MUST be lower case */
extern void FixupBlobRefs(ArchiveHandle *AH, TocEntry *te); extern void FixupBlobRefs(ArchiveHandle *AH, TocEntry *te);
extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, bool use_blob); extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, bool use_blob);
extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, int bufLen); extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, size_t bufLen);
extern void CreateBlobXrefTable(ArchiveHandle *AH); extern void CreateBlobXrefTable(ArchiveHandle *AH);
extern void InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new); extern void InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new);
......
...@@ -20,15 +20,7 @@ ...@@ -20,15 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.16 2002/05/29 01:38:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.17 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,12 +30,12 @@ ...@@ -38,12 +30,12 @@
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te);
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len); static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
...@@ -60,7 +52,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te); ...@@ -60,7 +52,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
typedef struct typedef struct
{ {
int hasSeek; int hasSeek;
int filePos; off_t filePos;
FILE *blobToc; FILE *blobToc;
} lclContext; } lclContext;
...@@ -116,8 +108,8 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -116,8 +108,8 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
/* Initialize LO buffering */ /* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE; AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE); AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL) if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n"); die_horribly(AH, modulename, "out of memory\n");
/* /*
* Now open the TOC file * Now open the TOC file
...@@ -137,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -137,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(NULL, modulename, "could not open output file: %s\n", strerror(errno)); die_horribly(NULL, modulename, "could not open output file: %s\n", strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
if (AH->compression < 0 || AH->compression > 9) if (AH->compression < 0 || AH->compression > 9)
AH->compression = Z_DEFAULT_COMPRESSION; AH->compression = Z_DEFAULT_COMPRESSION;
...@@ -155,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -155,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(NULL, modulename, "could not open input file: %s\n", strerror(errno)); die_horribly(NULL, modulename, "could not open input file: %s\n", strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
ReadHead(AH); ReadHead(AH);
ReadToc(AH); ReadToc(AH);
...@@ -255,8 +247,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te) ...@@ -255,8 +247,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
} }
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData; lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData;
...@@ -284,7 +276,7 @@ static void ...@@ -284,7 +276,7 @@ static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
{ {
char buf[4096]; char buf[4096];
int cnt; size_t cnt;
if (!filename) if (!filename)
return; return;
...@@ -332,8 +324,8 @@ _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char fname[K_STD_BUF_SIZE]) ...@@ -332,8 +324,8 @@ _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char fname[K_STD_BUF_SIZE])
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
char blobTe[K_STD_BUF_SIZE]; char blobTe[K_STD_BUF_SIZE];
int fpos; size_t fpos;
int eos; size_t eos;
if (fgets(&blobTe[0], K_STD_BUF_SIZE - 1, ctx->blobToc) != NULL) if (fgets(&blobTe[0], K_STD_BUF_SIZE - 1, ctx->blobToc) != NULL)
{ {
...@@ -413,11 +405,11 @@ _ReadByte(ArchiveHandle *AH) ...@@ -413,11 +405,11 @@ _ReadByte(ArchiveHandle *AH)
return res; return res;
} }
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fwrite(buf, 1, len, AH->FH); res = fwrite(buf, 1, len, AH->FH);
if (res != len) if (res != len)
...@@ -427,11 +419,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len) ...@@ -427,11 +419,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
return res; return res;
} }
static int static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, int len) _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fread(buf, 1, len, AH->FH); res = fread(buf, 1, len, AH->FH);
ctx->filePos += res; ctx->filePos += res;
......
...@@ -17,16 +17,7 @@ ...@@ -17,16 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.9 2002/05/10 22:36:26 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.10 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 09-Jul-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
*
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,10 +29,10 @@ ...@@ -38,10 +29,10 @@
#include <string.h> #include <string.h>
#include <unistd.h> /* for dup */ #include <unistd.h> /* for dup */
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
...@@ -75,8 +66,8 @@ InitArchiveFmt_Null(ArchiveHandle *AH) ...@@ -75,8 +66,8 @@ InitArchiveFmt_Null(ArchiveHandle *AH)
* As at V1.3, this is only called for COPY FROM dfata, and BLOB data * As at V1.3, this is only called for COPY FROM dfata, and BLOB data
*------ *------
*/ */
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
/* Just send it to output */ /* Just send it to output */
ahwrite(data, 1, dLen, AH); ahwrite(data, 1, dLen, AH);
...@@ -112,8 +103,8 @@ _WriteByte(ArchiveHandle *AH, const int i) ...@@ -112,8 +103,8 @@ _WriteByte(ArchiveHandle *AH, const int i)
return 0; return 0;
} }
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
/* Don't do anything */ /* Don't do anything */
return len; return len;
......
...@@ -16,15 +16,7 @@ ...@@ -16,15 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.24 2002/07/04 15:35:07 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.25 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,12 +32,12 @@ ...@@ -40,12 +32,12 @@
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te);
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len); static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
...@@ -76,19 +68,19 @@ typedef struct ...@@ -76,19 +68,19 @@ typedef struct
FILE *tmpFH; FILE *tmpFH;
char *targetFile; char *targetFile;
char mode; char mode;
int pos; off_t pos;
int fileLen; off_t fileLen;
ArchiveHandle *AH; ArchiveHandle *AH;
} TAR_MEMBER; } TAR_MEMBER;
typedef struct typedef struct
{ {
int hasSeek; int hasSeek;
int filePos; off_t filePos;
TAR_MEMBER *blobToc; TAR_MEMBER *blobToc;
FILE *tarFH; FILE *tarFH;
int tarFHpos; off_t tarFHpos;
int tarNextMember; off_t tarNextMember;
TAR_MEMBER *FH; TAR_MEMBER *FH;
int isSpecialScript; int isSpecialScript;
TAR_MEMBER *scriptTH; TAR_MEMBER *scriptTH;
...@@ -108,20 +100,20 @@ static TAR_MEMBER *tarOpen(ArchiveHandle *AH, const char *filename, char mode); ...@@ -108,20 +100,20 @@ static TAR_MEMBER *tarOpen(ArchiveHandle *AH, const char *filename, char mode);
static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH); static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH);
#ifdef __NOT_USED__ #ifdef __NOT_USED__
static char *tarGets(char *buf, int len, TAR_MEMBER *th); static char *tarGets(char *buf, size_t len, TAR_MEMBER *th);
#endif #endif
static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...); static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...);
static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th); static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th);
static int _tarChecksum(char *th); static int _tarChecksum(char *th);
static TAR_MEMBER *_tarPositionTo(ArchiveHandle *AH, const char *filename); static TAR_MEMBER *_tarPositionTo(ArchiveHandle *AH, const char *filename);
static int tarRead(void *buf, int len, TAR_MEMBER *th); static size_t tarRead(void *buf, size_t len, TAR_MEMBER *th);
static int tarWrite(const void *buf, int len, TAR_MEMBER *th); static size_t tarWrite(const void *buf, size_t len, TAR_MEMBER *th);
static void _tarWriteHeader(TAR_MEMBER *th); static void _tarWriteHeader(TAR_MEMBER *th);
static int _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th); static int _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th);
static int _tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh); static size_t _tarReadRaw(ArchiveHandle *AH, void *buf, size_t len, TAR_MEMBER *th, FILE *fh);
static int _scriptOut(ArchiveHandle *AH, const void *buf, int len); static size_t _scriptOut(ArchiveHandle *AH, const void *buf, size_t len);
/* /*
* Initializer * Initializer
...@@ -161,8 +153,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -161,8 +153,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
/* Initialize LO buffering */ /* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE; AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE); AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL) if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n"); die_horribly(AH, modulename, "out of memory\n");
/* /*
* Now open the TOC file * Now open the TOC file
...@@ -187,7 +179,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -187,7 +179,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
*/ */
/* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */ /* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */
ctx->hasSeek = (fseek(ctx->tarFH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(ctx->tarFH, 0, SEEK_CUR) == 0);
if (AH->compression < 0 || AH->compression > 9) if (AH->compression < 0 || AH->compression > 9)
AH->compression = Z_DEFAULT_COMPRESSION; AH->compression = Z_DEFAULT_COMPRESSION;
...@@ -224,7 +216,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -224,7 +216,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
ctx->tarFHpos = 0; ctx->tarFHpos = 0;
ctx->hasSeek = (fseek(ctx->tarFH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(ctx->tarFH, 0, SEEK_CUR) == 0);
/* /*
* Forcibly unmark the header as read since we use the lookahead * Forcibly unmark the header as read since we use the lookahead
...@@ -421,10 +413,10 @@ tarClose(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -421,10 +413,10 @@ tarClose(ArchiveHandle *AH, TAR_MEMBER *th)
#ifdef __NOT_USED__ #ifdef __NOT_USED__
static char * static char *
tarGets(char *buf, int len, TAR_MEMBER *th) tarGets(char *buf, size_t len, TAR_MEMBER *th)
{ {
char *s; char *s;
int cnt = 0; size_t cnt = 0;
char c = ' '; char c = ' ';
int eof = 0; int eof = 0;
...@@ -464,13 +456,13 @@ tarGets(char *buf, int len, TAR_MEMBER *th) ...@@ -464,13 +456,13 @@ tarGets(char *buf, int len, TAR_MEMBER *th)
* Just read bytes from the archive. This is the low level read routine * Just read bytes from the archive. This is the low level read routine
* that is used for ALL reads on a tar file. * that is used for ALL reads on a tar file.
*/ */
static int static size_t
_tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh) _tarReadRaw(ArchiveHandle *AH, void *buf, size_t len, TAR_MEMBER *th, FILE *fh)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int avail; size_t avail;
int used = 0; size_t used = 0;
int res = 0; size_t res = 0;
avail = AH->lookaheadLen - AH->lookaheadPos; avail = AH->lookaheadLen - AH->lookaheadPos;
if (avail > 0) if (avail > 0)
...@@ -515,10 +507,10 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh) ...@@ -515,10 +507,10 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh)
return (res + used); return (res + used);
} }
static int static size_t
tarRead(void *buf, int len, TAR_MEMBER *th) tarRead(void *buf, size_t len, TAR_MEMBER *th)
{ {
int res; size_t res;
if (th->pos + len > th->fileLen) if (th->pos + len > th->fileLen)
len = th->fileLen - th->pos; len = th->fileLen - th->pos;
...@@ -533,10 +525,10 @@ tarRead(void *buf, int len, TAR_MEMBER *th) ...@@ -533,10 +525,10 @@ tarRead(void *buf, int len, TAR_MEMBER *th)
return res; return res;
} }
static int static size_t
tarWrite(const void *buf, int len, TAR_MEMBER *th) tarWrite(const void *buf, size_t len, TAR_MEMBER *th)
{ {
int res; size_t res;
if (th->zFH != 0) if (th->zFH != 0)
res = GZWRITE((void *) buf, 1, len, th->zFH); res = GZWRITE((void *) buf, 1, len, th->zFH);
...@@ -545,14 +537,15 @@ tarWrite(const void *buf, int len, TAR_MEMBER *th) ...@@ -545,14 +537,15 @@ tarWrite(const void *buf, int len, TAR_MEMBER *th)
if (res != len) if (res != len)
die_horribly(th->AH, modulename, die_horribly(th->AH, modulename,
"could not write to tar member (wrote %d, attempted %d)\n", res, len); "could not write to tar member (wrote %lu, attempted %lu)\n",
(unsigned long) res, (unsigned long) len);
th->pos += res; th->pos += res;
return res; return res;
} }
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData; lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData;
...@@ -579,7 +572,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) ...@@ -579,7 +572,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
char buf[4096]; char buf[4096];
int cnt; size_t cnt;
TAR_MEMBER *th; TAR_MEMBER *th;
if (!filename) if (!filename)
...@@ -607,7 +600,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -607,7 +600,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
lclTocEntry *tctx = (lclTocEntry *) te->formatData; lclTocEntry *tctx = (lclTocEntry *) te->formatData;
char *tmpCopy; char *tmpCopy;
int i, size_t i,
pos1, pos1,
pos2; pos2;
...@@ -651,8 +644,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -651,8 +644,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
if (pos2 >= strlen(tmpCopy)) if (pos2 >= strlen(tmpCopy))
die_horribly(AH, modulename, die_horribly(AH, modulename,
"bad COPY statement - could not find \"from stdin\" in string \"%s\" starting at position %d\n", "bad COPY statement - could not find \"from stdin\" in string \"%s\" starting at position %lu\n",
tmpCopy, pos1); tmpCopy, (unsigned long) pos1);
ahwrite(tmpCopy, 1, pos2, AH); /* 'copy "table" [with oids]' */ ahwrite(tmpCopy, 1, pos2, AH); /* 'copy "table" [with oids]' */
ahprintf(AH, " from '$$PATH$$/%s' %s", tctx->filename, &tmpCopy[pos2 + 10]); ahprintf(AH, " from '$$PATH$$/%s' %s", tctx->filename, &tmpCopy[pos2 + 10]);
...@@ -672,7 +665,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) ...@@ -672,7 +665,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
Oid oid; Oid oid;
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th; TAR_MEMBER *th;
int cnt; size_t cnt;
char buf[4096]; char buf[4096];
StartRestoreBlobs(AH); StartRestoreBlobs(AH);
...@@ -736,22 +729,22 @@ _ReadByte(ArchiveHandle *AH) ...@@ -736,22 +729,22 @@ _ReadByte(ArchiveHandle *AH)
return c; return c;
} }
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = tarWrite((void *) buf, len, ctx->FH); res = tarWrite((void *) buf, len, ctx->FH);
ctx->filePos += res; ctx->filePos += res;
return res; return res;
} }
static int static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, int len) _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = tarRead(buf, len, ctx->FH); res = tarRead(buf, len, ctx->FH);
ctx->filePos += res; ctx->filePos += res;
...@@ -834,8 +827,8 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -834,8 +827,8 @@ _CloseArchive(ArchiveHandle *AH)
AH->FH = NULL; AH->FH = NULL;
} }
static int static size_t
_scriptOut(ArchiveHandle *AH, const void *buf, int len) _scriptOut(ArchiveHandle *AH, const void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
...@@ -942,7 +935,7 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) ...@@ -942,7 +935,7 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...)
{ {
char *p = NULL; char *p = NULL;
va_list ap; va_list ap;
int bSize = strlen(fmt) + 256; /* Should be enough */ size_t bSize = strlen(fmt) + 256; /* Should be enough */
int cnt = -1; int cnt = -1;
/* /*
...@@ -1002,18 +995,18 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1002,18 +995,18 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
FILE *tmp = th->tmpFH; /* Grab it for convenience */ FILE *tmp = th->tmpFH; /* Grab it for convenience */
char buf[32768]; char buf[32768];
int cnt; size_t cnt;
int len = 0; off_t len = 0;
int res; size_t res;
int i, size_t i,
pad; pad;
/* /*
* Find file len & go back to start. * Find file len & go back to start.
*/ */
fseek(tmp, 0, SEEK_END); fseeko(tmp, 0, SEEK_END);
th->fileLen = ftell(tmp); th->fileLen = ftello(tmp);
fseek(tmp, 0, SEEK_SET); fseeko(tmp, 0, SEEK_SET);
_tarWriteHeader(th); _tarWriteHeader(th);
...@@ -1021,7 +1014,9 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1021,7 +1014,9 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
{ {
res = fwrite(&buf[0], 1, cnt, th->tarFH); res = fwrite(&buf[0], 1, cnt, th->tarFH);
if (res != cnt) if (res != cnt)
die_horribly(AH, modulename, "write error appending to tar archive (wrote %d, attempted %d)\n", res, cnt); die_horribly(AH, modulename,
"write error appending to tar archive (wrote %lu, attempted %lu)\n",
(unsigned long) res, (unsigned long) cnt);
len += res; len += res;
} }
...@@ -1029,8 +1024,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1029,8 +1024,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno)); die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
if (len != th->fileLen) if (len != th->fileLen)
die_horribly(AH, modulename, "actual file length (%d) does not match expected (%d)\n", die_horribly(AH, modulename, "actual file length (" INT64_FORMAT ") does not match expected (" INT64_FORMAT ")\n",
len, th->pos); (int64) len, (int64) th->pos);
pad = ((len + 511) & ~511) - len; pad = ((len + 511) & ~511) - len;
for (i = 0; i < pad; i++) for (i = 0; i < pad; i++)
...@@ -1050,25 +1045,24 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1050,25 +1045,24 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
TAR_MEMBER *th = calloc(1, sizeof(TAR_MEMBER)); TAR_MEMBER *th = calloc(1, sizeof(TAR_MEMBER));
char c; char c;
char header[512]; char header[512];
int i, size_t i,
len, len,
blks, blks;
id; int id;
th->AH = AH; th->AH = AH;
/* Go to end of current file, if any */ /* Go to end of current file, if any */
if (ctx->tarFHpos != 0) if (ctx->tarFHpos != 0)
{ {
ahlog(AH, 4, "moving from position %d (%x) to next member at file position %d (%x)\n", ahlog(AH, 4, "moving from position " INT64_FORMAT " to next member at file position " INT64_FORMAT "\n",
ctx->tarFHpos, ctx->tarFHpos, (int64) ctx->tarFHpos, (int64) ctx->tarNextMember);
ctx->tarNextMember, ctx->tarNextMember);
while (ctx->tarFHpos < ctx->tarNextMember) while (ctx->tarFHpos < ctx->tarNextMember)
_tarReadRaw(AH, &c, 1, NULL, ctx->tarFH); _tarReadRaw(AH, &c, 1, NULL, ctx->tarFH);
} }
ahlog(AH, 4, "now at file position %d (%x)\n", ctx->tarFHpos, ctx->tarFHpos); ahlog(AH, 4, "now at file position " INT64_FORMAT "\n", (int64) ctx->tarFHpos);
/* We are at the start of the file. or at the next member */ /* We are at the start of the file. or at the next member */
...@@ -1122,18 +1116,18 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1122,18 +1116,18 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
char tag[100]; char tag[100];
int sum, int sum,
chk; chk;
int len; size_t len;
int hPos; off_t hPos;
int i; int i;
bool gotBlock = false; bool gotBlock = false;
while (!gotBlock) while (!gotBlock)
{ {
#if 0 #if 0
if (ftell(ctx->tarFH) != ctx->tarFHpos) if (ftello(ctx->tarFH) != ctx->tarFHpos)
die_horribly(AH, modulename, die_horribly(AH, modulename,
"mismatch in actual vs. predicted file position (%d vs. %d)\n", "mismatch in actual vs. predicted file position (" INT64_FORMAT " vs. " INT64_FORMAT ")\n",
ftell(ctx->tarFH), ctx->tarFHpos); (int64) ftello(ctx->tarFH), (int64) ctx->tarFHpos);
#endif #endif
/* Save the pos for reporting purposes */ /* Save the pos for reporting purposes */
...@@ -1145,7 +1139,9 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1145,7 +1139,9 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
return 0; return 0;
if (len != 512) if (len != 512)
die_horribly(AH, modulename, "incomplete tar header found (%d bytes)\n", len); die_horribly(AH, modulename,
"incomplete tar header found (%lu bytes)\n",
(unsigned long) len);
/* Calc checksum */ /* Calc checksum */
chk = _tarChecksum(&h[0]); chk = _tarChecksum(&h[0]);
...@@ -1174,13 +1170,14 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1174,13 +1170,14 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
sscanf(&h[124], "%12o", &len); sscanf(&h[124], "%12o", &len);
sscanf(&h[148], "%8o", &sum); sscanf(&h[148], "%8o", &sum);
ahlog(AH, 3, "TOC Entry %s at %d (length %d, checksum %d)\n", &tag[0], hPos, len, sum); ahlog(AH, 3, "TOC Entry %s at " INT64_FORMAT " (length %lu, checksum %d)\n",
&tag[0], (int64) hPos, (unsigned long) len, sum);
if (chk != sum) if (chk != sum)
die_horribly(AH, modulename, die_horribly(AH, modulename,
"corrupt tar header found in %s " "corrupt tar header found in %s "
"(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n", "(expected %d, computed %d) file position " INT64_FORMAT "\n",
&tag[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH)); &tag[0], sum, chk, (int64) ftello(ctx->tarFH));
th->targetFile = strdup(tag); th->targetFile = strdup(tag);
th->fileLen = len; th->fileLen = len;
...@@ -1212,7 +1209,8 @@ _tarWriteHeader(TAR_MEMBER *th) ...@@ -1212,7 +1209,8 @@ _tarWriteHeader(TAR_MEMBER *th)
sprintf(&h[116], " 02000 "); sprintf(&h[116], " 02000 ");
/* File size 12 */ /* File size 12 */
sprintf(&h[124], "%10o ", th->fileLen); /* FIXME: This goes only up to 2^30. -- What about larger files? */
sprintf(&h[124], "%10o ", (unsigned int) th->fileLen);
/* Mod Time 12 */ /* Mod Time 12 */
sprintf(&h[136], "%10o ", (int) time(NULL)); sprintf(&h[136], "%10o ", (int) time(NULL));
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.287 2002/08/19 19:33:35 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.288 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1302,7 +1302,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) ...@@ -1302,7 +1302,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
int i; int i;
int loFd; int loFd;
char buf[loBufSize]; char buf[loBufSize];
int cnt; size_t cnt;
Oid blobOid; Oid blobOid;
if (g_verbose) if (g_verbose)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your * or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
* changes will be overwritten the next time you run configure. * changes will be overwritten the next time you run configure.
* *
* $Id: pg_config.h.in,v 1.27 2002/08/13 20:40:44 momjian Exp $ * $Id: pg_config.h.in,v 1.28 2002/08/20 17:54:45 petere Exp $
*/ */
#ifndef PG_CONFIG_H #ifndef PG_CONFIG_H
...@@ -720,6 +720,23 @@ extern int fdatasync(int fildes); ...@@ -720,6 +720,23 @@ extern int fdatasync(int fildes);
/* Define exactly one of these symbols to select shared-mem implementation */ /* Define exactly one of these symbols to select shared-mem implementation */
#undef USE_SYSV_SHARED_MEMORY #undef USE_SYSV_SHARED_MEMORY
/* Define to 1 to make fseeko visible on some hosts. */
#undef _LARGEFILE_SOURCE
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#undef HAVE_FSEEKO
#ifndef HAVE_FSEEKO
#define fseeko(a, b, c) fseek((a), (b), (c))
#define ftello(a) ftell((a))
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* /*
*------------------------------------------------------------------------ *------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment