Enable large file support.
Use off_t and size_t in pg_dump to handle file offset arithmetic correctly.
This commit is contained in:
parent
0d6f613817
commit
6faf8024fa
|
@ -858,6 +858,7 @@ Optional Features:
|
|||
--enable-depend turn on automatic dependency tracking
|
||||
--enable-cassert enable assertion checks (for debugging)
|
||||
--enable-odbc build the ODBC driver package
|
||||
--disable-largefile omit support for large files
|
||||
|
||||
Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
|
@ -12147,6 +12148,157 @@ fi
|
|||
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
|
||||
# library is found by the linker, but the runtime linker can't find it.
|
||||
|
@ -15127,6 +15279,321 @@ _ACEOF
|
|||
fi
|
||||
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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 Developers, please strive to achieve this order:
|
||||
dnl
|
||||
|
@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [],
|
|||
[AC_CHECK_FUNCS(on_exit, [],
|
||||
[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
|
||||
# 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>])
|
|||
|
||||
|
||||
PGAC_FUNC_POSIX_SIGNALS
|
||||
if test $ac_cv_func_fseeko = yes; then
|
||||
AC_SYS_LARGEFILE
|
||||
fi
|
||||
|
||||
|
||||
# Select semaphore implementation type.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!--
|
||||
$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">
|
||||
|
@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
|
|||
worries about funny characters.
|
||||
-->
|
||||
<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
|
||||
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
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*
|
||||
* 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,
|
|||
DataDumperPtr dumpFn, void *dumpArg);
|
||||
|
||||
/* 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);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*
|
||||
* 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
|
|||
*/
|
||||
|
||||
/* Public */
|
||||
int
|
||||
WriteData(Archive *AHX, const void *data, int dLen)
|
||||
size_t
|
||||
WriteData(Archive *AHX, const void *data, size_t dLen)
|
||||
{
|
||||
ArchiveHandle *AH = (ArchiveHandle *) AHX;
|
||||
|
||||
|
@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
|
|||
(*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);
|
||||
*/
|
||||
}
|
||||
|
@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
|
|||
if (AH->lo_buf_used > 0)
|
||||
{
|
||||
/* 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);
|
||||
|
||||
ahlog(AH, 5, "wrote remaining %d bytes of large object data (result = %d)\n",
|
||||
(int)AH->lo_buf_used, res);
|
||||
ahlog(AH, 5, "wrote remaining %lu bytes of large object data (result = %lu)\n",
|
||||
(unsigned long) AH->lo_buf_used, (unsigned long) res);
|
||||
if (res != AH->lo_buf_used)
|
||||
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n",
|
||||
res, AH->lo_buf_used);
|
||||
die_horribly(AH, modulename, "could not write to large object (result: %lu, expected: %lu)\n",
|
||||
(unsigned long) res, (unsigned long) AH->lo_buf_used);
|
||||
AH->lo_buf_used = 0;
|
||||
}
|
||||
|
||||
|
@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH)
|
|||
int
|
||||
ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
|
||||
{
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
if (AH->writingBlob)
|
||||
{
|
||||
if(AH->lo_buf_used + size * nmemb > AH->lo_buf_size) {
|
||||
/* Split LO buffer */
|
||||
int remaining = AH->lo_buf_size - AH->lo_buf_used;
|
||||
int slack = nmemb * size - remaining;
|
||||
if (AH->lo_buf_used + size * nmemb > AH->lo_buf_size)
|
||||
{
|
||||
/* Split LO buffer */
|
||||
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);
|
||||
ahlog(AH, 5, "wrote %d bytes of large object data (result = %d)\n",
|
||||
AH->lo_buf_size, res);
|
||||
if (res != AH->lo_buf_size)
|
||||
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n",
|
||||
res, AH->lo_buf_size);
|
||||
memcpy(AH->lo_buf, (char *)ptr + remaining, slack);
|
||||
AH->lo_buf_used = slack;
|
||||
} else {
|
||||
/* LO Buffer is still large enough, buffer it */
|
||||
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb);
|
||||
AH->lo_buf_used += size * nmemb;
|
||||
}
|
||||
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);
|
||||
ahlog(AH, 5, "wrote %lu bytes of large object data (result = %lu)\n",
|
||||
(unsigned long) AH->lo_buf_size, (unsigned long) res);
|
||||
if (res != AH->lo_buf_size)
|
||||
die_horribly(AH, modulename,
|
||||
"could not write to large object (result: %lu, expected: %lu)\n",
|
||||
(unsigned long) res, (unsigned long) AH->lo_buf_size);
|
||||
memcpy(AH->lo_buf, (char *)ptr + remaining, slack);
|
||||
AH->lo_buf_used = slack;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LO Buffer is still large enough, buffer it */
|
||||
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb);
|
||||
AH->lo_buf_used += size * nmemb;
|
||||
}
|
||||
|
||||
return size * nmemb;
|
||||
return size * nmemb;
|
||||
}
|
||||
else if (AH->gzOut)
|
||||
{
|
||||
|
@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
|
|||
{
|
||||
res = fwrite((void *) ptr, size, nmemb, AH->OF);
|
||||
if (res != nmemb)
|
||||
die_horribly(AH, modulename, "could not write to output file (%d != %d)\n",
|
||||
res, (int) nmemb);
|
||||
die_horribly(AH, modulename, "could not write to output file (%lu != %lu)\n",
|
||||
(unsigned long) res, (unsigned long) nmemb);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt)
|
|||
return _tocEntryRequired(te, ropt);
|
||||
}
|
||||
|
||||
int
|
||||
size_t
|
||||
WriteInt(ArchiveHandle *AH, int i)
|
||||
{
|
||||
int b;
|
||||
|
@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH)
|
|||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
size_t
|
||||
WriteStr(ArchiveHandle *AH, const char *c)
|
||||
{
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
if (c)
|
||||
{
|
||||
|
@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
|
|||
{
|
||||
FILE *fh;
|
||||
char sig[6]; /* More than enough */
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
int wantClose = 0;
|
||||
|
||||
#if 0
|
||||
|
@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
|
|||
if (ferror(fh))
|
||||
die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno));
|
||||
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 */
|
||||
|
@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
|
|||
}
|
||||
|
||||
/* 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
|
||||
|
@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
|
|||
AH->lookaheadLen = 0; /* Don't bother since we've reset the file */
|
||||
|
||||
#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
|
||||
|
||||
/* Close the file */
|
||||
|
@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH)
|
|||
|
||||
AH->intSize = (*AH->ReadBytePtr) (AH);
|
||||
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))
|
||||
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)
|
|||
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);
|
||||
*/
|
||||
tea[i] = te;
|
||||
|
@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
|
|||
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 = te->next;
|
||||
|
@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2)
|
|||
Oid id2 = te2->maxOidVal;
|
||||
int cmpval;
|
||||
|
||||
/* printf("Comparing %d to %d\n", id1, id2); */
|
||||
/* printf("Comparing %u to %u\n", id1, id2); */
|
||||
|
||||
cmpval = oidcmp(id1, id2);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
*
|
||||
* 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
|
|||
{
|
||||
void *next_in;
|
||||
void *next_out;
|
||||
int avail_in;
|
||||
int avail_out;
|
||||
size_t avail_in;
|
||||
size_t avail_out;
|
||||
} z_stream;
|
||||
typedef z_stream *z_streamp;
|
||||
#endif
|
||||
|
@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH);
|
|||
typedef void (*ArchiveEntryPtr) (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 (*StartBlobsPtr) (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 (*ReadBytePtr) (struct _archiveHandle * AH);
|
||||
typedef int (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, int len);
|
||||
typedef int (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, int len);
|
||||
typedef size_t (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
|
||||
typedef size_t (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
|
||||
typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
|
||||
typedef void (*WriteExtraTocPtr) (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 (*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);
|
||||
|
||||
|
@ -147,7 +147,7 @@ typedef struct _archiveHandle
|
|||
|
||||
int debugLevel; /* Used for logging (currently only by
|
||||
* --verbose) */
|
||||
int intSize; /* Size of an integer in the archive */
|
||||
size_t intSize; /* Size of an integer in the archive */
|
||||
ArchiveFormat format; /* Archive format */
|
||||
|
||||
sqlparseInfo sqlparse;
|
||||
|
@ -163,9 +163,9 @@ typedef struct _archiveHandle
|
|||
* already */
|
||||
char *lookahead; /* Buffer used when reading header to
|
||||
* discover format */
|
||||
int lookaheadSize; /* Size of allocated buffer */
|
||||
int lookaheadLen; /* Length of data in lookahead */
|
||||
int lookaheadPos; /* Current read position in lookahead
|
||||
size_t lookaheadSize; /* Size of allocated buffer */
|
||||
size_t lookaheadLen; /* Length of data in lookahead */
|
||||
off_t lookaheadPos; /* Current read position in lookahead
|
||||
* buffer */
|
||||
|
||||
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
|
||||
|
@ -230,8 +230,8 @@ typedef struct _archiveHandle
|
|||
RestoreOptions *ropt; /* Used to check restore options in
|
||||
* ahwrite etc */
|
||||
void *lo_buf;
|
||||
int lo_buf_used;
|
||||
int lo_buf_size;
|
||||
size_t lo_buf_used;
|
||||
size_t lo_buf_size;
|
||||
} ArchiveHandle;
|
||||
|
||||
typedef struct _tocEntry
|
||||
|
@ -282,10 +282,10 @@ extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt);
|
|||
* 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 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 StartRestoreBlob(ArchiveHandle *AH, Oid oid);
|
||||
|
|
|
@ -19,15 +19,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.19 2002/05/29 01:38:56 tgl 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.
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.20 2002/08/20 17:54:44 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -44,12 +36,12 @@
|
|||
|
||||
static void _ArchiveEntry(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 int _WriteByte(ArchiveHandle *AH, const int i);
|
||||
static int _ReadByte(ArchiveHandle *);
|
||||
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len);
|
||||
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len);
|
||||
static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
|
||||
static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
|
||||
static void _CloseArchive(ArchiveHandle *AH);
|
||||
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
|
||||
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
|
||||
|
@ -79,16 +71,16 @@ typedef struct
|
|||
z_streamp zp;
|
||||
char *zlibOut;
|
||||
char *zlibIn;
|
||||
int inSize;
|
||||
size_t inSize;
|
||||
int hasSeek;
|
||||
int filePos;
|
||||
int dataStart;
|
||||
off_t filePos;
|
||||
off_t dataStart;
|
||||
} lclContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int dataPos;
|
||||
int dataLen;
|
||||
off_t dataPos;
|
||||
size_t dataLen;
|
||||
} lclTocEntry;
|
||||
|
||||
|
||||
|
@ -99,7 +91,7 @@ typedef struct
|
|||
static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id);
|
||||
static void _StartDataCompressor(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 char *modulename = gettext_noop("custom archiver");
|
||||
|
@ -156,8 +148,8 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
|
|||
/* Initialize LO buffering */
|
||||
AH->lo_buf_size = LOBBUFSIZE;
|
||||
AH->lo_buf = (void *)malloc(LOBBUFSIZE);
|
||||
if(AH->lo_buf == NULL)
|
||||
die_horribly(AH, modulename, "out of memory\n");
|
||||
if (AH->lo_buf == NULL)
|
||||
die_horribly(AH, modulename, "out of memory\n");
|
||||
|
||||
/*
|
||||
* zlibOutSize is the buffer size we tell zlib it can output to. We
|
||||
|
@ -188,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
|
|||
if (!AH->FH)
|
||||
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
|
||||
|
@ -201,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
|
|||
if (!AH->FH)
|
||||
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);
|
||||
ReadToc(AH);
|
||||
|
@ -285,7 +277,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
|
|||
{
|
||||
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)
|
|||
* Mandatory.
|
||||
*
|
||||
*/
|
||||
static int
|
||||
_WriteData(ArchiveHandle *AH, const void *data, int dLen)
|
||||
static size_t
|
||||
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
z_streamp zp = ctx->zp;
|
||||
|
@ -334,7 +327,7 @@ _WriteData(ArchiveHandle *AH, const void *data, int dLen)
|
|||
|
||||
while (zp->avail_in != 0)
|
||||
{
|
||||
/* printf("Deflating %d bytes\n", dLen); */
|
||||
/* printf("Deflating %lu bytes\n", (unsigned long) dLen); */
|
||||
_DoDeflate(AH, ctx, 0);
|
||||
}
|
||||
return dLen;
|
||||
|
@ -486,7 +479,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
|
|||
|
||||
/* 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));
|
||||
|
||||
_readBlockHeader(AH, &blkType, &id);
|
||||
|
@ -532,9 +525,9 @@ _PrintData(ArchiveHandle *AH)
|
|||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
z_streamp zp = ctx->zp;
|
||||
int blkLen;
|
||||
size_t blkLen;
|
||||
char *in = ctx->zlibIn;
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
int res;
|
||||
|
@ -573,7 +566,9 @@ _PrintData(ArchiveHandle *AH)
|
|||
|
||||
cnt = fread(in, 1, blkLen, AH->FH);
|
||||
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;
|
||||
|
||||
|
@ -683,9 +678,9 @@ static void
|
|||
_skipData(ArchiveHandle *AH)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int blkLen;
|
||||
size_t blkLen;
|
||||
char *in = ctx->zlibIn;
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
|
||||
blkLen = ReadInt(AH);
|
||||
while (blkLen != 0)
|
||||
|
@ -699,7 +694,9 @@ _skipData(ArchiveHandle *AH)
|
|||
}
|
||||
cnt = fread(in, 1, blkLen, AH->FH);
|
||||
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;
|
||||
|
||||
|
@ -761,16 +758,18 @@ _ReadByte(ArchiveHandle *AH)
|
|||
* These routines are only used to read & write headers & TOC.
|
||||
*
|
||||
*/
|
||||
static int
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
|
||||
static size_t
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
res = fwrite(buf, 1, len, AH->FH);
|
||||
|
||||
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;
|
||||
return res;
|
||||
|
@ -785,11 +784,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
|
|||
* These routines are only used to read & write headers & TOC.
|
||||
*
|
||||
*/
|
||||
static int
|
||||
_ReadBuf(ArchiveHandle *AH, void *buf, int len)
|
||||
static size_t
|
||||
_ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
res = fread(buf, 1, len, AH->FH);
|
||||
ctx->filePos += res;
|
||||
|
@ -816,12 +815,12 @@ static void
|
|||
_CloseArchive(ArchiveHandle *AH)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int tpos;
|
||||
off_t tpos;
|
||||
|
||||
if (AH->mode == archModeWrite)
|
||||
{
|
||||
WriteHead(AH);
|
||||
tpos = ftell(AH->FH);
|
||||
tpos = ftello(AH->FH);
|
||||
WriteToc(AH);
|
||||
ctx->dataStart = _getFilePos(AH, ctx);
|
||||
WriteDataChunks(AH);
|
||||
|
@ -834,7 +833,7 @@ _CloseArchive(ArchiveHandle *AH)
|
|||
*/
|
||||
if (ctx->hasSeek)
|
||||
{
|
||||
fseek(AH->FH, tpos, SEEK_SET);
|
||||
fseeko(AH->FH, tpos, SEEK_SET);
|
||||
WriteToc(AH);
|
||||
}
|
||||
}
|
||||
|
@ -853,14 +852,14 @@ _CloseArchive(ArchiveHandle *AH)
|
|||
/*
|
||||
* Get the current position in the archive file.
|
||||
*/
|
||||
static int
|
||||
static off_t
|
||||
_getFilePos(ArchiveHandle *AH, lclContext *ctx)
|
||||
{
|
||||
int pos;
|
||||
off_t pos;
|
||||
|
||||
if (ctx->hasSeek)
|
||||
{
|
||||
pos = ftell(AH->FH);
|
||||
pos = ftello(AH->FH);
|
||||
if (pos != ctx->filePos)
|
||||
{
|
||||
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell ignored\n");
|
||||
|
@ -957,8 +956,8 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
|
|||
if (zp->avail_out < zlibOutSize)
|
||||
{
|
||||
/*
|
||||
* printf("Wrote %d byte deflated chunk\n", zlibOutSize -
|
||||
* zp->avail_out);
|
||||
* printf("Wrote %lu byte deflated chunk\n", (unsigned long) (zlibOutSize -
|
||||
* zp->avail_out));
|
||||
*/
|
||||
WriteInt(AH, zlibOutSize - zp->avail_out);
|
||||
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Implements the basic DB functions used by the archiver.
|
||||
*
|
||||
* 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 @@
|
|||
#include "pg_backup_archiver.h"
|
||||
#include "pg_backup_db.h"
|
||||
|
||||
#include <unistd.h> /* for getopt() */
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
|
@ -347,7 +347,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
|
|||
static char *
|
||||
_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 sPos = 0; /* Last pos of a slash char */
|
||||
int isEnd = 0;
|
||||
|
@ -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 */
|
||||
int
|
||||
ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
|
||||
ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen)
|
||||
{
|
||||
char *qry = (char *) qryv;
|
||||
char *eos = qry + bufLen;
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
* Definitions for pg_backup_db.c
|
||||
*
|
||||
* 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 */
|
||||
|
||||
extern void FixupBlobRefs(ArchiveHandle *AH, TocEntry *te);
|
||||
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 InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new);
|
||||
|
|
|
@ -20,15 +20,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.16 2002/05/29 01:38:56 tgl 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.
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.17 2002/08/20 17:54:44 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -38,12 +30,12 @@
|
|||
|
||||
static void _ArchiveEntry(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 int _WriteByte(ArchiveHandle *AH, const int i);
|
||||
static int _ReadByte(ArchiveHandle *);
|
||||
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len);
|
||||
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len);
|
||||
static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
|
||||
static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
|
||||
static void _CloseArchive(ArchiveHandle *AH);
|
||||
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
|
||||
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
|
||||
|
@ -60,7 +52,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
|
|||
typedef struct
|
||||
{
|
||||
int hasSeek;
|
||||
int filePos;
|
||||
off_t filePos;
|
||||
FILE *blobToc;
|
||||
} lclContext;
|
||||
|
||||
|
@ -116,8 +108,8 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
|
|||
/* Initialize LO buffering */
|
||||
AH->lo_buf_size = LOBBUFSIZE;
|
||||
AH->lo_buf = (void *)malloc(LOBBUFSIZE);
|
||||
if(AH->lo_buf == NULL)
|
||||
die_horribly(AH, modulename, "out of memory\n");
|
||||
if (AH->lo_buf == NULL)
|
||||
die_horribly(AH, modulename, "out of memory\n");
|
||||
|
||||
/*
|
||||
* Now open the TOC file
|
||||
|
@ -137,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
|
|||
if (AH->FH == NULL)
|
||||
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)
|
||||
AH->compression = Z_DEFAULT_COMPRESSION;
|
||||
|
@ -155,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
|
|||
if (AH->FH == NULL)
|
||||
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);
|
||||
ReadToc(AH);
|
||||
|
@ -255,8 +247,8 @@ _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)
|
||||
{
|
||||
lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData;
|
||||
|
||||
|
@ -284,7 +276,7 @@ static void
|
|||
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
|
||||
{
|
||||
char buf[4096];
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
|
||||
if (!filename)
|
||||
return;
|
||||
|
@ -332,8 +324,8 @@ _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char fname[K_STD_BUF_SIZE])
|
|||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
char blobTe[K_STD_BUF_SIZE];
|
||||
int fpos;
|
||||
int eos;
|
||||
size_t fpos;
|
||||
size_t eos;
|
||||
|
||||
if (fgets(&blobTe[0], K_STD_BUF_SIZE - 1, ctx->blobToc) != NULL)
|
||||
{
|
||||
|
@ -413,11 +405,11 @@ _ReadByte(ArchiveHandle *AH)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
|
||||
static size_t
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
res = fwrite(buf, 1, len, AH->FH);
|
||||
if (res != len)
|
||||
|
@ -427,11 +419,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
_ReadBuf(ArchiveHandle *AH, void *buf, int len)
|
||||
static size_t
|
||||
_ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
res = fread(buf, 1, len, AH->FH);
|
||||
ctx->filePos += res;
|
||||
|
|
|
@ -17,16 +17,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.9 2002/05/10 22:36:26 tgl 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.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.10 2002/08/20 17:54:44 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -38,10 +29,10 @@
|
|||
#include <string.h>
|
||||
#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 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 _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
|
||||
|
||||
|
@ -75,8 +66,8 @@ InitArchiveFmt_Null(ArchiveHandle *AH)
|
|||
* As at V1.3, this is only called for COPY FROM dfata, and BLOB data
|
||||
*------
|
||||
*/
|
||||
static int
|
||||
_WriteData(ArchiveHandle *AH, const void *data, int dLen)
|
||||
static size_t
|
||||
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
|
||||
{
|
||||
/* Just send it to output */
|
||||
ahwrite(data, 1, dLen, AH);
|
||||
|
@ -112,8 +103,8 @@ _WriteByte(ArchiveHandle *AH, const int i)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
|
||||
static size_t
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
|
||||
{
|
||||
/* Don't do anything */
|
||||
return len;
|
||||
|
|
|
@ -16,15 +16,7 @@
|
|||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.24 2002/07/04 15:35:07 momjian 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.
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.25 2002/08/20 17:54:44 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -40,12 +32,12 @@
|
|||
|
||||
static void _ArchiveEntry(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 int _WriteByte(ArchiveHandle *AH, const int i);
|
||||
static int _ReadByte(ArchiveHandle *);
|
||||
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len);
|
||||
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len);
|
||||
static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
|
||||
static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
|
||||
static void _CloseArchive(ArchiveHandle *AH);
|
||||
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
|
||||
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
|
||||
|
@ -76,19 +68,19 @@ typedef struct
|
|||
FILE *tmpFH;
|
||||
char *targetFile;
|
||||
char mode;
|
||||
int pos;
|
||||
int fileLen;
|
||||
off_t pos;
|
||||
off_t fileLen;
|
||||
ArchiveHandle *AH;
|
||||
} TAR_MEMBER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int hasSeek;
|
||||
int filePos;
|
||||
off_t filePos;
|
||||
TAR_MEMBER *blobToc;
|
||||
FILE *tarFH;
|
||||
int tarFHpos;
|
||||
int tarNextMember;
|
||||
off_t tarFHpos;
|
||||
off_t tarNextMember;
|
||||
TAR_MEMBER *FH;
|
||||
int isSpecialScript;
|
||||
TAR_MEMBER *scriptTH;
|
||||
|
@ -108,20 +100,20 @@ static TAR_MEMBER *tarOpen(ArchiveHandle *AH, const char *filename, char mode);
|
|||
static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH);
|
||||
|
||||
#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
|
||||
static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...);
|
||||
|
||||
static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th);
|
||||
static int _tarChecksum(char *th);
|
||||
static TAR_MEMBER *_tarPositionTo(ArchiveHandle *AH, const char *filename);
|
||||
static int tarRead(void *buf, int len, TAR_MEMBER *th);
|
||||
static int tarWrite(const void *buf, int len, TAR_MEMBER *th);
|
||||
static size_t tarRead(void *buf, size_t len, TAR_MEMBER *th);
|
||||
static size_t tarWrite(const void *buf, size_t len, TAR_MEMBER *th);
|
||||
static void _tarWriteHeader(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
|
||||
|
@ -161,8 +153,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
|
|||
/* Initialize LO buffering */
|
||||
AH->lo_buf_size = LOBBUFSIZE;
|
||||
AH->lo_buf = (void *)malloc(LOBBUFSIZE);
|
||||
if(AH->lo_buf == NULL)
|
||||
die_horribly(AH, modulename, "out of memory\n");
|
||||
if (AH->lo_buf == NULL)
|
||||
die_horribly(AH, modulename, "out of memory\n");
|
||||
|
||||
/*
|
||||
* Now open the TOC file
|
||||
|
@ -187,7 +179,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
|
|||
*/
|
||||
/* 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)
|
||||
AH->compression = Z_DEFAULT_COMPRESSION;
|
||||
|
@ -224,7 +216,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
|
|||
|
||||
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
|
||||
|
@ -421,10 +413,10 @@ tarClose(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
|
||||
#ifdef __NOT_USED__
|
||||
static char *
|
||||
tarGets(char *buf, int len, TAR_MEMBER *th)
|
||||
tarGets(char *buf, size_t len, TAR_MEMBER *th)
|
||||
{
|
||||
char *s;
|
||||
int cnt = 0;
|
||||
size_t cnt = 0;
|
||||
char c = ' ';
|
||||
int eof = 0;
|
||||
|
||||
|
@ -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
|
||||
* that is used for ALL reads on a tar file.
|
||||
*/
|
||||
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)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int avail;
|
||||
int used = 0;
|
||||
int res = 0;
|
||||
size_t avail;
|
||||
size_t used = 0;
|
||||
size_t res = 0;
|
||||
|
||||
avail = AH->lookaheadLen - AH->lookaheadPos;
|
||||
if (avail > 0)
|
||||
|
@ -515,10 +507,10 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh)
|
|||
return (res + used);
|
||||
}
|
||||
|
||||
static int
|
||||
tarRead(void *buf, int len, TAR_MEMBER *th)
|
||||
static size_t
|
||||
tarRead(void *buf, size_t len, TAR_MEMBER *th)
|
||||
{
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
if (th->pos + len > th->fileLen)
|
||||
len = th->fileLen - th->pos;
|
||||
|
@ -533,10 +525,10 @@ tarRead(void *buf, int len, TAR_MEMBER *th)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
tarWrite(const void *buf, int len, TAR_MEMBER *th)
|
||||
static size_t
|
||||
tarWrite(const void *buf, size_t len, TAR_MEMBER *th)
|
||||
{
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
if (th->zFH != 0)
|
||||
res = GZWRITE((void *) buf, 1, len, th->zFH);
|
||||
|
@ -545,14 +537,15 @@ tarWrite(const void *buf, int len, TAR_MEMBER *th)
|
|||
|
||||
if (res != len)
|
||||
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;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
_WriteData(ArchiveHandle *AH, const void *data, int dLen)
|
||||
static size_t
|
||||
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
|
||||
{
|
||||
lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData;
|
||||
|
||||
|
@ -579,7 +572,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
|
|||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
char buf[4096];
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
TAR_MEMBER *th;
|
||||
|
||||
if (!filename)
|
||||
|
@ -607,7 +600,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
|
|||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
lclTocEntry *tctx = (lclTocEntry *) te->formatData;
|
||||
char *tmpCopy;
|
||||
int i,
|
||||
size_t i,
|
||||
pos1,
|
||||
pos2;
|
||||
|
||||
|
@ -651,8 +644,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
|
|||
|
||||
if (pos2 >= strlen(tmpCopy))
|
||||
die_horribly(AH, modulename,
|
||||
"bad COPY statement - could not find \"from stdin\" in string \"%s\" starting at position %d\n",
|
||||
tmpCopy, pos1);
|
||||
"bad COPY statement - could not find \"from stdin\" in string \"%s\" starting at position %lu\n",
|
||||
tmpCopy, (unsigned long) pos1);
|
||||
|
||||
ahwrite(tmpCopy, 1, pos2, AH); /* 'copy "table" [with oids]' */
|
||||
ahprintf(AH, " from '$$PATH$$/%s' %s", tctx->filename, &tmpCopy[pos2 + 10]);
|
||||
|
@ -672,7 +665,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
|
|||
Oid oid;
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
TAR_MEMBER *th;
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
char buf[4096];
|
||||
|
||||
StartRestoreBlobs(AH);
|
||||
|
@ -736,22 +729,22 @@ _ReadByte(ArchiveHandle *AH)
|
|||
return c;
|
||||
}
|
||||
|
||||
static int
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
|
||||
static size_t
|
||||
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
res = tarWrite((void *) buf, len, ctx->FH);
|
||||
ctx->filePos += res;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
_ReadBuf(ArchiveHandle *AH, void *buf, int len)
|
||||
static size_t
|
||||
_ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
int res;
|
||||
size_t res;
|
||||
|
||||
res = tarRead(buf, len, ctx->FH);
|
||||
ctx->filePos += res;
|
||||
|
@ -834,8 +827,8 @@ _CloseArchive(ArchiveHandle *AH)
|
|||
AH->FH = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_scriptOut(ArchiveHandle *AH, const void *buf, int len)
|
||||
static size_t
|
||||
_scriptOut(ArchiveHandle *AH, const void *buf, size_t len)
|
||||
{
|
||||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
|
||||
|
@ -942,7 +935,7 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...)
|
|||
{
|
||||
char *p = NULL;
|
||||
va_list ap;
|
||||
int bSize = strlen(fmt) + 256; /* Should be enough */
|
||||
size_t bSize = strlen(fmt) + 256; /* Should be enough */
|
||||
int cnt = -1;
|
||||
|
||||
/*
|
||||
|
@ -1002,18 +995,18 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
lclContext *ctx = (lclContext *) AH->formatData;
|
||||
FILE *tmp = th->tmpFH; /* Grab it for convenience */
|
||||
char buf[32768];
|
||||
int cnt;
|
||||
int len = 0;
|
||||
int res;
|
||||
int i,
|
||||
size_t cnt;
|
||||
off_t len = 0;
|
||||
size_t res;
|
||||
size_t i,
|
||||
pad;
|
||||
|
||||
/*
|
||||
* Find file len & go back to start.
|
||||
*/
|
||||
fseek(tmp, 0, SEEK_END);
|
||||
th->fileLen = ftell(tmp);
|
||||
fseek(tmp, 0, SEEK_SET);
|
||||
fseeko(tmp, 0, SEEK_END);
|
||||
th->fileLen = ftello(tmp);
|
||||
fseeko(tmp, 0, SEEK_SET);
|
||||
|
||||
_tarWriteHeader(th);
|
||||
|
||||
|
@ -1021,7 +1014,9 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
{
|
||||
res = fwrite(&buf[0], 1, cnt, th->tarFH);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1029,8 +1024,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
|
||||
|
||||
if (len != th->fileLen)
|
||||
die_horribly(AH, modulename, "actual file length (%d) does not match expected (%d)\n",
|
||||
len, th->pos);
|
||||
die_horribly(AH, modulename, "actual file length (" INT64_FORMAT ") does not match expected (" INT64_FORMAT ")\n",
|
||||
(int64) len, (int64) th->pos);
|
||||
|
||||
pad = ((len + 511) & ~511) - len;
|
||||
for (i = 0; i < pad; i++)
|
||||
|
@ -1050,25 +1045,24 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
|
|||
TAR_MEMBER *th = calloc(1, sizeof(TAR_MEMBER));
|
||||
char c;
|
||||
char header[512];
|
||||
int i,
|
||||
size_t i,
|
||||
len,
|
||||
blks,
|
||||
id;
|
||||
blks;
|
||||
int id;
|
||||
|
||||
th->AH = AH;
|
||||
|
||||
/* Go to end of current file, if any */
|
||||
if (ctx->tarFHpos != 0)
|
||||
{
|
||||
ahlog(AH, 4, "moving from position %d (%x) to next member at file position %d (%x)\n",
|
||||
ctx->tarFHpos, ctx->tarFHpos,
|
||||
ctx->tarNextMember, ctx->tarNextMember);
|
||||
ahlog(AH, 4, "moving from position " INT64_FORMAT " to next member at file position " INT64_FORMAT "\n",
|
||||
(int64) ctx->tarFHpos, (int64) ctx->tarNextMember);
|
||||
|
||||
while (ctx->tarFHpos < ctx->tarNextMember)
|
||||
_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 */
|
||||
|
||||
|
@ -1122,18 +1116,18 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
char tag[100];
|
||||
int sum,
|
||||
chk;
|
||||
int len;
|
||||
int hPos;
|
||||
size_t len;
|
||||
off_t hPos;
|
||||
int i;
|
||||
bool gotBlock = false;
|
||||
|
||||
while (!gotBlock)
|
||||
{
|
||||
#if 0
|
||||
if (ftell(ctx->tarFH) != ctx->tarFHpos)
|
||||
if (ftello(ctx->tarFH) != ctx->tarFHpos)
|
||||
die_horribly(AH, modulename,
|
||||
"mismatch in actual vs. predicted file position (%d vs. %d)\n",
|
||||
ftell(ctx->tarFH), ctx->tarFHpos);
|
||||
"mismatch in actual vs. predicted file position (" INT64_FORMAT " vs. " INT64_FORMAT ")\n",
|
||||
(int64) ftello(ctx->tarFH), (int64) ctx->tarFHpos);
|
||||
#endif
|
||||
|
||||
/* Save the pos for reporting purposes */
|
||||
|
@ -1145,7 +1139,9 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
return 0;
|
||||
|
||||
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 */
|
||||
chk = _tarChecksum(&h[0]);
|
||||
|
@ -1174,13 +1170,14 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||
sscanf(&h[124], "%12o", &len);
|
||||
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)
|
||||
die_horribly(AH, modulename,
|
||||
"corrupt tar header found in %s "
|
||||
"(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n",
|
||||
&tag[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH));
|
||||
"(expected %d, computed %d) file position " INT64_FORMAT "\n",
|
||||
&tag[0], sum, chk, (int64) ftello(ctx->tarFH));
|
||||
|
||||
th->targetFile = strdup(tag);
|
||||
th->fileLen = len;
|
||||
|
@ -1212,7 +1209,8 @@ _tarWriteHeader(TAR_MEMBER *th)
|
|||
sprintf(&h[116], " 02000 ");
|
||||
|
||||
/* 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 */
|
||||
sprintf(&h[136], "%10o ", (int) time(NULL));
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*
|
||||
*
|
||||
* 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)
|
|||
int i;
|
||||
int loFd;
|
||||
char buf[loBufSize];
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
Oid blobOid;
|
||||
|
||||
if (g_verbose)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* 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.
|
||||
*
|
||||
* $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
|
||||
|
@ -720,6 +720,23 @@ extern int fdatasync(int fildes);
|
|||
/* Define exactly one of these symbols to select shared-mem implementation */
|
||||
#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
|
||||
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue