diff options
author | Bernd Helmle | 2011-05-28 10:34:43 +0000 |
---|---|---|
committer | Bernd Helmle | 2011-05-28 10:34:43 +0000 |
commit | b9b93512ec3c880d9081b05791e19244798ffe94 (patch) | |
tree | d956e7aa264cbe2730d647cb7dd006cdfa1fb8e2 | |
parent | 42bc6f45df9ac4767100777e0806a86459300d71 (diff) | |
parent | 4c60a77508ee4f4d895629905265d79feaab108c (diff) |
Merge branch 'master' of ../bernd_pg into notnull_constraint
57 files changed, 1296 insertions, 877 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 9c069f4c92..9398ca6c47 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -130,9 +130,12 @@ AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT], AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar], [pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS $1" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [Ac_cachevar=yes], [Ac_cachevar=no]) +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS"]) if test x"$Ac_cachevar" = x"yes"; then CFLAGS="$CFLAGS $1" diff --git a/config/config.guess b/config/config.guess index 115f944a61..40eaed4821 100755 --- a/config/config.guess +++ b/config/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. -timestamp='2010-04-03' +timestamp='2011-05-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -57,7 +57,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -92,7 +92,7 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' HUP INT TERM +trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -106,7 +106,7 @@ trap 'exit 1' HUP INT TERM set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" HUP INT PIPE TERM ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || @@ -181,7 +181,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -224,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -270,7 +270,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -296,7 +299,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} @@ -395,23 +398,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -481,8 +484,8 @@ EOF echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -495,7 +498,7 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -552,7 +555,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -595,52 +598,52 @@ EOF 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include <stdlib.h> - #include <unistd.h> + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -731,22 +734,22 @@ EOF exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -770,14 +773,14 @@ EOF exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -805,14 +808,14 @@ EOF echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; @@ -867,7 +870,7 @@ EOF EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac + esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} @@ -879,7 +882,13 @@ EOF then echo ${UNAME_MACHINE}-unknown-linux-gnu else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi fi exit ;; avr32*:Linux:*:*) @@ -892,7 +901,7 @@ EOF echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu @@ -960,7 +969,7 @@ EOF echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -968,6 +977,9 @@ EOF sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-tilera-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; @@ -975,7 +987,7 @@ EOF echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -984,11 +996,11 @@ EOF echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1020,7 +1032,7 @@ EOF fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1048,13 +1060,13 @@ EOF exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1089,8 +1101,8 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ @@ -1133,10 +1145,10 @@ EOF echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <[email protected]> - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <[email protected]> + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <[email protected]>. # How about differentiating between stratus architectures? -djm @@ -1162,11 +1174,11 @@ EOF exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1231,6 +1243,9 @@ EOF *:QNX:*:4*) echo i386-pc-qnx exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; @@ -1276,13 +1291,13 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1322,11 +1337,11 @@ main () #include <sys/param.h> printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif diff --git a/config/config.sub b/config/config.sub index ae35431611..30fdca8121 100755 --- a/config/config.sub +++ b/config/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. -timestamp='2010-03-22' +timestamp='2011-03-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -76,7 +76,7 @@ version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -124,8 +124,9 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os @@ -157,8 +158,8 @@ case $os in os= basic_machine=$1 ;; - -bluegene*) - os=-cnk + -bluegene*) + os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= @@ -174,10 +175,10 @@ case $os in os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -282,11 +283,13 @@ case $basic_machine in | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ + | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rx \ | score \ @@ -294,12 +297,12 @@ case $basic_machine in | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; @@ -323,6 +326,18 @@ case $basic_machine in basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -377,26 +392,28 @@ case $basic_machine in | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -421,7 +438,7 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -504,7 +521,7 @@ case $basic_machine in basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -536,7 +553,7 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -752,7 +769,7 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; - microblaze) + microblaze) basic_machine=microblaze-xilinx ;; mingw32) @@ -859,6 +876,12 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -941,9 +964,10 @@ case $basic_machine in ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -1037,6 +1061,9 @@ case $basic_machine in basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1093,8 +1120,8 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - # This must be matched before tile*. - tilegx*) + # This must be matched before tile*. + tilegx*) basic_machine=tilegx-unknown os=-linux-gnu ;; @@ -1169,6 +1196,9 @@ case $basic_machine in xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1266,11 +1296,11 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + -auroraux) + os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` @@ -1307,7 +1337,8 @@ case $os in | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1354,7 +1385,7 @@ case $os in -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1403,7 +1434,7 @@ case $os in -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1448,8 +1479,8 @@ case $os in -dicos*) os=-dicos ;; - -nacl*) - ;; + -nacl*) + ;; -none) ;; *) @@ -1472,10 +1503,10 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1487,8 +1518,8 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff ;; tic54x-*) os=-coff @@ -1524,7 +1555,7 @@ case $basic_machine in m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1551,7 +1582,7 @@ case $basic_machine in *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) @@ -1539,8 +1539,7 @@ Optional Packages: --without-readline do not use GNU Readline nor BSD Libedit for editing --with-libedit-preferred prefer BSD Libedit over GNU Readline - --with-ossp-uuid use OSSP UUID library when building - contrib/uuid-ossp + --with-ossp-uuid build contrib/uuid-ossp, requires OSSP UUID library --with-libxml build with XML support --with-libxslt use XSLT support when building contrib/xml2 --with-system-tzdata=DIR @@ -4011,6 +4010,8 @@ if test "${pgac_cv_prog_cc_cflags__Wdeclaration_after_statement+set}" = set; the else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -Wdeclaration-after-statement" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4053,6 +4054,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wdeclaration_after_statement" >&5 @@ -4068,6 +4070,8 @@ if test "${pgac_cv_prog_cc_cflags__Wendif_labels+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -Wendif-labels" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4110,6 +4114,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wendif_labels" >&5 @@ -4126,6 +4131,8 @@ if test "${pgac_cv_prog_cc_cflags__Wformat_security+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -Wformat-security" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4168,6 +4175,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wformat_security" >&5 @@ -4184,6 +4192,8 @@ if test "${pgac_cv_prog_cc_cflags__fno_strict_aliasing+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -fno-strict-aliasing" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4226,6 +4236,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__fno_strict_aliasing" >&5 @@ -4242,6 +4253,8 @@ if test "${pgac_cv_prog_cc_cflags__fwrapv+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -fwrapv" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4284,6 +4297,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__fwrapv" >&5 @@ -4302,6 +4316,8 @@ if test "${pgac_cv_prog_cc_cflags__mp1+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -mp1" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4344,6 +4360,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__mp1" >&5 @@ -4360,6 +4377,8 @@ if test "${pgac_cv_prog_cc_cflags__fno_strict_aliasing+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -fno-strict-aliasing" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4402,6 +4421,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__fno_strict_aliasing" >&5 @@ -4419,6 +4439,8 @@ if test "${pgac_cv_prog_cc_cflags__qnoansialias+set}" = set; then else pgac_save_CFLAGS=$CFLAGS CFLAGS="$pgac_save_CFLAGS -qnoansialias" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -4461,6 +4483,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" fi { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__qnoansialias" >&5 @@ -4469,6 +4492,69 @@ if test x"$pgac_cv_prog_cc_cflags__qnoansialias" = x"yes"; then CFLAGS="$CFLAGS -qnoansialias" fi +elif test "$PORTNAME" = "hpux"; then + # On some versions of HP-UX, libm functions do not set errno by default. + # Fix that by using +Olibmerrno if the compiler recognizes it. + { $as_echo "$as_me:$LINENO: checking whether $CC supports +Olibmerrno" >&5 +$as_echo_n "checking whether $CC supports +Olibmerrno... " >&6; } +if test "${pgac_cv_prog_cc_cflags_pOlibmerrno+set}" = set; then + $as_echo_n "(cached) " >&6 +else + pgac_save_CFLAGS=$CFLAGS +CFLAGS="$pgac_save_CFLAGS +Olibmerrno" +ac_save_c_werror_flag=$ac_c_werror_flag +ac_c_werror_flag=yes +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + pgac_cv_prog_cc_cflags_pOlibmerrno=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + pgac_cv_prog_cc_cflags_pOlibmerrno=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_c_werror_flag=$ac_save_c_werror_flag +CFLAGS="$pgac_save_CFLAGS" +fi +{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags_pOlibmerrno" >&5 +$as_echo "$pgac_cv_prog_cc_cflags_pOlibmerrno" >&6; } +if test x"$pgac_cv_prog_cc_cflags_pOlibmerrno" = x"yes"; then + CFLAGS="$CFLAGS +Olibmerrno" +fi + fi # supply -g if --enable-debug @@ -9390,9 +9476,9 @@ fi # for contrib/sepgsql if test "$with_selinux" = yes; then -{ $as_echo "$as_me:$LINENO: checking for getpeercon_raw in -lselinux" >&5 -$as_echo_n "checking for getpeercon_raw in -lselinux... " >&6; } -if test "${ac_cv_lib_selinux_getpeercon_raw+set}" = set; then +{ $as_echo "$as_me:$LINENO: checking for selinux_sepgsql_context_path in -lselinux" >&5 +$as_echo_n "checking for selinux_sepgsql_context_path in -lselinux... " >&6; } +if test "${ac_cv_lib_selinux_selinux_sepgsql_context_path+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9410,11 +9496,11 @@ cat >>conftest.$ac_ext <<_ACEOF #ifdef __cplusplus extern "C" #endif -char getpeercon_raw (); +char selinux_sepgsql_context_path (); int main () { -return getpeercon_raw (); +return selinux_sepgsql_context_path (); ; return 0; } @@ -9440,12 +9526,12 @@ $as_echo "$ac_try_echo") >&5 test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then - ac_cv_lib_selinux_getpeercon_raw=yes + ac_cv_lib_selinux_selinux_sepgsql_context_path=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_selinux_getpeercon_raw=no + ac_cv_lib_selinux_selinux_sepgsql_context_path=no fi rm -rf conftest.dSYM @@ -9453,9 +9539,9 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_getpeercon_raw" >&5 -$as_echo "$ac_cv_lib_selinux_getpeercon_raw" >&6; } -if test "x$ac_cv_lib_selinux_getpeercon_raw" = x""yes; then +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_selinux_sepgsql_context_path" >&5 +$as_echo "$ac_cv_lib_selinux_selinux_sepgsql_context_path" >&6; } +if test "x$ac_cv_lib_selinux_selinux_sepgsql_context_path" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSELINUX 1 _ACEOF @@ -9463,8 +9549,8 @@ _ACEOF LIBS="-lselinux $LIBS" else - { { $as_echo "$as_me:$LINENO: error: library 'libselinux' is required for SELinux support" >&5 -$as_echo "$as_me: error: library 'libselinux' is required for SELinux support" >&2;} + { { $as_echo "$as_me:$LINENO: error: library 'libselinux', version 2.0.93 or newer, is required for SELinux support" >&5 +$as_echo "$as_me: error: library 'libselinux', version 2.0.93 or newer, is required for SELinux support" >&2;} { (exit 1); exit 1; }; } fi diff --git a/configure.in b/configure.in index 0a85a05641..a752618bf5 100644 --- a/configure.in +++ b/configure.in @@ -445,6 +445,10 @@ elif test "$ICC" = yes; then elif test "$PORTNAME" = "aix"; then # AIX's xlc has to have strict aliasing turned off too PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias]) +elif test "$PORTNAME" = "hpux"; then + # On some versions of HP-UX, libm functions do not set errno by default. + # Fix that by using +Olibmerrno if the compiler recognizes it. + PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno]) fi # supply -g if --enable-debug @@ -713,7 +717,7 @@ PGAC_ARG_BOOL(with, libedit-preferred, no, # # OSSP UUID library # -PGAC_ARG_BOOL(with, ossp-uuid, no, [use OSSP UUID library when building contrib/uuid-ossp]) +PGAC_ARG_BOOL(with, ossp-uuid, no, [build contrib/uuid-ossp, requires OSSP UUID library]) AC_SUBST(with_ossp_uuid) @@ -960,8 +964,8 @@ fi # for contrib/sepgsql if test "$with_selinux" = yes; then - AC_CHECK_LIB(selinux, getpeercon_raw, [], - [AC_MSG_ERROR([library 'libselinux' is required for SELinux support])]) + AC_CHECK_LIB(selinux, selinux_sepgsql_context_path, [], + [AC_MSG_ERROR([library 'libselinux', version 2.0.93 or newer, is required for SELinux support])]) fi # for contrib/uuid-ossp diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c index 7204b447da..281d5892ee 100644 --- a/contrib/pg_standby/pg_standby.c +++ b/contrib/pg_standby/pg_standby.c @@ -722,20 +722,20 @@ main(int argc, char **argv) if (debug) { - fprintf(stderr, "Trigger file : %s\n", triggerPath ? triggerPath : "<not set>"); - fprintf(stderr, "Waiting for WAL file : %s\n", nextWALFileName); - fprintf(stderr, "WAL file path : %s\n", WALFilePath); - fprintf(stderr, "Restoring to : %s\n", xlogFilePath); - fprintf(stderr, "Sleep interval : %d second%s\n", + fprintf(stderr, "Trigger file: %s\n", triggerPath ? triggerPath : "<not set>"); + fprintf(stderr, "Waiting for WAL file: %s\n", nextWALFileName); + fprintf(stderr, "WAL file path: %s\n", WALFilePath); + fprintf(stderr, "Restoring to: %s\n", xlogFilePath); + fprintf(stderr, "Sleep interval: %d second%s\n", sleeptime, (sleeptime > 1 ? "s" : " ")); - fprintf(stderr, "Max wait interval : %d %s\n", + fprintf(stderr, "Max wait interval: %d %s\n", maxwaittime, (maxwaittime > 0 ? "seconds" : "forever")); - fprintf(stderr, "Command for restore : %s\n", restoreCommand); - fprintf(stderr, "Keep archive history : "); + fprintf(stderr, "Command for restore: %s\n", restoreCommand); + fprintf(stderr, "Keep archive history: "); if (need_cleanup) fprintf(stderr, "%s and later\n", exclusiveCleanupFileName); else - fprintf(stderr, "No cleanup required\n"); + fprintf(stderr, "no cleanup required\n"); fflush(stderr); } diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c index 2117b7f80d..60c1fbbf97 100644 --- a/contrib/pg_upgrade/check.c +++ b/contrib/pg_upgrade/check.c @@ -333,13 +333,14 @@ static void check_locale_and_encoding(ControlData *oldctrl, ControlData *newctrl) { - if (strcmp(oldctrl->lc_collate, newctrl->lc_collate) != 0) + /* These are often defined with inconsistent case, so use pg_strcasecmp(). */ + if (pg_strcasecmp(oldctrl->lc_collate, newctrl->lc_collate) != 0) pg_log(PG_FATAL, "old and new cluster lc_collate values do not match\n"); - if (strcmp(oldctrl->lc_ctype, newctrl->lc_ctype) != 0) + if (pg_strcasecmp(oldctrl->lc_ctype, newctrl->lc_ctype) != 0) pg_log(PG_FATAL, "old and new cluster lc_ctype values do not match\n"); - if (strcmp(oldctrl->encoding, newctrl->encoding) != 0) + if (pg_strcasecmp(oldctrl->encoding, newctrl->encoding) != 0) pg_log(PG_FATAL, "old and new cluster encoding values do not match\n"); } diff --git a/doc/src/sgml/errcodes.sgml b/doc/src/sgml/errcodes.sgml index 0f3659fc87..16cb6c7fcd 100644 --- a/doc/src/sgml/errcodes.sgml +++ b/doc/src/sgml/errcodes.sgml @@ -42,11 +42,9 @@ </para> <para> - The <application>PL/pgSQL</> condition name for each error code is the - same as the phrase shown in the table, with underscores substituted - for spaces. For example, code <literal>22012</>, DIVISION BY ZERO, - has condition name <literal>DIVISION_BY_ZERO</>. Condition names can - be written in either upper or lower case. (Note that + The symbol shown in the column <quote>Condition Name</quote> is also + the condition name to use in <application>PL/pgSQL</>. Condition + names can be written in either upper or lower case. (Note that <application>PL/pgSQL</> does not recognize warning, as opposed to error, condition names; those are classes 00, 01, and 02.) </para> @@ -55,15 +53,14 @@ <table id="errcodes-table"> <title><productname>PostgreSQL</productname> Error Codes</title> - <tgroup cols="3"> + <tgroup cols="2"> <colspec colnum="1" colname="errorcode"> - <colspec colnum="3" colname="condname"> - <spanspec namest="errorcode" nameend="condname" spanname="span13"> + <colspec colnum="2" colname="condname"> + <spanspec namest="errorcode" nameend="condname" spanname="span12"> <thead> <row> <entry>Error Code</entry> - <entry>Meaning</entry> <entry>Condition Name</entry> </row> </thead> diff --git a/doc/src/sgml/generate-errcodes-table.pl b/doc/src/sgml/generate-errcodes-table.pl index 5d0ccffadd..0ac020ee24 100644 --- a/doc/src/sgml/generate-errcodes-table.pl +++ b/doc/src/sgml/generate-errcodes-table.pl @@ -29,7 +29,7 @@ while (<$errcodes>) { print "\n\n"; print "<row>\n"; - print "<entry spanname=\"span13\">"; + print "<entry spanname=\"span12\">"; print "<emphasis role=\"bold\">$_</></entry>\n"; print "</row>\n"; @@ -46,17 +46,10 @@ while (<$errcodes>) { # Skip lines without PL/pgSQL condition names next unless defined($condition_name); - my $meaning = $condition_name; - # Remove underscores - $meaning =~ s/_/ /g; - # And capitalize - $meaning =~ tr/[a-z]/[A-Z]/; - print "\n"; print "<row>\n"; print "<entry><literal>$sqlstate</literal></entry>\n"; - print "<entry>$meaning</entry>\n"; - print "<entry>$condition_name</entry>\n"; + print "<entry><symbol>$condition_name</symbol></entry>\n"; print "</row>\n"; } diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml index eba3a0a25d..2febb4ced8 100644 --- a/doc/src/sgml/information_schema.sgml +++ b/doc/src/sgml/information_schema.sgml @@ -34,13 +34,13 @@ </para> <para> - This problem can appear when querying information schema views like - <literal>referential_constraints</>, <literal>check_constraints</>, - <literal>domain_constraints</>, and - <literal>check_constraint_routine_usage</>. Some other views have - similar issues but contain the table name to help distinguish - duplicate rows, e.g. <literal>table_constraints</>, - <literal>constraint_table_usage</>, <literal>constraint_column_usage</>. + This problem can appear when querying information schema views such + as <literal>check_constraint_routine_usage</>, + <literal>check_constraints</>, <literal>domain_constraints</>, and + <literal>referential_constraints</>. Some other views have similar + issues but contain the table name to help distinguish duplicate + rows, e.g., <literal>constraint_column_usage</>, + <literal>constraint_table_usage</>, <literal>table_constraints</>. </para> </note> diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index 61e34126c0..0410cff4ac 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -861,11 +861,12 @@ su - postgres <term><option>--with-ossp-uuid</option></term> <listitem> <para> - Use the <ulink url="http://www.ossp.org/pkg/lib/uuid/">OSSP UUID - library</ulink> when building the + Build components using the <ulink + url="http://www.ossp.org/pkg/lib/uuid/">OSSP UUID + library</ulink>. Specifically, build the <![%standalone-include[uuid-ossp]]> - <![%standalone-ignore[<xref linkend="uuid-ossp">]]> - module. The library provides functions to generate + <![%standalone-ignore[<xref linkend="uuid-ossp">]]> module, + which provides functions to generate UUIDs.<indexterm><primary>UUID</primary></indexterm> </para> </listitem> diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index cb1773eeaa..c24cc394d6 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -559,25 +559,6 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>--inserts</option></term> - <listitem> - <para> - Dump data as <command>INSERT</command> commands (rather - than <command>COPY</command>). This will make restoration very slow; - it is mainly useful for making dumps that can be loaded into - non-<productname>PostgreSQL</productname> databases. - However, since this option generates a separate command for each row, - an error in reloading a row causes only that row to be lost rather - than the entire table contents. - Note that - the restore might fail altogether if you have rearranged column order. - The <option>--column-inserts</option> option is safe against column - order changes, though even slower. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>--column-inserts</option></term> <term><option>--attribute-inserts</option></term> <listitem> @@ -634,6 +615,25 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>--inserts</option></term> + <listitem> + <para> + Dump data as <command>INSERT</command> commands (rather + than <command>COPY</command>). This will make restoration very slow; + it is mainly useful for making dumps that can be loaded into + non-<productname>PostgreSQL</productname> databases. + However, since this option generates a separate command for each row, + an error in reloading a row causes only that row to be lost rather + than the entire table contents. + Note that + the restore might fail altogether if you have rearranged column order. + The <option>--column-inserts</option> option is safe against column + order changes, though even slower. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>--lock-wait-timeout=<replaceable class="parameter">timeout</replaceable></option></term> <listitem> <para> @@ -650,36 +650,10 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>--serializable-deferrable</option></term> + <term><option>--no-security-labels</option></term> <listitem> <para> - Use a <literal>serializable</literal> transaction for the dump, to - ensure that the snapshot used is consistent with later database - states; but do this by waiting for a point in the transaction stream - at which no anomalies can be present, so that there isn't a risk of - the dump failing or causing other transactions to roll back with a - <literal>serialization_failure</literal>. See <xref linkend="mvcc"> - for more information about transaction isolation and concurrency - control. - </para> - - <para> - This option is not beneficial for a dump which is intended only for - disaster recovery. It could be useful for a dump used to load a - copy of the database for reporting or other read-only load sharing - while the original database continues to be updated. Without it the - dump may reflect a state which is not consistent with any serial - execution of the transactions eventually committed. For example, if - batch processing techniques are used, a batch may show as closed in - the dump without all of the items which are in the batch appearing. - </para> - - <para> - This option will make no difference if there are no read-write - transactions active when pg_dump is started. If read-write - transactions are active, the start of the dump may be delayed for an - indeterminate length of time. Once running, performance with or - without the switch is the same. + Do not dump security labels. </para> </listitem> </varlistentry> @@ -702,47 +676,73 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>--no-security-label</option></term> + <term><option>--no-unlogged-table-data</option></term> <listitem> <para> - Do not dump security labels. + Do not dump the contents of unlogged tables. This option has no + effect on whether or not the table definitions (schema) are dumped; + it only suppresses dumping the table data. </para> </listitem> </varlistentry> <varlistentry> - <term><option>--use-set-session-authorization</></term> + <term><option>--quote-all-identifiers</></term> <listitem> <para> - Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands - instead of <command>ALTER OWNER</> commands to determine object - ownership. This makes the dump more standards-compatible, but - depending on the history of the objects in the dump, might not restore - properly. Also, a dump using <command>SET SESSION AUTHORIZATION</> - will certainly require superuser privileges to restore correctly, - whereas <command>ALTER OWNER</> requires lesser privileges. + Force quoting of all identifiers. This may be useful when dumping a + database for migration to a future version that may have introduced + additional keywords. </para> </listitem> </varlistentry> <varlistentry> - <term><option>--no-unlogged-table-data</option></term> + <term><option>--serializable-deferrable</option></term> <listitem> <para> - Do not dump the contents of unlogged tables. This option has no - effect on whether or not the table definitions (schema) are dumped; - it only suppresses dumping the table data. + Use a <literal>serializable</literal> transaction for the dump, to + ensure that the snapshot used is consistent with later database + states; but do this by waiting for a point in the transaction stream + at which no anomalies can be present, so that there isn't a risk of + the dump failing or causing other transactions to roll back with a + <literal>serialization_failure</literal>. See <xref linkend="mvcc"> + for more information about transaction isolation and concurrency + control. + </para> + + <para> + This option is not beneficial for a dump which is intended only for + disaster recovery. It could be useful for a dump used to load a + copy of the database for reporting or other read-only load sharing + while the original database continues to be updated. Without it the + dump may reflect a state which is not consistent with any serial + execution of the transactions eventually committed. For example, if + batch processing techniques are used, a batch may show as closed in + the dump without all of the items which are in the batch appearing. + </para> + + <para> + This option will make no difference if there are no read-write + transactions active when pg_dump is started. If read-write + transactions are active, the start of the dump may be delayed for an + indeterminate length of time. Once running, performance with or + without the switch is the same. </para> </listitem> </varlistentry> <varlistentry> - <term><option>--quote-all-identifiers</></term> + <term><option>--use-set-session-authorization</></term> <listitem> <para> - Force quoting of all identifiers. This may be useful when dumping a - database for migration to a future version that may have introduced - additional keywords. + Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands + instead of <command>ALTER OWNER</> commands to determine object + ownership. This makes the dump more standards-compatible, but + depending on the history of the objects in the dump, might not restore + properly. Also, a dump using <command>SET SESSION AUTHORIZATION</> + will certainly require superuser privileges to restore correctly, + whereas <command>ALTER OWNER</> requires lesser privileges. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml index 04e95e876d..7c49c0364f 100644 --- a/doc/src/sgml/ref/pg_dumpall.sgml +++ b/doc/src/sgml/ref/pg_dumpall.sgml @@ -165,54 +165,6 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>--lock-wait-timeout=<replaceable class="parameter">timeout</replaceable></option></term> - <listitem> - <para> - Do not wait forever to acquire shared table locks at the beginning of - the dump. Instead, fail if unable to lock a table within the specified - <replaceable class="parameter">timeout</>. The timeout may be - specified in any of the formats accepted by <command>SET - statement_timeout</>. Allowed values vary depending on the server - version you are dumping from, but an integer number of milliseconds - is accepted by all versions since 7.3. This option is ignored when - dumping from a pre-7.3 server. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><option>--no-tablespaces</option></term> - <listitem> - <para> - Do not output commands to create tablespaces nor select tablespaces - for objects. - With this option, all objects will be created in whichever - tablespace is the default during restore. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><option>--no-security-label</option></term> - <listitem> - <para> - Do not dump security labels. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><option>--no-unlogged-table-data</option></term> - <listitem> - <para> - Do not dump the contents of unlogged tables. This option has no - effect on whether or not the table definitions (schema) are dumped; - it only suppresses dumping the table data. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>-r</option></term> <term><option>--roles-only</option></term> <listitem> @@ -302,21 +254,6 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>--inserts</option></term> - <listitem> - <para> - Dump data as <command>INSERT</command> commands (rather - than <command>COPY</command>). This will make restoration very slow; - it is mainly useful for making dumps that can be loaded into - non-<productname>PostgreSQL</productname> databases. Note that - the restore might fail altogether if you have rearranged column order. - The <option>--column-inserts</option> option is safer, though even - slower. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>--column-inserts</option></term> <term><option>--attribute-inserts</option></term> <listitem> @@ -364,14 +301,64 @@ PostgreSQL documentation </varlistentry> <varlistentry> - <term><option>--use-set-session-authorization</></term> + <term><option>--inserts</option></term> <listitem> <para> - Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands - instead of <command>ALTER OWNER</> commands to determine object - ownership. This makes the dump more standards compatible, but - depending on the history of the objects in the dump, might not restore - properly. + Dump data as <command>INSERT</command> commands (rather + than <command>COPY</command>). This will make restoration very slow; + it is mainly useful for making dumps that can be loaded into + non-<productname>PostgreSQL</productname> databases. Note that + the restore might fail altogether if you have rearranged column order. + The <option>--column-inserts</option> option is safer, though even + slower. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--lock-wait-timeout=<replaceable class="parameter">timeout</replaceable></option></term> + <listitem> + <para> + Do not wait forever to acquire shared table locks at the beginning of + the dump. Instead, fail if unable to lock a table within the specified + <replaceable class="parameter">timeout</>. The timeout may be + specified in any of the formats accepted by <command>SET + statement_timeout</>. Allowed values vary depending on the server + version you are dumping from, but an integer number of milliseconds + is accepted by all versions since 7.3. This option is ignored when + dumping from a pre-7.3 server. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--no-security-labels</option></term> + <listitem> + <para> + Do not dump security labels. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--no-tablespaces</option></term> + <listitem> + <para> + Do not output commands to create tablespaces nor select tablespaces + for objects. + With this option, all objects will be created in whichever + tablespace is the default during restore. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--no-unlogged-table-data</option></term> + <listitem> + <para> + Do not dump the contents of unlogged tables. This option has no + effect on whether or not the table definitions (schema) are dumped; + it only suppresses dumping the table data. </para> </listitem> </varlistentry> @@ -388,6 +375,19 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>--use-set-session-authorization</></term> + <listitem> + <para> + Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands + instead of <command>ALTER OWNER</> commands to determine object + ownership. This makes the dump more standards compatible, but + depending on the history of the objects in the dump, might not restore + properly. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>-?</></term> <term><option>--help</></term> <listitem> diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index bf261af9d6..be4851b657 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -168,32 +168,32 @@ <variablelist> <varlistentry> - <term><literal>d</></term> - <term><literal>directory</></term> + <term><literal>c</></term> + <term><literal>custom</></term> <listitem> <para> - The archive is a <command>directory</command> archive. + The archive is in the custom format of + <application>pg_dump</application>. </para> </listitem> </varlistentry> <varlistentry> - <term><literal>t</></term> - <term><literal>tar</></term> + <term><literal>d</></term> + <term><literal>directory</></term> <listitem> <para> - The archive is a <command>tar</command> archive. + The archive is a directory archive. </para> </listitem> </varlistentry> <varlistentry> - <term><literal>c</></term> - <term><literal>custom</></term> + <term><literal>t</></term> + <term><literal>tar</></term> <listitem> <para> - The archive is in the custom format of - <application>pg_dump</application>. + The archive is a <command>tar</command> archive. </para> </listitem> </varlistentry> @@ -329,27 +329,6 @@ </varlistentry> <varlistentry> - <term><option>--no-tablespaces</option></term> - <listitem> - <para> - Do not output commands to select tablespaces. - With this option, all objects will be created in whichever - tablespace is the default during restore. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><option>--no-security-label</option></term> - <listitem> - <para> - Do not output commands to restore security labels, - even if the archive contains them. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>-P <replaceable class="parameter">function-name(argtype [, ...])</replaceable></option></term> <term><option>--function=<replaceable class="parameter">function-name(argtype [, ...])</replaceable></option></term> <listitem> @@ -449,6 +428,20 @@ </varlistentry> <varlistentry> + <term><option>-1</option></term> + <term><option>--single-transaction</option></term> + <listitem> + <para> + Execute the restore as a single transaction (that is, wrap the + emitted commands in <command>BEGIN</>/<command>COMMIT</>). This + ensures that either all the commands complete successfully, or no + changes are applied. This option implies + <option>--exit-on-error</>. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>--disable-triggers</></term> <listitem> <para> @@ -471,19 +464,6 @@ </varlistentry> <varlistentry> - <term><option>--use-set-session-authorization</option></term> - <listitem> - <para> - Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands - instead of <command>ALTER OWNER</> commands to determine object - ownership. This makes the dump more standards-compatible, but - depending on the history of the objects in the dump, might not restore - properly. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><option>--no-data-for-failed-tables</option></term> <listitem> <para> @@ -506,15 +486,35 @@ </varlistentry> <varlistentry> - <term><option>-1</option></term> - <term><option>--single-transaction</option></term> + <term><option>--no-security-labels</option></term> <listitem> <para> - Execute the restore as a single transaction (that is, wrap the - emitted commands in <command>BEGIN</>/<command>COMMIT</>). This - ensures that either all the commands complete successfully, or no - changes are applied. This option implies - <option>--exit-on-error</>. + Do not output commands to restore security labels, + even if the archive contains them. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--no-tablespaces</option></term> + <listitem> + <para> + Do not output commands to select tablespaces. + With this option, all objects will be created in whichever + tablespace is the default during restore. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--use-set-session-authorization</option></term> + <listitem> + <para> + Output SQL-standard <command>SET SESSION AUTHORIZATION</> commands + instead of <command>ALTER OWNER</> commands to determine object + ownership. This makes the dump more standards-compatible, but + depending on the history of the objects in the dump, might not restore + properly. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index ac351d32d4..eaf901d328 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -730,39 +730,7 @@ testdb=> </varlistentry> <varlistentry> - <term><literal>\cd [ <replaceable>directory</replaceable> ]</literal></term> - <listitem> - <para> - Changes the current working directory to - <replaceable>directory</replaceable>. Without argument, changes - to the current user's home directory. - </para> - - <tip> - <para> - To print your current working directory, use <literal>\! pwd</literal>. - </para> - </tip> - </listitem> - </varlistentry> - - <varlistentry> - <term><literal>\C [ <replaceable class="parameter">title</replaceable> ]</literal></term> - <listitem> - <para> - Sets the title of any tables being printed as the result of a - query or unset any such title. This command is equivalent to - <literal>\pset title <replaceable - class="parameter">title</replaceable></literal>. (The name of - this command derives from <quote>caption</quote>, as it was - previously only used to set the caption in an - <acronym>HTML</acronym> table.) - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><literal>\connect</literal> (or <literal>\c</literal>) <literal>[ <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">host</replaceable> ] [ <replaceable class="parameter">port</replaceable> ] ]</literal></term> + <term><literal>\c</literal> or <literal>\connect</literal> <literal>[ <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">host</replaceable> ] [ <replaceable class="parameter">port</replaceable> ] ]</literal></term> <listitem> <para> Establishes a new connection to a <productname>PostgreSQL</> @@ -792,6 +760,38 @@ testdb=> </varlistentry> <varlistentry> + <term><literal>\C [ <replaceable class="parameter">title</replaceable> ]</literal></term> + <listitem> + <para> + Sets the title of any tables being printed as the result of a + query or unset any such title. This command is equivalent to + <literal>\pset title <replaceable + class="parameter">title</replaceable></literal>. (The name of + this command derives from <quote>caption</quote>, as it was + previously only used to set the caption in an + <acronym>HTML</acronym> table.) + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>\cd [ <replaceable>directory</replaceable> ]</literal></term> + <listitem> + <para> + Changes the current working directory to + <replaceable>directory</replaceable>. Without argument, changes + to the current user's home directory. + </para> + + <tip> + <para> + To print your current working directory, use <literal>\! pwd</literal>. + </para> + </tip> + </listitem> + </varlistentry> + + <varlistentry> <term><literal>\conninfo</literal></term> <listitem> <para> @@ -1049,14 +1049,30 @@ testdb=> <varlistentry> - <term><literal>\det[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <term><literal>\dE[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <term><literal>\di[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <term><literal>\ds[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <term><literal>\dt[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <term><literal>\dv[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <listitem> <para> - Lists foreign tables (mnemonic: <quote>external tables</quote>). + In this group of commands, the letters <literal>E</literal>, + <literal>i</literal>, <literal>s</literal>, + <literal>t</literal>, and <literal>v</literal> + stand for foreign table, index, sequence, table, and view, + respectively. + You can specify any or all of + these letters, in any order, to obtain a listing of objects + of these types. For example, <literal>\dit</> lists indexes + and tables. If <literal>+</literal> is + appended to the command name, each object is listed with its + physical size on disk and its associated description, if any. If <replaceable class="parameter">pattern</replaceable> is - specified, only entries whose table name or schema name matches - the pattern are listed. If the form <literal>\det+</literal> - is used, generic options are also displayed. + specified, only objects whose names match the pattern are listed. + By default, only user-created objects are shown; supply a + pattern or the <literal>S</literal> modifier to include system + objects. </para> </listitem> </varlistentry> @@ -1079,6 +1095,20 @@ testdb=> <varlistentry> + <term><literal>\det[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <listitem> + <para> + Lists foreign tables (mnemonic: <quote>external tables</quote>). + If <replaceable class="parameter">pattern</replaceable> is + specified, only entries whose table name or schema name matches + the pattern are listed. If the form <literal>\det+</literal> + is used, generic options are also displayed. + </para> + </listitem> + </varlistentry> + + + <varlistentry> <term><literal>\deu[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> <listitem> <para> @@ -1221,36 +1251,6 @@ testdb=> <varlistentry> - <term><literal>\di[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> - <term><literal>\ds[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> - <term><literal>\dt[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> - <term><literal>\dv[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> - <term><literal>\dE[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> - - <listitem> - <para> - In this group of commands, the letters - <literal>i</literal>, <literal>s</literal>, - <literal>t</literal>, <literal>v</literal>, and <literal>E</literal> - stand for index, sequence, table, view, and foreign table, - respectively. - You can specify any or all of - these letters, in any order, to obtain a listing of objects - of these types. For example, <literal>\dit</> lists indexes - and tables. If <literal>+</literal> is - appended to the command name, each object is listed with its - physical size on disk and its associated description, if any. - If <replaceable class="parameter">pattern</replaceable> is - specified, only objects whose names match the pattern are listed. - By default, only user-created objects are shown; supply a - pattern or the <literal>S</literal> modifier to include system - objects. - </para> - </listitem> - </varlistentry> - - - <varlistentry> <term><literal>\dl</literal></term> <listitem> <para> @@ -1417,7 +1417,7 @@ testdb=> </varlistentry> <varlistentry> - <term><literal>\edit</> (or <literal>\e</>) <literal> <optional> <replaceable class="parameter">filename</> </optional> <optional> <replaceable class="parameter">line_number</> </optional> </literal></term> + <term><literal>\e</literal> or <literal>\edit</> <literal> <optional> <replaceable class="parameter">filename</> </optional> <optional> <replaceable class="parameter">line_number</> </optional> </literal></term> <listitem> <para> @@ -1462,6 +1462,30 @@ testdb=> </listitem> </varlistentry> + <varlistentry> + <term><literal>\echo <replaceable class="parameter">text</replaceable> [ ... ]</literal></term> + <listitem> + <para> + Prints the arguments to the standard output, separated by one + space and followed by a newline. This can be useful to + intersperse information in the output of scripts. For example: +<programlisting> +=> <userinput>\echo `date`</userinput> +Tue Oct 26 21:40:57 CEST 1999 +</programlisting> + If the first argument is an unquoted <literal>-n</literal> the trailing + newline is not written. + </para> + + <tip> + <para> + If you use the <command>\o</command> command to redirect your + query output you might wish to use <command>\qecho</command> + instead of this command. + </para> + </tip> + </listitem> + </varlistentry> <varlistentry> <term><literal>\ef <optional> <replaceable class="parameter">function_description</> <optional> <replaceable class="parameter">line_number</> </optional> </optional> </literal></term> @@ -1502,32 +1526,6 @@ testdb=> <varlistentry> - <term><literal>\echo <replaceable class="parameter">text</replaceable> [ ... ]</literal></term> - <listitem> - <para> - Prints the arguments to the standard output, separated by one - space and followed by a newline. This can be useful to - intersperse information in the output of scripts. For example: -<programlisting> -=> <userinput>\echo `date`</userinput> -Tue Oct 26 21:40:57 CEST 1999 -</programlisting> - If the first argument is an unquoted <literal>-n</literal> the trailing - newline is not written. - </para> - - <tip> - <para> - If you use the <command>\o</command> command to redirect your - query output you might wish to use <command>\qecho</command> - instead of this command. - </para> - </tip> - </listitem> - </varlistentry> - - - <varlistentry> <term><literal>\encoding [ <replaceable class="parameter">encoding</replaceable> ]</literal></term> <listitem> @@ -1571,7 +1569,7 @@ Tue Oct 26 21:40:57 CEST 1999 </varlistentry> <varlistentry> - <term><literal>\help</literal> (or <literal>\h</literal>) <literal>[ <replaceable class="parameter">command</replaceable> ]</literal></term> + <term><literal>\h</literal> or <literal>\help</literal> <literal>[ <replaceable class="parameter">command</replaceable> ]</literal></term> <listitem> <para> Gives syntax help on the specified <acronym>SQL</acronym> @@ -1818,6 +1816,85 @@ lo_import 152801 Adjustable printing options are: <variablelist> <varlistentry> + <term><literal>border</literal></term> + <listitem> + <para> + The <replaceable class="parameter">value</replaceable> must be a + number. In general, the higher + the number the more borders and lines the tables will have, + but this depends on the particular format. In + <acronym>HTML</acronym> format, this will translate directly + into the <literal>border=...</literal> attribute; in the + other formats only values 0 (no border), 1 (internal dividing lines), + and 2 (table frame) make sense. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>columns</literal></term> + <listitem> + <para> + Sets the target width for the <literal>wrapped</> format, and also + the width limit for determining whether output is wide enough to + require the pager. + Zero (the default) causes the target width to be controlled by the + environment variable <envar>COLUMNS</>, or the detected screen width + if <envar>COLUMNS</> is not set. + In addition, if <literal>columns</> is zero then the + <literal>wrapped</> format only affects screen output. + If <literal>columns</> is nonzero then file and pipe output is + wrapped to that width as well. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>expanded</literal> (or <literal>x</literal>)</term> + <listitem> + <para> + If <replaceable class="parameter">value</replaceable> is specified + it must be either <literal>on</literal> or <literal>off</literal> + which will enable or disable expanded mode. If <replaceable + class="parameter">value</replaceable> is omitted the command toggles + between regular and expanded mode. + When expanded mode is enabled, query results + are displayed in two columns, with the column name on the left and + the data on the right. This mode is useful if the data wouldn't fit + on the screen in the normal <quote>horizontal</quote> mode. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>fieldsep</literal></term> + <listitem> + <para> + Specifies the field separator to be used in unaligned output + format. That way one can create, for example, tab- or + comma-separated output, which other programs might prefer. To + set a tab as field separator, type <literal>\pset fieldsep + '\t'</literal>. The default field separator is + <literal>'|'</literal> (a vertical bar). + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>footer</literal></term> + <listitem> + <para> + If <replaceable class="parameter">value</replaceable> is specified + it must be either <literal>on</literal> or <literal>off</literal> + which will enable or disable display of the table footer + (the <literal>(<replaceable>n</> rows)</literal> count). + If <replaceable class="parameter">value</replaceable> is omitted the + command toggles footer display on or off. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><literal>format</literal></term> <listitem> <para> @@ -1864,40 +1941,6 @@ lo_import 152801 </varlistentry> <varlistentry> - <term><literal>columns</literal></term> - <listitem> - <para> - Sets the target width for the <literal>wrapped</> format, and also - the width limit for determining whether output is wide enough to - require the pager. - Zero (the default) causes the target width to be controlled by the - environment variable <envar>COLUMNS</>, or the detected screen width - if <envar>COLUMNS</> is not set. - In addition, if <literal>columns</> is zero then the - <literal>wrapped</> format only affects screen output. - If <literal>columns</> is nonzero then file and pipe output is - wrapped to that width as well. - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><literal>border</literal></term> - <listitem> - <para> - The <replaceable class="parameter">value</replaceable> must be a - number. In general, the higher - the number the more borders and lines the tables will have, - but this depends on the particular format. In - <acronym>HTML</acronym> format, this will translate directly - into the <literal>border=...</literal> attribute; in the - other formats only values 0 (no border), 1 (internal dividing lines), - and 2 (table frame) make sense. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><literal>linestyle</literal></term> <listitem> <para> @@ -1952,23 +1995,6 @@ lo_import 152801 </varlistentry> <varlistentry> - <term><literal>expanded</literal> (or <literal>x</literal>)</term> - <listitem> - <para> - If <replaceable class="parameter">value</replaceable> is specified - it must be either <literal>on</literal> or <literal>off</literal> - which will enable or disable expanded mode. If <replaceable - class="parameter">value</replaceable> is omitted the command toggles - between regular and expanded mode. - When expanded mode is enabled, query results - are displayed in two columns, with the column name on the left and - the data on the right. This mode is useful if the data wouldn't fit - on the screen in the normal <quote>horizontal</quote> mode. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><literal>null</literal></term> <listitem> <para> @@ -1981,34 +2007,6 @@ lo_import 152801 </varlistentry> <varlistentry> - <term><literal>fieldsep</literal></term> - <listitem> - <para> - Specifies the field separator to be used in unaligned output - format. That way one can create, for example, tab- or - comma-separated output, which other programs might prefer. To - set a tab as field separator, type <literal>\pset fieldsep - '\t'</literal>. The default field separator is - <literal>'|'</literal> (a vertical bar). - </para> - </listitem> - </varlistentry> - - <varlistentry> - <term><literal>footer</literal></term> - <listitem> - <para> - If <replaceable class="parameter">value</replaceable> is specified - it must be either <literal>on</literal> or <literal>off</literal> - which will enable or disable display of the table footer - (the <literal>(<replaceable>n</> rows)</literal> count). - If <replaceable class="parameter">value</replaceable> is omitted the - command toggles footer display on or off. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><literal>numericlocale</literal></term> <listitem> <para> @@ -2023,39 +2021,36 @@ lo_import 152801 </varlistentry> <varlistentry> - <term><literal>recordsep</literal></term> + <term><literal>pager</literal></term> <listitem> <para> - Specifies the record (line) separator to use in unaligned - output format. The default is a newline character. + Controls use of a pager program for query and <application>psql</> + help output. If the environment variable <envar>PAGER</envar> + is set, the output is piped to the specified program. + Otherwise a platform-dependent default (such as + <filename>more</filename>) is used. </para> - </listitem> - </varlistentry> - <varlistentry> - <term><literal>tuples_only</literal> (or <literal>t</literal>)</term> - <listitem> <para> - If <replaceable class="parameter">value</replaceable> is specified - it must be either <literal>on</literal> or <literal>off</literal> - which will enable or disable tuples-only mode. - If <replaceable class="parameter">value</replaceable> is omitted the - command toggles between regular and tuples-only output. - Regular output includes extra information such - as column headers, titles, and various footers. In tuples-only - mode, only actual table data is shown. + When the <literal>pager</> option is <literal>off</>, the pager + program is not used. When the <literal>pager</> option is + <literal>on</>, the pager is used when appropriate, i.e., when the + output is to a terminal and will not fit on the screen. + The <literal>pager</> option can also be set to <literal>always</>, + which causes the pager to be used for all terminal output regardless + of whether it fits on the screen. <literal>\pset pager</> + without a <replaceable class="parameter">value</replaceable> + toggles pager use on and off. </para> </listitem> </varlistentry> <varlistentry> - <term><literal>title</literal></term> + <term><literal>recordsep</literal></term> <listitem> <para> - Sets the table title for any subsequently printed tables. This - can be used to give your output descriptive tags. If no - <replaceable class="parameter">value</replaceable> is given, - the title is unset. + Specifies the record (line) separator to use in unaligned + output format. The default is a newline character. </para> </listitem> </varlistentry> @@ -2079,26 +2074,29 @@ lo_import 152801 </varlistentry> <varlistentry> - <term><literal>pager</literal></term> + <term><literal>title</literal></term> <listitem> <para> - Controls use of a pager program for query and <application>psql</> - help output. If the environment variable <envar>PAGER</envar> - is set, the output is piped to the specified program. - Otherwise a platform-dependent default (such as - <filename>more</filename>) is used. + Sets the table title for any subsequently printed tables. This + can be used to give your output descriptive tags. If no + <replaceable class="parameter">value</replaceable> is given, + the title is unset. </para> + </listitem> + </varlistentry> + <varlistentry> + <term><literal>tuples_only</literal> (or <literal>t</literal>)</term> + <listitem> <para> - When the <literal>pager</> option is <literal>off</>, the pager - program is not used. When the <literal>pager</> option is - <literal>on</>, the pager is used when appropriate, i.e., when the - output is to a terminal and will not fit on the screen. - The <literal>pager</> option can also be set to <literal>always</>, - which causes the pager to be used for all terminal output regardless - of whether it fits on the screen. <literal>\pset pager</> - without a <replaceable class="parameter">value</replaceable> - toggles pager use on and off. + If <replaceable class="parameter">value</replaceable> is specified + it must be either <literal>on</literal> or <literal>off</literal> + which will enable or disable tuples-only mode. + If <replaceable class="parameter">value</replaceable> is omitted the + command toggles between regular and tuples-only output. + Regular output includes extra information such + as column headers, titles, and various footers. In tuples-only + mode, only actual table data is shown. </para> </listitem> </varlistentry> diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 588e9f2b85..02f8f9cd63 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -1090,6 +1090,7 @@ Exec_UnlistenAllCommit(void) void ProcessCompletedNotifies(void) { + MemoryContext caller_context; bool signalled; /* Nothing to do if we didn't send any notifications */ @@ -1103,6 +1104,12 @@ ProcessCompletedNotifies(void) */ backendHasSentNotifications = false; + /* + * We must preserve the caller's memory context (probably MessageContext) + * across the transaction we do here. + */ + caller_context = CurrentMemoryContext; + if (Trace_notify) elog(DEBUG1, "ProcessCompletedNotifies"); @@ -1135,6 +1142,8 @@ ProcessCompletedNotifies(void) CommitTransactionCommand(); + MemoryContextSwitchTo(caller_context); + /* We don't need pq_flush() here since postgres.c will do one shortly */ } diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 04a8acc505..398056fff3 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -9784,7 +9784,6 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode) { Oid relid = RelationGetRelid(rel); Type typetuple; - Form_pg_type typ; Oid typeid; Relation inheritsRelation, relationRelation; @@ -9801,7 +9800,6 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode) /* Validate the type. */ typetuple = typenameType(NULL, ofTypename, NULL); check_of_type(typetuple); - typ = (Form_pg_type) GETSTRUCT(typetuple); typeid = HeapTupleGetOid(typetuple); /* Fail if the table has any inheritance parents. */ diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c index bfb8cbb303..17098efa67 100644 --- a/src/backend/executor/execGrouping.c +++ b/src/backend/executor/execGrouping.c @@ -19,6 +19,7 @@ #include "postgres.h" #include "executor/executor.h" +#include "miscadmin.h" #include "parser/parse_oper.h" #include "utils/lsyscache.h" #include "utils/memutils.h" @@ -276,7 +277,7 @@ TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, FmgrInfo *eqfunctions, FmgrInfo *hashfunctions, - int nbuckets, Size entrysize, + long nbuckets, Size entrysize, MemoryContext tablecxt, MemoryContext tempcxt) { TupleHashTable hashtable; @@ -285,6 +286,9 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, Assert(nbuckets > 0); Assert(entrysize >= sizeof(TupleHashEntryData)); + /* Limit initial table size request to not more than work_mem */ + nbuckets = Min(nbuckets, (long) ((work_mem * 1024L) / entrysize)); + hashtable = (TupleHashTable) MemoryContextAlloc(tablecxt, sizeof(TupleHashTableData)); @@ -306,7 +310,7 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, hash_ctl.hash = TupleHashTableHash; hash_ctl.match = TupleHashTableMatch; hash_ctl.hcxt = tablecxt; - hashtable->hashtab = hash_create("TupleHashTable", (long) nbuckets, + hashtable->hashtab = hash_create("TupleHashTable", nbuckets, &hash_ctl, HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 5089616f59..e90058847d 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -120,13 +120,17 @@ ExecScan(ScanState *node, */ qual = node->ps.qual; projInfo = node->ps.ps_ProjInfo; + econtext = node->ps.ps_ExprContext; /* * If we have neither a qual to check nor a projection to do, just skip * all the overhead and return the raw scan tuple. */ if (!qual && !projInfo) + { + ResetExprContext(econtext); return ExecScanFetch(node, accessMtd, recheckMtd); + } /* * Check to see if we're still projecting out tuples from a previous scan @@ -148,7 +152,6 @@ ExecScan(ScanState *node, * storage allocated in the previous tuple cycle. Note this can't happen * until we're done projecting out tuples from a scan tuple. */ - econtext = node->ps.ps_ExprContext; ResetExprContext(econtext); /* diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 4fcb66bbb0..0e12bb5afb 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -432,7 +432,7 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext) int ncols = list_length(subplan->paramIds); ExprContext *innerecontext = node->innerecontext; MemoryContext oldcontext; - int nbuckets; + long nbuckets; TupleTableSlot *slot; Assert(subplan->subLinkType == ANY_SUBLINK); @@ -458,7 +458,7 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext) node->havehashrows = false; node->havenullrows = false; - nbuckets = (int) ceil(planstate->plan->plan_rows); + nbuckets = (long) Min(planstate->plan->plan_rows, (double) LONG_MAX); if (nbuckets < 1) nbuckets = 1; diff --git a/src/backend/libpq/pg_hba.conf.sample b/src/backend/libpq/pg_hba.conf.sample index 0a90b68c10..f913b9aabb 100644 --- a/src/backend/libpq/pg_hba.conf.sample +++ b/src/backend/libpq/pg_hba.conf.sample @@ -22,7 +22,9 @@ # plain TCP/IP socket. # # DATABASE can be "all", "sameuser", "samerole", "replication", a -# database name, or a comma-separated list thereof. +# database name, or a comma-separated list thereof. The "all" +# keyword does not match "replication". Access to replication +# must be enabled in a separate record (see example below). # # USER can be "all", a user name, a group name prefixed with "+", or a # comma-separated list thereof. In both the DATABASE and USER fields @@ -80,3 +82,8 @@ host all all 127.0.0.1/32 @authmethod@ # IPv6 local connections: host all all ::1/128 @authmethod@ +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication @default_username@ @authmethod@ +#host replication @default_username@ 127.0.0.1/32 @authmethod@ +#host replication @default_username@ ::1/128 @authmethod@ diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c index 72f62e7951..c64f5114c2 100644 --- a/src/backend/port/sysv_sema.c +++ b/src/backend/port/sysv_sema.c @@ -116,16 +116,14 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems) (unsigned long) semKey, numSems, IPC_CREAT | IPC_EXCL | IPCProtection), (errno == ENOSPC) ? - errhint("This error does *not* mean that you have run out of disk space.\n" + errhint("This error does *not* mean that you have run out of disk space. " "It occurs when either the system limit for the maximum number of " "semaphore sets (SEMMNI), or the system wide maximum number of " "semaphores (SEMMNS), would be exceeded. You need to raise the " "respective kernel parameter. Alternatively, reduce PostgreSQL's " - "consumption of semaphores by reducing its max_connections parameter " - "(currently %d).\n" + "consumption of semaphores by reducing its max_connections parameter.\n" "The PostgreSQL documentation contains more information about " - "configuring your system for PostgreSQL.", - MaxBackends) : 0)); + "configuring your system for PostgreSQL.") : 0)); } return semId; diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 754d2ac7e0..285d5f20ae 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -173,7 +173,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) "memory configuration.", (unsigned long) size) : 0, (errno == ENOSPC) ? - errhint("This error does *not* mean that you have run out of disk space. " + errhint("This error does *not* mean that you have run out of disk space. " "It occurs either if all available shared memory IDs have been taken, " "in which case you need to raise the SHMMNI parameter in your kernel, " "or because the system's overall limit for shared memory has been " diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index f5218111db..3e43e951e1 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -3533,7 +3533,7 @@ hash_array(PG_FUNCTION_ARGS) int ndims = ARR_NDIM(array); int *dims = ARR_DIMS(array); Oid element_type = ARR_ELEMTYPE(array); - uint32 result = 0; + uint32 result = 1; int nitems; TypeCacheEntry *typentry; int typlen; @@ -3617,11 +3617,17 @@ hash_array(PG_FUNCTION_ARGS) } /* - * Combine hash values of successive elements by rotating the previous - * value left 1 bit, then XOR'ing in the new element's hash value. + * Combine hash values of successive elements by multiplying the + * current value by 31 and adding on the new element's hash value. + * + * The result is a sum in which each element's hash value is + * multiplied by a different power of 31. This is modulo 2^32 + * arithmetic, and the powers of 31 modulo 2^32 form a cyclic group of + * order 2^27. So for arrays of up to 2^27 elements, each element's + * hash value is multiplied by a different (odd) number, resulting in + * a good mixing of all the elements' hash values. */ - result = (result << 1) | (result >> 31); - result ^= elthash; + result = (result << 5) - result + elthash; } /* Avoid leaking memory when handed toasted input. */ @@ -4805,7 +4811,7 @@ array_fill_with_lower_bounds(PG_FUNCTION_ARGS) if (PG_ARGISNULL(1) || PG_ARGISNULL(2)) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("dimension array or low bound array cannot be NULL"))); + errmsg("dimension array or low bound array cannot be null"))); dims = PG_GETARG_ARRAYTYPE_P(1); lbs = PG_GETARG_ARRAYTYPE_P(2); @@ -4845,7 +4851,7 @@ array_fill(PG_FUNCTION_ARGS) if (PG_ARGISNULL(1)) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("dimension array or low bound array cannot be NULL"))); + errmsg("dimension array or low bound array cannot be null"))); dims = PG_GETARG_ARRAYTYPE_P(1); diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 0a12a9b2e1..0289dbdf02 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -4049,6 +4049,11 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) /* Compatible with postgresql < 8.4 when DateStyle = 'iso' */ case INTSTYLE_POSTGRES: cp = AddPostgresIntPart(cp, year, "year", &is_zero, &is_before); + /* + * Ideally we should spell out "month" like we do for "year" + * and "day". However, for backward compatibility, we can't + * easily fix this. bjm 2011-05-24 + */ cp = AddPostgresIntPart(cp, mon, "mon", &is_zero, &is_before); cp = AddPostgresIntPart(cp, mday, "day", &is_zero, &is_before); if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index af6737f7a5..b457a72034 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -5225,50 +5225,36 @@ get_rule_expr(Node *node, deparse_context *context, CaseWhen *when = (CaseWhen *) lfirst(temp); Node *w = (Node *) when->expr; - if (!PRETTY_INDENT(context)) - appendStringInfoChar(buf, ' '); - appendContextKeyword(context, "WHEN ", - 0, 0, 0); if (caseexpr->arg) { /* - * The parser should have produced WHEN clauses of the - * form "CaseTestExpr = RHS"; we want to show just the - * RHS. If the user wrote something silly like "CASE - * boolexpr WHEN TRUE THEN ...", then the optimizer's - * simplify_boolean_equality() may have reduced this - * to just "CaseTestExpr" or "NOT CaseTestExpr", for - * which we have to show "TRUE" or "FALSE". We have - * also to consider the possibility that an implicit - * coercion was inserted between the CaseTestExpr and - * the operator. + * The parser should have produced WHEN clauses of + * the form "CaseTestExpr = RHS", possibly with an + * implicit coercion inserted above the CaseTestExpr. + * For accurate decompilation of rules it's essential + * that we show just the RHS. However in an + * expression that's been through the optimizer, the + * WHEN clause could be almost anything (since the + * equality operator could have been expanded into an + * inline function). If we don't recognize the form + * of the WHEN clause, just punt and display it as-is. */ if (IsA(w, OpExpr)) { List *args = ((OpExpr *) w)->args; - Node *rhs; - Assert(list_length(args) == 2); - Assert(IsA(strip_implicit_coercions(linitial(args)), - CaseTestExpr)); - rhs = (Node *) lsecond(args); - get_rule_expr(rhs, context, false); + if (list_length(args) == 2 && + IsA(strip_implicit_coercions(linitial(args)), + CaseTestExpr)) + w = (Node *) lsecond(args); } - else if (IsA(strip_implicit_coercions(w), - CaseTestExpr)) - appendStringInfo(buf, "TRUE"); - else if (not_clause(w)) - { - Assert(IsA(strip_implicit_coercions((Node *) get_notclausearg((Expr *) w)), - CaseTestExpr)); - appendStringInfo(buf, "FALSE"); - } - else - elog(ERROR, "unexpected CASE WHEN clause: %d", - (int) nodeTag(w)); } - else - get_rule_expr(w, context, false); + + if (!PRETTY_INDENT(context)) + appendStringInfoChar(buf, ' '); + appendContextKeyword(context, "WHEN ", + 0, 0, 0); + get_rule_expr(w, context, false); appendStringInfo(buf, " THEN "); get_rule_expr((Node *) when->result, context, true); } @@ -5284,6 +5270,19 @@ get_rule_expr(Node *node, deparse_context *context, } break; + case T_CaseTestExpr: + { + /* + * Normally we should never get here, since for expressions + * that can contain this node type we attempt to avoid + * recursing to it. But in an optimized expression we might + * be unable to avoid that (see comments for CaseExpr). If we + * do see one, print it as CASE_TEST_EXPR. + */ + appendStringInfo(buf, "CASE_TEST_EXPR"); + } + break; + case T_ArrayExpr: { ArrayExpr *arrayexpr = (ArrayExpr *) node; diff --git a/src/backend/utils/adt/tsquery_util.c b/src/backend/utils/adt/tsquery_util.c index ca254f901f..53093f1e86 100644 --- a/src/backend/utils/adt/tsquery_util.c +++ b/src/backend/utils/adt/tsquery_util.c @@ -336,7 +336,7 @@ QTN2QT(QTNode *in) cntsize(in, &sumlen, &nnode); len = COMPUTESIZE(nnode, sumlen); - out = (TSQuery) palloc(len); + out = (TSQuery) palloc0(len); SET_VARSIZE(out, len); out->size = nnode; diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 9d96013d57..6005d68576 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -3827,7 +3827,19 @@ text_format(PG_FUNCTION_ARGS) * to the next one. If they have, we must parse it. */ if (*cp < '0' || *cp > '9') + { ++arg; + if (arg <= 0) /* overflow? */ + { + /* + * Should not happen, as you can't pass billions of arguments + * to a function, but better safe than sorry. + */ + ereport(ERROR, + (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), + errmsg("argument number is out of range"))); + } + } else { bool unterminated = false; @@ -3836,10 +3848,13 @@ text_format(PG_FUNCTION_ARGS) arg = 0; do { - /* Treat overflowing arg position as unterminated. */ - if (arg > INT_MAX / 10) - break; - arg = arg * 10 + (*cp - '0'); + int newarg = arg * 10 + (*cp - '0'); + + if (newarg / 10 != arg) /* overflow? */ + ereport(ERROR, + (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), + errmsg("argument number is out of range"))); + arg = newarg; ++cp; } while (cp < end_ptr && *cp >= '0' && *cp <= '9'); @@ -3954,7 +3969,9 @@ text_format_string_conversion(StringInfo buf, char conversion, /* * text_format_nv - nonvariadic wrapper for text_format function. * - * note: this wrapper is necessary to be sanity_checks test ok + * note: this wrapper is necessary to pass the sanity check in opr_sanity, + * which checks that all built-in functions that share the implementing C + * function take the same number of arguments. */ Datum text_format_nv(PG_FUNCTION_ARGS) diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 140b0c74d9..e202acac93 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -128,11 +128,11 @@ typedef void *AllocPointer; /* * AllocSetContext is our standard implementation of MemoryContext. * - * Note: isReset means there is nothing for AllocSetReset to do. This is - * different from the aset being physically empty (empty blocks list) because - * we may still have a keeper block. It's also different from the set being - * logically empty, because we don't attempt to detect pfree'ing the last - * active chunk. + * Note: header.isReset means there is nothing for AllocSetReset to do. + * This is different from the aset being physically empty (empty blocks list) + * because we may still have a keeper block. It's also different from the set + * being logically empty, because we don't attempt to detect pfree'ing the + * last active chunk. */ typedef struct AllocSetContext { @@ -140,7 +140,6 @@ typedef struct AllocSetContext /* Info about storage allocated in this context: */ AllocBlock blocks; /* head of list of blocks in this set */ AllocChunk freelist[ALLOCSET_NUM_FREELISTS]; /* free chunk lists */ - bool isReset; /* T = no space alloced since last reset */ /* Allocation parameters for this context: */ Size initBlockSize; /* initial block size */ Size maxBlockSize; /* maximum block size */ @@ -427,8 +426,6 @@ AllocSetContextCreate(MemoryContext parent, context->keeper = block; } - context->isReset = true; - return (MemoryContext) context; } @@ -472,10 +469,6 @@ AllocSetReset(MemoryContext context) AssertArg(AllocSetIsValid(set)); - /* Nothing to do if no pallocs since startup or last reset */ - if (set->isReset) - return; - #ifdef MEMORY_CONTEXT_CHECKING /* Check for corruption and leaks before freeing */ AllocSetCheck(context); @@ -519,8 +512,6 @@ AllocSetReset(MemoryContext context) /* Reset block size allocation sequence, too */ set->nextBlockSize = set->initBlockSize; - - set->isReset = true; } /* @@ -629,8 +620,6 @@ AllocSetAlloc(MemoryContext context, Size size) set->blocks = block; } - set->isReset = false; - AllocAllocInfo(set, chunk); return AllocChunkGetPointer(chunk); } @@ -662,9 +651,6 @@ AllocSetAlloc(MemoryContext context, Size size) randomize_mem((char *) AllocChunkGetPointer(chunk), size); #endif - /* isReset must be false already */ - Assert(!set->isReset); - AllocAllocInfo(set, chunk); return AllocChunkGetPointer(chunk); } @@ -822,8 +808,6 @@ AllocSetAlloc(MemoryContext context, Size size) randomize_mem((char *) AllocChunkGetPointer(chunk), size); #endif - set->isReset = false; - AllocAllocInfo(set, chunk); return AllocChunkGetPointer(chunk); } @@ -922,9 +906,6 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) set->header.name, chunk); #endif - /* isReset must be false already */ - Assert(!set->isReset); - /* * Chunk sizes are aligned to power of 2 in AllocSetAlloc(). Maybe the * allocated area already is >= the new size. (In particular, we always @@ -1059,15 +1040,13 @@ AllocSetGetChunkSpace(MemoryContext context, void *pointer) static bool AllocSetIsEmpty(MemoryContext context) { - AllocSet set = (AllocSet) context; - /* * For now, we say "empty" only if the context is new or just reset. We * could examine the freelists to determine if all space has been freed, * but it's not really worth the trouble for present uses of this * functionality. */ - if (set->isReset) + if (context->isReset) return true; return false; } diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 8783edf026..7ed35d5bdf 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -127,7 +127,12 @@ MemoryContextReset(MemoryContext context) if (context->firstchild != NULL) MemoryContextResetChildren(context); - (*context->methods->reset) (context); + /* Nothing to do if no pallocs since startup or last reset */ + if (!context->isReset) + { + (*context->methods->reset) (context); + context->isReset = true; + } } /* @@ -229,7 +234,7 @@ MemoryContextResetAndDeleteChildren(MemoryContext context) AssertArg(MemoryContextIsValid(context)); MemoryContextDeleteChildren(context); - (*context->methods->reset) (context); + MemoryContextReset(context); } /* @@ -476,6 +481,7 @@ MemoryContextCreate(NodeTag tag, Size size, node->parent = NULL; /* for the moment */ node->firstchild = NULL; node->nextchild = NULL; + node->isReset = true; node->name = ((char *) node) + size; strcpy(node->name, name); @@ -510,6 +516,8 @@ MemoryContextAlloc(MemoryContext context, Size size) elog(ERROR, "invalid memory alloc request size %lu", (unsigned long) size); + context->isReset = false; + return (*context->methods->alloc) (context, size); } @@ -531,6 +539,8 @@ MemoryContextAllocZero(MemoryContext context, Size size) elog(ERROR, "invalid memory alloc request size %lu", (unsigned long) size); + context->isReset = false; + ret = (*context->methods->alloc) (context, size); MemSetAligned(ret, 0, size); @@ -556,6 +566,8 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size) elog(ERROR, "invalid memory alloc request size %lu", (unsigned long) size); + context->isReset = false; + ret = (*context->methods->alloc) (context, size); MemSetLoop(ret, 0, size); @@ -620,6 +632,9 @@ repalloc(void *pointer, Size size) elog(ERROR, "invalid memory alloc request size %lu", (unsigned long) size); + /* isReset must be false already */ + Assert(!header->context->isReset); + return (*header->context->methods->realloc) (header->context, pointer, size); } diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 56a396bddd..4949af9657 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1086,6 +1086,11 @@ setup_config(void) "@authcomment@", strcmp(authmethod, "trust") ? "" : AUTHTRUST_WARNING); + /* Replace username for replication */ + conflines = replace_token(conflines, + "@default_username@", + username); + snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data); writefile(path, conflines); diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 3feb3ee548..1f31fe0694 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -574,7 +574,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) if (symlink(©buf[157], fn) != 0) { fprintf(stderr, - _("%s: could not create symbolic link from %s to %s: %s\n"), + _("%s: could not create symbolic link from \"%s\" to \"%s\": %s\n"), progname, fn, ©buf[157], strerror(errno)); disconnect_and_exit(1); } @@ -659,7 +659,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) if (file != NULL) { - fprintf(stderr, _("%s: last file was never finished\n"), progname); + fprintf(stderr, _("%s: COPY stream ended before last file was finished\n"), progname); disconnect_and_exit(1); } @@ -780,7 +780,7 @@ BaseBackup(void) if (PQsendQuery(conn, current_path) == 0) { - fprintf(stderr, _("%s: could not start base backup: %s"), + fprintf(stderr, _("%s: could not send base backup command: %s"), progname, PQerrorMessage(conn)); disconnect_and_exit(1); } @@ -876,7 +876,7 @@ BaseBackup(void) res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) { - fprintf(stderr, _("%s: could not get end xlog position from server\n"), + fprintf(stderr, _("%s: could not get WAL end position from server\n"), progname); disconnect_and_exit(1); } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 98bbaefd8c..7af3b913ff 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -411,10 +411,14 @@ start_postmaster(void) static PGPing test_postmaster_connection(bool do_checkpoint) { - PGPing ret = PQPING_OK; /* assume success for wait == zero */ + PGPing ret = PQPING_NO_RESPONSE; char connstr[MAXPGPATH * 2 + 256]; int i; + /* if requested wait time is zero, return "still starting up" code */ + if (wait_seconds <= 0) + return PQPING_REJECT; + connstr[0] = '\0'; for (i = 0; i < wait_seconds; i++) @@ -538,6 +542,19 @@ test_postmaster_connection(bool do_checkpoint) break; } + /* + * The postmaster should create postmaster.pid very soon after being + * started. If it's not there after we've waited 5 or more seconds, + * assume startup failed and give up waiting. + */ + if (i >= 5) + { + struct stat statbuf; + + if (stat(pid_file, &statbuf) != 0) + return PQPING_NO_RESPONSE; + } + /* No response, or startup still in process; wait */ #if defined(WIN32) if (do_checkpoint) diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index b37cc19c4e..28175674c0 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -104,7 +104,7 @@ typedef struct _restoreOptions * restore */ int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands * instead of OWNER TO */ - int skip_seclabel; /* Skip security label entries */ + int no_security_labels; /* Skip security label entries */ char *superuser; /* Username to use as superuser */ char *use_role; /* Issue SET ROLE to this */ int dataOnly; diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 7e1ce20745..0e1037cf00 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2352,7 +2352,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls) return 0; /* If it's security labels, maybe ignore it */ - if (ropt->skip_seclabel && strcmp(te->desc, "SECURITY LABEL") == 0) + if (ropt->no_security_labels && strcmp(te->desc, "SECURITY LABEL") == 0) return 0; /* Ignore DATABASE entry unless we should create it */ diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 616c8855a0..f925be1ffa 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -135,7 +135,7 @@ static int binary_upgrade = 0; static int disable_dollar_quoting = 0; static int dump_inserts = 0; static int column_inserts = 0; -static int no_security_label = 0; +static int no_security_labels = 0; static int no_unlogged_table_data = 0; static int serializable_deferrable = 0; @@ -329,7 +329,7 @@ main(int argc, char **argv) {"role", required_argument, NULL, 3}, {"serializable-deferrable", no_argument, &serializable_deferrable, 1}, {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, - {"no-security-label", no_argument, &no_security_label, 1}, + {"no-security-labels", no_argument, &no_security_labels, 1}, {"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1}, {NULL, 0, NULL, 0} @@ -651,8 +651,8 @@ main(int argc, char **argv) /* * Disables security label support if server version < v9.1.x */ - if (!no_security_label && g_fout->remoteVersion < 90100) - no_security_label = 1; + if (!no_security_labels && g_fout->remoteVersion < 90100) + no_security_labels = 1; /* * Start transaction-snapshot mode transaction to dump consistent data. @@ -829,7 +829,7 @@ help(const char *progname) printf(_(" %s [OPTION]... [DBNAME]\n"), progname); printf(_("\nGeneral options:\n")); - printf(_(" -f, --file=OUTPUT output file or directory name\n")); + printf(_(" -f, --file=FILENAME output file or directory name\n")); printf(_(" -F, --format=c|d|t|p output file format (custom, directory, tar, plain text)\n")); printf(_(" -v, --verbose verbose mode\n")); printf(_(" -Z, --compress=0-9 compression level for compressed formats\n")); @@ -854,16 +854,15 @@ help(const char *progname) printf(_(" -T, --exclude-table=TABLE do NOT dump the named table(s)\n")); printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n")); printf(_(" --binary-upgrade for use by upgrade utilities only\n")); - printf(_(" --inserts dump data as INSERT commands, rather than COPY\n")); printf(_(" --column-inserts dump data as INSERT commands with column names\n")); printf(_(" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n")); printf(_(" --disable-triggers disable triggers during data-only restore\n")); + printf(_(" --inserts dump data as INSERT commands, rather than COPY\n")); + printf(_(" --no-security-labels do not dump security label assignments\n")); printf(_(" --no-tablespaces do not dump tablespace assignments\n")); - printf(_(" --quote-all-identifiers quote all identifiers, even if not keywords\n")); - printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); - printf(_(" --role=ROLENAME do SET ROLE before dump\n")); - printf(_(" --no-security-label do not dump security label assignments\n")); printf(_(" --no-unlogged-table-data do not dump unlogged table data\n")); + printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); + printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --use-set-session-authorization\n" " use SET SESSION AUTHORIZATION commands instead of\n" " ALTER OWNER commands to set ownership\n")); @@ -874,6 +873,7 @@ help(const char *progname) printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -w, --no-password never prompt for password\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); + printf(_(" --role=ROLENAME do SET ROLE before dump\n")); printf(_("\nIf no database name is supplied, then the PGDATABASE environment\n" "variable value is used.\n\n")); @@ -1153,10 +1153,11 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo) * selectDumpableExtension: policy-setting subroutine * Mark an extension as to be dumped or not * - * Normally, we just dump all extensions. However, in binary-upgrade mode - * it's necessary to skip built-in extensions, since we assume those will - * already be installed in the target database. We identify such extensions - * by their having OIDs in the range reserved for initdb. + * Normally, we dump all extensions, or none of them if include_everything + * is false (i.e., a --schema or --table switch was given). However, in + * binary-upgrade mode it's necessary to skip built-in extensions, since we + * assume those will already be installed in the target database. We identify + * such extensions by their having OIDs in the range reserved for initdb. */ static void selectDumpableExtension(ExtensionInfo *extinfo) @@ -1164,7 +1165,7 @@ selectDumpableExtension(ExtensionInfo *extinfo) if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) extinfo->dobj.dump = false; else - extinfo->dobj.dump = true; + extinfo->dobj.dump = include_everything; } /* @@ -2541,7 +2542,7 @@ binary_upgrade_extension_member(PQExpBuffer upgrade_buffer, } if (extobj == NULL) { - write_msg(NULL, "failed to find parent extension for %s", objlabel); + write_msg(NULL, "could not find parent extension for %s", objlabel); exit_nicely(); } @@ -7937,6 +7938,7 @@ static void dumpCompositeType(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); + PQExpBuffer dropped = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); PQExpBuffer labelq = createPQExpBuffer(); PQExpBuffer query = createPQExpBuffer(); @@ -7944,9 +7946,13 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) int ntups; int i_attname; int i_atttypdefn; + int i_attlen; + int i_attalign; + int i_attisdropped; int i_attcollation; int i_typrelid; int i; + int actual_atts; /* Set proper schema search path so type references list correctly */ selectSourceSchema(tyinfo->dobj.namespace->dobj.name); @@ -7958,33 +7964,37 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) * attcollation is new in 9.1. Since we only want to dump COLLATE * clauses for attributes whose collation is different from their * type's default, we use a CASE here to suppress uninteresting - * attcollations cheaply. + * attcollations cheaply. atttypid will be 0 for dropped columns; + * collation does not matter for those. */ appendPQExpBuffer(query, "SELECT a.attname, " "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, " + "a.attlen, a.attalign, a.attisdropped, " "CASE WHEN a.attcollation <> at.typcollation " "THEN a.attcollation ELSE 0 END AS attcollation, " "ct.typrelid " - "FROM pg_catalog.pg_type ct, pg_catalog.pg_attribute a, " - "pg_catalog.pg_type at " + "FROM pg_catalog.pg_type ct " + "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid " + "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid " "WHERE ct.oid = '%u'::pg_catalog.oid " - "AND a.attrelid = ct.typrelid " - "AND a.atttypid = at.oid " - "AND NOT a.attisdropped " "ORDER BY a.attnum ", tyinfo->dobj.catId.oid); } else { - /* We assume here that remoteVersion must be at least 70300 */ + /* + * We assume here that remoteVersion must be at least 70300. Since + * ALTER TYPE could not drop columns until 9.1, attisdropped should + * always be false. + */ appendPQExpBuffer(query, "SELECT a.attname, " "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, " + "a.attlen, a.attalign, a.attisdropped, " "0 AS attcollation, " "ct.typrelid " "FROM pg_catalog.pg_type ct, pg_catalog.pg_attribute a " "WHERE ct.oid = '%u'::pg_catalog.oid " "AND a.attrelid = ct.typrelid " - "AND NOT a.attisdropped " "ORDER BY a.attnum ", tyinfo->dobj.catId.oid); } @@ -7996,6 +8006,9 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) i_attname = PQfnumber(res, "attname"); i_atttypdefn = PQfnumber(res, "atttypdefn"); + i_attlen = PQfnumber(res, "attlen"); + i_attalign = PQfnumber(res, "attalign"); + i_attisdropped = PQfnumber(res, "attisdropped"); i_attcollation = PQfnumber(res, "attcollation"); i_typrelid = PQfnumber(res, "typrelid"); @@ -8010,38 +8023,81 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(q, "CREATE TYPE %s AS (", fmtId(tyinfo->dobj.name)); + actual_atts = 0; for (i = 0; i < ntups; i++) { char *attname; char *atttypdefn; + char *attlen; + char *attalign; + bool attisdropped; Oid attcollation; attname = PQgetvalue(res, i, i_attname); atttypdefn = PQgetvalue(res, i, i_atttypdefn); + attlen = PQgetvalue(res, i, i_attlen); + attalign = PQgetvalue(res, i, i_attalign); + attisdropped = (PQgetvalue(res, i, i_attisdropped)[0] == 't'); attcollation = atooid(PQgetvalue(res, i, i_attcollation)); - appendPQExpBuffer(q, "\n\t%s %s", fmtId(attname), atttypdefn); + if (attisdropped && !binary_upgrade) + continue; + + /* Format properly if not first attr */ + if (actual_atts++ > 0) + appendPQExpBuffer(q, ","); + appendPQExpBuffer(q, "\n\t"); - /* Add collation if not default for the column type */ - if (OidIsValid(attcollation)) + if (!attisdropped) { - CollInfo *coll; + appendPQExpBuffer(q, "%s %s", fmtId(attname), atttypdefn); - coll = findCollationByOid(attcollation); - if (coll) + /* Add collation if not default for the column type */ + if (OidIsValid(attcollation)) { - /* always schema-qualify, don't try to be smart */ - appendPQExpBuffer(q, " COLLATE %s.", - fmtId(coll->dobj.namespace->dobj.name)); - appendPQExpBuffer(q, "%s", - fmtId(coll->dobj.name)); + CollInfo *coll; + + coll = findCollationByOid(attcollation); + if (coll) + { + /* always schema-qualify, don't try to be smart */ + appendPQExpBuffer(q, " COLLATE %s.", + fmtId(coll->dobj.namespace->dobj.name)); + appendPQExpBuffer(q, "%s", + fmtId(coll->dobj.name)); + } } } - - if (i < ntups - 1) - appendPQExpBuffer(q, ","); + else + { + /* + * This is a dropped attribute and we're in binary_upgrade mode. + * Insert a placeholder for it in the CREATE TYPE command, and + * set length and alignment with direct UPDATE to the catalogs + * afterwards. See similar code in dumpTableSchema(). + */ + appendPQExpBuffer(q, "%s INTEGER /* dummy */", fmtId(attname)); + + /* stash separately for insertion after the CREATE TYPE */ + appendPQExpBuffer(dropped, + "\n-- For binary upgrade, recreate dropped column.\n"); + appendPQExpBuffer(dropped, "UPDATE pg_catalog.pg_attribute\n" + "SET attlen = %s, " + "attalign = '%s', attbyval = false\n" + "WHERE attname = ", attlen, attalign); + appendStringLiteralAH(dropped, attname, fout); + appendPQExpBuffer(dropped, "\n AND attrelid = "); + appendStringLiteralAH(dropped, fmtId(tyinfo->dobj.name), fout); + appendPQExpBuffer(dropped, "::pg_catalog.regclass;\n"); + + appendPQExpBuffer(dropped, "ALTER TYPE %s ", + fmtId(tyinfo->dobj.name)); + appendPQExpBuffer(dropped, "DROP ATTRIBUTE %s;\n", + fmtId(attname)); + } } appendPQExpBuffer(q, "\n);\n"); + appendPQExpBufferStr(q, dropped->data); /* * DROP must be fully qualified in case same name appears in pg_catalog @@ -8077,6 +8133,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) PQclear(res); destroyPQExpBuffer(q); + destroyPQExpBuffer(dropped); destroyPQExpBuffer(delq); destroyPQExpBuffer(labelq); destroyPQExpBuffer(query); @@ -11535,8 +11592,8 @@ dumpSecLabel(Archive *fout, const char *target, int i; PQExpBuffer query; - /* do nothing, if --no-security-label is supplied */ - if (no_security_label) + /* do nothing, if --no-security-labels is supplied */ + if (no_security_labels) return; /* Comments are schema not data ... except blob comments are data */ @@ -11598,8 +11655,8 @@ dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename) PQExpBuffer query; PQExpBuffer target; - /* do nothing, if --no-security-label is supplied */ - if (no_security_label) + /* do nothing, if --no-security-labels is supplied */ + if (no_security_labels) return; /* SecLabel are SCHEMA not data */ diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 41a330763f..b3ad2eac29 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -69,7 +69,7 @@ static int disable_triggers = 0; static int inserts = 0; static int no_tablespaces = 0; static int use_setsessauth = 0; -static int no_security_label = 0; +static int no_security_labels = 0; static int no_unlogged_table_data = 0; static int server_version; @@ -134,7 +134,7 @@ main(int argc, char *argv[]) {"quote-all-identifiers", no_argument, "e_all_identifiers, 1}, {"role", required_argument, NULL, 3}, {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, - {"no-security-label", no_argument, &no_security_label, 1}, + {"no-security-labels", no_argument, &no_security_labels, 1}, {"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1}, {NULL, 0, NULL, 0} @@ -353,8 +353,8 @@ main(int argc, char *argv[]) appendPQExpBuffer(pgdumpopts, " --quote-all-identifiers"); if (use_setsessauth) appendPQExpBuffer(pgdumpopts, " --use-set-session-authorization"); - if (no_security_label) - appendPQExpBuffer(pgdumpopts, " --no-security-label"); + if (no_security_labels) + appendPQExpBuffer(pgdumpopts, " --no-security-labels"); if (no_unlogged_table_data) appendPQExpBuffer(pgdumpopts, " --no-unlogged-table-data"); @@ -546,15 +546,14 @@ help(void) printf(_(" -t, --tablespaces-only dump only tablespaces, no databases or roles\n")); printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n")); printf(_(" --binary-upgrade for use by upgrade utilities only\n")); - printf(_(" --inserts dump data as INSERT commands, rather than COPY\n")); printf(_(" --column-inserts dump data as INSERT commands with column names\n")); printf(_(" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n")); printf(_(" --disable-triggers disable triggers during data-only restore\n")); + printf(_(" --inserts dump data as INSERT commands, rather than COPY\n")); + printf(_(" --no-security-labels do not dump security label assignments\n")); printf(_(" --no-tablespaces do not dump tablespace assignments\n")); - printf(_(" --quote-all-identifiers quote all identifiers, even if not keywords\n")); - printf(_(" --role=ROLENAME do SET ROLE before dump\n")); - printf(_(" --no-security-label do not dump security label assignments\n")); printf(_(" --no-unlogged-table-data do not dump unlogged table data\n")); + printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --use-set-session-authorization\n" " use SET SESSION AUTHORIZATION commands instead of\n" " ALTER OWNER commands to set ownership\n")); @@ -566,6 +565,7 @@ help(void) printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -w, --no-password never prompt for password\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); + printf(_(" --role=ROLENAME do SET ROLE before dump\n")); printf(_("\nIf -f/--file is not used, then the SQL script will be written to the standard\n" "output.\n\n")); diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 241e29f149..7731d2540c 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -76,7 +76,7 @@ main(int argc, char **argv) static int no_data_for_failed_tables = 0; static int outputNoTablespaces = 0; static int use_setsessauth = 0; - static int skip_seclabel = 0; + static int no_security_labels = 0; struct option cmdopts[] = { {"clean", 0, NULL, 'c'}, @@ -117,7 +117,7 @@ main(int argc, char **argv) {"no-tablespaces", no_argument, &outputNoTablespaces, 1}, {"role", required_argument, NULL, 2}, {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, - {"no-security-label", no_argument, &skip_seclabel, 1}, + {"no-security-labels", no_argument, &no_security_labels, 1}, {NULL, 0, NULL, 0} }; @@ -318,7 +318,7 @@ main(int argc, char **argv) opts->noDataForFailedTables = no_data_for_failed_tables; opts->noTablespace = outputNoTablespaces; opts->use_setsessauth = use_setsessauth; - opts->skip_seclabel = skip_seclabel; + opts->no_security_labels = no_security_labels; if (opts->formatName) { @@ -345,7 +345,7 @@ main(int argc, char **argv) break; default: - write_msg(NULL, "unrecognized archive format \"%s\"; please specify \"c\", \"d\" or \"t\"\n", + write_msg(NULL, "unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"\n", opts->formatName); exit(1); } @@ -424,18 +424,17 @@ usage(const char *progname) printf(_(" -t, --table=NAME restore named table\n")); printf(_(" -T, --trigger=NAME restore named trigger\n")); printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n")); + printf(_(" -1, --single-transaction\n" + " restore as a single transaction\n")); printf(_(" --disable-triggers disable triggers during data-only restore\n")); printf(_(" --no-data-for-failed-tables\n" " do not restore data of tables that could not be\n" " created\n")); + printf(_(" --no-security-labels do not restore security labels\n")); printf(_(" --no-tablespaces do not restore tablespace assignments\n")); - printf(_(" --no-security-label do not restore security labels\n")); - printf(_(" --role=ROLENAME do SET ROLE before restore\n")); printf(_(" --use-set-session-authorization\n" " use SET SESSION AUTHORIZATION commands instead of\n" " ALTER OWNER commands to set ownership\n")); - printf(_(" -1, --single-transaction\n" - " restore as a single transaction\n")); printf(_("\nConnection options:\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); @@ -443,6 +442,7 @@ usage(const char *progname) printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -w, --no-password never prompt for password\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); + printf(_(" --role=ROLENAME do SET ROLE before restore\n")); printf(_("\nIf no input file name is supplied, then standard input is used.\n\n")); printf(_("Report bugs to <[email protected]>.\n")); diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 31a9ab909c..378330b96a 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -302,7 +302,7 @@ exec_command(const char *cmd, char *host = PQhost(pset.db); if (db == NULL) - printf(_("You are not connected.\n")); + printf(_("You are currently not connected to a database.\n")); else { if (host == NULL) diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 49d1e7db6f..0200a81dbf 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201105131 +#define CATALOG_VERSION_NO 201105231 #endif diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 1d651dd408..bdd499bea6 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -131,7 +131,7 @@ extern void execTuplesHashPrepare(int numCols, extern TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, FmgrInfo *eqfunctions, FmgrInfo *hashfunctions, - int nbuckets, Size entrysize, + long nbuckets, Size entrysize, MemoryContext tablecxt, MemoryContext tempcxt); extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h index b62ed8f904..62a0f9730e 100644 --- a/src/include/nodes/memnodes.h +++ b/src/include/nodes/memnodes.h @@ -59,6 +59,7 @@ typedef struct MemoryContextData MemoryContext firstchild; /* head of linked list of children */ MemoryContext nextchild; /* next child of same parent */ char *name; /* context name (just for debugging) */ + bool isReset; /* T = no space alloced since last reset */ } MemoryContextData; /* utils/palloc.h contains typedef struct MemoryContextData *MemoryContext */ diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 6648753da0..f89ceb9664 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -1012,7 +1012,7 @@ connectFailureMessage(PGconn *conn, int errorno) #endif /* HAVE_UNIX_SOCKETS */ { char host_addr[NI_MAXHOST]; - bool display_host_addr; + const char *displayed_host; struct sockaddr_storage *addr = &conn->raddr.addr; /* @@ -1042,30 +1042,36 @@ connectFailureMessage(PGconn *conn, int errorno) else strcpy(host_addr, "???"); + if (conn->pghostaddr && conn->pghostaddr[0] != '\0') + displayed_host = conn->pghostaddr; + else if (conn->pghost && conn->pghost[0] != '\0') + displayed_host = conn->pghost; + else + displayed_host = DefaultHost; + /* * If the user did not supply an IP address using 'hostaddr', and * 'host' was missing or does not match our lookup, display the * looked-up IP address. */ - display_host_addr = (conn->pghostaddr == NULL) && - ((conn->pghost == NULL) || - (strcmp(conn->pghost, host_addr) != 0)); - - appendPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not connect to server: %s\n" - "\tIs the server running on host \"%s\"%s%s%s and accepting\n" - "\tTCP/IP connections on port %s?\n"), - SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)), - (conn->pghostaddr && conn->pghostaddr[0] != '\0') - ? conn->pghostaddr - : (conn->pghost && conn->pghost[0] != '\0') - ? conn->pghost - : DefaultHost, - /* display the IP address only if not already output */ - display_host_addr ? " (" : "", - display_host_addr ? host_addr : "", - display_host_addr ? ")" : "", - conn->pgport); + if ((conn->pghostaddr == NULL) && + (conn->pghost == NULL || strcmp(conn->pghost, host_addr) != 0)) + appendPQExpBuffer(&conn->errorMessage, + libpq_gettext("could not connect to server: %s\n" + "\tIs the server running on host \"%s\" (%s) and accepting\n" + "\tTCP/IP connections on port %s?\n"), + SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)), + displayed_host, + host_addr, + conn->pgport); + else + appendPQExpBuffer(&conn->errorMessage, + libpq_gettext("could not connect to server: %s\n" + "\tIs the server running on host \"%s\" and accepting\n" + "\tTCP/IP connections on port %s?\n"), + SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)), + displayed_host, + conn->pgport); } } diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 535fea9257..75098ec6de 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -95,6 +95,7 @@ static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo, PLpgSQL_func_hashkey *hashkey, bool forValidator); static void plpgsql_compile_error_callback(void *arg); +static void add_parameter_name(int itemtype, int itemno, const char *name); static void add_dummy_return(PLpgSQL_function *function); static Node *plpgsql_pre_column_ref(ParseState *pstate, ColumnRef *cref); static Node *plpgsql_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var); @@ -451,11 +452,11 @@ do_compile(FunctionCallInfo fcinfo, out_arg_variables[num_out_args++] = argvariable; /* Add to namespace under the $n name */ - plpgsql_ns_additem(argitemtype, argvariable->dno, buf); + add_parameter_name(argitemtype, argvariable->dno, buf); /* If there's a name for the argument, make an alias */ if (argnames && argnames[i][0] != '\0') - plpgsql_ns_additem(argitemtype, argvariable->dno, + add_parameter_name(argitemtype, argvariable->dno, argnames[i]); } @@ -914,6 +915,31 @@ plpgsql_compile_error_callback(void *arg) /* + * Add a name for a function parameter to the function's namespace + */ +static void +add_parameter_name(int itemtype, int itemno, const char *name) +{ + /* + * Before adding the name, check for duplicates. We need this even though + * functioncmds.c has a similar check, because that code explicitly + * doesn't complain about conflicting IN and OUT parameter names. In + * plpgsql, such names are in the same namespace, so there is no way to + * disambiguate. + */ + if (plpgsql_ns_lookup(plpgsql_ns_top(), true, + name, NULL, NULL, + NULL) != NULL) + ereport(ERROR, + (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), + errmsg("parameter name \"%s\" used more than once", + name))); + + /* OK, add the name */ + plpgsql_ns_additem(itemtype, itemno, name); +} + +/* * Add a dummy RETURN statement to the given function's body */ static void @@ -1267,9 +1293,11 @@ make_datum_param(PLpgSQL_expr *expr, int dno, int location) param = makeNode(Param); param->paramkind = PARAM_EXTERN; param->paramid = dno + 1; - param->paramtype = exec_get_datum_type(estate, datum); - param->paramtypmod = -1; - param->paramcollid = exec_get_datum_collation(estate, datum); + exec_get_datum_type_info(estate, + datum, + ¶m->paramtype, + ¶m->paramtypmod, + ¶m->paramcollid); param->location = location; return (Node *) param; diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 1da5095507..4331a5c8df 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -2060,7 +2060,7 @@ exec_stmt_foreach_a(PLpgSQL_execstate *estate, PLpgSQL_stmt_foreach_a *stmt) if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("FOREACH expression must not be NULL"))); + errmsg("FOREACH expression must not be null"))); /* check the type of the expression - must be an array */ if (!OidIsValid(get_element_type(arrtype))) @@ -4307,29 +4307,63 @@ exec_get_datum_type(PLpgSQL_execstate *estate, } /* - * exec_get_datum_collation Get collation of a PLpgSQL_datum + * exec_get_datum_type_info Get datatype etc of a PLpgSQL_datum + * + * An extended version of exec_get_datum_type, which also retrieves the + * typmod and collation of the datum. */ -Oid -exec_get_datum_collation(PLpgSQL_execstate *estate, - PLpgSQL_datum *datum) +void +exec_get_datum_type_info(PLpgSQL_execstate *estate, + PLpgSQL_datum *datum, + Oid *typeid, int32 *typmod, Oid *collation) { - Oid collid; - switch (datum->dtype) { case PLPGSQL_DTYPE_VAR: { PLpgSQL_var *var = (PLpgSQL_var *) datum; - collid = var->datatype->collation; + *typeid = var->datatype->typoid; + *typmod = var->datatype->atttypmod; + *collation = var->datatype->collation; break; } case PLPGSQL_DTYPE_ROW: + { + PLpgSQL_row *row = (PLpgSQL_row *) datum; + + if (!row->rowtupdesc) /* should not happen */ + elog(ERROR, "row variable has no tupdesc"); + /* Make sure we have a valid type/typmod setting */ + BlessTupleDesc(row->rowtupdesc); + *typeid = row->rowtupdesc->tdtypeid; + /* do NOT return the mutable typmod of a RECORD variable */ + *typmod = -1; + /* composite types are never collatable */ + *collation = InvalidOid; + break; + } + case PLPGSQL_DTYPE_REC: - /* composite types are never collatable */ - collid = InvalidOid; - break; + { + PLpgSQL_rec *rec = (PLpgSQL_rec *) datum; + + if (rec->tupdesc == NULL) + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("record \"%s\" is not assigned yet", + rec->refname), + errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); + /* Make sure we have a valid type/typmod setting */ + BlessTupleDesc(rec->tupdesc); + *typeid = rec->tupdesc->tdtypeid; + /* do NOT return the mutable typmod of a RECORD variable */ + *typmod = -1; + /* composite types are never collatable */ + *collation = InvalidOid; + break; + } case PLPGSQL_DTYPE_RECFIELD: { @@ -4350,21 +4384,27 @@ exec_get_datum_collation(PLpgSQL_execstate *estate, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("record \"%s\" has no field \"%s\"", rec->refname, recfield->fieldname))); - /* XXX there's no SPI_getcollid, as yet */ + *typeid = SPI_gettypeid(rec->tupdesc, fno); + /* XXX there's no SPI_gettypmod, for some reason */ + if (fno > 0) + *typmod = rec->tupdesc->attrs[fno - 1]->atttypmod; + else + *typmod = -1; + /* XXX there's no SPI_getcollation either */ if (fno > 0) - collid = rec->tupdesc->attrs[fno - 1]->attcollation; + *collation = rec->tupdesc->attrs[fno - 1]->attcollation; else /* no system column types have collation */ - collid = InvalidOid; + *collation = InvalidOid; break; } default: elog(ERROR, "unrecognized dtype: %d", datum->dtype); - collid = InvalidOid; /* keep compiler quiet */ + *typeid = InvalidOid; /* keep compiler quiet */ + *typmod = -1; + *collation = InvalidOid; break; } - - return collid; } /* ---------- diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index e50d7eb45f..89103aea8c 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -905,8 +905,9 @@ extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid, SubTransactionId parentSubid, void *arg); extern Oid exec_get_datum_type(PLpgSQL_execstate *estate, PLpgSQL_datum *datum); -extern Oid exec_get_datum_collation(PLpgSQL_execstate *estate, - PLpgSQL_datum *datum); +extern void exec_get_datum_type_info(PLpgSQL_execstate *estate, + PLpgSQL_datum *datum, + Oid *typeid, int32 *typmod, Oid *collation); /* ---------- * Functions for namespace handling in pl_funcs.c diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index fe44a1a16a..e81f62542f 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -3937,7 +3937,7 @@ PLy_add_exceptions(PyObject *plpy) excmod = PyModule_Create(&PLy_exc_module); #endif if (PyModule_AddObject(plpy, "spiexceptions", excmod) < 0) - PLy_elog(ERROR, "failed to add the spiexceptions module"); + PLy_elog(ERROR, "could not add the spiexceptions module"); /* * XXX it appears that in some circumstances the reference count of the diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile index 6513b5f24e..7cbcd4b403 100644 --- a/src/test/isolation/Makefile +++ b/src/test/isolation/Makefile @@ -6,6 +6,9 @@ subdir = src/test/isolation top_builddir = ../../.. include $(top_builddir)/src/Makefile.global +# where to find psql for testing an existing installation +PSQLDIR = $(bindir) + ifeq ($(PORTNAME), win32) LDLIBS += -lws2_32 endif @@ -70,7 +73,7 @@ maintainer-clean: distclean rm -f specparse.c specscanner.c installcheck: all - ./pg_isolation_regress --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule + ./pg_isolation_regress --psqldir=$(PSQLDIR) --inputdir=$(srcdir) --schedule=$(srcdir)/isolation_schedule # We can't support "make check" because isolationtester requires libpq, and # in fact (on typical platforms using shared libraries) requires libpq to diff --git a/src/test/isolation/README b/src/test/isolation/README index ee94081f09..087ac279c7 100644 --- a/src/test/isolation/README +++ b/src/test/isolation/README @@ -4,7 +4,7 @@ Isolation tests =============== This directory contains a set of tests for the serializable isolation level. -Testing isolation requires running multiple overlapping transactions, so +Testing isolation requires running multiple overlapping transactions, which requires multiple concurrent connections, and can't therefore be tested using the normal pg_regress program. @@ -13,10 +13,10 @@ file with a custom syntax, described in the next section. isolationtester is program that uses libpq to open multiple connections, and executes a test specified by a spec file. A libpq connection string -to specify the server and database to connect to, the defaults derived from +specifies the server and database to connect to; defaults derived from environment variables are used otherwise. -pg_isolation_regress is a tool identical to pg_regress, but instead of using +pg_isolation_regress is a tool similar to pg_regress, but instead of using psql to execute a test, it uses isolationtester. To run the tests, you need to have a server up and running. Run @@ -58,7 +58,7 @@ session "<name>" permutation "<step name>" ... - A permutation line specifies a list of steps that are ran in that order. + A permutation line specifies a list of steps that are run in that order. If no permutation lines are given, the test program automatically generates all possible overlapping orderings of the given sessions. diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 1cb418164b..a200f8fe3d 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -1955,6 +1955,12 @@ Table "public.test_tbl2_subclass" Inherits: test_tbl2 DROP TABLE test_tbl2_subclass; +-- This test isn't that interesting on its own, but the purpose is to leave +-- behind a table to test pg_upgrade with. The table has a composite type +-- column in it, and the composite type has a dropped attribute. +CREATE TYPE test_type3 AS (a int); +CREATE TABLE test_tbl3 (c) AS SELECT '(1)'::test_type3; +ALTER TYPE test_type3 DROP ATTRIBUTE a, ADD ATTRIBUTE b int; CREATE TYPE test_type_empty AS (); DROP TYPE test_type_empty; -- diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out index 7b05ce3354..6e5534995d 100644 --- a/src/test/regress/expected/arrays.out +++ b/src/test/regress/expected/arrays.out @@ -1292,9 +1292,9 @@ select array_fill('juhu'::text, array[3,3]); -- raise exception select array_fill(1, null, array[2,2]); -ERROR: dimension array or low bound array cannot be NULL +ERROR: dimension array or low bound array cannot be null select array_fill(1, array[2,2], null); -ERROR: dimension array or low bound array cannot be NULL +ERROR: dimension array or low bound array cannot be null select array_fill(1, array[3,3], array[1,1,1]); ERROR: wrong number of array subscripts DETAIL: Low bound array has different size than dimensions array. diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 4b2afe8bc9..0ed16fb7cf 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -1371,6 +1371,13 @@ ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa CASCADE; DROP TABLE test_tbl2_subclass; +-- This test isn't that interesting on its own, but the purpose is to leave +-- behind a table to test pg_upgrade with. The table has a composite type +-- column in it, and the composite type has a dropped attribute. +CREATE TYPE test_type3 AS (a int); +CREATE TABLE test_tbl3 (c) AS SELECT '(1)'::test_type3; +ALTER TYPE test_type3 DROP ATTRIBUTE a, ADD ATTRIBUTE b int; + CREATE TYPE test_type_empty AS (); DROP TYPE test_type_empty; diff --git a/src/test/thread/thread_test.c b/src/test/thread/thread_test.c index 0782e8c66b..6a81829912 100644 --- a/src/test/thread/thread_test.c +++ b/src/test/thread/thread_test.c @@ -150,6 +150,7 @@ main(int argc, char *argv[]) pthread_t thread1, thread2; int fd; + int rc; #ifdef WIN32 WSADATA wsaData; @@ -199,8 +200,23 @@ main(int argc, char *argv[]) /* Hold lock until we are ready for the child threads to exit. */ pthread_mutex_lock(&init_mutex); - pthread_create(&thread1, NULL, (void *(*) (void *)) func_call_1, NULL); - pthread_create(&thread2, NULL, (void *(*) (void *)) func_call_2, NULL); + rc = pthread_create(&thread1, NULL, (void *(*) (void *)) func_call_1, NULL); + if (rc != 0) + { + fprintf(stderr, "Failed to create thread 1: %s **\nexiting\n", + strerror(rc)); + exit(1); + } + rc = pthread_create(&thread2, NULL, (void *(*) (void *)) func_call_2, NULL); + if (rc != 0) + { + /* + * strerror() might not be thread-safe, and we already spawned thread + * 1 that uses it + */ + fprintf(stderr, "Failed to create thread 2 **\nexiting\n"); + exit(1); + } while (thread1_done == 0 || thread2_done == 0) sched_yield(); /* if this is a portability problem, remove it */ diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 5d58463a1e..1d10ee98e8 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -272,7 +272,7 @@ sub mkvcbuild $pgregress_ecpg->AddDefine('FRONTEND'); $pgregress_ecpg->AddReference($libpgport); - my $isolation_tester = $solution->AddProject('isolation_tester','exe','misc'); + my $isolation_tester = $solution->AddProject('isolationtester','exe','misc'); $isolation_tester->AddFile('src\test\isolation\isolationtester.c'); $isolation_tester->AddFile('src\test\isolation\specparse.y'); $isolation_tester->AddFile('src\test\isolation\specscanner.l'); diff --git a/src/tools/msvc/builddoc.bat b/src/tools/msvc/builddoc.bat index dc76c7e048..024706989e 100755 --- a/src/tools/msvc/builddoc.bat +++ b/src/tools/msvc/builddoc.bat @@ -1,66 +1,7 @@ @echo off -REM Adjust path for your docbook installation in buildenv.pl REM src/tools/msvc/builddoc.bat - -SETLOCAL -SET STARTDIR=%CD% -SET OPENJADE=openjade-1.3.1 -SET DSSSL=docbook-dsssl-1.79 - -IF EXIST ..\msvc IF EXIST ..\..\..\src cd ..\..\.. -IF NOT EXIST doc\src\sgml\version.sgml goto noversion - -IF NOT EXIST src\tools\msvc\buildenv.pl goto nobuildenv -perl -e "require 'src/tools/msvc/buildenv.pl'; while(($k,$v) = each %ENV) { print qq[\@SET $k=$v\n]; }" > bldenv.bat -CALL bldenv.bat -del bldenv.bat -:nobuildenv - -IF NOT EXIST %DOCROOT%\%OPENJADE% SET NF=OpenJade -IF NOT EXIST %DOCROOT%\docbook SET NF=docbook -IF NOT EXIST %DOCROOT%\%DSSSL% set NF=docbook-dssl - -IF NOT "%NF%" == "" GOTO notfound - -IF "%1" == "renamefiles" GOTO renamefiles - -cmd /v /c src\tools\msvc\builddoc renamefiles -cd doc\src\sgml - -SET SGML_CATALOG_FILES=%DOCROOT%\%OPENJADE%\dsssl\catalog;%DOCROOT%\docbook\docbook.cat -perl %DOCROOT%\%DSSSL%\bin\collateindex.pl -f -g -o bookindex.sgml -N -perl mk_feature_tables.pl YES ..\..\..\src\backend\catalog\sql_feature_packages.txt ..\..\..\src\backend\catalog\sql_features.txt > features-supported.sgml -perl mk_feature_tables.pl NO ..\..\..\src\backend\catalog\sql_feature_packages.txt ..\..\..\src\backend\catalog\sql_features.txt > features-unsupported.sgml -perl make-errcodes-table.pl ..\..\..\src\backend\utils\errcodes.txt > errcodes-table.sgml - -echo Running first build... -%DOCROOT%\%OPENJADE%\bin\openjade -V draft-mode -wall -wno-unused-param -wno-empty -D . -c %DOCROOT%\%DSSSL%\catalog -d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 | findstr /V "DTDDECL catalog entries are not supported" -echo Running collateindex... -perl %DOCROOT%\%DSSSL%\bin\collateindex.pl -f -g -i bookindex -o bookindex.sgml HTML.index -echo Running second build... -%DOCROOT%\%OPENJADE%\bin\openjade -V draft-mode -wall -wno-unused-param -wno-empty -D . -c %DOCROOT%\%DSSSL%\catalog -d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 | findstr /V "DTDDECL catalog entries are not supported" - -cd %STARTDIR% -echo Docs build complete. -exit /b - - -:renamefiles -REM Rename ISO entity files -CD %DOCROOT%\docbook -FOR %%f in (ISO*) do ( - set foo=%%f - IF NOT "!foo:~-4!" == ".gml" ren !foo! !foo:~0,3!-!foo:~3!.gml -) -exit /b - -:notfound -echo Could not find directory for %NF%. -cd %STARTDIR% -goto :eof - -:noversion -echo Could not find version.sgml. Please run mkvcbuild.pl first! -cd %STARTDIR% -goto :eof +REM all the logic for this now belongs in builddoc.pl. This file really +REM only exists so you don't have to type "perl builddoc.pl" +REM Resist any temptation to add any logic here. +@perl builddoc.pl %* diff --git a/src/tools/msvc/builddoc.pl b/src/tools/msvc/builddoc.pl new file mode 100644 index 0000000000..deaf659e77 --- /dev/null +++ b/src/tools/msvc/builddoc.pl @@ -0,0 +1,122 @@ +# -*-perl-*- hey - emacs - this is a perl file + +# Adjust path for your docbook installation in buildenv.pl + +# src/tools/msvc/builddoc.pl +# translated from an earlier .bat file + +use strict; +use File::Copy; +use Cwd qw(abs_path getcwd); + + +my $startdir = getcwd(); + +my $openjade = 'openjade-1.3.1'; +my $dsssl = 'docbook-dsssl-1.79'; + +chdir '../../..' if (-d '../msvc' && -d '../../../src'); + +noversion() unless -e 'doc/src/sgml/version.sgml'; + +require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; + +my $docroot = $ENV{DOCROOT}; +die "bad DOCROOT '$docroot'" unless ($docroot && -d $docroot); + +my @notfound; +foreach my $dir ('docbook', $openjade, $dsssl) +{ + push(@notfound,$dir) unless -d "$docroot/$dir"; +} +missing() if @notfound; + +my $arg = shift; +renamefiles(); + + +chdir 'doc/src/sgml'; + +$ENV{SGML_CATALOG_FILES} = "$docroot/$openjade/dsssl/catalog;" . + "$docroot/docbook/docbook.cat"; + +my $cmd; + +# openjade exits below with a harmless non-zero status, so we +# can't die on "failure" + +$cmd = +"perl mk_feature_tables.pl YES " . + "../../../src/backend/catalog/sql_feature_packages.txt " . + "../../../src/backend/catalog/sql_features.txt " . + "> features-supported.sgml"; +system($cmd); die "features_supported" if $?; +$cmd = +"perl mk_feature_tables.pl NO " . + "\"../../../src/backend/catalog/sql_feature_packages.txt\" " . + "\"../../../src/backend/catalog/sql_features.txt\" " . + "> features-unsupported.sgml"; +system($cmd); die "features_unsupported" if $?; +$cmd = +"perl generate-errcodes-table.pl \"../../../src/backend/utils/errcodes.txt\" " . + "> errcodes-table.sgml"; +system($cmd); die "errcodes-table" if $?; + +print "Running first build...\n"; +$cmd = +"\"$docroot/$openjade/bin/openjade\" -V html-index -wall " . + "-wno-unused-param -wno-empty -D . -c \"$docroot/$dsssl/catalog\" " . + "-d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 " . + "| findstr /V \"DTDDECL catalog entries are not supported\" "; +system($cmd); # die "openjade" if $?; +print "Running collateindex...\n"; +$cmd = +"perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex " . + "-o bookindex.sgml HTML.index"; +system($cmd); die "collateindex" if $?; +mkdir "html"; +print "Running second build...\n"; +$cmd = +"\"$docroot/$openjade/bin/openjade\" -wall -wno-unused-param -wno-empty " . + "-D . -c \"$docroot/$dsssl/catalog\" -d stylesheet.dsl -t sgml " . + "-i output-html -i include-index postgres.sgml 2>&1 " . + "| findstr /V \"DTDDECL catalog entries are not supported\" "; + +system($cmd); # die "openjade" if $?; + +copy "stylesheet.css", "html/stylesheet.css"; + +print "Docs build complete.\n"; + +exit; + +######################################################## + +sub renamefiles +{ + # Rename ISO entity files + my $savedir = getcwd(); + chdir "$docroot/docbook"; + foreach my $f (glob('ISO*')) + { + next if $f =~ /\.gml$/i; + my $nf = $f; + $nf =~ s/ISO(.*)/ISO-$1.gml/; + move $f, $nf; + } + chdir $savedir; + +} + +sub missing +{ + print STDERR "could not find $docroot/$_\n" foreach (@notfound); + exit 1; +} + +sub noversion +{ + print STDERR "Could not find version.sgml. ", + "Please run mkvcbuild.pl first!\n"; + exit 1; +} diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index 588335a031..579ca52e02 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -141,7 +141,7 @@ sub ecpgcheck sub isolationcheck { chdir "../isolation"; - copy("../../../$Config/isolation_tester/isolation_tester.exe","."); + copy("../../../$Config/isolationtester/isolationtester.exe","."); my @args = ( "../../../$Config/pg_isolation_regress/pg_isolation_regress", "--psqldir=../../../$Config/psql", |