diff -Nru postgresql-common-173+ppa1/architecture.html postgresql-common-190~ubuntu16.04.1/architecture.html --- postgresql-common-173+ppa1/architecture.html 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/architecture.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - - - - - - - Multiversion/Multicluster PostgreSQL architecture - - - -

Multi-Version/Multi-Cluster PostgreSQL architecture

- - -

Solving a problem

- -

-When a new major version of PostgreSQL is released, it is necessary to -dump and reload the database. The old software must be used for the dump, -and the new software for the reload.

- -

This was a major problem for Red Hat and Debian, because a dump and reload was -not required by every upgrade and by the time the need for a dump is -realised, the old software might have been deleted. Debian had certain rather -unreliable procedures to save the old software and use it to do a dump, but -these procedures often went wrong. Red Hat's installation environment is so -rigid that it is not practicable for the Red Hat packages to attempt an -automatic upgrade. Debian offered a debconf choice for -whether to attempt automatic upgrading; if it failed or was not allowed, a -manual upgrade had to be done, either from a pre-existing dump or by -manual invocation of the postgresql-dump script.

- -

There was once an upstream program called pg_upgrade which could be -used for in-place upgrading. This does not currently work and does not seem to -be a high priority with upstream developers.

- -

It is possible to run different versions of PostgreSQL simultaneously, and -indeed to run the same version on separate database clusters simultaneously. -To do so, each postmaster must listen on a different port, so each client -must specify the correct port. By having two separate -versions of the PostgreSQL packages installed simultaneously, it is -simple to do database upgrades by dumping from the old version and -uploading to the new. The PostgreSQL client wrapper is designed to -permit this.

- -

General Architecture idea

- -

The Debian packaging has been changed to create a new package for each major -version. The criterion for creating a new package is that initdb is required -when upgrading from the previous version. Thus, there are now source packages -postgresql-8.1 and postgresql-8.3 (and similarly for -all the binary packages).

- -

The legacy postgresql and the other existing binary package names have -become dummy packages depending on one of the versioned equivalents. Their only -purpose is now to ensure a smooth upgrade and to register the existing database -cluster to the new architecture. These packages will be removed from the -archive as soon as the next Debian release after Sarge (Etch) is released.

- -

Each versioned package installs into -/usr/lib/postgresql/version. In order to allow users -easily to select the right version and cluster when working, the -postgresql-common package provides the pg_wrapper program, -which reads the per-user and system wide configuration file and forks the -correct executable with the correct library versions according to those -preferences. /usr/bin provides executables soft-linked to -pg_wrapper.

- -

This architecture also allows separate database clusters to be maintained -for the use of different groups of users; these clusters need not all be of the -same major version. This allows much greater flexibility for those people -who need to make application software changes consequent on a PostgreSQL -upgrade.

- -

Detailed structure

- -

Configuration hierarchy

- - - - - - - - - - - -
/etc/postgresql-common/user_clusters maps users -against clusters and default databases
$HOME/.postgresqlrc per-user preferences for -default version/cluster and database; overrides -/etc/postgresql-common/user_clusters
/etc/postgresql/version/clusternameCluster-specific configuration files: -
    -
  • postgresql.conf, pg_hba.conf, pg_ident.conf
  • -
  • optionally start.conf: startup mode of the - cluster: auto (start/stop in init script), - manual (do not start/stop in init script, but manual - control with pg_ctlcluster is possible), disabled - (pg_ctlcluster is not allowed).
  • -
  • optionally pg_ctl.conf: options to be passed to pg_ctl.
  • -
  • optionally a symbolic link log which points to - the postmaster log file. Defaults to - /var/log/postgresql/postgresql-version-cluster.conf. - Explicitly setting log_directory and/or - log_filename in postgresql.conf - overrides this.
  • -
-
- -

Per-version files and programs

- - - - - -
/usr/lib/postgresql/version version specific program and data files
/usr/share/postgresql/version
/usr/share/doc/postgresql/postgresql-doc-version
- -

Common programs

- - - - - - - - -
/usr/share/postgresql-common/pg_wrapper environment chooser and program selector
/usr/bin/program symbolic links to pg_wrapper, for all client programs
/usr/bin/pg_lsclusters list all available clusters with their status and configuration
/usr/bin/pg_createclusterwrapper for initdb, sets up the necessary configuration structure
/usr/bin/pg_ctlclusterwrapper for pg_ctl, control the cluster postmaster server
/usr/bin/pg_upgradeclusterUpgrade a cluster to a newer major version.
/usr/bin/pg_dropclusterremove a cluster and its configuration
- -

psql

- -

We have abandoned the old non-standard error abort if a connection database -is not specified; psql is not expected to be run directly and all -connection parameters should be provided by pg_wrapper as specified above. In -addition, if no explicit default database is specified in -user_clusters, the default database will correspond to the user -name, thus reintroducing the default upstream behaviour.

- -

/etc/init.d/postgresql

- -

This script now handles the postmaster server processes for each version and -all their clusters. However, most of the actual work is done by the new -pg_ctlcluster program.

- -

pg_upgradecluster

- -

This new program replaces postgresql-dump (a Debian specific program).

- -

It is used to migrate a cluster from one major version to another.

- -

Usage: pg_upgradecluster [-v newversion] -version name [data_dir]

- -

-v version specifies the version to upgrade to; defaults -to the newest available version.

- -

The Debian -PostgreSQL developers

- - - diff -Nru postgresql-common-173+ppa1/cleanpg postgresql-common-190~ubuntu16.04.1/cleanpg --- postgresql-common-173+ppa1/cleanpg 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/cleanpg 2018-01-12 14:08:46.000000000 +0000 @@ -18,5 +18,5 @@ [ `id -u` = 0 ] || SUDO=sudo $SUDO /etc/init.d/postgresql stop -$SUDO killall pg_autovacuum postmaster postgres +$SUDO killall pg_autovacuum postgres $SUDO rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/* /tmp/postgresql-testsuite/ /var/run/postgresql/* diff -Nru postgresql-common-173+ppa1/createcluster.conf postgresql-common-190~ubuntu16.04.1/createcluster.conf --- postgresql-common-173+ppa1/createcluster.conf 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/createcluster.conf 2018-01-12 14:08:46.000000000 +0000 @@ -13,8 +13,8 @@ #data_directory = '/var/lib/postgresql/%v/%c' # Default directory for transaction logs -# Unset by default, i.e. pg_xlog remains in the data directory. -#xlogdir = '/var/lib/postgresql/xlog/%v/%c/pg_xlog' +# Unset by default, i.e. transaction logs remain in the data directory. +#waldir = '/var/lib/postgresql/wal/%v/%c/pg_wal' # Options to pass to initdb. #initdb_options = '' @@ -25,8 +25,17 @@ # ssl-cert package, unless configured otherwise here) ssl = on +# Show cluster name in process title +cluster_name = '%v/%c' + # Put stats_temp_directory on tmpfs stats_temp_directory = '/var/run/postgresql/%v-%c.pg_stat_tmp' # Add prefix to log lines -log_line_prefix = '%%t [%%p-%%l] %%q%%u@%%d ' +log_line_prefix = '%%m [%%p] %%q%%u@%%d ' + +# Add "include_dir" in postgresql.conf +add_include_dir = 'conf.d' + +# Directory for additional createcluster config +include_dir '/etc/postgresql-common/createcluster.d' diff -Nru postgresql-common-173+ppa1/debian/changelog postgresql-common-190~ubuntu16.04.1/debian/changelog --- postgresql-common-173+ppa1/debian/changelog 2017-01-13 00:33:22.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/changelog 2019-03-14 23:34:37.000000000 +0000 @@ -1,8 +1,322 @@ -postgresql-common (173+ppa1) xenial; urgency=medium +postgresql-common (190~ubuntu16.04.1) xenial; urgency=medium - * Add 9.6 to 16.04's supported-versions. + * Backport to xenial: + - Add 10 to 16.04's supported-versions. - -- Colin Watson Fri, 13 Jan 2017 00:33:21 +0000 + -- Colin Watson Thu, 14 Mar 2019 23:34:37 +0000 + +postgresql-common (190) unstable; urgency=medium + + * Move packaging repository to salsa.debian.org + * pg_lsclusters: Add --help. + * pg_virtualenv: Error out if no server packages are installed. + * postgresql-common recommends e2fsprogs, we are using chattr in + pg_createcluster. (Closes: #887251) + * PgCommon.pm: Fix include directives parser, spotted by ironhalik, thanks! + * postgresql@.service: Set Timeoutstart=0, which is the same as infinity, + but works on older systemd versions as well. + * Rewrite architecture.html as README.md. + * t/006_next_free_port.t: Drop -q argument from netcat, nmap-ncat.rpm + doesn't have it. + * t/032_ssl_key_permissions.t: Adjust for 9.4 in oldstable which still has + the old permissions check. + + -- Christoph Berg Thu, 08 Feb 2018 13:26:44 +0100 + +postgresql-common (189) unstable; urgency=medium + + [ Chris Lamb ] + * Update README.Debian for postgresql-10. (Closes: #876438) + + [ Christoph Berg ] + * dh_make_pgxs: Use PostgreSQL license as default, fix extension name. + * Modernize README.Debian's version numbers and SSL instructions. + * postgresql@.service: Ignore startup failure, recovery might take + arbitrarily long to finish. The actual service status still correctly + reflects if the postmaster process is running. + https://www.postgresql.org/message-id/20171111205316.u56lkmkakdmcx6zm%40msg.df7cb.de + * supported-versions: Version 10 on Ubuntu 18.04 (bionic). (Closes: #881501) + * debian/maintscripts-functions: bump update-alternatives priority of + version 1x to 1x0. + * Unsupport 9.2 on apt.postgresql.org. + * t/140_pg_config.t: Also test /usr/bin/pg_config.libpq-dev, and check + MKDIR_P and abs_top_build/srcdir in Makefile.global. + + -- Christoph Berg Thu, 14 Dec 2017 21:13:24 +0100 + +postgresql-common (188) unstable; urgency=medium + + * pg_ctlcluster, pg_createcluster, pg_upgradecluster: Use lchown instead + of chown to mitigate privilege escalation via symlinks. (CVE-2017-8806. + Related to CVE-2017-12172 in PostgreSQL; extends our earlier fix for + CVE-2016-1255.) + * dh_make_pgxs: Add options to set package name and version. + * pg_lsclusters: Raise error when called on a specific cluster that does not + exist. This was the behavior before the "accept dead postgresql.conf + symlinks" change, but not coded explicitly. + + -- Christoph Berg Wed, 08 Nov 2017 16:03:19 +0100 + +postgresql-common (187) unstable; urgency=medium + + * Consistently call psql -X. (Closes: #877920) + * Update pt translation, thanks Ricardo Silva! (Closes: #872430) + * pg_virtualenv: Drop "BUG" message that really just means that + pg_createcluster threw an error. + * pg_createcluster: Drop new cluster if --start was requested and starting + fails. + * pg_createcluster: If not running as postgres or root, don't attempt to + install config and data parent directories with owner postgres. + * pg_lsclusters, postgresql-generator, get_version_clusters, cluster_info, + read_conf_file: Accept dead postgresql.conf symlinks, filesystem might not + be mounted yet. + * pg_virtualenv: Fix version comparison when determining newest PG major. + * pg_updatedicts, postgresql-common.postinst: Create tsearch dictionaries on + first install and set umask for correct permissions. (Closes: #868232) + Thanks to Christian Ehrhardt for the analysis! + * Demote postgresql-common hunspell/myspell triggers to noawait. + + -- Christoph Berg Sun, 22 Oct 2017 20:44:38 +0200 + +postgresql-common (186) unstable; urgency=medium + + * Team upload. + * Bump default apt.postgresql.org version to 10. + * t/020_create_sql_remove.t: Support 8.x xlog filenames. + * Update ca translation, thanks Innocent De Marchi! (Closes: #876472) + * PgCommon.pm: Use BSD ps syntax in check_pidfile_running. + + -- Christoph Berg Thu, 05 Oct 2017 16:04:18 +0200 + +postgresql-common (185) unstable; urgency=medium + + * Team upload. + + [ Christoph Berg ] + * Revert "Error out if a recovery.conf file is found in /etc/postgresql". + It caused too many false positives for setups where a recovery.conf + template is located in the etc directory. (Closes: #868367) + * Bump default PostgreSQL version to 10. + + [ Marco Nenciarini ] + * supported-versions: correctly detect version 10 when using 'installed'. + + -- Christoph Berg Thu, 21 Sep 2017 12:07:30 +0200 + +postgresql-common (184) unstable; urgency=high + + * debian/maintscripts-functions: Use deb-systemd-invoke instead of + invoke-rc.d to stop "postgresql@$ver-*"; jessie's invoke-rc.d does not + support service patterns. + + -- Christoph Berg Tue, 11 Jul 2017 20:19:21 +0200 + +postgresql-common (183) unstable; urgency=medium + + * Team upload. + + [ Nishanth Aravamudan ] + * debian/supported-versions: add Ubuntu 17.10. (Closes: #862420) + + [ Bernd Helmle ] + * postgresql-common.spec: Fix installation path of manpages. + + [ Alex Badics ] + * pg_ctlcluster: Use pg_ctl.conf during stop too. + + [ Christoph Berg ] + * PgCommon.pm: Sort get_versions and get_version_clusters output. + * PgCommon.pm: Revert to old quote_conf_value behavior, the new regexp was + too liberal. The new input behavior is retained, though. + * pg_ctlcluster: Error out if a recovery.conf file is found in + /etc/postgresql to catch a common mistake. (Closes: #853868) + * pg_upgradecluster: Allow configuring the maintenance database. + (Closes: #851874) + * pg_upgradecluster: Pass config directory to pg_upgrade instead of + symlinking the config files. This breaks using "-m upgrade" for upgrades + *to* versions before 9.2; upgrades from older versions are unaffected. + * pg_upgradecluster, pg_renamecluster: Use default pg_ctl timeout when + stopping cluster. + * pg_dropcluster: Remove custom xlog directory. (Closes: #830789) + * pg_createcluster, pg_ctlcluster: cd / to prevent warnings from PostgreSQL + tools. (Closes: #834264) + * pg_wrapper: Don't fail if no local cluster exists on port 5432. + Code cleanup. (Closes: #777623) + * pg_lsclusters: --start-conf shows start.conf information. + * createcluster.conf: Add add_include_dir='conf.d' for drop-in PostgreSQL + config snippets in /etc/postgresql/version/cluster/conf.d/ and + include_dir='/etc/postgresql-common/createcluster.d' for pg_createcluster + config snippets. + * t/051_inconsistent_encoding_upgrade.t: Remove, only relevant for <= 8.2. + * logrotate config: Ship as static conffile again and remove ucf handling. + * pg_conftool: Fix operation when no cluster exists yet. + * pg_conftool: --boolean normalizes boolean variable in output; use this in + debian/maintscripts-functions. + * debian/maintscripts-functions: Unconditionally call invoke-rc.d, and drop + path names from program invocations (Standards-Version 4.0.0). + * debian/maintscripts-functions: Use 'invoke-rc.d "postgresql@$ver-*" stop' + to prevent upgrading/removing server packages from stopping other major + version clusters when running systemd. (Closes: #809811) + * debian/maintscripts-functions: Avoid update-alternatives failing if the + user removed /usr/share/man. (Closes: #866729) + * t/TestLib.pm: Vacuum tests left behind when postmaster and pg_autovacuum + were removed. Update test counts in *.t. + * B-D on debhelper (>= 10.1) | dh-systemd (>= 1.19) to pick up + dh_systemd_start. + + -- Christoph Berg Wed, 05 Jul 2017 16:15:48 +0200 + +postgresql-common (182) experimental; urgency=medium + + * Team upload. + * pg_buildext: Resurrect the previously deprecated "srcdir" mode to allow + building packages from a subdirectory, and make "loop" support it as well. + * t/001_packages.t: PostgreSQL 10 doesn't have a separate contrib package. + * t/020_create_sql_remove.t: Use CREATE EXTENSION, createlang is being + removed. + * t/120_pg_upgradecluster_scripts.t: Don't try to rename + pg_upgradecluster.d, fails on overlayfs. + * pg_lsclusters, t: pg_log directory name changed in 10. + * pg_lsclusters: Allow listing one version or one cluster only. + * pg_lsclusters: Support JSON output, suggest libjson-perl for that. + * pg_createcluster, createcluster.conf: Update for --waldir rename. + * pg_createcluster: Do not suppress initdb output, and use pg_lsclusters to + show created cluster info. + * pg_ctlcluster: Suppress "Redirecting to systemctl message". + * pg_upgradecluster: Deprecate min_parallel_relation_size and + sql_inheritance in 10. + * Symlink /usr/bin/pg_receivewal to pg_wrapper. + * PgCommon.pm: Include postgresql.conf in cluster_info and remove variables + directly copied from config; adjust callers. + * PgCommon.pm: Allow more characters in unquoted config values. + Spotted by Fabien Coelho, merci! + * postgresql-server-dev-all: dh_make_pgxs: Template mechanism for new + Debian packages based on PGXS Makefiles. + + -- Christoph Berg Thu, 11 May 2017 14:01:59 +0200 + +postgresql-common (181) unstable; urgency=medium + + * debian/postgresql-common.config: Fix deprecation warning debconf message + to use a numerical comparison on the version number. + * pg_buildext: Fix to use a numerical comparison on the version number. + * pg_buildext.pod: Drop outdated PG_VIRTUALENV_UNSHARE=-n documentation. + * pgdg/apt.postgresql.org.sh: Add known distributions. + * Updated Danish debconf translation by Joe Dalton, thanks! + (Closes: #856787) + + -- Christoph Berg Sat, 15 Apr 2017 18:56:38 +0200 + +postgresql-common (180) unstable; urgency=medium + + * supported-versions: Retire 9.1 on apt.postgresql.org. + + -- Christoph Berg Thu, 09 Feb 2017 15:30:23 +0100 + +postgresql-common (179) unstable; urgency=medium + + * Catch all pg_ctl output by redirecting it to /var/log/postgresql. + (Closes: #830485) + * Dump locale environment variables if setlocale fails. + (Closes: #848869) + * Set default log_line_prefix to '%m [%p] %q%u@%d ' to match upstream + moving to '%m [%p] ' in PostgreSQL 10. + * Support include_dir in read_conf_file. Patch by Andreas Dewes, thanks! + * Support adding include directives to the new postgresql.conf from + createcluster.conf; harness directives with an "add_" prefix, e.g. + "add_include_dir". + * Import new apt.postgresql.org key. + * Support 9.6 for jessie-backports. + + -- Christoph Berg Tue, 24 Jan 2017 23:03:12 +0100 + +postgresql-common (178) unstable; urgency=medium + + [ Christoph Berg ] + * pg_buildext: Don't ask pg_virtualenv for a new network namespace by + default. + * postgresql-all: New meta package depending on all server packages in all + supported versions. Intended to be used for installing test dependencies. + * pg_upgradecluster: Properly upgrade databases with non-login role owners. + (Closes: #614374, #838812) + * pg_upgradecluster, pg_renamecluster: Update cluster_name. + * Rebuild upgrades libreadline to 7 in unstable. (Closes: #845356) + * Replace most occurrences of "postmaster" by "postgres". Notable leftover + is the postmaster.1.gz leader of the manpages alternatives group. + * pg_ctlcluster, t/020_create_sql_remove.t: Protect against symlink in + /var/log/postgresql/ allowing the creation of arbitrary files elsewhere. + Discovered by Dawid Golunski, thanks! (CVE-2016-1255) + + [ Martin Pitt ] + * debian/supported-versions: Add Ubuntu 17.04, drop EOLed releases. + * t/TestLib.pm, check_clean(): Quiesce stderr of netstat, which shows a "Not + all processes could be identified" warning in unprivileged containers. + + -- Christoph Berg Tue, 20 Dec 2016 17:11:15 +0100 + +postgresql-common (177) unstable; urgency=medium + + [ Martin Pitt ] + * Replace hardcoded Recommends: libreadline6 with a build-time detection of + the current ABI. + + [ Christoph Berg ] + * Team upload. + * Mark 9.6 as stable for apt.postgresql.org. + + -- Christoph Berg Wed, 28 Sep 2016 11:55:12 +0200 + +postgresql-common (176) unstable; urgency=medium + + * Team upload. + * Bump default PostgreSQL server version to 9.6. + * Use C.UTF-8 instead of C when the initial main cluster is created and no + locale is configured explicitly as system default. (Closes: #790507) + * Support "NN" major version numbers, next version will be PostgreSQL 10. + * debian/postgresql-common.templates: Properly mark not-to-be-translated + shell code-only chunk as such using flag:translate. Thanks to Rhonda for + the pointer! (See: #820756, #832282) + * testsuite: Run with umask 077 only by default. + * t/025_logging.t: Fix tests when grep thinks syslog is a binary file. + * t/031_errors_disk_full.t: Raise tmpfs size to account for larger cluster + footprint observed on ppc64el. + * t/032_ssl_key_permissions.t: Skip tests on 9.0 and earlier. + * pg_createcluster, t/025_logging.t: Skip logging_collector for 8.2. + * Ship /etc/postgresql-common/supported_versions even in non-backport + packages. (Closes: #808353) + * pg_createcluster: Error out if provided log file is a directory. + (Closes: #791556) + * pg_upgradecluster: Set dynamic_shared_memory_type from the new + postgresql.conf instead of defaulting to mmap. (Closes: #823209) + * pg_upgradecluster: Use data checksums in the new cluster if the old uses + them. (Closes: #830228) + + -- Christoph Berg Fri, 23 Sep 2016 12:32:16 +0200 + +postgresql-common (175) unstable; urgency=medium + + * pg_createcluster, createcluster.conf: Set cluster_name on 9.5+. + * pg_buildext: Don't set any CFLAGS by default. + * start.conf: Update documentation/comments to recommend running + systemctl daemon-reload. + + -- Christoph Berg Thu, 23 Jun 2016 12:26:27 +0200 + +postgresql-common (174) unstable; urgency=medium + + [ Christoph Berg ] + * postgresql-common: Enforce strict version dependency on + postgresql-client-common to avoid API mismatch bugs in PgCommon.pm. + * maintscripts-functions: Save pg_dump on catversion bumps as well. + * Updated ja translation by Takuma Yamada, thanks! (Closes: #820756) + * Remove not-to-be-translated shell code-only chunk from + debian/po/templates.pot. (debconf-updatepo --skip-pot to the rescue!) + (Closes: #821445) + + [ Martin Pitt ] + * debian/supported-versions: Add Ubuntu 16.10. + + -- Christoph Berg Wed, 11 May 2016 15:04:25 +0200 postgresql-common (173) unstable; urgency=medium diff -Nru postgresql-common-173+ppa1/debian/clean postgresql-common-190~ubuntu16.04.1/debian/clean --- postgresql-common-173+ppa1/debian/clean 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/clean 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1 @@ +tags diff -Nru postgresql-common-173+ppa1/debian/control postgresql-common-190~ubuntu16.04.1/debian/control --- postgresql-common-173+ppa1/debian/control 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/control 2018-01-31 12:17:35.000000000 +0000 @@ -2,28 +2,42 @@ Section: database Priority: optional Maintainer: Debian PostgreSQL Maintainers -Uploaders: Martin Pitt , Christoph Berg , Peter Eisentraut -Standards-Version: 3.9.6 -Vcs-Git: git://anonscm.debian.org/pkg-postgresql/postgresql-common.git -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-postgresql/postgresql-common.git -Build-Depends: debhelper (>= 9), - dh-systemd (>= 1.19) | sysvinit (<< 2.88dsf-42), - lsb-release +Uploaders: + Martin Pitt , + Christoph Berg , + Peter Eisentraut , +Standards-Version: 4.1.2 +Vcs-Git: https://salsa.debian.org/postgresql/postgresql-common.git +Vcs-Browser: https://salsa.debian.org/postgresql/postgresql-common +Build-Depends: + debhelper (>= 9), + debhelper (>= 10.1) | dh-systemd (>= 1.19), + libreadline-dev, + lsb-release, Package: postgresql-common Architecture: all Multi-Arch: foreign -Conflicts: postgresql-7.4, postgresql-8.0 -Depends: postgresql-client-common (>= ${source:Version}), - procps, +Conflicts: + postgresql-7.4, + postgresql-8.0, +Depends: adduser, debconf (>= 0.5.00) | debconf-2.0, lsb-base (>= 3.0-3), + postgresql-client-common (= ${source:Version}), + procps, ssl-cert (>= 1.0.11), ucf, - ${misc:Depends} -Recommends: logrotate -Breaks: postgresql-9.1 (<< 9.1.1-3~), systemd (<< 204) + ${misc:Depends}, +Recommends: + e2fsprogs, + logrotate, +Suggests: + libjson-perl, +Breaks: + postgresql-9.1 (<< 9.1.1-3~), + systemd (<< 204), Description: PostgreSQL database-cluster manager The postgresql-common package provides a structure under which multiple versions of PostgreSQL may be installed and/or multiple @@ -43,9 +57,13 @@ Package: postgresql-client-common Architecture: all Multi-Arch: foreign -Depends: ${misc:Depends}, ${pgdg:Depends}, - netbase -Recommends: lsb-release, libreadline6 +Depends: + netbase, + ${misc:Depends}, + ${pgdg:Depends}, +Recommends: + lsb-release, + ${readline:Recommends}, Description: manager for multiple PostgreSQL client versions The postgresql-client-common package provides a structure under which multiple versions of PostgreSQL client programs may be installed at @@ -63,13 +81,14 @@ Package: postgresql-server-dev-all Architecture: all -Depends: ${misc:Depends}, - postgresql-common (>= 117~), +Depends: + dctrl-tools, iproute2 | net-tools, lsb-release, - dctrl-tools, make, - ${server-dev-all-depends} + postgresql-common (>= 117~), + ${misc:Depends}, + ${server-dev-all-depends}, Description: extension build tool for multiple PostgreSQL versions The postgresql-server-dev-all package provides the pg_buildext script for simplifying packaging of a PostgreSQL extension supporting multiple major @@ -84,8 +103,11 @@ Package: postgresql Architecture: all -Depends: postgresql-${default-version}, ${misc:Depends} -Suggests: postgresql-doc +Depends: + postgresql-${default-version}, + ${misc:Depends}, +Suggests: + postgresql-doc, Description: object-relational SQL database (supported version) This metapackage always depends on the currently supported PostgreSQL database server version. @@ -101,7 +123,9 @@ Package: postgresql-client Architecture: all Multi-Arch: foreign -Depends: postgresql-client-${default-version}, ${misc:Depends} +Depends: + postgresql-client-${default-version}, + ${misc:Depends}, Description: front-end programs for PostgreSQL (supported version) This metapackage always depends on the currently supported database client package for PostgreSQL. @@ -118,7 +142,9 @@ Architecture: all Multi-Arch: foreign Section: doc -Depends: postgresql-doc-${default-version}, ${misc:Depends} +Depends: + postgresql-doc-${default-version}, + ${misc:Depends}, Description: documentation for the PostgreSQL database management system This metapackage always depends on the currently supported PostgreSQL database documentation package. @@ -133,13 +159,37 @@ Package: postgresql-contrib Architecture: all -Depends: postgresql-contrib-${default-version}, ${misc:Depends} +Depends: + postgresql-contrib-${default-version}, + ${misc:Depends}, Description: additional facilities for PostgreSQL (supported version) This metapackage always depends on the currently supported PostgreSQL database contrib package. . PostgreSQL is a fully featured object-relational database management system. It supports a large part of the SQL standard and is designed + to be extensible by users in many aspects. Some of the features are: + ACID transactions, foreign keys, views, sequences, subqueries, + triggers, user-defined types and functions, outer joins, multiversion + concurrency control. Graphical user interfaces and bindings for many + programming languages are available as well. + +Package: postgresql-all +Architecture: all +Depends: + libecpg-dev, + libpq-dev, + postgresql-server-dev-all, + ${postgresql-all-depends}, + ${misc:Depends}, +Description: metapackage depending on all PostgreSQL server packages + This metapackage depends on all PostgreSQL server packages, in all + supported versions (excluding documentation and debug symbols). It + exists to facilitate depending on the server packages in test + environments. + . + PostgreSQL is a fully featured object-relational database management + system. It supports a large part of the SQL standard and is designed to be extensible by users in many aspects. Some of the features are: ACID transactions, foreign keys, views, sequences, subqueries, triggers, user-defined types and functions, outer joins, multiversion diff -Nru postgresql-common-173+ppa1/debian/init.d-functions postgresql-common-190~ubuntu16.04.1/debian/init.d-functions --- postgresql-common-173+ppa1/debian/init.d-functions 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/init.d-functions 2018-01-12 14:08:46.000000000 +0000 @@ -16,7 +16,7 @@ [ "$2" ] || { echo "Error: invalid version '$2'" >&2; exit 1; } [ -d "/etc/postgresql/$2" ] || return 0 [ "$(ls /etc/postgresql/$2)" ] || return 0 - [ -x "$PGBINROOT$2/bin/postmaster" ] || return 0 + [ -x "$PGBINROOT$2/bin/postgres" ] || return 0 status=0 log_daemon_msg "$3" diff -Nru postgresql-common-173+ppa1/debian/logrotate.template postgresql-common-190~ubuntu16.04.1/debian/logrotate.template --- postgresql-common-173+ppa1/debian/logrotate.template 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/logrotate.template 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -/var/log/postgresql/*.log { - weekly - rotate 10 - copytruncate - delaycompress - compress - notifempty - missingok - su root root -} diff -Nru postgresql-common-173+ppa1/debian/maintscripts-functions postgresql-common-190~ubuntu16.04.1/debian/maintscripts-functions --- postgresql-common-173+ppa1/debian/maintscripts-functions 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/maintscripts-functions 2018-01-12 14:08:46.000000000 +0000 @@ -28,14 +28,22 @@ fi fi + # user might have removed the directories, allow u-a to succeed + mkdir -p /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man7 section=$(echo "$2" | sed -e 's/.*\.\(.*\)\..*/man\1/') + case $1 in + [89]*) priority=$(echo "$1" | tr -cd 0-9) ;; + *) priority="${1}0" ;; + esac update-alternatives --install /usr/share/man/$section/$2 \ $2 /usr/share/postgresql/$1/man/$section/$2 \ - $(echo "$1" | tr -cd 0-9) $SLAVES + $priority $SLAVES } # arguments: version master _unlink_manpages() { + # user might have removed the directories, allow u-a to succeed + mkdir -p /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man7 section=$(echo "$2" | sed -e 's/.*\.\(.*\)\..*/man\1/') update-alternatives --remove $2 /usr/share/postgresql/$1/man/$section/$2 } @@ -54,6 +62,7 @@ set_system_locale() { loc_vars="LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL" unset $loc_vars + LANG="C.UTF-8" # fallback locale if nothing is configured explicitly for v in $loc_vars; do unset val val=`pam_getenv -l $v` || true @@ -73,11 +82,11 @@ if [ ! -d "/etc/postgresql/$VERSION" ] || [ -z "$(ls /etc/postgresql/$VERSION)" ] || \ [ -z "$(ls /etc/postgresql/$VERSION/*/postgresql.conf 2>/dev/null)" ]; then # skip creating the main cluster when this is not the first install, or - # when explicitely disabled ($create is 1/0/"") - create=$(perl -I/usr/share/postgresql-common -mPgCommon -e 'print PgCommon::config_bool(PgCommon::get_conf_value 0, 0, "createcluster.conf", "create_main_cluster")') - if [ -z "$2" ] && [ "$create" != "0" ]; then + # when explicitly disabled ($create is on/off/"") + create=$(pg_conftool /etc/postgresql-common/createcluster.conf show -bs create_main_cluster || :) + if [ -z "$2" ] && [ "$create" != "off" ]; then set_system_locale - /usr/bin/pg_createcluster -u postgres $VERSION main || + pg_createcluster -u postgres $VERSION main || echo "Error: could not create default cluster. Please create it manually with pg_createcluster $VERSION main --start @@ -94,27 +103,19 @@ # done with debconf db_stop - if [ -x /etc/init.d/postgresql ] && [ ! -x /etc/init.d/postgresql-$VERSION ]; then - # reload systemd to let the generator pick up the new unit - if [ -d /run/systemd/system ]; then - systemctl daemon-reload - fi - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d postgresql start $VERSION || exit $? - else - /etc/init.d/postgresql start $VERSION || exit $? - fi + # reload systemd to let the generator pick up the new unit + if [ -d /run/systemd/system ]; then + systemctl daemon-reload fi + invoke-rc.d postgresql start $VERSION # systemd: argument ignored, starts all versions } stop_version() { - if [ -x /etc/init.d/postgresql ] && [ ! -x /etc/init.d/postgresql-$1 ]; then - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d postgresql stop $1 || exit $? - else - /etc/init.d/postgresql stop $1 || exit $? - fi - + if [ -d /run/systemd/system ]; then + # cannot use invoke-rc.d here because jessie's version doesn't like patterns + deb-systemd-invoke stop "postgresql@$1-*" + else + invoke-rc.d postgresql stop $1 fi } @@ -190,7 +191,7 @@ ( cd "$VARTMPDIR" mkdir bin lib # lib needs to exists, but we do not copy files there - for f in pg_ctl pg_resetxlog postgres; do + for f in pg_ctl pg_dump pg_resetwal postgres; do cp -a /usr/lib/postgresql/$MAJOR_VER/bin/$f bin done ) @@ -245,7 +246,7 @@ # start debconf if we are in the server's postinst (can't run from a function) if [ "${DPKG_MAINTSCRIPT_NAME:-}" = "postinst" ] && [ "$1" = "configure" ]; then case $DPKG_MAINTSCRIPT_PACKAGE in - postgresql-?.?|postgresql-?.??) + postgresql-[89].?|postgresql-[1-9]?) . /usr/share/debconf/confmodule ;; esac diff -Nru postgresql-common-173+ppa1/debian/po/ca.po postgresql-common-190~ubuntu16.04.1/debian/po/ca.po --- postgresql-common-173+ppa1/debian/po/ca.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/ca.po 2018-01-12 14:08:46.000000000 +0000 @@ -2,22 +2,21 @@ # Copyright (C) 2006 Software in the Public Interest, SPI Inc. # This file is distributed under the same license as the postgresql-common # package. -# Innocent De Marchi , 2011. +# Innocent De Marchi , 2011, 2017. # msgid "" msgstr "" -"Project-Id-Version: postgresql-common 114\n" +"Project-Id-Version: postgresql-common 184\n" "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" "POT-Creation-Date: 2016-03-05 11:47+0100\n" -"PO-Revision-Date: 2011-06-01 18:32+0100\n" +"PO-Revision-Date: 2017-09-07 18:59+0200\n" "Last-Translator: Innocent De Marchi \n" "Language-Team: Catalan \n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Language: Catalan\n" -"X-Poedit-Country: SPAIN\n" +"X-Generator: Poedit 2.0.3\n" #. Type: error #. Description @@ -37,7 +36,7 @@ "La versió de «PostgreSQL» ${old} és obsoleta, però el paquet del client o " "del servidor encara estan instal·lats. Heu d'instal·lar les darreres " "versions dels paquets (postgresql-${latest} i postgresql-client-${latest}) i " -"actualitzar els clusters de la versió ${oldversion} amb l'ordre " +"actualitzar els clústers de la versió ${oldversion} amb l'ordre " "«pg_upgradecluster» (consulteu la pàgina del manual)." #. Type: error @@ -51,9 +50,9 @@ "details)." msgstr "" "Tingueu en present que la instal lació de postgresql-${latest} generarà " -"automàticament un «cluster» pre-determinat ${latest}/main. Heu d'eliminar el " -"«cluster» ${latest} existent («pg_dropcluster --stop ${latest}) si desitjau " -"actualitzar el «cluster» ${old}/main, consulteu la pàgina de manual per " +"automàticament un clúster pre-determinat ${latest}/main. Heu d'eliminar el " +"clúster ${latest} existent («pg_dropcluster --stop ${latest}) si desitjau " +"actualitzar el clúster ${old}/main, consulteu la pàgina de manual per " "conèixer els detalls." #. Type: error @@ -66,7 +65,7 @@ msgstr "" "Ja no se dona suport als paquets antics de client i servidor. Haureu " "d'eliminar els paquets postgresql-${old} i postgresql-client-${old} després " -"d'actualitzar els «clusters» que tingui." +"d'actualitzar els clústers que tingui." #. Type: error #. Description @@ -80,7 +79,7 @@ #. Description #: ../postgresql-common.templates:2001 msgid "Enable SSL by default in new PostgreSQL clusters?" -msgstr "" +msgstr "Permet SSL de forma predeterminada en clústers PostgreSQL nous?" #. Type: boolean #. Description @@ -90,6 +89,9 @@ "However, if the database is solely accessed using TCP connections on " "localhost, SSL can be turned off without introducing security issues." msgstr "" +"PostgreSQL admet connexions SSL encriptades. És una opció adequada. " +"Tanmateix, si l'accés a la base de dades es fa només amb connexions TCP amb " +"el servidor local, desactivar SSL no afecta a la seguretat." #. Type: boolean #. Description @@ -100,18 +102,23 @@ "created during package install, or by using the pg_createcluster command. It " "does not reconfigure existing clusters." msgstr "" +"Les connexions de sòcol de domini UNIX (anomenades «locals» al fitxer " +"«pg_hba.conf») no es veuen afectades per aquesta configuració. Aquesta " +"configuració afecta els clústers PostgreSQL nous generats en al instal·lació " +"del paquet o mitjançant l'ordre «pg_createcluster». No configura els " +"clústers existents." #. Type: boolean #. Description #: ../postgresql-common.templates:2001 msgid "If unsure, enable SSL." -msgstr "" +msgstr "En cas de dubte, activau SSL." #. Type: note #. Description #: ../postgresql-common.templates:3001 msgid "PostgreSQL ${version} catalog version changed" -msgstr "" +msgstr "S'ha canviat la versió del catàleg de PostgreSQL ${version}" #. Type: note #. Description @@ -123,6 +130,11 @@ "not be able to use this cluster until it was upgraded to the new catalog " "version." msgstr "" +"El clúster ${cluster} de PostgreSQL ${version} es va generar amb la versió " +"${db_catversion} dels catàleg, però el paquet postgresql-${version} " +"instal·lat actualment fa servir la versió ${new_catversion} del catàleg. No " +"podreu fer servir aquest clúster fins que no s'hagi actualitzat a la nova " +"versió del catàleg." #. Type: note #. Description @@ -131,14 +143,5 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" +"El subconjunt de binaris necessari de la versió anterior es va desar a " +"${vartmpdir}. Per actualitzar el clúster, executeu aquestes ordres:" diff -Nru postgresql-common-173+ppa1/debian/po/cs.po postgresql-common-190~ubuntu16.04.1/debian/po/cs.po --- postgresql-common-173+ppa1/debian/po/cs.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/cs.po 2018-01-12 14:08:46.000000000 +0000 @@ -126,14 +126,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/da.po postgresql-common-190~ubuntu16.04.1/debian/po/da.po --- postgresql-common-173+ppa1/debian/po/da.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/da.po 2018-01-12 14:08:46.000000000 +0000 @@ -1,14 +1,14 @@ # Danish translation postgresql-common. -# Copyright (C) 2014 THE PACKAGE'S COPYRIGHT HOLDER. +# Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER. # This file is distributed under the same license as the postgresql-common package. -# Joe Hansen (joedalton2@yahoo.dk), 2011, 2014. +# Joe Hansen (joedalton2@yahoo.dk), 2011, 2014, 2017. # msgid "" msgstr "" "Project-Id-Version: postgresql-common\n" "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" "POT-Creation-Date: 2016-03-05 11:47+0100\n" -"PO-Revision-Date: 2014-07-06 19:25+0200\n" +"PO-Revision-Date: 2017-03-04 19:25+0200\n" "Last-Translator: Joe Hansen \n" "Language-Team: Danish \n" "Language: da\n" @@ -114,7 +114,7 @@ #. Description #: ../postgresql-common.templates:3001 msgid "PostgreSQL ${version} catalog version changed" -msgstr "" +msgstr "PostgreSQL ${version}-katalogversion ændrede sig" #. Type: note #. Description @@ -126,6 +126,10 @@ "not be able to use this cluster until it was upgraded to the new catalog " "version." msgstr "" +"PostgreSQL-klyngen ${version} ${cluster} blev oprettet med katalogversion " +"${db_catversion}, men den i øjeblikket installeret pakke postgresql-${version} " +"bruger katalogversion ${new_catversion}. Du vil ikke være i stand til " +"at bruge denne klynge indtil den er opgraderet til den nye katalogversion." #. Type: note #. Description @@ -134,14 +138,6 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" +"Det nødvendige undersæt af binære filer fra den gamle version blev " +"gemt i ${vartmpdir}. For at opgradere klyngen, så kør disse kommandoer:" -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/de.po postgresql-common-190~ubuntu16.04.1/debian/po/de.po --- postgresql-common-173+ppa1/debian/po/de.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/de.po 2018-01-12 14:08:46.000000000 +0000 @@ -144,14 +144,3 @@ msgstr "" "Die notwendigen Programmdateien der alten Version wurden in ${vartmpdir} " "gesichert. Benutzen Sie folgende Kommandos um den Cluster zu aktualisieren:" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/es.po postgresql-common-190~ubuntu16.04.1/debian/po/es.po --- postgresql-common-173+ppa1/debian/po/es.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/es.po 2018-01-12 14:08:46.000000000 +0000 @@ -174,14 +174,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/eu.po postgresql-common-190~ubuntu16.04.1/debian/po/eu.po --- postgresql-common-173+ppa1/debian/po/eu.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/eu.po 2018-01-12 14:08:46.000000000 +0000 @@ -129,14 +129,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/fi.po postgresql-common-190~ubuntu16.04.1/debian/po/fi.po --- postgresql-common-173+ppa1/debian/po/fi.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/fi.po 2018-01-12 14:08:46.000000000 +0000 @@ -124,14 +124,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/fr.po postgresql-common-190~ubuntu16.04.1/debian/po/fr.po --- postgresql-common-173+ppa1/debian/po/fr.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/fr.po 2018-01-12 14:08:46.000000000 +0000 @@ -150,14 +150,3 @@ "L'ensemble des exécutables nécessaires de l'ancienne version ont été " "sauvegardés dans ${vartmpdir}. Pour mettre à jour la grappe, veuillez " "exécuter ces commandes :" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/gl.po postgresql-common-190~ubuntu16.04.1/debian/po/gl.po --- postgresql-common-173+ppa1/debian/po/gl.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/gl.po 2018-01-12 14:08:46.000000000 +0000 @@ -127,14 +127,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/it.po postgresql-common-190~ubuntu16.04.1/debian/po/it.po --- postgresql-common-173+ppa1/debian/po/it.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/it.po 2018-01-12 14:08:46.000000000 +0000 @@ -134,14 +134,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/ja.po postgresql-common-190~ubuntu16.04.1/debian/po/ja.po --- postgresql-common-173+ppa1/debian/po/ja.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/ja.po 2018-01-12 14:08:46.000000000 +0000 @@ -8,7 +8,7 @@ "Project-Id-Version: postgresql-common 155\n" "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" "POT-Creation-Date: 2016-03-05 11:47+0100\n" -"PO-Revision-Date: 2016-02-22 11:32+0900\n" +"PO-Revision-Date: 2016-04-07 11:35+0900\n" "Last-Translator: Takuma Yamada \n" "Language-Team: Japanese \n" "Language: ja\n" @@ -101,10 +101,10 @@ "created during package install, or by using the pg_createcluster command. It " "does not reconfigure existing clusters." msgstr "" -"UNIX ドメインソケット接続 (pg_hba.conf 中で「local」と呼ばれる) は、この設定" -"の影響を受けません。この設定は、パッケージのインストールや pg_createcluster " -"コマンドの使用で作成される新しい PostgreSQL クラスタに関するものです。これ" -"は、既存のクラスタを再設定しません。" +"UNIX ドメインソケット接続 (pg_hba.conf 中で \"local\" と呼ばれる) は、この設" +"定の影響を受けません。この設定は、パッケージのインストールや " +"pg_createcluster コマンドの使用で作成される新しい PostgreSQL クラスタに関する" +"ものです。これは、既存のクラスタを再設定しません。" #. Type: boolean #. Description @@ -143,14 +143,3 @@ msgstr "" "古いバージョンからのバイナリの必要なサブセットは、${vartmpdir} に保存されてい" "ました。クラスタをアップグレードするには、次のコマンドを実行します。" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/nl.po postgresql-common-190~ubuntu16.04.1/debian/po/nl.po --- postgresql-common-173+ppa1/debian/po/nl.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/nl.po 2018-01-12 14:08:46.000000000 +0000 @@ -148,14 +148,3 @@ "Van de oude versie werd een subset binaire bestanden die u daarvoor nog " "nodig heeft, opgeslagen in ${vartmpdir}. Voer de volgende commando's uit om " "de cluster op te waarderen:" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/pt_BR.po postgresql-common-190~ubuntu16.04.1/debian/po/pt_BR.po --- postgresql-common-173+ppa1/debian/po/pt_BR.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/pt_BR.po 2018-01-12 14:08:46.000000000 +0000 @@ -131,14 +131,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/pt.po postgresql-common-190~ubuntu16.04.1/debian/po/pt.po --- postgresql-common-173+ppa1/debian/po/pt.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/pt.po 2018-01-12 14:08:46.000000000 +0000 @@ -1,14 +1,14 @@ # Portuguese translation of postgresql-common debconf messages. # This file is distributed under the same license as the postgresql-common package. -# Ricardo Silva , 2006. +# Ricardo Silva , 2006,2017. # # msgid "" msgstr "" -"Project-Id-Version: postgresql-common 163\n" +"Project-Id-Version: postgresql-common 184\n" "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" "POT-Creation-Date: 2016-03-05 11:47+0100\n" -"PO-Revision-Date: 2014-10-28 10:32-0000\n" +"PO-Revision-Date: 2017-08-17 11:35-0000\n" "Last-Translator: Ricardo Silva \n" "Language-Team: Portuguese \n" "Language: pt\n" @@ -117,7 +117,7 @@ #. Description #: ../postgresql-common.templates:3001 msgid "PostgreSQL ${version} catalog version changed" -msgstr "" +msgstr "A versão do catálogo mudou no PostgreSQL {version}" #. Type: note #. Description @@ -129,6 +129,10 @@ "not be able to use this cluster until it was upgraded to the new catalog " "version." msgstr "" +"O cluster PostgreSQL ${version} ${cluster} foi criado usando o catálogo na " +"versão ${db_catversion}, mas o pacote que está a ser instalado postgresql-${version} " +"usa a versão de catálogo ${new_catversion}. Não será possível usar este " +"cluster até que seja actualizado para a nova versão de catálogo." #. Type: note #. Description @@ -137,14 +141,5 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" +"O subconjunto de binários da versão antiga foi guardado em " +"${vartmpdir}. Para actualizar o cluster, execute os seguintes comandos:" diff -Nru postgresql-common-173+ppa1/debian/po/ro.po postgresql-common-190~ubuntu16.04.1/debian/po/ro.po --- postgresql-common-173+ppa1/debian/po/ro.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/ro.po 2018-01-12 14:08:46.000000000 +0000 @@ -131,14 +131,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/ru.po postgresql-common-190~ubuntu16.04.1/debian/po/ru.po --- postgresql-common-173+ppa1/debian/po/ru.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/ru.po 2018-01-12 14:08:46.000000000 +0000 @@ -146,14 +146,3 @@ msgstr "" "Необходимый набор двоичных файлов из старой версии был сохранён в " "${vartmpdir}. Для обновления кластера выполните следующие команды:" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/sv.po postgresql-common-190~ubuntu16.04.1/debian/po/sv.po --- postgresql-common-173+ppa1/debian/po/sv.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/sv.po 2018-01-12 14:08:46.000000000 +0000 @@ -128,14 +128,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/templates.pot postgresql-common-190~ubuntu16.04.1/debian/po/templates.pot --- postgresql-common-173+ppa1/debian/po/templates.pot 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/templates.pot 2018-01-12 14:08:46.000000000 +0000 @@ -115,14 +115,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/tr.po postgresql-common-190~ubuntu16.04.1/debian/po/tr.po --- postgresql-common-173+ppa1/debian/po/tr.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/tr.po 2018-01-12 14:08:46.000000000 +0000 @@ -140,14 +140,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/po/vi.po postgresql-common-190~ubuntu16.04.1/debian/po/vi.po --- postgresql-common-173+ppa1/debian/po/vi.po 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/po/vi.po 2018-01-12 14:08:46.000000000 +0000 @@ -129,14 +129,3 @@ "The necessary subset of binaries from the old version was saved in " "${vartmpdir}. To upgrade the cluster, execute these commands:" msgstr "" - -#. Type: note -#. Description -#: ../postgresql-common.templates:3001 -msgid "" -" pg_renamecluster ${version} ${cluster} ${cluster}.old\n" -" pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \\\n" -" -m upgrade --old-bindir=${vartmpdir}/bin\n" -" pg_dropcluster ${version} ${cluster}.old\n" -" rm -rf ${vartmpdir}" -msgstr "" diff -Nru postgresql-common-173+ppa1/debian/postgresql-client-common.install postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.install --- postgresql-common-173+ppa1/debian/postgresql-client-common.install 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.install 2018-01-12 14:08:46.000000000 +0000 @@ -1,6 +1,6 @@ -user_clusters etc/postgresql-common -debian/supported-versions usr/share/postgresql-common -debian/maintscripts-functions usr/share/postgresql-common -pgcommon.sh usr/share/postgresql-common PgCommon.pm usr/share/perl5 +debian/maintscripts-functions usr/share/postgresql-common +debian/supported-versions usr/share/postgresql-common pg_wrapper usr/share/postgresql-common +pgcommon.sh usr/share/postgresql-common +user_clusters etc/postgresql-common diff -Nru postgresql-common-173+ppa1/debian/postgresql-client-common.links postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.links --- postgresql-common-173+ppa1/debian/postgresql-client-common.links 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.links 2018-01-12 14:08:46.000000000 +0000 @@ -1,3 +1,4 @@ +usr/share/man/man1/pg_wrapper.1.gz usr/share/man/man7/postgresql-common.7.gz usr/share/postgresql-common/pg_wrapper usr/bin/clusterdb usr/share/postgresql-common/pg_wrapper usr/bin/createdb usr/share/postgresql-common/pg_wrapper usr/bin/createlang @@ -5,16 +6,16 @@ usr/share/postgresql-common/pg_wrapper usr/bin/dropdb usr/share/postgresql-common/pg_wrapper usr/bin/droplang usr/share/postgresql-common/pg_wrapper usr/bin/dropuser +usr/share/postgresql-common/pg_wrapper usr/bin/pg_basebackup usr/share/postgresql-common/pg_wrapper usr/bin/pg_dump usr/share/postgresql-common/pg_wrapper usr/bin/pg_dumpall -usr/share/postgresql-common/pg_wrapper usr/bin/pg_basebackup usr/share/postgresql-common/pg_wrapper usr/bin/pg_isready -usr/share/postgresql-common/pg_wrapper usr/bin/pg_restore +usr/share/postgresql-common/pg_wrapper usr/bin/pg_receivewal usr/share/postgresql-common/pg_wrapper usr/bin/pg_receivexlog usr/share/postgresql-common/pg_wrapper usr/bin/pg_recvlogical +usr/share/postgresql-common/pg_wrapper usr/bin/pg_restore +usr/share/postgresql-common/pg_wrapper usr/bin/pgbench usr/share/postgresql-common/pg_wrapper usr/bin/psql usr/share/postgresql-common/pg_wrapper usr/bin/reindexdb usr/share/postgresql-common/pg_wrapper usr/bin/vacuumdb usr/share/postgresql-common/pg_wrapper usr/bin/vacuumlo -usr/share/postgresql-common/pg_wrapper usr/bin/pgbench -/usr/share/man/man1/pg_wrapper.1.gz /usr/share/man/man7/postgresql-common.7.gz diff -Nru postgresql-common-173+ppa1/debian/postgresql-client-common.lintian-overrides postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.lintian-overrides --- postgresql-common-173+ppa1/debian/postgresql-client-common.lintian-overrides 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.lintian-overrides 2018-01-12 14:08:46.000000000 +0000 @@ -10,6 +10,7 @@ postgresql-client-common: binary-without-manpage usr/bin/pg_dump postgresql-client-common: binary-without-manpage usr/bin/pg_dumpall postgresql-client-common: binary-without-manpage usr/bin/pg_isready +postgresql-client-common: binary-without-manpage usr/bin/pg_receivewal postgresql-client-common: binary-without-manpage usr/bin/pg_receivexlog postgresql-client-common: binary-without-manpage usr/bin/pg_recvlogical postgresql-client-common: binary-without-manpage usr/bin/pg_restore diff -Nru postgresql-common-173+ppa1/debian/postgresql-client-common.manpages postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.manpages --- postgresql-common-173+ppa1/debian/postgresql-client-common.manpages 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-client-common.manpages 2018-01-12 14:08:46.000000000 +0000 @@ -1,2 +1,2 @@ -pg_wrapper.1 *.5 +pg_wrapper.1 diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.config postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.config --- postgresql-common-173+ppa1/debian/postgresql-common.config 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.config 2018-01-12 14:08:46.000000000 +0000 @@ -33,8 +33,8 @@ if [ "$RET" != "true" ]; then for v in $AVAILABLE; do unset sup - for s in $SUPPORTED; do - if [ "$v" = "$s" ] || [[ "$v" > "$LATEST" ]]; then + for s in $SUPPORTED; do + if dpkg --compare-versions "$v" ge "$s"; then sup=1 break fi diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.dirs postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.dirs --- postgresql-common-173+ppa1/debian/postgresql-common.dirs 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.dirs 2018-01-12 14:08:46.000000000 +0000 @@ -1,4 +1,4 @@ /etc/postgresql -/var/log/postgresql -/var/lib/postgresql /etc/postgresql-common/pg_upgradecluster.d +/var/lib/postgresql +/var/log/postgresql diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.docs postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.docs --- postgresql-common-173+ppa1/debian/postgresql-common.docs 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.docs 2018-01-29 14:14:22.000000000 +0000 @@ -1,4 +1,4 @@ -architecture.html +README.md debian/README.Devel doc/dependencies.png systemd/README.systemd diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.install postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.install --- postgresql-common-173+ppa1/debian/postgresql-common.install 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.install 2018-01-12 14:08:46.000000000 +0000 @@ -1,20 +1,19 @@ +createcluster.conf usr/share/postgresql-common debian/01autoremove-postgresql etc/apt/apt.conf.d debian/init.d-functions usr/share/postgresql-common -debian/logrotate.template usr/share/postgresql-common -pg_lsclusters usr/bin +pg_checksystem usr/share/postgresql-common +pg_config usr/bin +pg_conftool usr/bin pg_createcluster usr/bin -pg_dropcluster usr/bin pg_ctlcluster usr/bin +pg_dropcluster usr/bin +pg_lsclusters usr/bin pg_renamecluster usr/bin -pg_upgradecluster usr/bin pg_updatedicts usr/sbin -pg_config usr/bin -pg_conftool usr/bin +pg_upgradecluster usr/bin pg_virtualenv usr/bin -upgrade-scripts/* usr/share/postgresql-common/upgrade-scripts -run-upgrade-scripts usr/share/postgresql-common -pg_checksystem usr/share/postgresql-common pgdg usr/share/postgresql-common -testsuite usr/share/postgresql-common +run-upgrade-scripts usr/share/postgresql-common t/* usr/share/postgresql-common/t -createcluster.conf usr/share/postgresql-common +testsuite usr/share/postgresql-common +upgrade-scripts/* usr/share/postgresql-common/upgrade-scripts diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.logrotate postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.logrotate --- postgresql-common-173+ppa1/debian/postgresql-common.logrotate 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.logrotate 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,10 @@ +/var/log/postgresql/*.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok + su root root +} diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.postinst postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.postinst --- postgresql-common-173+ppa1/debian/postgresql-common.postinst 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.postinst 2018-01-12 14:08:46.000000000 +0000 @@ -26,28 +26,6 @@ rm -f $CCTMP } -setup_logrotate () -{ - [ "$DPKG_MAINTSCRIPT_PACKAGE" ] || return 0 - LRVERSION=$(dpkg-query -f '${Version}' --show logrotate 2> /dev/null) || return - [ "$LRVERSION" ] || return 0 - LRTEMPLATE="/usr/share/postgresql-common/logrotate.template" - LRCONFIG="/etc/logrotate.d/postgresql-common" - if dpkg --compare-versions "$LRVERSION" ge 3.8; then - LRCONFSRC=$LRTEMPLATE - else - LRCONFSRC=`mktemp --tmpdir postgresql-common.XXXXXX` - trap "rm -f $LRCONFSRC" 0 2 3 15 - sed -e '/ su /d' $LRTEMPLATE > $LRCONFSRC - chmod 644 $LRCONFSRC - fi - ucf --debconf-ok $LRCONFSRC $LRCONFIG - ucfr postgresql-common $LRCONFIG - if [ $LRCONFSRC != $LRTEMPLATE ]; then - rm -f $LRCONFSRC - fi -} - if [ "$1" = configure ]; then [ "$DPKG_MAINTSCRIPT_PACKAGE" ] && quiet="--quiet" # RedHat doesn't have this # Make sure the administrative user exists @@ -115,11 +93,6 @@ fi fi - # clean /usr/share/postgresql/*/tsearch_data/system_* stuff - if dpkg --compare-versions "$2" lt-nl 105; then - find /usr/share/postgresql/*/tsearch_data -type l \( -name 'system_*.dict' -o -name 'system_*.affix' \) -exec rm '{}' \; && pg_updatedicts || true - fi - if [ "$2" ]; then /usr/share/postgresql-common/run-upgrade-scripts "$2" || true fi @@ -129,16 +102,20 @@ # Create createcluster.conf from debconf setup_createclusterconf - # Create logrotate config - setup_logrotate + # Forget about ucf logrotate config handling + if dpkg --compare-versions "$2" lt 183~; then + LRCONFIG="/etc/logrotate.d/postgresql-common" + ucf --purge $LRCONFIG + ucfr --purge postgresql-common $LRCONFIG + fi - if dpkg --compare-versions "$2" lt 94; then - pg_updatedicts || true + # Create tsearch dictionaries on first install + if [ -z "$2" ]; then + pg_updatedicts fi fi if [ "$1" = triggered ]; then - setup_logrotate pg_updatedicts || true db_stop exit 0 # skip daemon restart below diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.postrm postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.postrm --- postgresql-common-173+ppa1/debian/postgresql-common.postrm 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.postrm 2018-01-12 14:08:46.000000000 +0000 @@ -18,17 +18,14 @@ rm -rf /var/cache/postgresql # unregister and remove files maintained by ucf - LRCONFIG="/etc/logrotate.d/postgresql-common" CCCONFIG="/etc/postgresql-common/createcluster.conf" if which ucf >/dev/null; then - ucf --purge $LRCONFIG ucf --purge $CCCONFIG fi if which ucfr >/dev/null; then - ucfr --purge postgresql-common $LRCONFIG ucfr --purge postgresql-common $CCCONFIG fi - rm -f $LRCONFIG $LRCONFIG.ucf-* $CCCONFIG $CCCONFIG.ucf-* + rm -f $CCCONFIG $CCCONFIG.ucf-* fi #DEBHELPER# diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.templates postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.templates --- postgresql-common-173+ppa1/debian/postgresql-common.templates 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.templates 2018-01-12 14:08:46.000000000 +0000 @@ -33,8 +33,11 @@ . If unsure, enable SSL. +# The last paragraph of this note does not appear in PO files. +# It contains shell commands and should not be translated. Template: postgresql-common/catversion-bump Type: note +#flag:translate:1,2,3 _Description: PostgreSQL ${version} catalog version changed The PostgreSQL cluster ${version} ${cluster} was created using catalog version ${db_catversion}, but the currently being installed package diff -Nru postgresql-common-173+ppa1/debian/postgresql-common.triggers postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.triggers --- postgresql-common-173+ppa1/debian/postgresql-common.triggers 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-common.triggers 2018-01-12 14:08:46.000000000 +0000 @@ -1,4 +1,5 @@ -interest /usr/share/myspell/dicts -interest /usr/share/hunspell -interest /usr/share/postgresql -interest /usr/sbin/logrotate +# trigger pg_updatedicts on installation of new myspell/hunspell dictionaries +interest-noawait /usr/share/myspell/dicts +interest-noawait /usr/share/hunspell +# also trigger on installation of new server versions so pg_updatedicts can update the symlinks +interest-noawait /usr/share/postgresql diff -Nru postgresql-common-173+ppa1/debian/postgresql-server-dev-all.install postgresql-common-190~ubuntu16.04.1/debian/postgresql-server-dev-all.install --- postgresql-common-173+ppa1/debian/postgresql-server-dev-all.install 2016-01-04 23:11:29.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-server-dev-all.install 2018-01-12 14:08:46.000000000 +0000 @@ -1,2 +1,4 @@ -pgxs_debian_control.mk /usr/share/postgresql-common/ pg_buildext /usr/bin +pgxs_debian_control.mk /usr/share/postgresql-common/ +dh_make_pgxs/dh_make_pgxs /usr/bin +dh_make_pgxs/debian /usr/share/postgresql-common/dh_make_pgxs diff -Nru postgresql-common-173+ppa1/debian/postgresql-server-dev-all.manpages postgresql-common-190~ubuntu16.04.1/debian/postgresql-server-dev-all.manpages --- postgresql-common-173+ppa1/debian/postgresql-server-dev-all.manpages 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/postgresql-server-dev-all.manpages 2018-01-12 14:08:46.000000000 +0000 @@ -1 +1,2 @@ +dh_make_pgxs/dh_make_pgxs.1 pg_buildext.1 diff -Nru postgresql-common-173+ppa1/debian/README.Debian postgresql-common-190~ubuntu16.04.1/debian/README.Debian --- postgresql-common-173+ppa1/debian/README.Debian 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/README.Debian 2018-01-12 14:08:46.000000000 +0000 @@ -1,13 +1,14 @@ PostgreSQL for Debian ===================== -PostgreSQL is the successor to Postgres95, which in turn succeeded POSTGRES. -PostgreSQL is a relational database with object-oriented extensions. It -implements the greater part of SQL-92 and is intended to implement it in full; -in addition it supports its own extended facilities. +PostgreSQL is a fully featured object-relational database management system. It +supports a large part of the SQL standard and is designed to be extensible by +users in many aspects. Its features include ACID transactions, foreign keys, +views, sequences, subqueries, triggers, outer joins, multiversion concurrency +control, and user-defined types and functions. -Since the on-disk data format of all major PostgreSQL versions (like 9.1, -9.4, etc.) is incompatible to each other, Debian's PostgreSQL packaging +Since the on-disk data format of all major PostgreSQL versions (like 9.6, +10, etc.) is incompatible to each other, Debian's PostgreSQL packaging architecture is designed to maintain clusters of different major versions in parallel. @@ -26,7 +27,7 @@ a database user and a database for the Unix user 'joe': 1. Install a database server with the major version of your choice - ('postgresql-X.Y', e. g. 'postgresql-9.1'). Preferably the latest + ('postgresql-XY', e. g. 'postgresql-10'). Preferably the latest version, which you can get by installing the metapackage 'postgresql'. This will automatically create a default cluster 'main' with the database superuser 'postgres'. @@ -44,7 +45,7 @@ Unix login: $ createuser -DRS joe - + For details about the options, see createuser(1). 4. Create a database "joework" which is owned by "joe": @@ -59,7 +60,6 @@ $ psql joework - Cluster management ------------------ For managing clusters, the following commands are provided (each with its own @@ -79,7 +79,7 @@ this case you cannot expect *any* of above pg_* tools to work, since they use different configuration settings (SSL, data directories, etc.) and file locations (e. g. -/etc/postgresql/9.1/main/postgresql.conf). If in doubt, then do *not* +/etc/postgresql/10/main/postgresql.conf). If in doubt, then do *not* use initdb, but only pg_createcluster. Since merely installing postgresql-X.Y will already set up a default cluster which is ready to work, most people do not need to bother about initdb or @@ -92,9 +92,9 @@ created (by any major version) will run on the default port 5432, and each new cluster will use the next higher free one. -E. g. if you first install "postgresql-9.1" on a clean system, the -default 9.1/main cluster will run on port 5432. If you then create -another 9.1 cluster, or install the "postgresql-9.4" package, that new +E. g. if you first install "postgresql-10" on a clean system, the +default 10/main cluster will run on port 5432. If you then create +another 10 cluster, or install the "postgresql-11" package, that new one will run on 5433. Please use "pg_lsclusters" for displaying the cluster <-> port @@ -110,18 +110,18 @@ Due to this default cluster, an immediate attempt to upgrade an earlier 'main' cluster to a new version will fail and you need to remove the newer default cluster first. E. g., if you have -postgresql-9.1 installed and want to upgrade to 9.4, you first install -postgresql-9.4: +postgresql-9.6 installed and want to upgrade to 10, you first install +postgresql-10: - apt-get install postgresql-9.4 + apt-get install postgresql-10 -Then drop the default 9.4 cluster that was just created: +Then drop the default 10 cluster that was just created: - pg_dropcluster 9.4 main --stop + pg_dropcluster 10 main --stop -And then upgrade the 9.1 cluster to the latest installed version (e. g. 9.4): +And then upgrade the 9.6 cluster to the latest installed version (e. g. 10): - pg_upgradecluster 9.1 main + pg_upgradecluster 9.6 main SSL --- @@ -130,17 +130,12 @@ untrusted network between a database server and a client and these exchange security sensitive data like passwords or confidential database contents. -postgresql-common makes use of the 'snakeoil' SSL certificate that is -generated by the ssl-cert package, so that SSL works out of the box. -When a cluster is created with pg_createcluster, SSL support will -automatically be enabled in that cluster, and symlinks "server.key" -and "server.crt" are created in the data directory which point to the -snakeoil certificate in /etc/ssl; therefore all clusters use the same -certificate by default. Of course you can replace these symlinks by -cluster-specific certificates. +When a cluster is created with pg_createcluster, SSL support will automatically +be enabled. postgresql-common makes use of the 'snakeoil' SSL certificate that +is generated by the ssl-cert package, so that SSL works out of the box +(ssl_cert_file, ssl_key_file). In addition, if /etc/postgresql-common/root.crt +exists, it will be used as CA certificate file (ssl_ca_file). -In addition, if /etc/postgresql-common/root.crt exists, a symbolic -link "root.crt" will be created in the data directory. /etc/postgresql-common/root.crt is a dummy file by default, so that client-side authentication is not performed. To enable it, you should add some root certificates to it. A reasonable choice is to just @@ -148,7 +143,7 @@ case, client certificates need to be signed by the snakeoil certificate, which might be desirable in many cases. See - /usr/share/doc/postgresql-doc-9.1/html/ssl-tcp.html + /usr/share/doc/postgresql-doc-10/html/ssl-tcp.html for details (in package postgresql-doc). diff -Nru postgresql-common-173+ppa1/debian/rules postgresql-common-190~ubuntu16.04.1/debian/rules --- postgresql-common-173+ppa1/debian/rules 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/rules 2018-01-29 12:17:05.000000000 +0000 @@ -5,16 +5,16 @@ FLAVOR := debian-backports else ifneq ($(findstring pgdg,$(VERSION)),) FLAVOR := pgdg + # for apt.postgresql.org builds, pull in the repository key package + PGDG_DEPENDS := pgdg-keyring else FLAVOR := default endif SUPPORTED_VERSIONS := $(shell PG_SUPPORTED_VERSIONS="$(FLAVOR)" debian/supported-versions) DEFAULT_VER := $(lastword $(SUPPORTED_VERSIONS)) +LIBREADLINE := $(shell dpkg-query -W --showformat '$${Status} $${Package}\n' 'libreadline[0-9]'| sed -n '/ installed / {s/^.* //; p}'|sort -ru | head -n1) -# use dh_systemd_* only on recent dists that have dh-systemd (>= 1.19) -ifneq ($(wildcard /usr/bin/dh_systemd_start),) WITH_SYSTEMD=--with systemd -endif %: dh $@ $(WITH_SYSTEMD) @@ -27,9 +27,7 @@ dh_install $(MAKE) -C systemd install DESTDIR=$(CURDIR)/debian/postgresql-common install -m 644 -D debian/postgresql-common.sysctl debian/postgresql-common/etc/sysctl.d/30-postgresql-shm.conf -ifneq ($(FLAVOR),default) /bin/echo -e "# See /usr/share/postgresql-common/supported-versions for documentation of this file\n$(FLAVOR)" > debian/postgresql-client-common/etc/postgresql-common/supported_versions -endif override_dh_installinit: dh_installinit --name=postgresql -u'defaults 19 21' -r @@ -39,12 +37,10 @@ # the versionless metapackages need to have version numbers which match # the server version, not the p-common version - dh_gencontrol -ppostgresql -ppostgresql-client -ppostgresql-doc -ppostgresql-contrib -- \ - -Vdefault-version="$(DEFAULT_VER)" -v'$(DEFAULT_VER)+$${source:Version}' + dh_gencontrol -ppostgresql -ppostgresql-client -ppostgresql-doc -ppostgresql-contrib -ppostgresql-all -- \ + -Vdefault-version="$(DEFAULT_VER)" -v'$(DEFAULT_VER)+$${source:Version}' \ + -Vpostgresql-all-depends="$(foreach v,$(SUPPORTED_VERSIONS),postgresql-contrib-$v,postgresql-plperl-$v,postgresql-plpython-$v,postgresql-plpython3-$v,postgresql-pltcl-$v,)" -ifeq ($(FLAVOR),pgdg) - # for apt.postgresql.org builds, pull in the repository key package - dh_gencontrol -ppostgresql-client-common -- -Vpgdg:Depends="pgdg-keyring" -endif + dh_gencontrol -ppostgresql-client-common -- -Vpgdg:Depends="$(PGDG_DEPENDS)" -Vreadline:Recommends=$(LIBREADLINE) dh_gencontrol --remaining-packages diff -Nru postgresql-common-173+ppa1/debian/source/lintian-overrides postgresql-common-190~ubuntu16.04.1/debian/source/lintian-overrides --- postgresql-common-173+ppa1/debian/source/lintian-overrides 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/source/lintian-overrides 2018-02-08 12:26:44.000000000 +0000 @@ -1,3 +1,3 @@ -# don't bother us about NMUs when uploading using the company address: -postgresql-common source: changelog-should-mention-nmu -postgresql-common source: source-nmu-has-incorrect-version-number +# don't bug people uploading from @work +source: changelog-should-mention-nmu +source: source-nmu-has-incorrect-version-number diff -Nru postgresql-common-173+ppa1/debian/supported-versions postgresql-common-190~ubuntu16.04.1/debian/supported-versions --- postgresql-common-173+ppa1/debian/supported-versions 2017-01-13 00:32:56.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/debian/supported-versions 2019-03-14 23:34:25.000000000 +0000 @@ -33,11 +33,11 @@ # ubuntu [release]: use Ubuntu defaults # pgdg [release]: use defaults for apt.postgresql.org # installed: consider all installed versions supported (determined by -# postgresql-server-dev-X.Y packages) -# X.Y: consider this version supported +# postgresql-server-dev-X packages) +# X: consider this version supported # # (C) 2005-2016 Martin Pitt -# (C) 2012-2016 Christoph Berg +# (C) 2012-2017 Christoph Berg set -eu @@ -49,7 +49,7 @@ . /usr/share/postgresql-common/pgcommon.sh fi -DEFAULT="9.5" +DEFAULT="10" # functions @@ -79,87 +79,58 @@ ubuntu() { case "$1" in - 12.04) - /bin/echo -e "9.1" - ;; - 14.04) - /bin/echo -e "9.3" - ;; - 14.10|15.04|15.10) - /bin/echo -e "9.4" - ;; - 16.04) - /bin/echo -e "9.5\n9.6" - ;; + 12.04) /bin/echo -e "9.1" ;; + 14.04) /bin/echo -e "9.3" ;; + 16.04) /bin/echo -e "9.5\n10" ;; + 16.10) /bin/echo -e "9.5" ;; + 17.04|17.10) /bin/echo -e "9.6" ;; + 18.04) /bin/echo -e "10" ;; *) echo "supported-versions: WARNING: Unknown Ubuntu release: $1" >&2 - /bin/echo -e "$DEFAULT" - ;; + /bin/echo -e "$DEFAULT" ;; esac } debian() { case "$1" in - 5.0*) # Lenny - /bin/echo -e "8.3" - ;; - 6.0*) # Squeeze - /bin/echo -e "8.4" - ;; - 7|7.*) # Wheezy - /bin/echo -e "9.1" - ;; - 8|8.*) # Jessie - /bin/echo -e "9.4" - ;; + 5.0*) /bin/echo -e "8.3" ;; # Lenny + 6.0*) /bin/echo -e "8.4" ;; # Squeeze + 7|7.*) /bin/echo -e "9.1" ;; # Wheezy + 8|8.*) /bin/echo -e "9.4" ;; # Jessie + 9|9.*) /bin/echo -e "9.6" ;; # Stretch + 10|10.*) /bin/echo -e "10" ;; # Buster testing | unstable) - /bin/echo -e "$DEFAULT" - ;; + /bin/echo -e "$DEFAULT" ;; *) echo "supported-versions: WARNING: Unknown Debian release: $1" >&2 - /bin/echo -e "$DEFAULT" - ;; + /bin/echo -e "$DEFAULT" ;; esac } debian_backports() { case "$1" in - 5.0*) # Lenny - /bin/echo -e "8.3" - ;; - 6.0*) # Squeeze - /bin/echo -e "8.4\n9.1" - ;; - 7|7.*) # Wheezy - /bin/echo -e "9.1\n9.4" - ;; - 8|8.*) # Jessie - /bin/echo -e "9.4" - ;; + 5.0*) /bin/echo -e "8.3" ;; # Lenny + 6.0*) /bin/echo -e "8.4\n9.1" ;; # Squeeze + 7|7.*) /bin/echo -e "9.1\n9.4" ;; # Wheezy + 8|8.*) /bin/echo -e "9.4\n9.6" ;; # Jessie + 9|9.*) /bin/echo -e "9.6" ;; # Stretch + 10|10.*) /bin/echo -e "10" ;; # Buster testing | unstable) - /bin/echo -e "$DEFAULT" - ;; + /bin/echo -e "$DEFAULT" ;; *) echo "supported-versions: WARNING: Unknown Debian release: $1" >&2 - /bin/echo -e "$DEFAULT" - ;; + /bin/echo -e "$DEFAULT" ;; esac } pgdg() { - case $1 in - testing | unstable) - /bin/echo -e "9.1\n9.2\n9.3\n9.4\n9.5" # 9.5 default - ;; - *) - /bin/echo -e "9.1\n9.2\n9.3\n9.4\n9.5" # 9.5 default - ;; - esac + /bin/echo -e "9.3\n9.4\n9.5\n9.6\n10" } installed() { - dpkg -l 'postgresql-server-dev-[1-9].*' | \ - sed -ne 's/^ii *postgresql-server-dev-\([^ ]*\).*/\1/p' + dpkg -l 'postgresql-server-dev-[1-9]*' | \ + sed -ne 's/^ii *postgresql-server-dev-\([^ ]*\).*/\1/p' | \ + sort -V } # main diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/compat postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/compat --- postgresql-common-173+ppa1/dh_make_pgxs/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/compat 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1 @@ +@COMPAT@ diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/control.in postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/control.in --- postgresql-common-173+ppa1/dh_make_pgxs/debian/control.in 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/control.in 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,15 @@ +Source: @SOURCE@ +Section: database +Priority: optional +Maintainer: Debian PostgreSQL Maintainers +Uploaders: @MAINTAINER_NAME@ <@DEBEMAIL@> +Build-Depends: debhelper (>= @COMPAT@), postgresql-server-dev-all (>= 153~) +Standards-Version: @STANDARDS_VERSION@ +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-postgresql/@SOURCE@.git/ +Vcs-Git: https://anonscm.debian.org/git/pkg-postgresql/@SOURCE@.git + +Package: postgresql-PGVERSION-@EXTNAME@ +Architecture: any +Depends: postgresql-PGVERSION, ${misc:Depends}, ${shlibs:Depends} +Description: FIXME PostgreSQL extension @SOURCE@ + FIXME long description here diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/copyright postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/copyright --- postgresql-common-173+ppa1/dh_make_pgxs/debian/copyright 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/copyright 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,24 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: @NAME@ +#Source: @URL@ + +Files: * +Copyright: Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + Portions Copyright (c) 1994, The Regents of the University of California +License: PostgreSQL + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose, without fee, and without a written agreement + is hereby granted, provided that the above copyright notice and this + paragraph and the following two paragraphs appear in all copies. + . + IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING + LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS + DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + . + THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO + PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/pgversions postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/pgversions --- postgresql-common-173+ppa1/dh_make_pgxs/debian/pgversions 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/pgversions 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1 @@ +all diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/rules postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/rules --- postgresql-common-173+ppa1/dh_make_pgxs/debian/rules 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/rules 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,21 @@ +#!/usr/bin/make -f + +include /usr/share/postgresql-common/pgxs_debian_control.mk + +override_dh_auto_build: + +pg_buildext build build-%v + +override_dh_auto_test: + # nothing to do here, see debian/tests/* instead + +override_dh_auto_install: + +pg_buildext install build-%v postgresql-%v-@EXTNAME@ + +override_dh_installdocs: + dh_installdocs --all README.* + +override_dh_auto_clean: + +pg_buildext clean build-%v + +%: + dh $@ diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/source/format postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/source/format --- postgresql-common-173+ppa1/dh_make_pgxs/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/source/format 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/tests/control postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/tests/control --- postgresql-common-173+ppa1/dh_make_pgxs/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/tests/control 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,3 @@ +Depends: @, postgresql-server-dev-all +Tests: installcheck +Restrictions: allow-stderr diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/debian/tests/installcheck postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/tests/installcheck --- postgresql-common-173+ppa1/dh_make_pgxs/debian/tests/installcheck 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/debian/tests/installcheck 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,2 @@ +#!/bin/sh +pg_buildext installcheck diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/dh_make_pgxs postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/dh_make_pgxs --- postgresql-common-173+ppa1/dh_make_pgxs/dh_make_pgxs 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/dh_make_pgxs 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,112 @@ +#!/bin/bash + +# (C) 2015-2017 Christoph Berg +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +set -eu + +# basic variables + +template_dir="/usr/share/postgresql-common/dh_make_pgxs/debian" +DIRECTORY="$(basename $PWD)" +NAME="${DIRECTORY%-*}" # Upstream name +VERSION="${DIRECTORY##*-}" + +# options + +while getopts "fn:v:" opt ; do + case $opt in + f) FORCE=yes ;; + n) NAME="$OPTARG" ;; + v) VERSION="$OPTARG" ;; + *) exit 5 ;; + esac +done +shift $((OPTIND - 1)) # shift away args + +# more variables + +SOURCE="${NAME//_/-}" # Debian name +EXTNAME="$(echo $SOURCE | sed -e 's/^\(postgresql\|pgsql\|pg\)-//')" # binary package name suffix +COMPAT="$(apt-cache show debhelper | sed -n 's/Version: \([0-9]*\)\..*/\1/p' | head -n1)" +STANDARDS_VERSION="$(apt-cache show debian-policy | sed -n 's/Version: \(.*\)\..*/\1/p' | head -n1)" +USERNAME=${LOGNAME:-${USER:-root}} +MAINTAINER_NAME=$(getent passwd $USERNAME | cut -d : -f 5 | sed -e 's/,.*//') +: ${DEBEMAIL:=$USERNAME@localhost} + +echo "Upstream: $NAME ($VERSION)" +echo "Debian: $SOURCE ($VERSION-1)" +echo "Binaries: postgresql-PGVERSION-$EXTNAME ($VERSION-1)" +echo "Uploader: $MAINTAINER_NAME <$DEBEMAIL>" +echo +if [ -t 0 ]; then + echo -n "Press Enter to continue, ^C to abort " + read +fi + +# install files + +install_dir () +{ + local directory="debian/$1" + #[ -z "$directory" ] && return + [ -d "$directory" ] && return + echo "Creating $directory/" + mkdir "$directory" +} + +install_template () +{ + local template="$1" + + if [ "${FORCE:-}" ] || ! [ -e debian/$template ]; then + echo "Installing debian/$template" + sed -e "s/@COMPAT@/$COMPAT/g" \ + -e "s/@EXTNAME@/$EXTNAME/g" \ + -e "s/@NAME@/$NAME/g" \ + -e "s/@STANDARDS_VERSION@/$STANDARDS_VERSION/g" \ + -e "s/@SOURCE@/$SOURCE/g" \ + -e "s/@MAINTAINER_NAME@/$MAINTAINER_NAME/g" \ + -e "s/@DEBEMAIL@/$DEBEMAIL/g" \ + "$template_dir/$template" > "debian/$template" + if [ -x $template_dir/$template ]; then + chmod +x "debian/$template" + fi + else + echo "Keeping existing debian/$template" + fi +} + +mkdir -p debian + +for template in $(find $template_dir -mindepth 1 | sort); do + case $template in + *.swp|*~) continue ;; # skip vim stuff + esac + basename=${template##$template_dir/} + if [ -d $template ]; then + install_dir "$basename" + else + install_template "$basename" + fi +done + +echo "Updating debian/control from debian/control.in" +pg_buildext updatecontrol + +if [ "${FORCE:-}" ] || ! [ -e debian/changelog ]; then + rm -f debian/changelog + echo "Creating debian/changelog" + dch --create --package "$SOURCE" --newversion "$VERSION-1" +else + echo "Keeping existing debian/changelog" +fi diff -Nru postgresql-common-173+ppa1/dh_make_pgxs/dh_make_pgxs.pod postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/dh_make_pgxs.pod --- postgresql-common-173+ppa1/dh_make_pgxs/dh_make_pgxs.pod 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/dh_make_pgxs/dh_make_pgxs.pod 2018-01-12 14:08:46.000000000 +0000 @@ -0,0 +1,39 @@ +=head1 NAME + +dh_make_pgxs - Create a new Debian source package for a PGXS PostgreSQL extension + +=head1 SYNOPSIS + +B [B<-f>] [B<-n> I] [B<-v> I] + +=head1 DESCRIPTION + +B creates a F directory tree for PostgreSQL extension +packages using the PGXS build system. The B tool is used for the +build process. + +=head1 OPTIONS + +=over 4 + +=item B<-f> + +Overwrite existing files. + +=item B<-n> I + +Package name to use. Default is to extract it from the current directory's name. + +=item B<-v> I + +Package version to use. Default is to extract it from the current directory's name. + +=back + +=head1 SEE ALSO + +dh_make(1), pg_buildext(1). + +=head1 AUTHOR + +Christoph Berg Lmyon@debian.orgE> diff -Nru postgresql-common-173+ppa1/.gitlab-ci.yml postgresql-common-190~ubuntu16.04.1/.gitlab-ci.yml --- postgresql-common-173+ppa1/.gitlab-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/.gitlab-ci.yml 2018-01-31 12:29:59.000000000 +0000 @@ -0,0 +1,39 @@ +unstable: + image: debian:unstable + script: + - apt-get update + - apt-get install -y build-essential fakeroot + - apt-get build-dep -y . + - dpkg-buildpackage -uc -us -rfakeroot + - ( set -x; for deb in ../*.deb; do dpkg-deb --info $deb; dpkg-deb --contents $deb; done ) + - ( set -x; dpkg --force-confmiss --force-confnew -i ../*.deb || { apt-get install -fy; dpkg --force-confmiss --force-confnew -i ../*.deb; } ) + - ./cleanpg + - dpkg -l postgresql\* | cat + - pg_lsclusters + - SKIP_IPV6=1 ./testsuite -v "$(debian/supported-versions)" -i -M + +jessie: + tags: + - jessie + script: + - sudo apt-get update + - sudo apt-get install -y build-essential fakeroot debhelper libreadline-dev lsb-release dh-systemd + - dpkg-buildpackage -uc -us -rfakeroot + - ( set -x; for deb in ../*.deb; do dpkg-deb --info $deb; dpkg-deb --contents $deb; done ) + - ( set -x; sudo dpkg --force-confmiss --force-confnew -i ../*.deb || { sudo apt-get install -fy; sudo dpkg --force-confmiss --force-confnew -i ../*.deb; } ) + - dpkg -l postgresql\* | cat + - pg_lsclusters + - sudo ./testsuite -v "$(debian/supported-versions)" -i + +centos7: + tags: + - centos7 + script: + - sudo yum install -y rpm-build + - rm -rf $HOME/rpmbuild + - make rpmremove + - make rpmbuild + - rpm -ql pgdg-centos10 > /dev/null || sudo yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm + - make rpminstall + - pg_lsclusters + - sudo ./testsuite -v "$(debian/supported-versions)" -i diff -Nru postgresql-common-173+ppa1/Makefile postgresql-common-190~ubuntu16.04.1/Makefile --- postgresql-common-173+ppa1/Makefile 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/Makefile 2018-01-31 12:29:59.000000000 +0000 @@ -8,7 +8,8 @@ pg_upgradecluster.1 \ pg_wrapper.1 POD1PROGS_POD = pg_buildext.1 \ - pg_virtualenv.1 + pg_virtualenv.1 \ + dh_make_pgxs/dh_make_pgxs.1 POD8PROGS = pg_updatedicts.8 all: man @@ -25,4 +26,26 @@ $(POD2MAN) --quotes=none --section 8 $< $@ clean: - rm -f *.1 *.8 + rm -f *.1 *.8 dh_make_pgxs/*.1 + +# rpm + +DPKG_VERSION=$(shell sed -ne '1s/.*(//; 1s/).*//p' debian/changelog) +RPMDIR=$(HOME)/rpmbuild +TARBALL=$(RPMDIR)/SOURCES/postgresql-common_$(DPKG_VERSION).tar.xz + +rpmbuild: $(TARBALL) + rpmbuild --define='version $(DPKG_VERSION)' -ba rpm/postgresql-common.spec + +$(TARBALL): + mkdir -p $(dir $(TARBALL)) + git archive --prefix=postgresql-common-$(DPKG_VERSION)/ HEAD | xz > $(TARBALL) + +rpminstall: + sudo rpm --upgrade --replacefiles --replacepkgs -v $(RPMDIR)/RPMS/noarch/*-$(DPKG_VERSION)-*.rpm + +rpmremove: + -sudo rpm -e postgresql-common postgresql-client-common postgresql-server-dev-all + +rpmclean: + rm -rf $(TARBALL) $(RPMDIR)/BUILD diff -Nru postgresql-common-173+ppa1/pg_buildext postgresql-common-190~ubuntu16.04.1/pg_buildext --- postgresql-common-173+ppa1/pg_buildext 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_buildext 2018-01-12 14:08:46.000000000 +0000 @@ -4,7 +4,7 @@ # versions # # (C) 2010 Dimitri Fontaine -# (C) 2011-2014 Christoph Berg +# (C) 2011-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,12 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -set -e +set -eu + +die() { + echo "$(basename $0): error: $*" >&2 + exit 1 +} VENVARGS="" while getopts "c:i:o:s" opt ; do @@ -29,23 +34,19 @@ # shift away args shift $(($OPTIND - 1)) +[ "${1:-}" ] || die "no action given" action="$1" -if [ -d "$2" ] && [ "$3" ]; then # compat mode: $2 is source directory - srcdir="$2" +if [ -d "${2:-}" ] && [ "${3:-}" ]; then # optional: $2 is source directory + srcdir="${2:-}" shift else srcdir="$PWD" fi -target="$2" -opt="$3" - -die() { - echo "`basename $0`: error: $*" >&2 - exit 1 -} +target="${2:-}" +opt="${3:-}" prepare_env() { - version=$1 + local version=$1 vtarget=`echo $target | sed -e "s:%v:$version:g"` pgc="/usr/lib/postgresql/$version/bin/pg_config" [ -e "$pgc" ] || die "$pgc does not exist" @@ -53,31 +54,33 @@ configure() { prepare_env $1 - confopts=`echo $opt | sed -e "s:%v:$version:g"` + confopts=`echo $opt | sed -e "s:%v:$1:g"` mkdir -p $vtarget ( echo "calling configure in $vtarget" && - cd $vtarget && $srcdir/configure $confopts DESTDIR="$srcdir/debian/$package" PG_CONFIG="$pgc" VPATH="$srcdir" ) + cd $vtarget && $srcdir/configure $confopts PG_CONFIG="$pgc" VPATH="$srcdir" ) } build() { prepare_env $1 - cflags="`$pgc --cflags` `echo $opt | sed -e "s:%v:$version:g"`" + if [ "$opt" ]; then + cflags="$(echo $opt | sed -e "s:%v:$1:g")" + fi mkdir -p $vtarget # if a Makefile was created by configure, use it, else the top level Makefile [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" - make -C $vtarget $makefile CFLAGS="$cflags" DESTDIR="$srcdir/debian/$package" PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1 + make -C $vtarget ${makefile:-} ${cflags:+CFLAGS="$cflags"} PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1 } install() { prepare_env $1 - package=`echo $opt | sed -e "s:%v:$version:g"` + package=`echo $opt | sed -e "s:%v:$1:g"` mkdir -p $vtarget # if a Makefile was created by configure, use it, else the top level Makefile [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" - make -C $vtarget $makefile install DESTDIR="$srcdir/debian/$package" PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1 + make -C $vtarget ${makefile:-} install DESTDIR="$PWD/debian/$package" PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1 } clean() { @@ -85,31 +88,27 @@ # if a Makefile was created by configure, use it, else the top level Makefile [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" - [ -d $vtarget ] && make -C $vtarget clean $makefile DESTDIR="$srcdir/debian/$package" PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1 + [ -d $vtarget ] && make -C $vtarget clean ${makefile:-} PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1 rm -rf $vtarget } loop() { echo "### $1 ###" prepare_env $1 - package=$(echo $target | sed -e "s:%v:$version:g") + package=$(echo $target | sed -e "s:%v:$1:g") echo "# $1: make clean" - make clean DESTDIR="$PWD/debian/$package" PG_CONFIG="$pgc" USE_PGXS=1 + make -C "$srcdir" clean PG_CONFIG="$pgc" USE_PGXS=1 echo "# $1: make" - make CFLAGS="$cflags" DESTDIR="$PWD/debian/$package" PG_CONFIG="$pgc" USE_PGXS=1 + make -C "$srcdir" PG_CONFIG="$pgc" USE_PGXS=1 echo "# $1: make install" - make install DESTDIR="$PWD/debian/$package" PG_CONFIG="$pgc" USE_PGXS=1 + make -C "$srcdir" install DESTDIR="$PWD/debian/$package" PG_CONFIG="$pgc" USE_PGXS=1 echo "### done $1 ###" } installcheck() { prepare_env $1 - if [ "${PG_VIRTUALENV_UNSHARE-unset}" = "unset" ] && [ $(id -u) = 0 ]; then - export PG_VIRTUALENV_UNSHARE="-n" # request new network namespace by default - fi - # ask pg_virtualenv to create a non-system cluster if [ "${NONROOT-unset}" = "unset" ]; then export NONROOT=1 @@ -119,7 +118,7 @@ # if a Makefile was created by configure, use it, else the top level Makefile [ -f $vtarget/Makefile ] || makefile="-f $srcdir/Makefile" if ! pg_virtualenv $VENVARGS -v $1 \ - make -C $vtarget $makefile installcheck \ + make -C $vtarget ${makefile:-} installcheck \ PG_CONFIG="$pgc" VPATH="$srcdir" srcdir="$srcdir" USE_PGXS=1; then if [ -r $vtarget/regression.diffs ]; then echo "**** $vtarget/regression.diffs ****" @@ -144,12 +143,13 @@ die "/usr/share/postgresql-common/supported-versions not found" [ -e debian/pgversions ] || die "debian/pgversions not found" supported_versions=$(/usr/share/postgresql-common/supported-versions) + local version while read version; do case $version in all) echo "$supported_versions" ;; [1-9]*+) for sup_version in $supported_versions; do - if expr $(echo "$version" | tr -d +) '<=' $sup_version > /dev/null; then echo "$sup_version"; fi + if dpkg --compare-versions "${version%+}" le "$sup_version"; then echo "$sup_version"; fi done ;; [1-9]*) for sup_version in $supported_versions; do @@ -213,6 +213,7 @@ checkcontrol) gencontrol + need_update= if ! diff -u debian/control $tmpcontrol; then if [ "${PG_UPDATECONTROL:-no}" != "no" ] || head -1 debian/changelog | egrep -q -- '-backports|-pgdg|-pgapt'; then echo "Notice: Updating debian/control from debian/control.in." @@ -248,7 +249,7 @@ ;; configure|build|install|clean|loop) - [ "$target" ] || die "syntax: pg_buildext $action [...]" + [ "$target" ] || die "syntax: pg_buildext $action [] []" echo "### $action $v ###" $action $v ;; @@ -259,7 +260,7 @@ ;; *) - die "unsupported $action" + die "unsupported action '$action'" ;; esac done diff -Nru postgresql-common-173+ppa1/pg_buildext.pod postgresql-common-190~ubuntu16.04.1/pg_buildext.pod --- postgresql-common-173+ppa1/pg_buildext.pod 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_buildext.pod 2018-01-12 14:08:46.000000000 +0000 @@ -4,7 +4,7 @@ =head1 SYNOPSIS -B [I] I [I] +B [I] I [I] [I] =head1 DESCRIPTION @@ -82,27 +82,27 @@ Update C from C, and C from C if the latter exists. -=item B I [I] +=item B [I] I [I] For every supported version, call B<../configure> from the I directory. (Most PostgreSQL extensions do not have a configure script.) -=item B I [I] +=item B [I] I [I] Build the extension in the I directory. -=item B I I +=item B [I] I I Invoke B from the I directory. The third parameter specifies the package name to use. Most packages use B. Make will be called with DESTDIR="$(CURDIR)/debian/I". -=item B I +=item B [I] I Clean the build directory. -=item B I +=item B [I] I As a variant to calling B and B separately for VPATH builds, loop over the supported PostgreSQL versions in the top source directory. This @@ -110,7 +110,7 @@ B, it should be placed were installation happens in debian/rules, rather than where build would normally be called. -=item B [I] +=item B [I] [I] Use B to run the extension regression tests. This is meant to be run from C using B. If @@ -226,16 +226,15 @@ =back -=head1 ENVIRONMENT +=head1 SOURCE DIRECTORY -B sets B for the installcheck actions by -default to request a new network namespace, enabling several instances running -in parallel to share port 5432. Override by setting to a different value. +If the package source code is not in the top level directory (i.e. the directory +which has C as subdirectory), use the I argument. Example: -=head1 COMPATIBILITY + override_dh_auto_build: + +pg_buildext build $(CURDIR)/postgresql-module build-%v -Earlier B versions required a "source dir" argument after the -action. This is now deprecated, but still accepted (and ignored). +=head1 COMPATIBILITY B was introduced in postgresql-server-dev-all (>= 141~). diff -Nru postgresql-common-173+ppa1/PgCommon.pm postgresql-common-190~ubuntu16.04.1/PgCommon.pm --- postgresql-common-173+ppa1/PgCommon.pm 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/PgCommon.pm 2018-02-02 08:51:46.000000000 +0000 @@ -1,7 +1,7 @@ # Common functions for the postgresql-common framework # # (C) 2008-2009 Martin Pitt -# (C) 2012-2014 Christoph Berg +# (C) 2012-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ get_cluster_start_conf set_cluster_start_conf set_cluster_pg_ctl_conf get_program_path cluster_info get_versions get_newest_version version_exists get_version_clusters next_free_port cluster_exists install_file - change_ugid config_bool get_db_encoding get_db_locales get_cluster_locales - get_cluster_databases read_cluster_conf_file read_pg_hba read_pidfile/; + change_ugid config_bool get_db_encoding get_db_locales get_cluster_locales get_cluster_controldata + get_cluster_databases read_cluster_conf_file read_pg_hba read_pidfile valid_hba_method/; our @EXPORT_OK = qw/$confroot $binroot $rpm quote_conf_value read_conf_file get_conf_value set_conf_value set_conffile_value disable_conffile_value disable_conf_value replace_conf_value cluster_data_directory get_file_device @@ -101,8 +101,9 @@ # Returns: quoted string sub quote_conf_value ($) { my $value = shift; - return $value if ($value =~ /^-?[\w.]+$/); - $value =~ s/'/''/g; + return $value if ($value =~ /^-?[\d.]+$/); # integer or float + return $value if ($value =~ /^\w+$/); # plain word + $value =~ s/'/''/g; # else quote it return "'$value'"; } @@ -114,52 +115,66 @@ # Arguments: # Returns: hash (empty if file does not exist) sub read_conf_file { + my ($config_path) = @_; my %conf; local (*F); - return %conf unless -e $_[0]; + sub get_absolute_path { + my ($path, $parent_path) = @_; + return $path if ($path =~ m!^/!); # path is absolute + # else strip filename component from parent path + $parent_path =~ s!/[^/]*$!!; + return "$parent_path/$path"; + } - if (open F, $_[0]) { + if (open F, $config_path) { while () { if (/^\s*(?:#.*)?$/) { next; - } elsif (/^\s*include(?:_if_exists)?\s+'([^']+)'\s*$/i) { - my ($k, $v, $path, %include_conf); - $path = $1; - unless (substr($path, 0, 1) eq '/') { - my @p = split '/', $_[0]; - my $dirname = join '/', @p[0..($#p-1)]; - $path = "$dirname/$path"; - } - - # read included file and merge into %conf - %include_conf = read_conf_file($path); - while ( ($k, $v) = each(%include_conf) ) { - $conf{$k} = $v; - } - + } elsif(/^\s*include_dir\s*=?\s*'([^']+)'\s*(?:#.*)?$/i) { + # read included configuration directory and merge into %conf + # files in the directory will be read in ascending order + my $path = $1; + my $absolute_path = get_absolute_path($path, $config_path); + next unless -e $absolute_path && -d $absolute_path; + my $dir; + opendir($dir, $absolute_path) or next; + foreach my $filename (sort readdir($dir) ) { + next if ($filename =~ m/^\./ or not $filename =~/\.conf$/ ); + my %include_conf = read_conf_file("$absolute_path/$filename"); + while ( my ($k, $v) = each(%include_conf) ) { + $conf{$k} = $v; + } + } + closedir($dir); + } elsif (/^\s*include(?:_if_exists)?\s*=?\s*'([^']+)'\s*(?:#.*)?$/i) { + # read included file and merge into %conf + my $path = $1; + my $absolute_path = get_absolute_path($path, $config_path); + my %include_conf = read_conf_file($absolute_path); + while ( my ($k, $v) = each(%include_conf) ) { + $conf{$k} = $v; + } } elsif (/^\s*([a-zA-Z0-9_.-]+)\s*(?:=|\s)\s*'((?:[^']|''|(?:(?<=\\)'))*)'\s*(?:#.*)?$/i) { # string value my $v = $2; my $k = $1; - $k = lc $k if $_[0] =~ /\.conf$/; + $k = lc $k if $config_path =~ /\.conf$/; $v =~ s/\\(.)/$1/g; $v =~ s/''/'/g; $conf{$k} = $v; - } elsif (/^\s*([a-zA-Z0-9_.-]+)\s*(?:=|\s)\s*(-?[\w.]+)\s*(?:#.*)?$/i) { + } elsif (m{^\s*([a-zA-Z0-9_.-]+)\s*(?:=|\s)\s*(-?[[:alnum:]][[:alnum:]._:/-]*)\s*(?:\#.*)?$}i) { # simple value my $v = $2; - my $k = $1; - $k = lc $k if $_[0] =~ /\.conf$/; + my $k = $1; + $k = lc $k if $config_path =~ /\.conf$/; $conf{$k} = $v; } else { chomp; - error "Invalid line $. in $_[0]: »$_«"; + error "invalid line $. in $config_path: $_"; } } close F; - } else { - error "could not read $_[0]: $!"; } return %conf; @@ -360,7 +375,7 @@ return get_conf_value($_[0], $_[1], 'postgresql.conf', 'port'); } -# Set the port of a particular cluster. +# Set the port of a particular cluster. # Arguments: sub set_cluster_port { set_conf_value $_[0], $_[1], 'postgresql.conf', 'port', $_[2]; @@ -417,7 +432,7 @@ return $socketdir; } -# Set the socket directory of a particular cluster. +# Set the socket directory of a particular cluster. # Arguments: sub set_cluster_socketdir { set_conf_value $_[0], $_[1], 'postgresql.conf', @@ -435,7 +450,7 @@ return ''; } -# Check whether a postmaster server is running at the specified port. +# Check whether a postgres server is running at the specified port. # Arguments: sub cluster_port_running { die "port_running: invalid port $_[2]" if $_[2] !~ /\d+/; @@ -453,8 +468,6 @@ # Arguments: # Returns: auto | manual | disabled sub get_cluster_start_conf { - # start.conf setting - my $start = 'auto'; my $start_conf = "$confroot/$_[0]/$_[1]/start.conf"; if (-e $start_conf) { open F, $start_conf or error "Could not open $start_conf: $!"; @@ -463,16 +476,13 @@ s/^\s*//; s/\s*$//; next unless $_; - $start = $_; - last; + close F; + return $1 if (/^(auto|manual|disabled)/); + error "Invalid mode in $start_conf, must be one of auto, manual, disabled"; } close F; - - error 'Invalid mode in start.conf' unless $start eq 'auto' || - $start eq 'manual' || $start eq 'disabled'; } - - return $start; + return 'auto'; # default } # Change start.conf setting. @@ -481,7 +491,7 @@ sub set_cluster_start_conf { my ($v, $c, $val) = @_; - error "Invalid mode: '$val'" unless $val eq 'auto' || + error "Invalid mode: '$val'" unless $val eq 'auto' || $val eq 'manual' || $val eq 'disabled'; my $perms = 0644; @@ -505,12 +515,11 @@ close F; } else { $text = "# Automatic startup configuration -# auto: automatically start/stop the cluster in the init script -# manual: do not start/stop in init scripts, but allow manual startup with -# pg_ctlcluster -# disabled: do not allow manual startup with pg_ctlcluster (this can be easily -# circumvented and is only meant to be a small protection for -# accidents). +# auto: automatically start the cluster +# manual: manual startup with pg_ctlcluster/postgresql@.service only +# disabled: refuse to start cluster +# See pg_createcluster(1) for details. When running from systemd, +# invoke 'systemctl daemon-reload' after editing this file. $val "; @@ -561,11 +570,11 @@ } } -# Check whether a pid file is present and belongs to a running postmaster. +# Check whether a pid file is present and belongs to a running postgres. # Returns undef if it cannot be determined # Arguments: sub check_pidfile_running { - # postmaster does not clean up the PID file when it stops, and it is + # postgres does not clean up the PID file when it stops, and it is # not world readable, so only its absence is a definitive result; if it # is present, we need to read it and check the PID, which will only # work as root @@ -574,13 +583,13 @@ my $pid = read_pidfile $_[0]; if (defined $pid) { prepare_exec; - my $res = open PS, '-|', '/bin/ps', '-o', 'comm', 'h', 'p', $pid; + my $res = open PS, '-|', '/bin/ps', '-o', 'comm=', '-p', $pid; restore_exec; if ($res) { my $process = ; chomp $process if defined $process; close PS; - if (defined $process and ($process eq 'postmaster' or $process eq 'postgres')) { + if (defined $process and ($process eq 'postgres')) { return 1; } else { return 0; @@ -595,22 +604,22 @@ # Return a hash with information about a specific cluster (which needs to exist). # Arguments: # Returns: information hash (keys: pgdata, port, running, logfile [unless it -# has a custom one], configdir, owneruid, ownergid, socketdir, -# statstempdir) +# has a custom one], configdir, owneruid, ownergid, waldir, socketdir, +# config->postgresql.conf) sub cluster_info { my ($v, $c) = @_; error 'cluster_info must be called with arguments' unless ($v and $c); my %result; $result{'configdir'} = "$confroot/$v/$c"; - error 'cluster_info called on non-existing cluster $v $c' unless (-e "$result{configdir}/postgresql.conf"); $result{'configuid'} = (stat "$result{configdir}/postgresql.conf")[4]; my %postgresql_conf = read_cluster_conf_file $v, $c, 'postgresql.conf'; + $result{'config'} = \%postgresql_conf; $result{'pgdata'} = cluster_data_directory $v, $c, \%postgresql_conf; + return %result unless (keys %postgresql_conf); $result{'port'} = $postgresql_conf{'port'} || $defaultport; $result{'socketdir'} = get_cluster_socketdir $v, $c; - $result{'statstempdir'} = $postgresql_conf{'stats_temp_directory'}; # if we can determine the running status with the pid file, prefer that if ($postgresql_conf{'external_pid_file'} && @@ -625,9 +634,13 @@ } if ($result{'pgdata'}) { - ($result{'owneruid'}, $result{'ownergid'}) = + ($result{'owneruid'}, $result{'ownergid'}) = (stat $result{'pgdata'})[4,5]; - $result{'recovery'} = -e "$result{'pgdata'}/recovery.conf"; + $result{'recovery'} = 1 if (-e "$result{'pgdata'}/recovery.conf"); + my $waldirname = $v >= 10 ? 'pg_wal' : 'pg_xlog'; + if (-l "$result{pgdata}/$waldirname") { # custom wal directory + ($result{waldir}) = readlink("$result{pgdata}/$waldirname") =~ /(.*)/; # untaint + } } $result{'start'} = get_cluster_start_conf $v, $c; @@ -638,18 +651,11 @@ } else { $result{'logfile'} = "/var/log/postgresql/postgresql-$v-$c.log"; } - $result{logging_collector} = $postgresql_conf{logging_collector}; - $result{log_destination} = $postgresql_conf{log_destination}; - $result{log_directory} = $postgresql_conf{log_directory}; - $result{log_filename} = $postgresql_conf{log_filename}; - - # autovacuum defaults to on since 8.3 - $result{'avac_enable'} = config_bool $postgresql_conf{'autovacuum'} || ($v >= '8.3'); return %result; } -# Return an array of all available PostgreSQL versions +# Return an array of all available psql versions sub get_versions { my @versions = (); my $dir = $binroot; @@ -660,19 +666,19 @@ next if $entry eq '.' || $entry eq '..'; my $pfx = ''; #redhat# $pfx = "pgsql-"; - ($entry) = $entry =~ /^$pfx(\d+\.\d+)$/; # untaint + ($entry) = $entry =~ /^$pfx(\d+\.?\d+)$/; # untaint push @versions, $entry if get_program_path ('psql', $entry); } closedir D; } - return @versions; + return sort { $a <=> $b } @versions; } # Return the newest available version sub get_newest_version { - my $newest = 0; - map { $newest = $_ if $newest < $_ } get_versions; - return $newest; + my @versions = get_versions; + return undef unless (@versions); + return $versions[-1]; } # Check whether a version exists @@ -690,13 +696,14 @@ while (defined ($entry = readdir D)) { next if $entry eq '.' || $entry eq '..'; ($entry) = $entry =~ /^(.*)$/; # untaint - if (-r $vdir.$entry.'/postgresql.conf') { + my $conf = "$vdir$entry/postgresql.conf"; + if (-e $conf or -l $conf) { # existing file, or dead symlink push @clusters, $entry; } } closedir D; } - return @clusters; + return sort @clusters; } # Check if a cluster exists. @@ -766,14 +773,16 @@ my $homemapfile = $home . '/.postgresqlrc'; if (open MAP, $homemapfile) { while () { - s/(.*?)#.*/$1/; + s/#.*//; next if /^\s*$/; my ($v,$c,$db) = split; if (!version_exists $v) { - error "$homemapfile line $.: version $v does not exist"; + print "Warning: $homemapfile line $.: version $v does not exist\n"; + next; } if (!cluster_exists $v, $c and $c !~ /^(\S+):(\d*)$/) { - error "$homemapfile line $.: cluster $v/$c does not exist"; + print "Warning: $homemapfile line $.: cluster $v/$c does not exist\n"; + next; } if ($db) { close MAP; @@ -789,7 +798,7 @@ # check global map file if (open MAP, $mapfile) { while () { - s/(.*?)#.*/$1/; + s/#.*//; next if /^\s*$/; my ($u,$g,$v,$c,$db) = split; if (!$db) { @@ -797,10 +806,12 @@ next; } if (!version_exists $v) { - error "$mapfile line $.: version $v does not exist"; + print "Warning: $mapfile line $.: version $v does not exist\n"; + next; } if (!cluster_exists $v, $c and $c !~ /^(\S+):(\d*)$/) { - error "$mapfile line $.: cluster $v/$c does not exist"; + print "Warning: $mapfile line $.: cluster $v/$c does not exist\n"; + next; } if (($u eq "*" || $u eq $user) && ($g eq "*" || $g eq $group)) { close MAP; @@ -841,7 +852,7 @@ # Arguments: sub install_file { my ($source, $dest, $uid, $gid, $perm) = @_; - + if (system 'install', '-o', $uid, '-g', $gid, '-m', $perm, $source, $dest) { error "install_file: could not install $source to $dest"; } @@ -884,8 +895,8 @@ $ENV{'LC_ALL'} = 'C'; my $orig_euid = $>; $> = (stat (cluster_data_directory $version, $cluster))[4]; - open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atc', - 'select getdatabaseencoding()', $db or + open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc', + 'select getdatabaseencoding()', $db or die "Internal error: could not call $psql to determine db encoding: $!"; my $out = ; close PSQL; @@ -910,21 +921,21 @@ return undef unless ($port && $socketdir && $psql); my ($ctype, $collate); - # try to swich to cluster owner + # try to switch to cluster owner prepare_exec 'LC_ALL'; $ENV{'LC_ALL'} = 'C'; my $orig_euid = $>; $> = (stat (cluster_data_directory $version, $cluster))[4]; - open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atc', - 'SHOW lc_ctype', $db or + open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc', + 'SHOW lc_ctype', $db or die "Internal error: could not call $psql to determine db lc_ctype: $!"; - my $out = ; + my $out = // error 'could not determine db lc_ctype'; close PSQL; ($ctype) = $out =~ /^([\w.\@-]+)$/; # untaint - open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atc', - 'SHOW lc_collate', $db or + open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc', + 'SHOW lc_collate', $db or die "Internal error: could not call $psql to determine db lc_collate: $!"; - $out = ; + $out = // error 'could not determine db lc_collate'; close PSQL; ($collate) = $out =~ /^([\w.\@-]+)$/; # untaint $> = $orig_euid; @@ -938,7 +949,7 @@ # Return the CTYPE and COLLATE locales of a cluster. This needs to be called # as root or as the cluster owner. (For versions <= 8.3; for >= 8.4, use # get_db_locales()). -# Arguments: +# Arguments: # Returns: (LC_CTYPE, LC_COLLATE) or (undef,undef) if it cannot be determined. sub get_cluster_locales { my ($version, $cluster) = @_; @@ -970,10 +981,38 @@ return ($lc_ctype, $lc_collate); } +# Return the pg_control data for a cluster +# Arguments: +# Returns: hashref +sub get_cluster_controldata { + my ($version, $cluster) = @_; + + my $pg_controldata = get_program_path 'pg_controldata', $version; + if (! -e $pg_controldata) { + print STDERR "Error: pg_controldata not found, please install postgresql-$version\n"; + exit 1; + } + prepare_exec ('LC_ALL', 'LANG', 'LANGUAGE'); + $ENV{'LC_ALL'} = 'C'; + my $result = open (CTRL, '-|', $pg_controldata, (cluster_data_directory $version, $cluster)); + restore_exec; + return undef unless defined $result; + my $data = {}; + while () { + if (/^(.+?):\s*(.*)/) { + $data->{$1} = $2; + } else { + error "Invalid pg_controldata output: $_"; + } + } + close CTRL; + return $data; +} + # Return an array with all databases of a cluster. This requires connection # privileges to template1, so this function should be called as the # cluster owner. -# Arguments: +# Arguments: # Returns: array of database names or undef on error. sub get_cluster_databases { my ($version, $cluster) = @_; @@ -990,7 +1029,7 @@ my @dbs; my @fields; - if (open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atl') { + if (open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtl') { while () { chomp; @fields = split '\|'; @@ -1037,7 +1076,6 @@ # method -> trust, reject, md5, crypt, password, krb5, ident, pam # ip -> ip address # mask -> network mask (either a single number as number of bits, or bit mask) -my %valid_methods = qw/trust 1 reject 1 md5 1 crypt 1 password 1 krb5 1 ident 1 pam 1/; sub parse_hba_line { my $l = $_[0]; chomp $l; @@ -1056,10 +1094,10 @@ # local connection? if ($$res{'type'} eq 'local') { goto error if $#tok > 1; - goto error unless $valid_methods{$tok[0]}; + goto error unless valid_hba_method($tok[0]); $$res{'method'} = join (' ', @tok); return $res; - } + } # host connection? if ($$res{'type'} =~ /^host((no)?ssl)?$/) { @@ -1076,7 +1114,7 @@ } goto error if $#tok > 1; - goto error unless $valid_methods{$tok[0]}; + goto error unless valid_hba_method($tok[0]); $$res{'method'} = join (' ', @tok); return $res; } @@ -1100,4 +1138,15 @@ return @hba; } +# Check if hba method is known +# Argument: hba method +# Returns: True if method is valid +sub valid_hba_method { + my $method = $_[0]; + + my %valid_methods = qw/trust 1 reject 1 md5 1 crypt 1 password 1 krb5 1 ident 1 pam 1/; + + return exists($valid_methods{$method}); +} + 1; diff -Nru postgresql-common-173+ppa1/pgcommon.sh postgresql-common-190~ubuntu16.04.1/pgcommon.sh --- postgresql-common-173+ppa1/pgcommon.sh 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pgcommon.sh 2018-01-12 14:08:46.000000000 +0000 @@ -54,6 +54,9 @@ ;; esac ;; + redhat|centos) + return 0 # not yet implemented + ;; esac case $METHOD in diff -Nru postgresql-common-173+ppa1/pg_config postgresql-common-190~ubuntu16.04.1/pg_config --- postgresql-common-173+ppa1/pg_config 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_config 2018-01-12 14:08:46.000000000 +0000 @@ -4,6 +4,7 @@ # available one. Otherwise fall back to libpq-dev's version. # # (C) 2011 Martin Pitt +# (C) 2014-2016 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,7 +19,7 @@ set -e PGBINROOT="/usr/lib/postgresql/" #redhat# PGBINROOT="/usr/pgsql-" -LATEST_SERVER_DEV=`ls $PGBINROOT*/bin/pg_config 2>/dev/null|tail -n1` +LATEST_SERVER_DEV=`ls -v $PGBINROOT*/bin/pg_config 2>/dev/null|tail -n1` if [ -n "$LATEST_SERVER_DEV" ]; then exec "$LATEST_SERVER_DEV" "$@" diff -Nru postgresql-common-173+ppa1/pg_conftool postgresql-common-190~ubuntu16.04.1/pg_conftool --- postgresql-common-173+ppa1/pg_conftool 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_conftool 2018-01-12 14:08:46.000000000 +0000 @@ -2,7 +2,7 @@ # Read and edit PostgreSQL config files # vim:sw=4:et: # -# (C) 2014-2016 Christoph Berg +# (C) 2014-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ use Getopt::Long; use PgCommon qw(quote_conf_value user_cluster_map read_cluster_conf_file read_conf_file set_conffile_value set_conf_value disable_conffile_value - disable_conf_value cluster_exists error); + disable_conf_value cluster_exists error config_bool); ## option parsing @@ -31,6 +31,7 @@ $0 [options] [ ] [] Options: + -b --boolean Format output as boolean -s --short Print only value -v --verbose Verbose output --help This help @@ -39,15 +40,19 @@ show |all set remove + edit "; exit $exit; } +my $boolean = 0; my $short = 0; my $verbose = 0; +Getopt::Long::Configure ("bundling"); help(1) unless GetOptions ( 'help' => sub { help(0); }, + 'b|boolean' => \$boolean, 's|short' => \$short, 'v|verbose' => \$verbose, ); @@ -63,22 +68,28 @@ help(1, 'No command given') unless (defined $cmdidx); my ($version, $cluster, $conffile); -if ($cmdidx == 0) { +if ($cmdidx == 0) { # operate on postgresql.conf in default cluster ($version, $cluster) = user_cluster_map(); + error "No default cluster found" unless ($cluster); $conffile = 'postgresql.conf'; -} elsif ($cmdidx == 1) { - ($version, $cluster) = user_cluster_map(); +} elsif ($cmdidx == 1) { # operate on given file; default cluster must exist if file is relative $conffile = $ARGV[0]; -} elsif ($cmdidx == 2) { + unless ($conffile =~ m!^/!) { + ($version, $cluster) = user_cluster_map(); + error "No default cluster found" unless ($cluster); + } +} elsif ($cmdidx == 2) { # version cluster, postgresql.conf ($version, $cluster, $conffile) = ($ARGV[0], $ARGV[1], 'postgresql.conf'); -} elsif ($cmdidx == 3) { +} elsif ($cmdidx == 3) { # version cluster conffile ($version, $cluster, $conffile) = ($ARGV[0], $ARGV[1], $ARGV[2]); } else { help(1, 'Too many arguments before command'); } -error "Cluster $version $cluster does not exist" - unless (cluster_exists $version, $cluster); +if ($cluster) { # the cluster needs to exist unless an absolute conffile was given + error "Cluster $version $cluster does not exist" + unless (cluster_exists $version, $cluster); +} splice @ARGV, 0, $cmdidx; # remove everything before the command $ARGV[0] = 'show' if ($ARGV[0] eq 'get'); # accept alternative variants of some commands @@ -101,7 +112,7 @@ if ($cmd eq 'show') { my %conf; - if ($conffile =~ m!/!) { + if ($conffile =~ m!^/!) { %conf = read_conf_file ($conffile); } else { %conf = read_cluster_conf_file ($version, $cluster, $conffile); @@ -112,6 +123,7 @@ printf "%s = %s\n", $k, quote_conf_value($conf{$k}); } } elsif (exists $conf{$key}) { + $conf{$key} = config_bool($conf{$key}) ? 'on' : 'off' if ($boolean); # normalize boolean output on request if ($short) { printf "%s\n", $conf{$key}; } else { @@ -123,14 +135,14 @@ } } elsif ($cmd eq 'set') { - if ($conffile =~ m!/!) { + if ($conffile =~ m!^/!) { set_conffile_value ($conffile, $key, $value); } else { set_conf_value ($version, $cluster, $conffile, $key, $value); } } elsif ($cmd eq 'remove') { - if ($conffile =~ m!/!) { + if ($conffile =~ m!^/!) { disable_conffile_value ($conffile, $key); } else { disable_conf_value ($version, $cluster, $conffile, $key); @@ -141,7 +153,7 @@ if ($ENV{EDITOR}) { ($editor) = $ENV{EDITOR} =~ /(.*)/; # untaint } - if ($conffile =~ m!/!) { + if ($conffile =~ m!^/!) { system $editor, $conffile; } else { system $editor, "$PgCommon::confroot/$version/$cluster/$conffile"; @@ -172,6 +184,10 @@ =over 4 +=item B<-b>, B<--boolean> + +Format boolean value as B or B (not for "show all"). + =item B<-s>, B<--short> Show only the value (instead of key = value pair). diff -Nru postgresql-common-173+ppa1/pg_createcluster postgresql-common-190~ubuntu16.04.1/pg_createcluster --- postgresql-common-173+ppa1/pg_createcluster 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_createcluster 2018-02-08 12:21:10.000000000 +0000 @@ -4,7 +4,7 @@ # the postgresql-common infrastructure. # # (C) 2005-2013 Martin Pitt -# (C) 2012-2015 Christoph Berg +# (C) 2012-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ use PgCommon; use Getopt::Long; -use POSIX qw/setlocale LC_ALL LC_CTYPE/; +use POSIX qw/lchown setlocale LC_ALL LC_CTYPE/; $ENV{'PATH'} = '/bin:/usr/bin'; # untaint @@ -26,6 +26,8 @@ my %defaultconf; my $explicit_auth_config = 0; +chdir '/'; + # replace placeholders # Arguments: sub replace_v_c ($$$) { @@ -65,8 +67,9 @@ push @initdb, split (/\s+/, replace_v_c ($options, $version, $cluster)); } push @initdb, ('-D', $datadir); - if (my $xlogdir = $defaultconf{'xlogdir'}) { - push @initdb, ('--xlogdir', replace_v_c ($xlogdir, $version, $cluster)); + if (my $waldir = $defaultconf{'waldir'} || $defaultconf{'xlogdir'}) { + my $wal = $version >= 10 ? 'wal' : 'xlog'; # renamed in PG 10 + push @initdb, ("--${wal}dir", replace_v_c ($waldir, $version, $cluster)); } if ($explicit_auth_config) { # do nothing @@ -86,19 +89,12 @@ push @initdb, ('--lc-time', $lc_time) if $lc_time; push @initdb, @$initdb_opts_from_cli; - # pre-8.2 servers do not ignore LANG when LC_ALL is set; work around this - # bug - if ($version <= '8.2' && $ENV{'LC_ALL'}) { - $ENV{'LANG'} = $ENV{'LC_ALL'}; - } - if (fork) { wait; error 'initdb failed' if $?; } else{ - close STDOUT; change_ugid $owneruid, $ownergid; - open STDOUT, ">/dev/null"; + print "@initdb\n"; exec @initdb; } } @@ -124,21 +120,6 @@ } } -# -# Version specific default configuration -# - -sub configure_8_1 { - PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'stats_row_level', 'on'; - PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'autovacuum', 'on'; -} - -sub configure_8_2 { - PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'stats_row_level', 'on'; - PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'autovacuum', 'on'; -} -# >= 8.3 enables autovacuum by default - # Set up the default pg_hba.conf file: # - Add a "local all" entry to pg_hba.conf for the db superuser before all # other entries. @@ -229,7 +210,10 @@ # check validity of locale unless (setlocale (LC_ALL, "")) { - error ('The locale requested by the environment is invalid.') + my $env = join "\n", + map { " $_: $ENV{$_}" } + grep { /^(LC_|LANG)/ } sort keys %ENV; + error ("The locale requested by the environment is invalid:\n$env") } if (@ARGV < 2) { @@ -282,7 +266,7 @@ error 'clusters must not be owned by root' unless $owneruid && $ownergid; -($version) = $ARGV[0] =~ /^(\d+\.\d+)$/; +($version) = $ARGV[0] =~ /^(\d+\.?\d+)$/; error "invalid version '$ARGV[0]'" unless defined $version; ($cluster) = $ARGV[1] =~ /^([-.\w]+)$/; error "invalid cluster name '$ARGV[1]'" unless defined $cluster; @@ -311,7 +295,9 @@ # ensure that the version data dir is owned by postgres as well, so that # it can be administrated without root permissions if (!stat $pd) { - system 'install', '-d', '-o', $postgres_user[2], '-g', $postgres_user[3], $pd; + my @install = qw(install -d); + push @install, '-o', $postgres_user[2], '-g', $postgres_user[3] if ($> == 0); + system @install, $pd; $datadirp_created = $pd; # clean up in case of error } } @@ -339,7 +325,9 @@ # create configuration directory if (!stat $confdirp) { - system 'install', '-d', '-o', $postgres_user[2], '-g', $postgres_user[3], $confdirp; + my @install = qw(install -d); + push @install, '-o', $postgres_user[2], '-g', $postgres_user[3] if ($> == 0); + system @install, $confdirp; } # now we created the first new directory for this cluster and start to rollback # on error @@ -366,11 +354,7 @@ error "$datadir already contains a version $existingver cluster"; } } else { - my $loc = $locale || setlocale (LC_CTYPE); - print "Creating new cluster $version/$cluster ...\n"; - print " config $confdir\n"; - print " data $datadir\n"; - print " locale $loc\n"; + print "Creating new PostgreSQL cluster $version/$cluster ...\n"; init_db $version, $datadir, $owneruid, $ownergid, \@initdb_opts_from_cli; $newcluster = 1; } @@ -385,8 +369,9 @@ move_conffile "$datadir/postgresql.conf", $confdir, $owneruid, $ownergid, '644'; move_conffile "$datadir/pg_hba.conf", $confdir, $owneruid, $ownergid, '640', 'hba_file'; move_conffile "$datadir/pg_ident.conf", $confdir, $owneruid, $ownergid, '640', 'ident_file'; -chown $owneruid, $ownergid, $datadir, $confdir, "$confdir/start.conf" or die "chown: $!"; -chown $owneruid, $ownergid, $datadir, $confdir, "$confdir/pg_ctl.conf" or die "chown: $!"; +foreach my $f ($datadir, $confdir, "$confdir/start.conf", "$confdir/pg_ctl.conf") { + lchown $owneruid, $ownergid, $f or error "lchown $f: $!"; +} PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'data_directory', $datadir; @@ -407,20 +392,18 @@ $) = $ownergid; $> = $owneruid; unless ($socketdir) { - if ($PgCommon::rpm) { - $socketdir = '/tmp'; # RedHat defaults to /tmp in libpq et al. + if ($version < 9.4 and $PgCommon::rpm) { + $socketdir = '/tmp'; # PGDG 9.3 and earlier defaults to /tmp in libpq et al. } elsif (-w '/var/run/postgresql') { $socketdir = '/var/run/postgresql'; } else { $socketdir='/tmp'; } } -print " socket $socketdir\n"; set_cluster_socketdir $version, $cluster, $socketdir; $> = $orig_euid; $) = $orig_egid; -print " port $port\n"; set_cluster_port $version, $cluster, $port; # create log file @@ -428,9 +411,10 @@ mkdir '/var/log/postgresql' or error "could not create log directory; you might need to run this program with root privileges"; chmod 01775, '/var/log/postgresql'; - chown 0, $postgres_user[3], '/var/log/postgresql'; + lchown 0, $postgres_user[3], '/var/log/postgresql'; } $real_logfile = $custom_logfile || "/var/log/postgresql/postgresql-$version-$cluster.log"; +error "logfile $real_logfile is a directory, not a file" if (-d $real_logfile); if (! -e $real_logfile) { open L, ">>$real_logfile" or error "could not create log file $real_logfile"; close L; @@ -442,20 +426,15 @@ } else { $g = $ownergid; } -chown $owneruid, $g, $real_logfile; +lchown $owneruid, $g, $real_logfile; # if we are using a non-default log file, create a log symlink if ($custom_logfile) { symlink $real_logfile, "$confdir/log"; - chown $owneruid, $ownergid, "$confdir/log"; + lchown $owneruid, $ownergid, "$confdir/log"; } -# version specific default configuration tweaking -$conf_fn = "configure_$version"; -$conf_fn =~tr/./_/; -&$conf_fn if defined &$conf_fn and $newcluster; - # SSL configuration -my $want_ssl = PgCommon::config_bool($defaultconf{ssl} || 'true'); +my $want_ssl = PgCommon::config_bool($defaultconf{ssl} || 'on'); # Check whether we can access the SSL private key as the cluster owner my $ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'; @@ -512,7 +491,7 @@ symlink $ssl_key_file, "$datadir/server.key"; } - PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'ssl', 'true'; + PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'ssl', 'on'; } # SSL client certificate CA @@ -542,7 +521,7 @@ } # create default (empty) environment file -my $defaultenv = "# environment variables for postmaster process +my $defaultenv = "# environment variables for postgres processes # This file has the same syntax as postgresql.conf: # VARIABLE = simple_value # VARIABLE2 = 'any value!' @@ -561,7 +540,7 @@ print ENV $defaultenv; close ENV; chmod 0644, "$confdir/environment"; -chown $owneruid, $ownergid, "$confdir/environment"; +lchown $owneruid, $ownergid, "$confdir/environment"; $cleanup_cruft = 0; @@ -572,8 +551,18 @@ # handle other createcluster.conf parameters foreach my $guc (sort keys %defaultconf) { - next if $guc =~ /^(create_main_cluster|start_conf|data_directory|xlogdir|initdb_options|ssl)$/; + next if $guc =~ /^(create_main_cluster|start_conf|data_directory|waldir|xlogdir|initdb_options|ssl)$/; + next if $guc eq 'logging_collector' and $version < 8.3; + next if $guc eq 'cluster_name' and $version < 9.5; my $val = replace_v_c ($defaultconf{$guc}, $version, $cluster); + $guc =~ s/^add_include/include/; # remove harness from include directives in createcluster.conf + if ($guc eq 'include_dir') { + next if ($version < 9.3); + if ($val =~ /^[\w.]+$/ and not -e "$confdir/$val") { # create directory relative to new config directory + mkdir "$confdir/$val", 0755; + lchown $owneruid, $ownergid, "$confdir/$val"; + } + } PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', $guc, $val; } @@ -595,8 +584,12 @@ # start it if requested if ($start) { system 'pg_ctlcluster', $version, $cluster, 'start'; + die "Could not start cluster\n" if ($?); } +# finally, show the cluster we created +system 'pg_lsclusters', $version, $cluster; + END { # clean up cruft if something went wrong if ($cleanup_cruft && defined $version && defined $cluster) { @@ -619,7 +612,7 @@ =head1 DESCRIPTION B creates a new PostgreSQL server cluster (i. e. a -collection of databases served by a L instance) and +collection of databases served by a L instance) and integrates it into the multi-version/multi-cluster architecture of the B package. @@ -700,7 +693,7 @@ =item B<-s> I, B<--socketdir=>I -Explicitly set the directory where the L server stores the Unix +Explicitly set the directory where the L server stores the Unix socket for local connections. Defaults to C for clusters owned by the user B, and C for clusters owned by other users. Please be aware that C is an unsafe directory since everybody can create @@ -709,7 +702,7 @@ =item B<-l> I, B<--logfile=>I -Explicitly set the path for the L server log file. Defaults to +Explicitly set the path for the L server log file. Defaults to CIC<->IC<.log>. =item B<--locale=>I @@ -795,7 +788,7 @@ =head1 STARTUP CONTROL The C file in the cluster configuration directory controls the -start/stop behavior of that cluster's postmaster process. The file can contain +start/stop behavior of that cluster's postgres process. The file can contain comment lines (started with '#'), empty lines, and must have exactly one line with one of the following keywords: @@ -803,25 +796,36 @@ =item B -The postmaster process is started/stopped automatically in the init script. +The postgres process is started/stopped automatically in the init script. + +When running from B, the cluster is started/stopped when +B is started/stopped. This is also the default if the file is missing. =item B -The postmaster process is not handled by the init script, but manually +The postgres process is not handled by the init script, but manually controlling the cluster with L is permitted. +When running from B, the cluster is not started automatically when +B is started. However, stopping/restarting +B will stop/restart the cluster. The cluster can be started +using BIB<->I. + =item B -Neither the init script nor L are permitted to start/stop the +Neither the init script, L, nor B are permitted to start/stop the cluster. Please be aware that this will not stop the cluster owner from calling -lower level tools to control the postmaster process; this option is only meant +lower level tools to control the postgres process; this option is only meant to prevent accidents during maintenance, not more. =back +When running from B, invoke B after editing +C. + The C file in the cluster configuration directory can contain -additional options passed to pg_ctl of that cluster. +additional options passed to B of that cluster. =head1 DEFAULT VALUES @@ -848,11 +852,13 @@ Default data directory. -=item B (Default: unset) +=item B (Default: unset) Default directory for transaction logs. When used, B will create a -symlink from C in the data directory to this location. Unset by -default, i.e. pg_xlog is remains in the data directory. +symlink from C (PostgreSQL 9.6 and earlier: C) in the data +directory to this location. Unset by default, i.e. transaction logs remain in +the data directory. Both spellings of this option are accepted, and translated +to the correct initdb invocation depending on the cluster version. =item B (Default: unset) @@ -881,6 +887,30 @@ =back +=item Include files + +=over 4 + +=item B + +=item B + +=item B + +B supports the same include directives as +B. + +=item B + +=item B + +=item B + +To add include directives to the new postgresql.conf file, use the B +directives. The B prefix is removed. + +=back + =back =head1 SEE ALSO diff -Nru postgresql-common-173+ppa1/pg_ctlcluster postgresql-common-190~ubuntu16.04.1/pg_ctlcluster --- postgresql-common-173+ppa1/pg_ctlcluster 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_ctlcluster 2018-01-12 14:08:46.000000000 +0000 @@ -6,7 +6,7 @@ # # (C) 2005-2009 Martin Pitt # (C) 2009 Cyril Bouthors -# (C) 2013-2015 Christoph Berg +# (C) 2013-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,32 +21,22 @@ use strict; use warnings; use Getopt::Long; -use POSIX qw/setsid dup2 setlocale LC_ALL :sys_wait_h/; +use POSIX qw/setsid dup2 :sys_wait_h/; use PgCommon; -use Fcntl 'SEEK_SET'; +use Fcntl qw(SEEK_SET O_RDWR O_CREAT O_EXCL); +use POSIX qw(lchown); my ($version, $cluster, $pg_ctl, $force); -my (@postmaster_auxoptions, @pg_ctl_opts_from_cli); +my (@postgres_auxoptions, @pg_ctl_opts_from_cli); my (%postgresql_conf, %info); my $mode = 'smart'; # default shutdown mode my $foreground = 0; # don't daemonize, use postgres instead of pg_ctl my $stdlog = 0; # when run in foreground, still log to the default logfile -# Check for known broken configurations of this cluster -sub check_valid_config { - my %postgresql_conf = read_cluster_conf_file $version, $cluster, - 'postgresql.conf'; - my $log_statement_stats = config_bool $postgresql_conf{'log_statement_stats'}; - my $log_parser_stats = config_bool $postgresql_conf{'log_parser_stats'}; - my $log_planner_stats = config_bool $postgresql_conf{'log_planner_stats'}; - my $log_executor_stats = config_bool $postgresql_conf{'log_executor_stats'}; - - # statement and other statistics are mutually exclusive - if ($log_statement_stats && ($log_parser_stats || $log_planner_stats || - $log_executor_stats)) { - error ('invalid postgresql.conf: log_statement_stats and the other log_*_stats options are mutually exclusive'); - } -} +# untaint environment +$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; +delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; +chdir '/'; # If a pid file is already present, delete it if it is stale/invalid, or exit # with a notice if it belongs to an already running postgres. @@ -97,7 +87,7 @@ my $out; while ($n < ($result ? 10 : 3)) { select undef, undef, undef, 0.5; - $out = `$psql -h '$sd' --port $p -l 2>&1 >/dev/null`; + $out = `$psql -h '$sd' --port $p -Xl 2>&1 >/dev/null`; if ($? == $result) { $n++; @@ -115,10 +105,6 @@ } sub start { - my $cdir = $info{'configdir'}; - - check_valid_config; - start_check_pid_file; # check conflicting port @@ -140,18 +126,19 @@ # PG_OOM_ADJUST_VALUE defaults to 0, but can be overridden here } - my $postmaster_opts = ''; + my $postgres_opts = ''; my $usd = $version >= 9.3 ? 'unix_socket_directories' : 'unix_socket_directory'; if (!(PgCommon::get_conf_value $version, $cluster, 'postgresql.conf', $usd)) { - $postmaster_opts .= "-c $usd=\"$info{'socketdir'}\""; + $postgres_opts .= "-c $usd=\"$info{'socketdir'}\""; } - $postmaster_opts .= " -c config_file=\"$cdir/postgresql.conf\""; + my $cdir = $info{'configdir'}; + $postgres_opts .= " -c config_file=\"$cdir/postgresql.conf\""; if (!(PgCommon::get_conf_value $version, $cluster, 'postgresql.conf', 'hba_file')) { - $postmaster_opts .= " -c hba_file=\"$cdir/pg_hba.conf\""; + $postgres_opts .= " -c hba_file=\"$cdir/pg_hba.conf\""; } if (!(PgCommon::get_conf_value $version, $cluster, 'postgresql.conf', 'ident_file')) { - $postmaster_opts .= " -c ident_file=\"$cdir/pg_ident.conf\""; + $postgres_opts .= " -c ident_file=\"$cdir/pg_ident.conf\""; } if ((-d '/var/run/postgresql') && !defined (PgCommon::get_conf_value $version, $cluster, 'postgresql.conf', 'external_pid_file')) { @@ -166,12 +153,12 @@ $vrp_writable = -w '/var/run/postgresql'; } if ($vrp_writable) { - $postmaster_opts .= " -c external_pid_file=\"/var/run/postgresql/$version-$cluster.pid\""; + $postgres_opts .= " -c external_pid_file=\"/var/run/postgresql/$version-$cluster.pid\""; } } - $postmaster_opts .= ' ' . (join ' ', @postmaster_auxoptions); - ($postmaster_opts) = $postmaster_opts =~ /(.*)/; # untaint + $postgres_opts .= ' ' . (join ' ', @postgres_auxoptions); + ($postgres_opts) = $postgres_opts =~ /(.*)/; # untaint if ($foreground) { if ($stdlog and $info{'logfile'}) { @@ -179,7 +166,7 @@ dup2(POSIX::open($info{logfile}, POSIX::O_WRONLY|POSIX::O_APPEND), 2); } my $postgres = get_program_path 'postgres', $version; - exec '/bin/sh', '-c', "exec $postgres $postmaster_opts" or + exec '/bin/sh', '-c', "exec $postgres $postgres_opts" or error "Executing $postgres failed: $!" } @@ -199,16 +186,28 @@ push @options, split(' ', $pg_ctl_opts_from_file{'pg_ctl_options'}) if defined $pg_ctl_opts_from_file{'pg_ctl_options'} and $pg_ctl_opts_from_file{'pg_ctl_options'} ne ''; - push @options, ('-s', '-o', $postmaster_opts); + push @options, ('-s', '-o', $postgres_opts); if (fork) { wait; - error "could not exec $pg_ctl @options: $!" if $?; + if ($?) { + my $exit = $? >> 8; + print STDERR "Error: $pg_ctl @options exited with status $exit: $!\n"; + my $currlogsize = (stat $info{'logfile'})[7] if $info{'logfile'} && -r $info{'logfile'}; + if ($currlogsize) { + open LOG, $info{'logfile'} or + error "Could not open log file " . $info{'logfile'}; + seek LOG, $logsize, SEEK_SET; + print STDERR $_ while ; + } + exit $exit; + } } else { setsid or error "could not start session: $!"; - # without this, you'll get zombies on startup - dup2(POSIX::open('/dev/null', POSIX::O_WRONLY), 1); - dup2(POSIX::open('/dev/null', POSIX::O_WRONLY), 2); + # without dup2, you'll get zombies on startup + my $output = $info{'logfile'} && -r $info{'logfile'} ? $info{'logfile'} : '/dev/null'; + dup2(POSIX::open($output, POSIX::O_WRONLY | POSIX::O_APPEND | POSIX::O_CREAT), 1); + dup2(POSIX::open($output, POSIX::O_WRONLY | POSIX::O_APPEND | POSIX::O_CREAT), 2); exec $pg_ctl @options or error "could not exec $pg_ctl @options: $!"; } @@ -254,10 +253,18 @@ stop_check_pid_file; my $result = 1; + my @options = ('stop', '-s', '-w', '-D', $info{'pgdata'}); + + push @options, @pg_ctl_opts_from_cli if @pg_ctl_opts_from_cli; + + my %pg_ctl_opts_from_file = read_cluster_conf_file $version, $cluster, 'pg_ctl.conf'; + push @options, split(' ', $pg_ctl_opts_from_file{'pg_ctl_options'}) + if defined $pg_ctl_opts_from_file{'pg_ctl_options'} and $pg_ctl_opts_from_file{'pg_ctl_options'} ne ''; + if ($force) { if (!fork()) { close STDOUT; - exec $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', 'fast', @pg_ctl_opts_from_cli, 'stop'; + exec $pg_ctl, @options, '-m', 'fast'; } else { wait; $result = $? >> 8; @@ -266,7 +273,7 @@ # try harder if "fast" mode does not work if (-f $info{'pgdata'}.'/postmaster.pid') { print "(does not shutdown gracefully, now stopping immediately)\n"; - $result = system $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', 'immediate', @pg_ctl_opts_from_cli, 'stop'; + $result = system $pg_ctl, @options, '-m', 'immediate'; } # if that still not helps, use the big hammer @@ -279,7 +286,7 @@ } else { if (!fork()) { close STDOUT; - exec $pg_ctl, '-D', $info{'pgdata'}, '-s', '-w', '-m', $mode, @pg_ctl_opts_from_cli, 'stop'; + exec $pg_ctl, @options, '-m', $mode; } else { wait; $result = $? >> 8; @@ -322,7 +329,7 @@ my ($skip_systemctl_redirect, $bindir); -exit 1 unless GetOptions ('o|options=s' => \@postmaster_auxoptions, +exit 1 unless GetOptions ('o|options=s' => \@postgres_auxoptions, 'f|force' => \$force, 'm|mode=s' => \$mode, 'foreground' => \$foreground, @@ -347,7 +354,7 @@ } $version = shift @ARGV; -if ($version =~ m!^(\d+\.\d)[-/](.+)!) { +if ($version =~ m!^(\d+\.?\d)[-/](.+)!) { ($version, $cluster) = ($1, $2); } else { $cluster = shift @ARGV; @@ -359,7 +366,7 @@ push @pg_ctl_opts_from_cli, $argv =~ /(.*)/; # untaint } -($version) = $version =~ /^(\d+\.\d+)$/; # untaint +($version) = $version =~ /^(\d+\.?\d+)$/; # untaint ($cluster) = $cluster =~ /^([^'"\s]+)$/; # untaint error 'specified cluster does not exist' unless $version && $cluster && cluster_exists $version, $cluster; %info = cluster_info ($version, $cluster); @@ -369,10 +376,6 @@ error 'Cluster is disabled' if $info{'start'} eq 'disabled'; } -# untaint environment -$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; -delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; - unless (-d $info{'pgdata'} && defined $info{'owneruid'}) { error $info{'pgdata'} . ' is not accessible or does not exist'; } @@ -403,14 +406,14 @@ my $unit_active = $? == 0; # if extra options are given, proceed with pg_ctlcluster with a warning - if (@postmaster_auxoptions != 0 or @pg_ctl_opts_from_cli != 0 or $bindir) { # extra options given + if (@postgres_auxoptions != 0 or @pg_ctl_opts_from_cli != 0 or $bindir) { # extra options given print "Notice: extra pg_ctl/postgres options given, bypassing systemctl for $action operation\n" if (-t 1); # if we are root, redirect to systemctl unless stopping a cluster running outside systemd } elsif ($> == 0) { if ($action eq 'stop' and not $unit_active) { # proceed with pg_ctlcluster } else { - print "Redirecting $action request to systemctl\n" if (-t 1); + #print "Redirecting $action request to systemctl\n" if (-t 1); system 'systemctl', $action, "postgresql\@$version-$cluster"; exit $? >> 8; # program end @@ -438,17 +441,20 @@ # recreate missing log file if ($action ne 'stop' && $info{'logfile'} && ! -e $info{'logfile'}) { - open L, '>', $info{'logfile'} or + if ($> == 0) { # drop privileges; this is important if logfile + # was determined via an /etc/postgresql/.../log symlink + change_ugid $info{'owneruid'}, $info{'ownergid'}; + } + sysopen (L, $info{'logfile'}, O_RDWR|O_CREAT|O_EXCL) or error 'Could not create log file ' . $info{'logfile'}; + close L; chmod 0640, $info{'logfile'}; - my $g; + $< = $> = 0; # will silently fail if we were not root before, that's intended + $( = $) = 0; if ($info{'owneruid'} < 500) { - $g = (getgrnam 'adm')[2]; - } else { - $g = $info{'ownergid'}; + my $g = (getgrnam 'adm')[2]; + lchown $info{'owneruid'}, $g, $info{'logfile'} if (defined $g); } - chown $info{'owneruid'}, $g, $info{'logfile'}; - close L; } # recreate /var/run/postgresql @@ -458,9 +464,9 @@ } # recreate stats_temp_directory -if ($action ne 'stop' && $info{'statstempdir'} && ! -d $info{'statstempdir'}) { +if ($action ne 'stop' && $info{config}->{stats_temp_directory} && ! -d $info{config}->{stats_temp_directory}) { system 'install', '-d', '-m', 750, - '-o', $info{'owneruid'}, '-g', $info{'ownergid'}, $info{'statstempdir'}; + '-o', $info{'owneruid'}, '-g', $info{'ownergid'}, $info{config}->{stats_temp_directory}; } if ($> == 0) { @@ -474,7 +480,6 @@ } } - chdir ('/var/lib/postgresql'); change_ugid $info{'owneruid'}, $info{'ownergid'}; } @@ -502,7 +507,7 @@ =head1 SYNOPSIS -B [I] I I I B<--> [I] +B [I] I I I [B<--> I] where I = B|B|B|B|B|B @@ -528,7 +533,7 @@ A log file for this specific cluster is created if it does not exist yet (by default, CIC<->IC<.log>), -and a PostreSQL server process (L) is started on it. Exits with +and a PostgreSQL server process (L) is started on it. Exits with 0 on success, with 2 if the server is already running, and with 1 on other failure conditions. diff -Nru postgresql-common-173+ppa1/pgdg/apt.postgresql.org.sh postgresql-common-190~ubuntu16.04.1/pgdg/apt.postgresql.org.sh --- postgresql-common-173+ppa1/pgdg/apt.postgresql.org.sh 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pgdg/apt.postgresql.org.sh 2018-01-12 14:08:46.000000000 +0000 @@ -40,8 +40,8 @@ case $CODENAME in # known distributions - sid|jessie|wheezy|squeeze|lenny|etch) ;; - xenial|wily|trusty|precise|lucid) ;; + sid|stretch|jessie|wheezy|squeeze|lenny|etch) ;; + zesty|xenial|wily|trusty|precise|lucid) ;; *) # unknown distribution, verify on the web DISTURL="http://apt.postgresql.org/pub/repos/apt/dists/" if [ -x /usr/bin/curl ]; then @@ -87,7 +87,6 @@ test -e $KEYRING || touch $KEYRING apt-key --keyring $KEYRING add - < -# (C) 2015 Christoph Berg +# (C) 2015-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ exit 1; } -($version) = $ARGV[0] =~ /^(\d+\.\d+)$/; +($version) = $ARGV[0] =~ /^(\d+\.?\d+)$/; ($cluster) = $ARGV[1] =~ /^([-.\w]+)$/; error 'invalid version' unless defined $version; error 'invalid cluster name' unless defined $cluster; @@ -50,7 +50,7 @@ error 'could not stop server, aborting'; } } else { - print STDERR "warning: corrupted cluster: data directory does not exist any more, but server is still running; you have to manually kill the postmaster process\n"; + print STDERR "Warning: corrupted cluster: data directory does not exist any more, but server is still running; you have to manually kill the postgres process\n"; } } else { error 'This cluster is still running. Stop it or supply the --stop option'; @@ -66,6 +66,20 @@ } if ($info{'pgdata'} && -d $info{'pgdata'}) { + # remove custom wal directory + if ($info{waldir} and -d $info{waldir}) { + my $walowner = (stat($info{waldir}))[4]; + if (defined $walowner and $walowner == $info{owneruid}) { + $result = system 'rm', '-r', '--', $info{waldir}; + if ($result) { + exit $result; + } + } else { + print STDERR "Warning: wal directory $info{waldir} is not owned by uid $info{owneruid}, not removing\n"; + } + } + + # remove pgdata $result = system 'rm', '-r', $info{'pgdata'}; if ($result) { if (! -w ($info{'pgdata'} . '/..')) { @@ -74,13 +88,17 @@ exit $result; } } else { - print STDERR "warning: corrupted cluster: data directory does not exist\n"; + print STDERR "Warning: corrupted cluster: data directory does not exist\n"; } + +# remove config unlink $c.'/pg_hba.conf', $c.'/pg_ident.conf', $c.'/postgresql.conf', $c.'/start.conf', $c.'/log', $c.'/autovacuum_log', $c.'/pgdata', $c.'/environment', $c.'/pg_ctl.conf'; +rmdir $_ foreach (map { /(.*)/ && $1 } glob "$c/*"); # remove empty conf.d directories + unlink $info{'logfile'} if defined ($info{'logfile'}); -if ($info{'socketdir'} !~ /^(\/tmp|\/var\/run\/postgresql)\/?$/) { +if ($info{'socketdir'} and $info{'socketdir'} !~ /^(\/tmp|\/var\/run\/postgresql)\/?$/) { rmdir $info{'socketdir'}; } rmdir $c; @@ -92,23 +110,25 @@ foreach my $f () { unlink ($f =~ /(.*)/); # untaint } + # remove stats_temp_directory -if ($info{statstempdir}) { - my $statsowner = (stat($info{statstempdir}))[4]; +my $statstempdir = $info{config}->{stats_temp_directory}; +if ($statstempdir) { + my $statsowner = (stat($statstempdir))[4]; if (defined $statsowner and $statsowner == $info{owneruid}) { - foreach my $f (<$info{statstempdir}/*.stat>) { + foreach my $f (<$statstempdir/*.stat>) { unlink ($f =~ /(.*)/); # untaint } - rmdir $info{statstempdir}; + rmdir $statstempdir; } } # notify systemd when an autostarted cluster went away -if (not exists $ENV{'PG_CLUSTER_CONF_ROOT'} and $startconf eq 'auto' and -d '/run/systemd/system') { +if (not exists $ENV{'PG_CLUSTER_CONF_ROOT'} and $startconf and $startconf eq 'auto' and -d '/run/systemd/system') { if ($> == 0) { system 'systemctl daemon-reload'; } elsif (-t 1) { - print "Warning: systemd was not informed about the removed yet. Operations like \"service postgresql start\" might fail. To fix, run:\n"; + print "Warning: systemd was not informed about the removed cluster yet. Operations like \"service postgresql start\" might fail. To fix, run:\n"; print " sudo systemctl daemon-reload\n"; } } diff -Nru postgresql-common-173+ppa1/pg_hba postgresql-common-190~ubuntu16.04.1/pg_hba --- postgresql-common-173+ppa1/pg_hba 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_hba 2018-02-02 08:51:46.000000000 +0000 @@ -19,8 +19,6 @@ use Getopt::Long; use Net::CIDR; -my %valid_methods = qw/trust 1 reject 1 md5 1 crypt 1 password 1 krb5 1 ident 1 pam 1/; - # global variables my $ip = ''; # default to local unix socket @@ -35,63 +33,6 @@ exit 2; } -# Parse a single pg_hba.conf line. -# Arguments: -# Returns: Hash reference; 'type' key (comment, local, host, hostssl, -# hostnossl) is always present, other keys depend on type. -sub parse_hba_line { - my $l = $_[0]; - - # comment line? - return { 'type' => 'comment', 'line' => $l } if ($l =~ /^\s*($|#)/); - - # not yet supported features - return undef if $l =~ /("|\+|@)/; - - my @tok = split /\s+/, $l; - return undef if $#tok < 3; - my $res = { - 'type' => shift @tok, - 'database' => shift @tok, - 'user' => shift @tok, - 'line' => $l - }; - - # local connection? - if ($$res{'type'} eq 'local') { - return undef if $#tok > 1; - return undef unless $valid_methods{$tok[0]}; - $$res{'method'} = join (' ', @tok); - return $res; - } - - # host connection? - if ($$res{'type'} =~ /^host((no)?ssl)?$/) { - my ($i, $c) = split '/', (shift @tok); - $i = Net::CIDR::cidrvalidate $i; - return undef unless $i; - - # CIDR mask given? - if (defined $c) { - return undef if $c !~ /^(\d+)$/; - $$res{'ip'} = "$i/$c"; - } else { - my $m = Net::CIDR::cidrvalidate (shift @tok); - return undef unless $m; - $$res{'ip'} = Net::CIDR::addrandmask2cidr ($i, $m); - return undef unless $$res{'ip'}; - } - - return undef if $#tok > 1; - return undef unless $valid_methods{$tok[0]}; - $$res{'method'} = join (' ', @tok); - return $res; - } - - print "Parse error: invalid line: $l"; - return undef; -} - # Check if s1 is equal to s2 or s2 is 'all'. # Arguments: sub match_all { @@ -114,9 +55,12 @@ # Return: 1 if match was found, 0 otherwise. sub mode_test { foreach my $hbarec (@hba) { + if (!defined($$hbarec{'type'})) { + next; + } next if $$hbarec{'type'} eq 'comment'; next unless match_all ($user, $$hbarec{'user'}) && - match_all ($db, $$hbarec{'database'}) && + match_all ($db, $$hbarec{'db'}) && $$hbarec{'method'} eq $method; if ($ip) { @@ -132,19 +76,11 @@ return 0; } -# Parse given pg_hba.conf file. -# Arguments: -# Returns: Array with hash refs; for hash contents, see parse_hba_line(). -sub read_pg_hba { - open HBA, $_[0] or return undef; - my @hba; - while () { - my $r = parse_hba_line $_; - return undef unless defined $r; - push @hba, $r; +# Print hba conf. +sub mode_print { + foreach my $hbarec (@hba) { + print "$$hbarec{'line'}\n"; } - close HBA; - return @hba; } # Generate a pg_hba.conf line that matches the command line args. @@ -186,7 +122,7 @@ unless (defined $method) { $method = ($ip ? 'md5' : 'ident sameuser'); } -error2 'Invalid --method argument' unless $valid_methods{(split /\s+/, $method)[0]}; +error2 'Invalid --method argument' unless PgCommon::valid_hba_method($method); # parse file @@ -201,6 +137,8 @@ print create_hba_line(); exit 1; } +} elsif ($mode eq 'pg_print_hba') { + mode_print(); } else { error2 "Unknown mode: $mode"; } diff -Nru postgresql-common-173+ppa1/pg_lsclusters postgresql-common-190~ubuntu16.04.1/pg_lsclusters --- postgresql-common-173+ppa1/pg_lsclusters 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_lsclusters 2018-02-08 09:28:06.000000000 +0000 @@ -2,7 +2,7 @@ # Show all PostgreSQL clusters in a list # # (C) 2005-2009 Martin Pitt -# (C) 2013-2015 Christoph Berg +# (C) 2013-2018 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,36 +18,94 @@ use PgCommon; use Getopt::Long; +sub help ($) +{ + my $exit = shift; + print "Usage: $0 [-hjs] + +Options: + -h --no-header Omit column headers in output + -j --json JSON output + -s --start-conf Include start.conf information in status column + --help Print help\n"; + + exit $exit; +} + +# option handling my $no_header; -exit 1 unless GetOptions ('h|no-header' => \$no_header); +my $json; +my $start_conf; +help(1) unless GetOptions ( + 'help' => sub { help(0); }, + 'h|no-header' => \$no_header, + 'j|json' => \$json, + 's|start-conf' => \$start_conf, +); + +my (@versions, $ls_cluster); +if (@ARGV == 1 and $ARGV[0] =~ m{^(\d+(?:\.\d+)?)[-/]([-.\w]+)$}) { + push @versions, $1; + $ls_cluster = $2; +} elsif (@ARGV >= 1) { + $ARGV[0] =~ /^(\d+(?:\.\d+)?)$/ or error "Invalid version number \"$ARGV[0]\""; + push @versions, $1; +} else { + @versions = get_versions(); +} +if (@ARGV >= 2 and $ARGV[1] =~ /^([-.\w]+)$/) { + $ls_cluster = $1; +} +error "Cluster @versions $ls_cluster does not exist" + if ($ls_cluster and not cluster_exists(@versions, $ls_cluster)); + +# data collection my @lines; push @lines, ['Ver', 'Cluster', 'Port', 'Status', 'Owner', 'Data directory', 'Log file'] unless ($no_header); +my $jsoninfo = []; -foreach my $v (sort (get_versions())) { - my @clusters = get_version_clusters $v; - foreach my $c (sort @clusters) { +foreach my $v (@versions) { + my $pg_log = $v >= 10 ? 'log' : 'pg_log'; # log directory in PGDATA changed in PG 10 + my @clusters = $ls_cluster ? $ls_cluster : get_version_clusters $v; + foreach my $c (@clusters) { my %info = cluster_info $v, $c; - my $logfile = $info{logfile}; # default logfile in /var/log/postgresql - if (config_bool ($info{logging_collector})) { - my $path = $info{log_directory} || 'pg_log'; - my $file = $info{log_filename} || 'postgresql-%Y-%m-%d_%H%M%S.log'; + + my $status = $info{'running'} ? "online" : "down"; + $status .= ",recovery" if ($info{'recovery'}); + $status .= ",$info{start}" if ($start_conf); + + my $logfile = $info{logfile} // ''; # default logfile in /var/log/postgresql + if (config_bool ($info{config}->{logging_collector})) { + my $path = $info{config}->{log_directory} || $pg_log; + my $file = $info{config}->{log_filename} || 'postgresql-%Y-%m-%d_%H%M%S.log'; $logfile = "$path/$file"; } - my $destination = $info{log_destination} || 'stderr'; + my $destination = $info{config}->{log_destination} || 'stderr'; $destination =~ s/stderr/$logfile/; my $csvlog = $logfile; $csvlog =~ s/(?:\.log)?$/.csv/; $destination =~ s/csvlog/$csvlog/; - push @lines, [$v, $c, $info{'port'}, - ($info{'running'} ? "online" : "down") . ($info{'recovery'} ? ",recovery" : ""), + push @lines, [$v, $c, $info{'port'} // '', $status, defined $info{'owneruid'} ? (getpwuid $info{'owneruid'})[0] : '', - $info{'pgdata'} || '', $destination]; + $info{'pgdata'} || '', $destination]; + $info{version} = $v; + $info{cluster} = $c; + push @$jsoninfo, \%info; } } +# output +if ($json) { + eval { require JSON; }; + error 'Please install JSON.pm for JSON output (Debian: libjson-perl)' + if ($@); + print JSON::encode_json($jsoninfo) . "\n"; + exit 0; +} + my @colwidth = qw(1 1 1 1 1 1 1); foreach my $line (@lines) { for (my $i = 0; $i < @$line - 1; $i++) { # skip adjustment for last column @@ -60,16 +118,13 @@ my $fmtstring = join ' ', map { "%-${_}s" } @colwidth; foreach my $line (@lines) { - if ($color and $line->[3] =~ /online/) { - print "\033[32m"; # green - } elsif ($color and $line->[3] =~ /down/) { - print "\033[31m"; # red + if ($color and $line->[0] ne 'Ver') { # don't color header + printf "\033[%dm$fmtstring\033[0m\n", + ($line->[3] =~ /^online/ ? 32 : 31), # green, red + @$line; + } else { + printf "$fmtstring\n", @$line; } - printf "$fmtstring\n", @$line; -} - -if ($color) { - print "\033[0m"; # reset terminal } __END__ @@ -80,11 +135,12 @@ =head1 SYNOPSIS -B [I] +B [I] [I [I]] =head1 DESCRIPTION -This command shows a list about the configuration and status of all clusters. +This command list the status and some configuration details of all clusters. +If a version and optionally a cluster name are given, only these are shown. =head1 OPTIONS @@ -94,6 +150,19 @@ Do not print the column header line. +=item B<-j>, B<--json> + +Output information in JSON format. Needs JSON.pm installed. +(Debian package: libjson-perl) + +=item B<-s>, B<--start-conf> + +Include F information in status column. + +=item B<--help> + +Print usage help. + =back =head1 NOTES diff -Nru postgresql-common-173+ppa1/pg_renamecluster postgresql-common-190~ubuntu16.04.1/pg_renamecluster --- postgresql-common-173+ppa1/pg_renamecluster 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_renamecluster 2018-01-12 14:08:46.000000000 +0000 @@ -2,7 +2,7 @@ # Rename a PostgreSQL cluster # -# (C) 2014-2015 Christoph Berg +# (C) 2014-2016 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ exit 1; } -my ($version) = $ARGV[0] =~ /^(\d+\.\d+)$/; +my ($version) = $ARGV[0] =~ /^(\d+\.?\d+)$/; my ($oldcluster) = $ARGV[1] =~ /^([-.\w]+)$/; my ($newcluster) = $ARGV[2] =~ /^([-.\w]+)$/; if ($newcluster =~ /-/ and -t 1) { @@ -48,8 +48,7 @@ # connections if ($info{'running'}) { print "Stopping cluster $version $oldcluster ...\n"; - my @argv = ('pg_ctlcluster', $version, $oldcluster, 'stop', '--'); - push @argv, ('-t', '5') if $version >= '8.4'; + my @argv = ('pg_ctlcluster', $version, $oldcluster, 'stop'); error "Could not stop cluster" if system @argv; } @@ -80,6 +79,13 @@ strrepl($c{external_pid_file}, $oldcluster, $newcluster); } +# update cluster_name +if ($c{cluster_name}) { + PgCommon::set_conf_value $version, $newcluster, 'postgresql.conf', 'cluster_name', + strrepl ($c{cluster_name}, $oldcluster, $newcluster); +} + + # rename data directory if ($info{pgdata}) { my $newpgdata = strrepl ($info{pgdata}, $oldcluster, $newcluster); @@ -92,14 +98,15 @@ } # rename stats_temp_directory -if ($info{statstempdir}) { - my $newstatstempdir = strrepl ($info{statstempdir}, $oldcluster, $newcluster); - if ($info{statstempdir} ne $newstatstempdir) { +my $statstempdir = $info{config}->{stats_temp_directory}; +if ($statstempdir) { + my $newstatstempdir = strrepl ($statstempdir, $oldcluster, $newcluster); + if ($statstempdir ne $newstatstempdir) { PgCommon::set_conf_value $version, $newcluster, 'postgresql.conf', 'stats_temp_directory', $newstatstempdir; - if (-d $info{statstempdir}) { - rename $info{statstempdir}, $newstatstempdir or - error "Could not rename stats temp directory $info{statstempdir}: $!"; + if (-d $statstempdir) { + rename $statstempdir, $newstatstempdir or + error "Could not rename stats temp directory $statstempdir}: $!"; } } } diff -Nru postgresql-common-173+ppa1/pg_updatedicts postgresql-common-190~ubuntu16.04.1/pg_updatedicts --- postgresql-common-173+ppa1/pg_updatedicts 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_updatedicts 2018-01-12 14:08:46.000000000 +0000 @@ -4,6 +4,7 @@ # myspell and hunspell dictionaries. # # (C) 2008-2009 Martin Pitt +# (C) 2012-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,6 +31,7 @@ return undef; } +umask 022; if ((system 'mkdir', '-p', $cachedir) != 0) { exit 1; } @@ -75,11 +77,10 @@ print STDERR "ERROR: Conversion of $dic failed\n"; next; } - chmod 0644, "$cachedir/$locale.affix", "$cachedir/$locale.dict"; # install symlinks to all versions >= 8.3 foreach my $v (get_versions) { - next if $v lt '8.3'; + next if $v < '8.3'; my $dest = "$pgsharedir/$v/tsearch_data"; next if ! -d $dest; $current{"$dest/$locale.affix"} = undef; diff -Nru postgresql-common-173+ppa1/pg_upgradecluster postgresql-common-190~ubuntu16.04.1/pg_upgradecluster --- postgresql-common-173+ppa1/pg_upgradecluster 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_upgradecluster 2018-01-12 14:08:46.000000000 +0000 @@ -4,7 +4,7 @@ # # (C) 2005-2009 Martin Pitt # (C) 2013 Peter Eisentraut -# (C) 2013-2015 Christoph Berg +# (C) 2013-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,9 +17,10 @@ # GNU General Public License for more details. use strict; +use warnings; use PgCommon; use Getopt::Long; -use POSIX; +use POSIX qw(lchown); # untaint environment $ENV{'PATH'} = '/bin:/usr/bin'; @@ -29,6 +30,7 @@ my ($version, $newversion, $cluster, $newcluster); my (%info, %newinfo); my ($encoding, $old_lc_ctype, $old_lc_collate); # old cluster encoding +my $maintenance_db = 'template1'; # do not trip over cwd not being accessible to postgres superuser chdir '/'; @@ -126,7 +128,7 @@ } close O; close N; - chown $newinfo{'owneruid'}, $newinfo{'ownergid'}, "$hba.new"; + lchown $newinfo{'owneruid'}, $newinfo{'ownergid'}, "$hba.new"; chmod 0640, "$hba.new"; rename "$hba.new", $hba or error "rename: $!"; } @@ -164,9 +166,9 @@ if ($newversion >= '9.4') { deprecate \%c, 'krb_srvname', 'native krb5 authentication deprecated in favor of GSSAPI'; - # d_s_m_t defaults to 'posix', but that has various problems. Pick a safer variant here + # grab dsmt from the new config just written by initdb unless ($c{dynamic_shared_memory_type}) { - set 'dynamic_shared_memory_type', 'mmap'; + set 'dynamic_shared_memory_type', ($newinfo{config}->{dynamic_shared_memory_type} || 'mmap'); } } @@ -177,6 +179,18 @@ set 'max_wal_size', $max_wal_size; } deprecate \%c, 'ssl_renegotiation_limit', 'does not exist anymore'; + # adapt cluster_name + my $cluster_name = PgCommon::get_conf_value ($newversion, $newcluster, 'postgresql.conf', 'cluster_name'); + if ($cluster_name) { + $cluster_name =~ s/\Q$version\E/$newversion/g; + $cluster_name =~ s/\Q$cluster\E/$newcluster/g; + set 'cluster_name', $cluster_name; + } + } + + if ($newversion >= '10') { + rename_ \%c, 'min_parallel_relation_size', 'min_parallel_table_scan_size'; + deprecate \%c, 'sql_inheritance', 'does not exist anymore'; } } @@ -194,7 +208,7 @@ error "could not create $hba"; } chmod 0400, $hba; - chown $_[3], 0, $hba; + lchown $_[3], 0, $hba; if ($_[0] >= '8.4') { print F "local all $_[2] ident\n"; } else { @@ -203,7 +217,7 @@ close F; } -# Restore original pg_hba.conf, but do not restart postmaster. +# Restore original pg_hba.conf, but do not restart postgres. # Arguments: sub enable_connections { my $hba = "$PgCommon::confroot/$_[0]/$_[1]/pg_hba.conf"; @@ -216,11 +230,11 @@ # Arguments: sub get_encoding { my ($version, $cluster) = @_; - $encoding = get_db_encoding $version, $cluster, 'template1'; + $encoding = get_db_encoding $version, $cluster, $maintenance_db; if ($version <= '8.3') { ($old_lc_ctype, $old_lc_collate) = get_cluster_locales $version, $cluster; } else { - ($old_lc_ctype, $old_lc_collate) = get_db_locales $version, $cluster, 'template1'; + ($old_lc_ctype, $old_lc_collate) = get_db_locales $version, $cluster, $maintenance_db; } unless ($encoding && $old_lc_ctype && $old_lc_collate) { error 'could not get cluster locales'; @@ -267,13 +281,14 @@ 'k|link' => \$link, 'rename=s' => \$newcluster, 'old-bindir=s' => \$old_bindir, + 'maintenance-db=s' => \$maintenance_db, ) or exit 1; $method eq 'dump' or $method eq 'upgrade' or error 'method must be "dump" or "upgrade"'; $link and $method eq 'dump' and error 'cannot use --link with --method=dump'; # untaint -($newversion) = $newversion =~ /^(\d+\.\d+)$/; +($newversion) = $newversion =~ /^(\d+\.?\d+)$/; ($locale) = $locale =~ /^([\w@._-]+)$/ if $locale; ($lc_collate) = $lc_collate =~ /^([\w@._-]+)$/ if $lc_collate; ($lc_ctype) = $lc_ctype =~ /^([\w@._-]+)$/ if $lc_ctype; @@ -283,13 +298,14 @@ ($lc_time) = $lc_time =~ /^([\w@._-]+)$/ if $lc_time; ($logfile) = $logfile =~ /^([^\n]+)$/ if $logfile; ($old_bindir) = $old_bindir =~ /^(\/.*)$/ if $old_bindir; +($maintenance_db) = $maintenance_db =~ /^([\w-]+)$/ if $maintenance_db; if ($#ARGV < 1) { print "Usage: $0 [OPTIONS] []\n"; exit 1; } -($version) = $ARGV[0] =~ /^(\d+\.\d+)$/; +($version) = $ARGV[0] =~ /^(\d+\.?\d+)$/; ($cluster) = $ARGV[1] =~ /^([-.\w]+)$/; $newcluster ||= $cluster; # use old cluster name by default ($newcluster) = $newcluster =~ /^([-.\w]+)$/; @@ -308,6 +324,8 @@ error "target cluster $newversion/$newcluster already exists"; } +my $oldcontrol = get_cluster_controldata ($version, $cluster); + my $oldpsql = get_program_path 'psql', $version; my $oldsocket = get_cluster_socketdir $version, $cluster; my $owner = getpwuid $info{'owneruid'}; @@ -319,8 +337,7 @@ if ($info{'running'}) { get_encoding $version, $cluster; print "Stopping old cluster...\n"; - my @argv = ('pg_ctlcluster', $version, $cluster, 'stop', '--'); - push @argv, ('-t', '5') if $version >= '8.4'; + my @argv = ('pg_ctlcluster', $version, $cluster, 'stop'); error "Could not stop old cluster" if system @argv; } @@ -340,8 +357,7 @@ if ($method eq 'upgrade') { print "Stopping old cluster...\n"; - @argv = ('pg_ctlcluster', $version, $cluster, 'stop', '--'); - push @argv, ('-t', '5') if $version >= '8.4'; + @argv = ('pg_ctlcluster', $version, $cluster, 'stop'); error "Could not stop old cluster" if system @argv; } } @@ -367,7 +383,9 @@ push @argv, ('--lc-numeric', $lc_numeric) if $lc_numeric; push @argv, ('--lc-time', $lc_time) if $lc_time; delete $ENV{'LC_ALL'}; +push @argv, ('--', '--data-checksums') if $oldcontrol->{'Data page checksum version'}; # 0 = off error "Could not create target cluster" if system @argv; +print "\n"; %newinfo = cluster_info($newversion, $newcluster); @@ -414,7 +432,7 @@ exit 0; } wait; - if ($?) { + if ($? > 0) { print STDERR "Error during running upgrade hooks, removing new cluster\n"; system 'pg_dropcluster', '--stop', $newversion, $newcluster; exit 1; @@ -431,18 +449,16 @@ my $newsocket = get_cluster_socketdir $newversion, $newcluster; if ($method eq 'dump') { - # get list of databases, owners, and allowed connections + # get list of databases (value = datallowconn) my %databases; open F, '-|', $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, - '-F|', '-d', 'template1', '-Atc', - 'SELECT datname, datallowconn, pg_catalog.pg_encoding_to_char(encoding), usename FROM pg_database, pg_user WHERE datdba = usesysid' or + '-F|', '-d', $maintenance_db, '-AXtc', + 'SELECT datname, datallowconn FROM pg_database' or error 'Could not get pg_database list'; while () { chomp; - my ($n, $a, $e, $o) = split '\|'; - ($o) = $o =~ /^(.*)$/; # untaint - ($e) = $e =~ /^([\w_]+)$/; # untaint - $databases{$n} = [$a eq 't', $o, $e]; + my ($n, $a) = split '\|'; + $databases{$n} = ($a eq 't'); } close F; error 'could not get list of databases' if $?; @@ -451,10 +467,10 @@ for my $db (keys %databases) { next if $db eq 'template0'; - unless (${$databases{$db}}[0]) { + unless ($databases{$db}) { print "Temporarily enabling access to database $db\n"; - (system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-q', - '-d', 'template1', '-c', + (system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-qX', + '-d', $maintenance_db, '-c', "BEGIN READ WRITE; UPDATE pg_database SET datallowconn = 't' WHERE datname = '$db'; COMMIT") == 0 or error 'Could not enable access to database'; } @@ -477,7 +493,7 @@ # create global objects in target cluster open SINK, '|-', $psql, '-h', $newsocket, '-p', $newinfo{'port'}, - '-q', '-d', 'template1' or + '-qX', '-d', $maintenance_db or error 'Could not execute psql for new cluster'; # ensure that we can upgrade tables for DBs with default read-only @@ -498,14 +514,14 @@ # starting from 9.0, replace() works on strings; for earlier versions it # works on bytea if ($version >= '9.0') { - (system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-q', '-d', + (system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-qX', '-d', $db, '-c', "BEGIN READ WRITE; \ UPDATE pg_proc SET probin = replace(\ replace(probin, '/usr/lib/postgresql/lib', '\$libdir'), \ '/usr/lib/postgresql/$version/lib', '\$libdir'); COMMIT") == 0 or error 'Could not fix library paths'; } else { - (system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-q', '-d', + (system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-qX', '-d', $db, '-c', "BEGIN READ WRITE; \ UPDATE pg_proc SET probin = decode(replace(\ replace(encode(probin, 'escape'), '/usr/lib/postgresql/lib', '\$libdir'), \ @@ -542,25 +558,25 @@ # clean up print 'Analyzing database ', $db, "...\n"; - (system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-q', + (system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-qX', '-d', $db, '-c', 'ANALYZE') == 0 or error 'Could not ANALYZE database'; - unless (${$databases{$db}}[0]) { - print "Disabling access to database $db\n"; - (system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-q', - '-d', 'template1', '-c', + unless ($databases{$db}) { + print "Disabling access to database $db again\n"; + (system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-qX', + '-d', $maintenance_db, '-c', "BEGIN READ WRITE; UPDATE pg_database SET datallowconn = 'f' where datname = '$db'; COMMIT") == 0 or error 'Could not disable access to database in old cluster'; - (system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-q', - '-d', 'template1', '-c', + (system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-qX', + '-d', $maintenance_db, '-c', "BEGIN READ WRITE; UPDATE pg_database SET datallowconn = 'f' where datname = '$db'; COMMIT") == 0 or error 'Could not disable access to database in new cluster'; } } # reset owner specific override for default read-only transactions - (system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-q', 'template1', '-c', + (system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-qX', $maintenance_db, '-c', "BEGIN READ WRITE; ALTER USER $owner RESET default_transaction_read_only; COMMIT;\n") == 0 or error 'Could not reset default_transaction_read_only value for superuser'; } else { @@ -573,11 +589,15 @@ my @argv = ($pg_upgrade, '-b', ($old_bindir || "$PgCommon::binroot$version/bin"), '-B', "$PgCommon::binroot$newversion/bin", - '-d', $info{'pgdata'}, - '-D', $newinfo{'pgdata'}, '-p', $info{'port'}, '-P', $newinfo{'port'}, ); + if ($version <= 9.1) { + push @argv, '-d', $info{pgdata}, '-o', "-D $info{configdir}"; # -o and -D configdir require $newversion >= 9.2 + } else { + push @argv, '-d', $info{configdir}; + } + push @argv, '-D', $newinfo{configdir}; push @argv, "--link" if $link; # Make a directory for pg_upgrade to store its reports and log @@ -585,25 +605,10 @@ my $logdir = tempdir("/var/log/postgresql/pg_upgradecluster-$version-$newversion-$newcluster.XXXX"); chdir $logdir; - # pg_upgrade doesn't support separate configuration and data - # directories, so we must fix this up temporarily. (In 9.2+, - # this could be done with the pg_upgrade -o/-O options (see - # man page), but we want to support some earlier versions as - # well for a while.) - foreach my $file ('postgresql.conf', 'pg_hba.conf', 'pg_ident.conf') { - -l "$info{pgdata}/$file" or - symlink("$info{configdir}/$file", "$info{pgdata}/$file") or - error "could not create symlink $info{pgdata}/$file"; - -l "$newinfo{pgdata}/$file" or - symlink("$newinfo{configdir}/$file", "$newinfo{pgdata}/$file") or - error "could not create symlink $newinfo{pgdata}/$file"; - } # Run pg_upgrade. + print "@argv\n"; my $status = system @argv; - # And remove the temporary configuration files again. - foreach my $file ('postgresql.conf', 'pg_hba.conf', 'pg_ident.conf') { - unlink($newinfo{'pgdata'}."/$file"); - } + # Remove the PID file of the old cluster (normally removed by # pg_ctlcluster, but not by pg_upgrade). unlink "/var/run/postgresql/$version-$cluster.pid"; @@ -725,9 +730,10 @@ print "Success. Please check that the upgraded cluster works. If it does, you can remove the old cluster with + pg_dropcluster $version $cluster\n\n"; - pg_dropcluster $version $cluster -" +system 'pg_lsclusters', $version, $cluster; +system 'pg_lsclusters', $newversion, $newcluster; __END__ @@ -742,9 +748,11 @@ =head1 DESCRIPTION B upgrades an existing PostgreSQL server cluster (i. e. a -collection of databases served by a B instance) to a new version +collection of databases served by a B instance) to a new version specified by I (default: latest available version). The -configuration files of the old version are copied to the new cluster. +configuration files of the old version are copied to the new cluster and +adjusted for the new version. The new cluster is set up to use data page +checksums if the old cluster uses them. The cluster of the old version will be configured to use a previously unused port since the upgraded one will use the original port. The old cluster is not @@ -803,14 +811,18 @@ cluster. This option is merely passed on to pg_upgrade. See L for details. -=item B<--rename> I +=item B<--rename=>I Use a different name for the upgraded cluster. -=item B<--old-bindir> I +=item B<--old-bindir=>I Passed to B. +=item B<--maintenance-db=>I + +Database to connect to for maintenance queries. The default is B. + =back =head1 HOOK SCRIPTS @@ -834,7 +846,7 @@ =item B A virgin cluster of version I has been created, i. e. this new -cluster will already have B, but no user databases. Please note that +cluster will already have B and B, but no user databases. Please note that you should not create tables in this phase, since they will be overwritten by the dump/restore or B operation. diff -Nru postgresql-common-173+ppa1/pg_virtualenv postgresql-common-190~ubuntu16.04.1/pg_virtualenv --- postgresql-common-173+ppa1/pg_virtualenv 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_virtualenv 2018-01-29 10:52:31.000000000 +0000 @@ -4,7 +4,7 @@ # This does not interfere with existing clusters. # # (C) 2005-2012 Martin Pitt -# (C) 2012-2015 Christoph Berg +# (C) 2012-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -78,7 +78,11 @@ done if [ -z "$PG_VERSIONS" ]; then # use latest version - d=$(ls $PGBINROOT*/bin/pg_ctl | tail -1) + d=$(ls -v $PGBINROOT*/bin/pg_ctl 2> /dev/null | tail -1) + if [ -z "$d" ]; then + echo "Could not determine PostgreSQL version, are any PostgreSQL server packages installed?" >&2 + exit 2 + fi dir=${d%%/bin/pg_ctl} PG_VERSIONS="${dir#$PGBINROOT}" fi @@ -114,10 +118,8 @@ cleanup () { set +e for v in $PG_VERSIONS; do - if [ ! -f $PG_CLUSTER_CONF_ROOT/$v/regress/.by_pg_virtualenv ]; then - echo "BUG: Cluster $v/regress was not created by me (PGSYSCONFDIR=${PGSYSCONFDIR:-}, PG_CLUSTER_CONF_ROOT=${PG_CLUSTER_CONF_ROOT:-})" >&2 - continue - fi + # don't drop existing clusters named "regress" + [ -f $PG_CLUSTER_CONF_ROOT/$v/regress/.by_pg_virtualenv ] || continue echo "Dropping cluster $v/regress ..." pg_ctlcluster --mode immediate $v regress stop done @@ -148,10 +150,8 @@ mv -f $pg_service.pg_virtualenv-save.$$ $pg_service fi for v in $PG_VERSIONS; do - if [ ! -f /etc/postgresql/$v/regress/.by_pg_virtualenv ]; then - echo "BUG: Cluster $v/regress was not created by me (PGSYSCONFDIR=${PGSYSCONFDIR:-}, PG_CLUSTER_CONF_ROOT=${PG_CLUSTER_CONF_ROOT:-})" >&2 - continue - fi + # don't drop existing clusters named "regress" + [ -f /etc/postgresql/$v/regress/.by_pg_virtualenv ] || continue echo "Dropping cluster $v/regress ..." rm -f /etc/postgresql/$v/regress/.by_pg_virtualenv pg_ctlcluster --mode immediate $v regress stop @@ -186,11 +186,10 @@ ${PGPORT:+-p "$PGPORT"} \ ${NONROOT:+-d "$WORKDIR/data/$v/regress"} \ ${NONROOT:+-l "$WORKDIR/log/postgresql-$v-regress.log"} \ - ${CREATE_OPTS:-} "${PGCONF_OPTS[@]}" $v regress -- \ + ${CREATE_OPTS:-} --pgoption fsync=off "${PGCONF_OPTS[@]}" --start $v regress -- \ --username="$PGUSER" --pwfile="$PWFILE" $NOSYNC ${INITDB_OPTS:-} # in fakeroot, the username will likely default to "postgres" otherwise echo "This is a temporary throw-away cluster" > ${PG_CLUSTER_CONF_ROOT:-/etc/postgresql}/$v/regress/.by_pg_virtualenv - pg_ctlcluster -o '-F' $v regress start ) port=$(pg_conftool -s $v regress show port) @@ -218,6 +217,7 @@ esac # run program +echo "$@" || EXIT="$?" if [ ${EXIT:-0} -gt 0 ]; then for log in ${LOGDIR:-/var/log/postgresql}/*.log; do diff -Nru postgresql-common-173+ppa1/pg_wrapper postgresql-common-190~ubuntu16.04.1/pg_wrapper --- postgresql-common-173+ppa1/pg_wrapper 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/pg_wrapper 2018-01-12 14:08:46.000000000 +0000 @@ -1,10 +1,10 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # Call a PostgreSQL client program with the version, cluster and default # database specified in ~/.postgresqlrc or # /etc/postgresql-common/user_clusters. # # (C) 2005-2009 Martin Pitt -# (C) 2013-2014 Christoph Berg +# (C) 2013-2017 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,23 +16,24 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. +use warnings; use strict; use POSIX; use PgCommon; -my ($version, $cluster, $db, $port, $host); +my ($version, $cluster); +my $explicit_host = exists $ENV{PGHOST}; +my $explicit_port = exists $ENV{PGPORT}; +my $explicit_service = exists $ENV{PGSERVICE}; -$host = $ENV{'PGHOST'}; - -# Check for PGCLUSTER in %ENV -if (defined $ENV{'PGCLUSTER'}) { +# Evaluate PGCLUSTER (unless PGHOST is set as well) +if (exists $ENV{'PGCLUSTER'} and not $explicit_host) { ($version, $cluster) = split ('/', $ENV{'PGCLUSTER'}, 2); - error 'Invalid version specified with $PGCLUSTER' unless version_exists $version; + error "Invalid version $version specified in PGCLUSTER" unless version_exists $version; error 'No cluster specified with $PGCLUSTER' unless $cluster; } -# Check for --cluster argument and filter it out, and check if --port is specified -my $port_specified = exists $ENV{'PGPORT'}; +# Check for --cluster argument and filter it out for (my $i = 0; $i <= $#ARGV; ++$i) { last if $ARGV[$i] eq '--'; @@ -40,78 +41,87 @@ error '--cluster option needs an argument (/)' if ($i >= $#ARGV); ($version, $cluster) = split ('/', $ARGV[$i+1], 2); - $host = undef; # --cluster overrides $PGHOST env var - error 'Invalid version specified with --cluster' unless version_exists $version; + error "Invalid version $version specified with --cluster" unless version_exists $version; error 'No cluster specified with --cluster' unless $cluster; splice @ARGV, $i, 2; last; - } elsif ($ARGV[$i] =~ /^--cluster=(\d+\.\d)\/(.+)/) { + } elsif ($ARGV[$i] =~ /^--cluster=(\d+\.?\d)\/(.+)/) { ($version, $cluster) = ($1, $2); - $host = undef; # --cluster overrides $PGHOST env var - error 'Invalid version specified with --cluster' unless version_exists $version; + error "Invalid version $version specified with --cluster" unless version_exists $version; error 'No cluster specified with --cluster' unless $cluster; splice @ARGV, $i, 1; last; } - - $port_specified = 1 if $ARGV[$i] =~ /^--port\b/ || $ARGV[$i] =~ /^-\w*p\w*\d*$/; - $host = '.from.commandline' if $ARGV[$i] =~ /^--host\b/ || $ARGV[$i] =~ /^-\w*h\w*$/; + # --host or -h on command line, drop info from PGCLUSTER + if ($ARGV[$i] =~ /^--host\b/ || $ARGV[$i] =~ /^-\w*h\w*$/) { + ($version, $cluster) = (undef, undef); + $explicit_host = 1; + delete $ENV{PGCLUSTER}; + } + # --port or -p on command line + if ($ARGV[$i] =~ /^--port\b/ || $ARGV[$i] =~ /^-\w*p\w*$/) { + $explicit_port = 1; + } + # "service=" in connection string + if ($ARGV[$i] =~ /\bservice=/) { + $explicit_service = 1; + } } -# Determine $version, $cluster, $db, $port from map files -($version, $cluster, $db) = user_cluster_map() unless $cluster; +my ($db); + +# if we don't have a cluster, and no specific host was given, consult postgresqlrc +# or fall back to default port cluster (on 5432), or undef otherwise +($version, $cluster, $db) = user_cluster_map() unless ($cluster or $explicit_host); -# check if we have a network cluster -if (!$host && $cluster && !cluster_exists $version, $cluster) { +my ($host, $port); + +if ($cluster) { + # check if we have a network cluster (N.N/the.host.name:port) if ($cluster =~ /^(\S+):(\d*)$/) { $host = $1; $port = $2 || 5432; + } elsif (not cluster_exists($version, $cluster)) { + # a specific cluster was requested, error out because it doesn't exist + error "Cluster $version $cluster does not exist"; } else { - error 'Specified cluster does not exist locally and does not specify a remote cluster'; - } -} - -if (!$host && $cluster) { - $port = get_cluster_port($version, $cluster); - - unless ($ENV{'PGHOST'}) { - # default to cluster specific Unix socket directory - $ENV{'PGHOST'} = get_cluster_socketdir $version, $cluster; + $host = get_cluster_socketdir ($version, $cluster); + $port = get_cluster_port($version, $cluster); } + # set PGCLUSTER variable for information + $ENV{PGCLUSTER} = "$version/$cluster"; } -$ENV{'PGSYSCONFDIR'} = '/etc/postgresql-common' if !$ENV{'PGSYSCONFDIR'}; +# setup environment +$ENV{'PGSYSCONFDIR'} //= '/etc/postgresql-common'; +$ENV{'PGHOST'} = $host if ($host); $ENV{'PGPORT'} = $port if $port && !$ENV{'PGPORT'}; $ENV{'PGDATABASE'} = $db if $db && !$ENV{'PGDATABASE'}; -$ENV{'PGHOST'} = $host if $host && $host ne '.from.commandline'; -# if we only have a port, but no version here, use the latest version -# TODO: this could be improved by better argument parsing and mapping back the -# port to a cluster version/name -if (!$version and $port_specified) { - $version = get_newest_version; +# check under which name we were called +my $cmdname = (split '/', $0)[-1]; + +unless ($version or $explicit_host or $explicit_port or $explicit_service) { + print STDERR "Warning: No existing local cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.\n"; } +# if we have no version yet, use the latest version. We were called as psql, +# pg_archivecleanup, or pg_isready, always use latest version +if (not $version or $cmdname =~ /^(psql|pg_archivecleanup|pg_isready)$/) { + $version = get_newest_version; +} unless ($version) { - if (get_versions) { - error 'No existing local cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.'; - } else { - error 'You must install at least one postgresql-client- package.'; - } + error 'You must install at least one postgresql-client- package'; } +error "PostgreSQL version $version is not installed" unless -d "$PgCommon::binroot$version"; -error 'Invalid PostgreSQL cluster version' unless -d "$PgCommon::binroot$version"; -my $cmdname = (split '/', $0)[-1]; my $cmd; - -# for psql we always want the latest version, as this is backwards compatible -# to every major version that that we support if ($cmdname eq 'pg_wrapper') { - error "pg_wrapper should not be called directly, but through a symlink"; -} elsif ($cmdname =~ /^(psql|pg_archivecleanup|pg_isready)$/) { - $cmd = get_program_path ($cmdname, get_newest_version); + error "pg_wrapper called directly but no program given as argument" + if (@ARGV == 0); + $cmd = shift; # will be unshifted back below } else { $cmd = get_program_path ($cmdname, $version); } @@ -215,7 +225,9 @@ =back -If none of these rules match, B aborts with an error. +If none of these rules match, B does not set any environment +variables and the program called will likely error out with a message like +"could not connect to server: Connection refused". For B, B, and B, B will always use the binary from the newest PostgreSQL version installed, as these are downwards compatible. @@ -226,6 +238,8 @@ =item B<--cluster> IBI +=item B<--cluster> IBIB<:>[I] + I is either the name of a local cluster, or takes the form I:I for a remote cluster. If I is left empty (i. e. you just specify I), it defaults to 5432. diff -Nru postgresql-common-173+ppa1/README.md postgresql-common-190~ubuntu16.04.1/README.md --- postgresql-common-173+ppa1/README.md 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/README.md 2018-01-29 14:11:53.000000000 +0000 @@ -0,0 +1,114 @@ +Multi-Version/Multi-Cluster PostgreSQL architecture +=================================================== +2004, Oliver Elphick, Martin Pitt + +Solving a problem +----------------- + +When a new major version of PostgreSQL is released, it is necessary to dump and +reload the database. The old software must be used for the dump, and the new +software for the reload. + +This was a major problem for RedHat and Debian, because a dump and reload was +not required by every upgrade and by the time the need for a dump is realised, +the old software might have been deleted. Debian had certain rather unreliable +procedures to save the old software and use it to do a dump, but these +procedures often went wrong. RedHat's installation environment is so rigid that +it is not practicable for the RedHat packages to attempt an automatic upgrade. +Debian offered a debconf choice for whether to attempt automatic upgrading; if +it failed or was not allowed, a manual upgrade had to be done, either from a +pre-existing dump or by manual invocation of the postgresql-dump script. + +It is possible to run different versions of PostgreSQL simultaneously, and +indeed to run the same version on separate database clusters simultaneously. To +do so, each postgres instance must listen on a different port, so each client +must specify the correct port. By having two separate versions of the +PostgreSQL packages installed simultaneously, it is simple to do database +upgrades by dumping from the old version and uploading to the new. The +PostgreSQL client wrapper is designed to permit this. + +General Architecture idea +------------------------- + +The Debian packaging has been changed to create a new package for each major +version. The criterion for creating a new package is that initdb is required +when upgrading from the previous version. Thus, there are now source packages +`postgresql-8.1` and `postgresql-8.3` (and similarly for all the binary +packages). + +The legacy postgresql and the other existing binary package names have become +dummy packages depending on one of the versioned equivalents. Their only +purpose is now to ensure a smooth upgrade and to register the existing database +cluster to the new architecture. These packages will be removed from the +archive as soon as the next Debian release after Sarge (Etch) is released. + +Each versioned package installs into `/usr/lib/postgresql/version`. In order +to allow users easily to select the right version and cluster when working, the +`postgresql-common` package provides the `pg_wrapper` program, which reads the +per-user and system wide configuration file and forks the correct executable +with the correct library versions according to those preferences. `/usr/bin` +provides executables soft-linked to `pg_wrapper`. + +This architecture also allows separate database clusters to be maintained for +the use of different groups of users; these clusters need not all be of the +same major version. This allows much greater flexibility for those people who +need to make application software changes consequent on a PostgreSQL upgrade. + +Detailed structure +------------------ + +### Configuration hierarchy + +* `/etc/postgresql-common/user_clusters`: maps users against clusters and + default databases + +* `$HOME/.postgresqlrc`: per-user preferences for default version/cluster and + database; overrides `/etc/postgresql-common/user_clusters` + +* `/etc/postgresql/version/clustername`: cluster-specific configuration files: + + * `postgresql.conf`, `pg_hba.conf`, `pg_ident.conf` + * optionally `start.conf`: startup mode of the cluster: `auto` (start/stop in + init script), `manual` (do not start/stop in init script, but manual + control with `pg_ctlcluster` is possible), `disabled` (`pg_ctlcluster` + is not allowed). + * optionally `pg_ctl.conf`: options to be passed to `pg_ctl`. + * optionally a symbolic link `log` which points to the postgres log file. + Defaults to `/var/log/postgresql/postgresql-version-cluster.conf`. + Explicitly setting `log_directory` and/or `log_filename` in + `postgresql.conf` overrides this. + +### Per-version files and programs + +* `/usr/lib/postgresql/version` +* `/usr/share/postgresql/version` +* `/usr/share/doc/postgresql/postgresql-doc-version`: +version specific program and data files + +### Common programs + +* `/usr/share/postgresql-common/pg_wrapper`: environment chooser and program selector +* `/usr/bin/program`: symbolic links to pg_wrapper, for all client programs +* `/usr/bin/pg_lsclusters`: list all available clusters with their status and configuration +* `/usr/bin/pg_createcluster: wrapper for `initdb`, sets up the necessary configuration structure +* `/usr/bin/pg_ctlcluster`: wrapper for `pg_ctl`, control the cluster postgres server +* `/usr/bin/pg_upgradecluster`: upgrade a cluster to a newer major version +* `/usr/bin/pg_dropcluster`: remove a cluster and its configuration + +### /etc/init.d/postgresql + +This script handles the postgres server processes for each version and all +their clusters. However, most of the actual work is done by the new +`pg_ctlcluster` program. + +### pg_upgradecluster + +This program replaces postgresql-dump (a Debian specific program). + +It is used to migrate a cluster from one major version to another. + +Usage: `pg_upgradecluster [-v newversion] version name [data_dir]` + +`-v`: specifies the version to upgrade to; defaults to the newest available version. + + -- The Debian PostgreSQL maintainers diff -Nru postgresql-common-173+ppa1/rpm/init-functions-compat postgresql-common-190~ubuntu16.04.1/rpm/init-functions-compat --- postgresql-common-173+ppa1/rpm/init-functions-compat 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/rpm/init-functions-compat 2018-01-12 14:08:47.000000000 +0000 @@ -8,4 +8,5 @@ function_exists log_progress_msg || log_progress_msg () { echo -n " $1"; } function_exists log_end_msg || log_end_msg () { if [ $1 -eq 0 ]; then echo "."; else echo "failed!"; fi; } # this one exists, but we provide it anyway so we don't need to depend on redhat-lsb-core: +function_exists log_warning_msg || log_warning_msg () { echo "$1"; } function_exists log_failure_msg || log_failure_msg () { echo "$1"; } diff -Nru postgresql-common-173+ppa1/rpm/postgresql-common.spec postgresql-common-190~ubuntu16.04.1/rpm/postgresql-common.spec --- postgresql-common-173+ppa1/rpm/postgresql-common.spec 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/rpm/postgresql-common.spec 2018-01-31 12:29:59.000000000 +0000 @@ -1,5 +1,5 @@ Name: postgresql-common -Version: 160 +Version: %{version} Release: 1%{?dist} BuildArch: noarch Summary: PostgreSQL database-cluster manager @@ -8,6 +8,7 @@ License: GPLv2+ URL: https://packages.debian.org/sid/%{name} Source0: http://ftp.debian.org/debian/pool/main/p/%{name}/%{name}_%{version}.tar.xz +Requires: postgresql-client-common %description The postgresql-common package provides a structure under which @@ -67,7 +68,7 @@ mkdir -p $mandir for f in $file; do # expand wildcards cp $f $mandir - echo "%doc %{_mandir}/man$section/$f.gz" >> files-$pkg + echo "%doc %{_mandir}/man$section/$(basename $f).gz" >> files-$pkg done done < $manpages done @@ -81,7 +82,7 @@ sed -i -e 's/#redhat# //' \ %{buildroot}/usr/bin/pg_config \ %{buildroot}/usr/bin/pg_virtualenv \ - %{buildroot}/usr/share/postgresql-common/PgCommon.pm \ + %{buildroot}/usr/share/perl5/PgCommon.pm \ %{buildroot}/usr/share/postgresql-common/init.d-functions # install init script mkdir -p %{buildroot}/etc/init.d %{buildroot}/etc/logrotate.d @@ -90,7 +91,14 @@ cp rpm/init-functions-compat %{buildroot}/usr/share/postgresql-common # ssl defaults to 'off' here because we don't have pregenerated snakeoil certs sed -e 's/__SSL__/off/' createcluster.conf > %{buildroot}/etc/postgresql-common/createcluster.conf -cp debian/logrotate.template %{buildroot}/etc/logrotate.d/postgresql-common +cp debian/postgresql-common.logrotate %{buildroot}/etc/logrotate.d/postgresql-common + +%if 0%{?rhel} >= 7 +# Prepare systemd unit files, but only for RHEL/CentOS 7 and above... +pushd systemd +DESTDIR=%{buildroot} gmake install +popd +%endif %files -n postgresql-common -f files-postgresql-common %attr(0755, root, root) %config /etc/init.d/postgresql @@ -99,6 +107,12 @@ %config /etc/postgresql-common/createcluster.conf %config /etc/logrotate.d/postgresql-common +%if 0%{?rhel} >= 7 +%config /lib/systemd/system/postgresql.service +%config /lib/systemd/system/postgresql@.service +%config /lib/systemd/system-generators/postgresql-generator +%endif + %files -n postgresql-client-common -f files-postgresql-client-common %files -n postgresql-server-dev-all -f files-postgresql-server-dev-all @@ -128,6 +142,10 @@ update-alternatives --remove pgsql-ecpg /usr/share/postgresql-common/pg_wrapper %changelog +* Fri Dec 09 2016 Bernd Helmle 177-1 +- New upstream release 177 +* Fri Jun 03 2016 Bernd Helmle 174-2 +- Fix package dependencies and systemd integration * Thu Aug 7 2014 Christoph Berg 160-1 - Omit the LD_PRELOAD logic in pg_wrapper * Thu Jun 5 2014 Christoph Berg 158-1 diff -Nru postgresql-common-173+ppa1/run-upgrade-scripts postgresql-common-190~ubuntu16.04.1/run-upgrade-scripts --- postgresql-common-173+ppa1/run-upgrade-scripts 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/run-upgrade-scripts 2018-01-12 14:08:47.000000000 +0000 @@ -51,17 +51,17 @@ $< = $> = (stat (PgCommon::cluster_data_directory $version, $cluster))[4]; # temporarily enable connections - my $conallow = `/usr/bin/psql --cluster '$version/$cluster' template1 -Atqc "select datallowconn from pg_database where datname='$db'"`; + my $conallow = `psql --cluster '$version/$cluster' template1 -AXtqc "select datallowconn from pg_database where datname='$db'"`; chomp $conallow; if ($conallow eq 'f') { - system "/usr/bin/psql --cluster '$version/$cluster' template1 -Atqc \"update pg_database set datallowconn = 't' where datname='$db'\""; + system "psql --cluster '$version/$cluster' template1 -AXtqc \"update pg_database set datallowconn = 't' where datname='$db'\""; } - my $out = `ON_ERROR_STOP=1 /usr/bin/psql --cluster '$version/$cluster' -f '$script' '$db' 2>&1`; + my $out = `ON_ERROR_STOP=1 psql --cluster '$version/$cluster' -f '$script' '$db' 2>&1`; # reset allowconn if ($conallow eq 'f') { - system "/usr/bin/psql --cluster '$version/$cluster' template1 -Atqc \"update pg_database set datallowconn = 'f' where datname='$db'\""; + system "psql --cluster '$version/$cluster' template1 -AXtqc \"update pg_database set datallowconn = 'f' where datname='$db'\""; } print "[FAIL]\n$out" if $?; diff -Nru postgresql-common-173+ppa1/systemd/postgresql-generator postgresql-common-190~ubuntu16.04.1/systemd/postgresql-generator --- postgresql-common-173+ppa1/systemd/postgresql-generator 2015-12-19 14:06:19.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/systemd/postgresql-generator 2018-01-12 14:08:47.000000000 +0000 @@ -13,7 +13,9 @@ mkdir -p "$wantdir" for conf in /etc/postgresql/*/*/postgresql.conf; do - test -e "$conf" || continue + # abort loop if glob was not expanded (but accept dead symlinks) + if ! test -e "$conf" && ! test -L "$conf"; then continue; fi + dir="${conf%/*}" # evaluate start.conf diff -Nru postgresql-common-173+ppa1/systemd/postgresql@.service postgresql-common-190~ubuntu16.04.1/systemd/postgresql@.service --- postgresql-common-173+ppa1/systemd/postgresql@.service 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/systemd/postgresql@.service 2018-01-31 12:29:59.000000000 +0000 @@ -12,9 +12,13 @@ [Service] Type=forking -# @: use "postgresql@%i" as process name -ExecStart=@/usr/bin/pg_ctlcluster postgresql@%i --skip-systemctl-redirect %i start +# -: ignore startup failure (recovery might take arbitrarily long) +# the actual pg_ctl timeout is configured in pg_ctl.conf +ExecStart=-/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i start +# 0 is the same as infinity, but "infinity" needs systemd 229 +TimeoutStartSec=0 ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast %i stop +TimeoutStopSec=1h ExecReload=/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i reload PIDFile=/var/run/postgresql/%i.pid SyslogIdentifier=postgresql@%i diff -Nru postgresql-common-173+ppa1/t/001_packages.t postgresql-common-190~ubuntu16.04.1/t/001_packages.t --- postgresql-common-173+ppa1/t/001_packages.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/001_packages.t 2018-01-12 14:08:47.000000000 +0000 @@ -6,7 +6,7 @@ use TestLib; use POSIX qw/setlocale LC_ALL LC_MESSAGES/; -use Test::More tests => $PgCommon::rpm ? (8*@MAJORS) : (12 + 7*@MAJORS); +use Test::More tests => $PgCommon::rpm ? (8*@MAJORS) : (11 + 7*@MAJORS); note "PostgreSQL versions installed: @MAJORS\n"; @@ -38,11 +38,13 @@ ok ((deb_installed "postgresql-plperl-$v"), "postgresql-plperl-$v installed"); ok ((deb_installed "postgresql-pltcl-$v"), "postgresql-pltcl-$v installed"); ok ((deb_installed "postgresql-server-dev-$v"), "postgresql-server-dev-$v installed"); + SKIP: { + skip "No postgresql-contrib-$v package for version $v", 1 if ($v >= 10); ok ((deb_installed "postgresql-contrib-$v"), "postgresql-contrib-$v installed"); + } } ok ((deb_installed 'libecpg-dev'), 'libecpg-dev installed'); -ok ((deb_installed 'logrotate'), 'logrotate installed'); ok ((deb_installed 'procps'), 'procps installed'); ok ((deb_installed 'netcat-openbsd'), 'netcat-openbsd installed'); diff -Nru postgresql-common-173+ppa1/t/002_existing_clusters.t postgresql-common-190~ubuntu16.04.1/t/002_existing_clusters.t --- postgresql-common-173+ppa1/t/002_existing_clusters.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/002_existing_clusters.t 2018-01-12 14:08:47.000000000 +0000 @@ -1,7 +1,7 @@ -# Check that no clusters and postmasters are present for this test. +# Check that no clusters and postgres processes are present for this test. use strict; -use Test::More tests => 10; +use Test::More tests => 8; use lib 't'; use TestLib; diff -Nru postgresql-common-173+ppa1/t/003_package_checks.t postgresql-common-190~ubuntu16.04.1/t/003_package_checks.t --- postgresql-common-173+ppa1/t/003_package_checks.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/003_package_checks.t 2018-01-12 14:08:47.000000000 +0000 @@ -6,7 +6,7 @@ use TestLib; use PgCommon qw/$binroot/; -use Test::More tests => (@MAJORS) * 4 + 1; +use Test::More tests => (@MAJORS) * 4; # Debian/Ubuntu packages are linked against libedit. If your psql binaries are # linked against libreadline, set PG_READLINE=1 when running this testsuite. @@ -20,18 +20,4 @@ "psql is not linked against $avoid_lib"); } -my $lrversion = package_version ('logrotate'); -my $is_logrotate_38 = version_ge ($lrversion, '3.8'); -note "logrotate version $lrversion is " . ($is_logrotate_38 ? 'greater' : 'smaller') . " than 3.8"; -my $f = "/etc/logrotate.d/postgresql-common"; -open F, $f; -undef $/; # slurp mode -my $t = ; -close F; -if ($is_logrotate_38) { - like $t, qr/\bsu /, "$f contains su directive"; -} else { - unlike $t, qr/\bsu /, "$f does not contain su directive"; -} - # vim: filetype=perl diff -Nru postgresql-common-173+ppa1/t/005_PgCommon.t postgresql-common-190~ubuntu16.04.1/t/005_PgCommon.t --- postgresql-common-173+ppa1/t/005_PgCommon.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/005_PgCommon.t 2018-01-29 10:52:31.000000000 +0000 @@ -94,6 +94,7 @@ mkdir "$tdir/8.4"; mkdir "$tdir/8.4/test" or die "mkdir: $!"; +mkdir "$tdir/conf.d" or die "mkdir: $!"; my $c = "$tdir/8.4/test/foo.conf"; open F, ">$c" or die "Could not create $c: $!"; print F <$tdir/conf.d/sub.conf" or die "Could not create $tdir/conf.d/sub.conf: $!"; +print F <$tdir/relative.conf" or die "Could not create $tdir/relative.conf: $!"; +print F <$tdir/absolute.conf" or die "Could not create $tdir/absolute.conf: $!"; +print F < '', 'quotestr' => "test ! -f '/tmp/%f' && echo 'yes'", 'condint' => 42, + 'subvalue' => 1, + 'relativevalue' => 1, + 'absolutevalue' => 1, }, 'read_conf_file() parsing with include directives'); @@ -171,6 +196,7 @@ PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'strval', 'Howdy'; PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'newval', 'NEW!'; PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'testpath', '/bin/new'; +PgCommon::set_conf_value '8.4', 'test', 'foo.conf', 'include_dir', 'conf.d'; open F, "$c"; my $conf; @@ -194,6 +220,7 @@ testpath = '/bin/new' QuoteStr = 'test ! -f \\'/tmp/%f\\' && echo \\'yes\\'' newval = 'NEW!' +include_dir = 'conf.d' EOF # test disable_conf_value() @@ -223,6 +250,7 @@ #testpath = '/bin/new' #now 2 comments QuoteStr = 'test ! -f \\'/tmp/%f\\' && echo \\'yes\\'' newval = 'NEW!' +include_dir = 'conf.d' EOF # test replace_conf_value() @@ -253,6 +281,7 @@ #testpath = '/bin/new' #now 2 comments QuoteStr = 'test ! -f \\'/tmp/%f\\' && echo \\'yes\\'' newval = 'NEW!' +include_dir = 'conf.d' EOF # vim: filetype=perl diff -Nru postgresql-common-173+ppa1/t/006_next_free_port.t postgresql-common-190~ubuntu16.04.1/t/006_next_free_port.t --- postgresql-common-173+ppa1/t/006_next_free_port.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/006_next_free_port.t 2018-01-31 12:29:59.000000000 +0000 @@ -19,27 +19,26 @@ # no ports open is (next_free_port, 5432, 'next_free_port is 5432'); -exit if ($PgCommon::rpm); # RedHat doesn't provide nc, stop here - # open a localhost ipv4 socket -push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -q0 -l 127.0.0.1 5432)); +push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -l 127.0.0.1 5432)); usleep 2*$delay; is (next_free_port, 5433, 'next_free_port detects localhost ipv4 socket'); # open a wildcard ipv4 socket -push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -q0 -l 5433)); +push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -l 5433)); usleep $delay; is (next_free_port, 5434, 'next_free_port detects wildcard ipv4 socket'); SKIP: { $^V =~ /^v(\d+\.\d+)/; # parse perl version skip "perl <= 5.10 does not have proper IPv6 support", 2 if ($1 <= 5.10); + skip "skipping IPv6 tests", 2 if ($ENV{SKIP_IPV6}); # open a localhost ipv6 socket - push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -q0 -l ::1 5434)); + push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -l ::1 5434)); usleep $delay; is (next_free_port, 5435, 'next_free_port detects localhost ipv6 socket'); # open a wildcard ipv6 socket - push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -q0 -l 5435)); + push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -l 5435)); usleep $delay; is (next_free_port, 5436, 'next_free_port detects wildcard ipv6 socket'); } diff -Nru postgresql-common-173+ppa1/t/007_pg_conftool.t postgresql-common-190~ubuntu16.04.1/t/007_pg_conftool.t --- postgresql-common-173+ppa1/t/007_pg_conftool.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/007_pg_conftool.t 2018-01-12 14:08:47.000000000 +0000 @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 33; +use Test::More tests => 41; use File::Temp qw/tempdir/; use lib '.'; use PgCommon; @@ -13,7 +13,19 @@ my $tdir = tempdir (CLEANUP => 1); $ENV{'PG_CLUSTER_CONF_ROOT'} = $tdir; +open F, "> $tdir/different.conf"; +print F "a = '5'\n"; +print F "#b = '6'\n"; +close F; + +note 'test without cluster'; +is_program_out 0, "pg_conftool show all", 1, "Error: No default cluster found\n"; +is_program_out 0, "pg_conftool foo.conf show all", 1, "Error: No default cluster found\n"; +is_program_out 0, "pg_conftool $tdir/different.conf show all", 0, "a = 5\n"; +is_program_out 0, "pg_conftool 9.7 main show all", 1, "Error: Cluster 9.7 main does not exist\n"; + my $version = $MAJORS[-1]; +die "Tests past this point need PostgreSQL installed" unless ($version); mkdir "$tdir/$version"; mkdir "$tdir/$version/main"; @@ -27,11 +39,6 @@ print F "#b = '4'\n"; close F; -open F, "> $tdir/different.conf"; -print F "a = '5'\n"; -print F "#b = '6'\n"; -close F; - sub pgconf { undef $/; open F, "$tdir/$version/main/postgresql.conf"; diff -Nru postgresql-common-173+ppa1/t/015_start_stop.t postgresql-common-190~ubuntu16.04.1/t/015_start_stop.t --- postgresql-common-173+ppa1/t/015_start_stop.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/015_start_stop.t 2018-01-12 14:08:47.000000000 +0000 @@ -4,7 +4,7 @@ use TestLib; use PgCommon; -use Test::More tests => 73 * ($#MAJORS+1); +use Test::More tests => 71 * @MAJORS; my $systemd = (-d "/var/run/systemd/system" and not $ENV{_SYSTEMCTL_SKIP_REDIRECT}); note $systemd ? "We are running systemd" : "We are not running systemd"; @@ -70,7 +70,7 @@ # stop postgresql if ($systemd) { program_ok (0, "systemctl stop postgresql"); - sleep 3; # FIXME: systemctl stop postgresql is not yet synchronous (#759725) + sleep 6; # FIXME: systemctl stop postgresql is not yet synchronous (#759725) } else { program_ok (0, "/etc/init.d/postgresql stop"); } diff -Nru postgresql-common-173+ppa1/t/020_create_sql_remove.t postgresql-common-190~ubuntu16.04.1/t/020_create_sql_remove.t --- postgresql-common-173+ppa1/t/020_create_sql_remove.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/020_create_sql_remove.t 2018-01-31 12:29:59.000000000 +0000 @@ -3,6 +3,7 @@ use strict; +use File::Temp qw(tempdir); use POSIX qw/dup2/; use Time::HiRes qw/usleep/; @@ -10,7 +11,7 @@ use TestLib; use PgCommon; -use Test::More tests => 127 * ($#MAJORS+1); +use Test::More tests => 131 * @MAJORS; $ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1; # FIXME: testsuite is hanging otherwise @@ -19,26 +20,35 @@ note "Running tests for $v"; # create cluster - ok ((system "pg_createcluster $v main --start >/dev/null") == 0, - "pg_createcluster $v main"); + my $xlogdir = tempdir("/tmp/$v.xlog.XXXXXX", CLEANUP => 1); + rmdir $xlogdir; # recreated by initdb + ok ((system "pg_createcluster $v main --start -- -X $xlogdir >/dev/null") == 0, + "pg_createcluster $v main"); # -X needs 8.3+ # check that a /var/run/postgresql/ pid file is created - unless ($PgCommon::rpm) { - ok_dir '/var/run/postgresql/', ['.s.PGSQL.5432', '.s.PGSQL.5432.lock', "$v-main.pid", "$v-main.pg_stat_tmp"], + my @contents = ('.s.PGSQL.5432', '.s.PGSQL.5432.lock', "$v-main.pid", "$v-main.pg_stat_tmp"); + pop @contents if ($v < 8.4); # remove pg_stat_tmp + unless ($PgCommon::rpm and $v < 9.4) { + ok_dir '/var/run/postgresql/', [@contents], 'Socket and pid file are in /var/run/postgresql/'; } else { - ok_dir '/var/run/postgresql/', ["$v-main.pid", "$v-main.pg_stat_tmp"], 'Pid File is in /var/run/postgresql/'; + ok_dir '/var/run/postgresql/', [grep {/main/} @contents], 'Pid File is in /var/run/postgresql/'; } - # verify that exactly one postmaster is running - my @pm_pids = pidof (($v >= '8.2') ? 'postgres' : 'postmaster'); - is $#pm_pids, 0, 'Exactly one postmaster process running'; + # check that the xlog/wal symlink was created + my $first_xlog = $v >= 9.0 ? "000000010000000000000001" : "000000010000000000000000"; + ok_dir $xlogdir, [$first_xlog, "archive_status"], + "xlog/wal directory $xlogdir was created"; + + # verify that exactly one postgres master is running + my @pm_pids = pidof ('postgres'); + is $#pm_pids, 0, 'Exactly one postgres master process running'; # check environment my %safe_env = qw/LC_ALL 1 LC_CTYPE 1 LANG 1 PWD 1 PGLOCALEDIR 1 PGSYSCONFDIR 1 PG_GRANDPARENT_PID 1 PG_OOM_ADJUST_FILE 1 PG_OOM_ADJUST_VALUE 1 SHLVL 1 PGDATA 1 _ 1/; - my %env = pid_env $pm_pids[0]; + my %env = pid_env 'postgres', $pm_pids[0]; foreach (keys %env) { - fail "postmaster has unsafe environment variable $_" unless exists $safe_env{$_}; + fail "postgres has unsafe environment variable $_" unless exists $safe_env{$_}; } # activate external_pid_file @@ -52,19 +62,19 @@ is_program_out 0, "pg_ctlcluster $v main restart", 0, '', 'cluster restarts with new environment file'; - @pm_pids = pidof (($v >= '8.2') ? 'postgres' : 'postmaster'); - is $#pm_pids, 0, 'Exactly one postmaster process running'; - %env = pid_env $pm_pids[0]; + @pm_pids = pidof ('postgres'); + is $#pm_pids, 0, 'Exactly one postgres master process running'; + %env = pid_env 'postgres', $pm_pids[0]; is $env{'PGEXTRAVAR1'}, '1', 'correct value of PGEXTRAVAR1 in environment'; is $env{'PGEXTRAVAR2'}, 'foo bar ', 'correct value of PGEXTRAVAR2 in environment'; # Now there should not be an external PID file any more, since we set it # explicitly - unless ($PgCommon::rpm) { - ok_dir '/var/run/postgresql', ['.s.PGSQL.5432', '.s.PGSQL.5432.lock', "$v-main.pg_stat_tmp"], - 'Socket, but not PID file in /var/run/postgresql/'; + unless ($PgCommon::rpm and $v < 9.4) { + ok_dir '/var/run/postgresql', [grep {! /pid/} @contents], + 'Socket and stats dir, but not PID file in /var/run/postgresql/'; } else { - ok_dir '/var/run/postgresql', [], '/var/run/postgresql/ is empty'; + ok_dir '/var/run/postgresql', ["$v-main.pg_stat_tmp"], 'Only stats dir in /var/run/postgresql/'; } # verify that the correct client version is selected @@ -133,10 +143,13 @@ 'restarting cluster with explicitly configured log file'); ok -z $default_log, "default log is not used"; ok !-z $p, "log symlink target is used for startup message"; - my @l = glob ((PgCommon::cluster_data_directory $v, 'main') . "/pg_log/$v#main.log*"); + my $pg_log = $v >= 10 ? 'log' : 'pg_log'; # log directory in PGDATA changed in PG 10 + my @l = glob ((PgCommon::cluster_data_directory $v, 'main') . "/$pg_log/$v#main.log*"); is $#l, 0, 'exactly one log file'; ok (-e $l[0] && ! -z $l[0], 'custom log is actually used'); + SKIP: { skip "no logging_collector in $v", 2 if ($v < 8.3); like_program_out 'postgres', 'pg_lsclusters -h', 0, qr/^$v\s+main.*$v#main.log\n$/; + } # clean up PgCommon::disable_conf_value ($v, 'main', 'postgresql.conf', @@ -144,9 +157,18 @@ PgCommon::disable_conf_value $v, 'main', 'postgresql.conf', 'log_filename', ''; unlink "/etc/postgresql/$v/main/log"; - # verify that the postmaster does not have an associated terminal + # check that log creation does not escalate privileges + program_ok 'root', "pg_ctlcluster $v main stop", 0, 'stopping cluster'; + unlink $default_log; + symlink "/etc/postgres-hack", $default_log; + program_ok 'root', "pg_ctlcluster $v main start", 1, 'starting cluster with rouge /var/log/postgresql symlink fails'; + ok !-f "/etc/postgres-hack", "/etc/postgres-hack was not created"; + unlink $default_log; + program_ok 'root', "pg_ctlcluster $v main start", 0, 'restarting cluster'; + + # verify that processes do not have an associated terminal unlike_program_out 0, 'ps -o tty -U postgres h', 0, qr/tty|pts/, - 'postmaster processes do not have an associated terminal'; + 'postgres processes do not have an associated terminal'; # verify that SSL is enabled (which should work for user postgres in a # default installation) @@ -191,10 +213,15 @@ tel|2 ', 'SQL command output: select -tAx'; + sub create_extension ($) { + return "psql -qc 'CREATE EXTENSION $_[0]' nobodydb" if ($v >= 9.1); + return "createlang $_[0] nobodydb"; + } + # Check PL/Perl untrusted my $fn_cmd = 'CREATE FUNCTION read_file() RETURNS text AS \'open F, \\"/etc/passwd\\"; \\$buf = ; close F; return \\$buf;\' LANGUAGE plperl'; - is ((exec_as 'nobody', 'createlang plperlu nobodydb'), 1, 'createlang plperlu fails for user nobody'); - is_program_out 'postgres', 'createlang plperlu nobodydb', 0, '', 'createlang plperlu succeeds for user postgres'; + is ((exec_as 'nobody', create_extension('plperlu')), 1, 'CREATE EXTENSION plperlu fails for user nobody'); + is_program_out 'postgres', create_extension('plperlu'), 0, '', 'CREATE EXTENSION plperlu succeeds for user postgres'; is ((exec_as 'nobody', "psql nobodydb -qc \"${fn_cmd}u;\""), 1, 'creating PL/PerlU function as user nobody fails'); is ((exec_as 'postgres', "psql nobodydb -qc \"${fn_cmd};\""), 1, 'creating unsafe PL/Perl function as user postgres fails'); is_program_out 'postgres', "psql nobodydb -qc \"${fn_cmd}u;\"", 0, '', 'creating PL/PerlU function as user postgres succeeds'; @@ -203,7 +230,7 @@ # Check PL/Perl trusted my $pluser = ($v >= '8.3') ? 'nobody' : 'postgres'; # pg_pltemplate allows non-superusers to install trusted languages in 8.3+ - is_program_out $pluser, 'createlang plperl nobodydb', 0, '', "createlang plperl succeeds for user $pluser"; + is_program_out $pluser, create_extension('plperl'), 0, '', "CREATE EXTENSION plperl succeeds for user $pluser"; is ((exec_as 'nobody', "psql nobodydb -qc \"${fn_cmd};\""), 1, 'creating unsafe PL/Perl function as user nobody fails'); is_program_out 'nobody', 'psql nobodydb -qc "CREATE FUNCTION remove_vowels(text) RETURNS text AS \'\\$_[0] =~ s/[aeiou]/_/ig; return \\$_[0];\' LANGUAGE plperl;"', 0, '', 'creating PL/Perl function as user nobody succeeds'; @@ -211,7 +238,7 @@ 0, "f__b_r_sh\n", 'calling PL/Perl function'; # Check PL/Python (untrusted) - is_program_out 'postgres', 'createlang plpythonu nobodydb', 0, '', 'createlang plpythonu succeeds for user postgres'; + is_program_out 'postgres', create_extension('plpythonu'), 0, '', 'CREATE EXTENSION plpythonu succeeds for user postgres'; is_program_out 'postgres', 'psql nobodydb -qc "CREATE FUNCTION capitalize(text) RETURNS text AS \'import sys; return args[0].capitalize() + sys.version[0]\' LANGUAGE plpythonu;"', 0, '', 'creating PL/Python function as user postgres succeeds'; is_program_out 'nobody', 'psql nobodydb -Atc "select capitalize(\'foo\')"', @@ -219,7 +246,7 @@ # Check PL/Python3 (untrusted) if ($v >= '9.1' and not $PgCommon::rpm) { - is_program_out 'postgres', 'createlang plpython3u nobodydb', 0, '', 'createlang plpython3u succeeds for user postgres'; + is_program_out 'postgres', create_extension('plpython3u'), 0, '', 'CREATE EXTENSION plpython3u succeeds for user postgres'; is_program_out 'postgres', 'psql nobodydb -qc "CREATE FUNCTION capitalize3(text) RETURNS text AS \'import sys; return args[0].capitalize() + sys.version[0]\' LANGUAGE plpython3u;"', 0, '', 'creating PL/Python3 function as user postgres succeeds'; is_program_out 'nobody', 'psql nobodydb -Atc "select capitalize3(\'foo\')"', @@ -234,8 +261,8 @@ } # Check PL/Tcl (trusted/untrusted) - is_program_out 'postgres', 'createlang pltcl nobodydb', 0, '', 'createlang pltcl succeeds for user postgres'; - is_program_out 'postgres', 'createlang pltclu nobodydb', 0, '', 'createlang pltclu succeeds for user postgres'; + is_program_out 'postgres', create_extension('pltcl'), 0, '', 'CREATE EXTENSION pltcl succeeds for user postgres'; + is_program_out 'postgres', create_extension('pltclu'), 0, '', 'CREATE EXTENSION pltclu succeeds for user postgres'; is_program_out 'nobody', 'psql nobodydb -qc "CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS \'if {\\$1 > \\$2} {return \\$1}; return \\$2\' LANGUAGE pltcl STRICT;"', 0, '', 'creating PL/Tcl function as user nobody succeeds'; is_program_out 'postgres', 'psql nobodydb -qc "CREATE FUNCTION tcl_max_u(integer, integer) RETURNS integer AS \'if {\\$1 > \\$2} {return \\$1}; return \\$2\' LANGUAGE pltclu STRICT;"', @@ -294,7 +321,7 @@ my $client_pid; while (!$client_pid) { usleep $delay; - $client_pid = `ps --user postgres hu | grep 'postgres: nobody nobodydb' | grep -v grep | awk '{print \$2}'`; + $client_pid = `ps --user postgres hu | grep 'postgres.*: nobody nobodydb' | grep -v grep | awk '{print \$2}'`; ($client_pid) = ($client_pid =~ /(\d+)/); # untaint } @@ -302,7 +329,7 @@ # 9.0, but client backends stay at default; this might not work in # containers with restricted privileges, so skip the check there my $adj; - my $detect_virt = system 'systemd-detect-virt --container --quiet'; + my $detect_virt = system 'systemd-detect-virt --container --quiet'; # from systemd open F, "/proc/$master_pid/oom_score_adj"; $adj = ; chomp $adj; @@ -327,7 +354,7 @@ print WH "BEGIN;\n"; usleep $delay; like_program_out 0, "ps h $client_pid", 0, qr/idle in transaction/, 'process title is idle in transaction'; - print WH "SELECT pg_sleep(1);\n"; + print WH "SELECT pg_sleep(2); COMMIT;\n"; usleep $delay; like_program_out 0, "ps h $client_pid", 0, qr/SELECT/, 'process title is SELECT'; @@ -349,6 +376,7 @@ ok ((system "pg_dropcluster $v main --stop") == 0, 'pg_dropcluster removes cluster'); + is (-e $xlogdir, undef, "xlog/wal directory $xlogdir was deleted"); check_clean; } diff -Nru postgresql-common-173+ppa1/t/021_pg_renamecluster.t postgresql-common-190~ubuntu16.04.1/t/021_pg_renamecluster.t --- postgresql-common-173+ppa1/t/021_pg_renamecluster.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/021_pg_renamecluster.t 2018-01-12 14:08:47.000000000 +0000 @@ -4,7 +4,7 @@ use TestLib; use PgCommon; -use Test::More tests => 21; +use Test::More tests => 20; my $v = $MAJORS[-1]; @@ -23,9 +23,16 @@ is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'external_pid_file'), "/var/run/postgresql/$v-donau.pid", 'external_pid_file location updated'); ok (-f "/var/run/postgresql/$v-donau.pid", 'external_pid_file exists'); -is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'stats_temp_directory'), - "/var/run/postgresql/$v-donau.pg_stat_tmp", 'stats_temp_directory location updated'); -ok (-d "/var/run/postgresql/$v-donau.pg_stat_tmp", 'stats_temp_directory exists'); +SKIP: { + skip "no stats_temp_directory in $v", 2 if ($v < 8.4); + is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'stats_temp_directory'), + "/var/run/postgresql/$v-donau.pg_stat_tmp", 'stats_temp_directory location updated'); + ok (-d "/var/run/postgresql/$v-donau.pg_stat_tmp", 'stats_temp_directory exists'); +} +SKIP: { + skip "cluster name not supported in $v", 1 if ($v < 9.5); + is (PgCommon::get_conf_value ($v, 'donau', 'postgresql.conf', 'cluster_name'), "$v/donau", "cluster_name is updated"); +} # stop server, clean up, check for leftovers ok ((system "pg_dropcluster $v donau --stop") == 0, diff -Nru postgresql-common-173+ppa1/t/022_recovery.t postgresql-common-190~ubuntu16.04.1/t/022_recovery.t --- postgresql-common-173+ppa1/t/022_recovery.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/022_recovery.t 2018-01-12 14:08:47.000000000 +0000 @@ -9,7 +9,7 @@ use TestLib; use PgCommon; -use Test::More tests => 19 * ($#MAJORS+1); +use Test::More tests => 17 * @MAJORS; sub check_major { my $v = $_[0]; @@ -22,7 +22,7 @@ program_ok (0, "pg_ctlcluster $v main stop -m i"); program_ok (0, "pg_ctlcluster $v main start"); my $c = 0; # fallback for when pg_isready is missing (PG < 9.3) - while (system ("pg_isready -q") >> 8 == 1 and $c++ < 15) { + while (system ("pg_isready -q 2>&1") >> 8 == 1 and $c++ < 15) { sleep(1); } program_ok ('postgres', "psql -c ''"); @@ -36,7 +36,7 @@ "create write-protected file in data directory"); program_ok (0, "pg_ctlcluster $v main start"); $c = 0; - while (system ("pg_isready -q") >> 8 == 1 and $c++ < 15) { + while (system ("pg_isready -q 2>&1") >> 8 == 1 and $c++ < 15) { sleep(1); } program_ok ('postgres', "psql -c ''"); diff -Nru postgresql-common-173+ppa1/t/025_logging.t postgresql-common-190~ubuntu16.04.1/t/025_logging.t --- postgresql-common-173+ppa1/t/025_logging.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/025_logging.t 2018-01-12 14:08:47.000000000 +0000 @@ -5,8 +5,9 @@ use lib 't'; use TestLib; use PgCommon; +use Time::HiRes qw/usleep/; -use Test::More tests => 57 * ($#MAJORS+1); +use Test::More tests => 55 * @MAJORS; my $syslog_works = 0; @@ -31,8 +32,8 @@ # default log setup my $default_log = "/var/log/postgresql/postgresql-$v-main.log"; check_logging qr($v main 5432 online postgres $pgdata $default_log), "pg_lscluster reports logfile $default_log"; - like_program_out 'postgres', "psql -qc \"foobar$$\"", 1, qr/syntax error.*foobar$$/, 'log an error'; - like_program_out 'postgres', "grep foobar$$ $default_log", 0, qr/syntax error.*foobar$$/, 'error appears in logfile'; + like_program_out 'postgres', "psql -qc \"'foobar_${v}_$$'\"", 1, qr/syntax error.*foobar_${v}_$$/, 'log an error'; + like_program_out 'postgres', "grep --binary-files=text foobar_${v}_$$ $default_log", 0, qr/syntax error.*foobar_${v}_$$/, 'error appears in logfile'; # syslog is_program_out 0, "pg_conftool $v main set log_destination syslog", 0, "", "set log_destination syslog"; @@ -41,31 +42,37 @@ check_logging qr($v main 5432 online postgres $pgdata syslog), "pg_lscluster reports syslog"; SKIP: { skip "/var/log/syslog not available", 2 unless ($syslog_works); - like_program_out 0, "grep 'postgres.*parameter \"log_destination\" changed to \"syslog\"' /var/log/syslog", 0, qr/log_destination/, 'error appears in /var/log/syslog'; + usleep $delay; + like_program_out 0, "grep --binary-files=text 'postgres.*parameter \"log_destination\" changed to \"syslog\"' /var/log/syslog", 0, qr/log_destination/, 'error appears in /var/log/syslog'; } # turn logging_collector on, csvlog + my $pg_log = $v >= 10 ? 'log' : 'pg_log'; # log directory in PGDATA changed in PG 10 + SKIP: { + skip "No logging collector in 8.2", 30 if ($v <= 8.2); is_program_out 0, "pg_conftool $v main set logging_collector on", 0, "", "set logging_collector on"; is_program_out 0, "pg_conftool $v main set log_destination csvlog", 0, "", "set log_destination csvlog"; is_program_out 0, "pg_ctlcluster $v main restart", 0, "", "$v main restart"; is_program_out 'postgres', "psql -Atc \"show logging_collector\"", 0, "on\n", 'logging_collector is on'; is_program_out 'postgres', "psql -Atc \"show log_destination\"", 0, "csvlog\n", 'log_destination is csvlog'; - check_logging qr($v main 5432 online postgres $pgdata pg_log/.*\.csv), "pg_lscluster reports csvlog"; - like_program_out 'postgres', "psql -qc \"barbaz$$\"", 1, qr/syntax error.*barbaz$$/, 'log an error'; - like_program_out 'postgres', "grep barbaz$$ $pgdata/pg_log/*.csv", 0, qr/syntax error.*barbaz$$/, 'error appears in pg_log/*.csv'; + check_logging qr($v main 5432 online postgres $pgdata $pg_log/.*\.csv), "pg_lscluster reports csvlog"; + like_program_out 'postgres', "psql -qc \"'barbaz_${v}_$$'\"", 1, qr/syntax error.*barbaz_${v}_$$/, 'log an error'; + like_program_out 'postgres', "grep --binary-files=text barbaz_${v}_$$ $pgdata/$pg_log/*.csv", 0, qr/syntax error.*barbaz_${v}_$$/, "error appears in $pg_log/*.csv"; # stderr,syslog,csvlog is_program_out 0, "pg_conftool $v main set log_destination stderr,syslog,csvlog", 0, "", "set log_destination stderr,syslog,csvlog"; is_program_out 0, "pg_ctlcluster $v main reload", 0, "", "$v main reload"; is_program_out 'postgres', "psql -Atc \"show log_destination\"", 0, "stderr,syslog,csvlog\n", 'log_destination is stderr,syslog,csvlog'; - check_logging qr($v main 5432 online postgres $pgdata pg_log/.*\.log,syslog,pg_log/.*\.csv), "pg_lscluster reports stderr,syslog,csvlog"; - like_program_out 'postgres', "psql -qc \"moo$$\"", 1, qr/syntax error.*moo$$/, 'log an error'; - like_program_out 'postgres', "grep moo$$ $pgdata/pg_log/*.log", 0, qr/syntax error.*moo$$/, 'error appears in pg_log/*.log'; + check_logging qr($v main 5432 online postgres $pgdata $pg_log/.*\.log,syslog,$pg_log/.*\.csv), "pg_lscluster reports stderr,syslog,csvlog"; + like_program_out 'postgres', "psql -qc \"'moo_${v}_$$'\"", 1, qr/syntax error.*moo_${v}_$$/, 'log an error'; + like_program_out 'postgres', "grep --binary-files=text moo_${v}_$$ $pgdata/$pg_log/*.log", 0, qr/syntax error.*moo_${v}_$$/, "error appears in $pg_log/*.log"; SKIP: { skip "/var/log/syslog not available", 2 unless ($syslog_works); - like_program_out 0, "grep 'postgres.*moo$$' /var/log/syslog", 0, qr/moo$$/, 'error appears in /var/log/syslog'; + usleep $delay; + like_program_out 0, "grep --binary-files=text 'postgres.*moo_${v}_$$' /var/log/syslog", 0, qr/moo_${v}_$$/, 'error appears in /var/log/syslog'; + } + like_program_out 'postgres', "grep --binary-files=text moo_${v}_$$ $pgdata/$pg_log/*.csv", 0, qr/syntax error.*moo_${v}_$$/, "error appears in $pg_log/*.csv"; } - like_program_out 'postgres', "grep moo$$ $pgdata/pg_log/*.csv", 0, qr/syntax error.*moo$$/, 'error appears in pg_log/*.csv'; # stop server, clean up, check for leftovers is_program_out 0, "pg_dropcluster $v main --stop", 0, "", 'pg_dropcluster removes cluster'; @@ -73,8 +80,9 @@ check_clean; } -system "logger -t '$0' 'test$$'"; -if (system ("grep -q 'test$$' /var/log/syslog 2> /dev/null") == 0) { +system "logger -t '$0' 'test-logging-$$'"; +usleep $delay; +if (system ("grep --binary-files=text -q 'test-logging-$$' /var/log/syslog 2> /dev/null") == 0) { note 'Logging to /var/log/syslog works'; $syslog_works = 1; } else { diff -Nru postgresql-common-173+ppa1/t/030_errors.t postgresql-common-190~ubuntu16.04.1/t/030_errors.t --- postgresql-common-173+ppa1/t/030_errors.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/030_errors.t 2018-01-31 12:29:59.000000000 +0000 @@ -6,7 +6,7 @@ use lib 't'; use TestLib; -use Test::More tests => 158; +use Test::More tests => 149; use PgCommon; my $version = $MAJORS[-1]; @@ -74,7 +74,9 @@ 'pg_ctlcluster succeeds on valid cluster owner uid/gid'); # check socket -ok_dir '/var/run/postgresql', ["$version-main.pid", "$version-main.pg_stat_tmp"], 'No sockets in /var/run/postgresql'; +my @contents = ('.s.PGSQL.5432', '.s.PGSQL.5432.lock', "$version-main.pid", "$version-main.pg_stat_tmp"); +pop @contents if ($version < 8.4); # remove pg_stat_tmp +ok_dir '/var/run/postgresql', [grep {/main/} @contents], 'No sockets in /var/run/postgresql'; ok_dir $socketdir, ['.s.PGSQL.5432', '.s.PGSQL.5432.lock'], "Socket is in $socketdir"; # stop cluster, check sockets @@ -98,7 +100,7 @@ if ($PgCommon::rpm) { ok ((grep { $_ eq '.s.PGSQL.5432' } @{TestLib::dircontent('/tmp')}) == 1, 'Socket is in /tmp'); } else { - ok_dir '/var/run/postgresql', ['.s.PGSQL.5432', '.s.PGSQL.5432.lock', "$version-main.pid", "$version-main.pg_stat_tmp"], + ok_dir '/var/run/postgresql', [@contents], 'Socket is in default dir /var/run/postgresql'; } ok_dir $socketdir, [], "No sockets in $socketdir"; @@ -173,23 +175,7 @@ # start running server is_program_out 'postgres', "pg_ctlcluster $version main start", 2, "Cluster is already running.\n", 'pg_ctlcluster start fails on running cluster'; - -# stop server, test invalid configuration is ((exec_as 'postgres', "pg_ctlcluster $version main stop"), 0, 'pg_ctlcluster stop'); -PgCommon::set_conf_value $version, 'main', 'postgresql.conf', - 'log_statement_stats', 'true'; -PgCommon::set_conf_value $version, 'main', 'postgresql.conf', - 'log_planner_stats', 'true'; -like_program_out 'postgres', "pg_ctlcluster $version main start", 1, - qr/Error: invalid postgresql.conf.*log_.*mutually exclusive/, - 'pg_ctlcluster start fails with invalid configuration'; - -# repair configuration -PgCommon::set_conf_value $version, 'main', 'postgresql.conf', - 'log_planner_stats', 'false'; -is_program_out 'postgres', "pg_ctlcluster $version main start", 0, '', - 'pg_ctlcluster start succeeds again with valid configuration'; -is_program_out 'postgres', "pg_ctlcluster $version main stop", 0, '', 'stopping cluster'; # backup pg_hba.conf rename "/etc/postgresql/$version/main/pg_hba.conf", @@ -274,7 +260,7 @@ is ((exec_as 'postgres', "pg_ctlcluster $version other stop"), 0); # ... but will give an error when running on the same port -set_cluster_socketdir $version, 'other', $PgCommon::rpm ? '/tmp' : '/var/run/postgresql'; +set_cluster_socketdir $version, 'other', ($PgCommon::rpm and $version < 9.4) ? '/tmp' : '/var/run/postgresql'; like_program_out 'postgres', "pg_ctlcluster $version other start", 1, qr/Port conflict:.*port 5432/, 'pg_ctlcluster other cluster fails on conflicting port and same socket dir'; @@ -292,6 +278,7 @@ rmdir $socketdir or die "rmdir: $!"; # ensure sane error messages for nonexisting clusters +check_nonexisting_cluster_error 'pg_lsclusters 4.5 foo'; check_nonexisting_cluster_error 'psql --cluster 4.5/foo'; check_nonexisting_cluster_error "psql --cluster $MAJORS[0]/foo"; check_nonexisting_cluster_error "pg_dropcluster 4.5 foo"; @@ -323,8 +310,8 @@ mkdir "/var/lib/postgresql/$MAJORS[-1]"; mkdir "/var/lib/postgresql/$MAJORS[-1]/broken"; mkdir "/var/lib/postgresql/$MAJORS[-1]/broken/base" or die "mkdir: $!"; -symlink "/var/lib/postgresql/$MAJORS[-1]/broken", "/etc/postgresql/$MAJORS[-1]/broken/pgdata" or die "symlink: $!"; open F, ">/etc/postgresql/$MAJORS[-1]/broken/postgresql.conf" or die "open: $!"; +print F "data_directory = '/var/lib/postgresql/$MAJORS[-1]/broken'\n"; close F; open F, ">/var/lib/postgresql/$MAJORS[-1]/broken/PG_VERSION" or die "open: $!"; close F; diff -Nru postgresql-common-173+ppa1/t/031_errors_disk_full.t postgresql-common-190~ubuntu16.04.1/t/031_errors_disk_full.t --- postgresql-common-173+ppa1/t/031_errors_disk_full.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/031_errors_disk_full.t 2018-01-31 12:29:59.000000000 +0000 @@ -6,15 +6,21 @@ use lib 't'; use TestLib; -use Test::More tests => 26; +use Test::More tests => $ENV{NO_TMPFS} ? 1 : 22; + +# skip tests if NO_TMPFS is set +if ($ENV{NO_TMPFS}) { + pass 'Skipping disk full tests, NO_TMPFS is set'; + exit; +} # we are using unshare here, won't work with systemd $ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1; my $outref; -# check that a failed pg_createcluster leaves no cruft behind: try creating a -# cluster on a 10 MB tmpfs +# +note 'check that a failed pg_createcluster leaves no cruft behind: try creating a cluster on a 10 MB tmpfs'; my $cmd = <&1 set -e @@ -41,7 +47,8 @@ check_clean; -# check disk full conditions on startup +# +note 'check disk full conditions on startup'; my $cmd = < /dev/null || : @@ -50,7 +57,8 @@ mkdir -p \$dirs trap "umount \$dirs" 0 HUP INT QUIT ILL ABRT PIPE TERM mount -t tmpfs -o size=1000000 none /etc/postgresql -mount -t tmpfs -o size=50000000 none /var/lib/postgresql +# an empty cluster needs 69MB on ppc64el, round up to 90 +mount -t tmpfs -o size=90000000 none /var/lib/postgresql mount -t tmpfs -o size=1000000 none /var/log/postgresql pg_createcluster $MAJORS[-1] test diff -Nru postgresql-common-173+ppa1/t/032_ssl_key_permissions.t postgresql-common-190~ubuntu16.04.1/t/032_ssl_key_permissions.t --- postgresql-common-173+ppa1/t/032_ssl_key_permissions.t 2016-03-29 18:41:54.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/032_ssl_key_permissions.t 2018-01-31 12:29:59.000000000 +0000 @@ -3,8 +3,10 @@ use lib 't'; use TestLib; -use Test::More tests => 3 + 21 * (@MAJORS); use PgCommon; +use Test::More tests => $PgCommon::rpm ? 1 : 3 + 19 * @MAJORS; + +if ($PgCommon::rpm) { pass 'No ssl key checks on RedHat'; exit; } my ($pg_uid, $pg_gid) = (getpwnam 'postgres')[2,3]; my $ssl_cert_gid = (getgrnam 'ssl-cert')[2]; # reset permissions @@ -16,14 +18,20 @@ is ((stat $snakekey)[2], 0100640, "$snakekey mode is 0640"); foreach my $version (@MAJORS) { + my $pkgversion = `dpkg-query -f '\${Version}' -W postgresql-$version`; + note "$version ($pkgversion)"; +SKIP: { + skip "No SSL key check on <= 9.0", 19 if ($version <= 9.0); program_ok (0, "pg_createcluster $version main"); my $nobody_uid = (getpwnam 'nobody')[2]; chown $nobody_uid, 0, $snakekey; like_program_out 'postgres', "pg_ctlcluster $version main start", 1, - qr/private key file.*must be owned by the database user or root/, + qr/private key file.*must be owned by the database user or root/s, 'ssl key owned by nobody refused'; +SKIP: { + skip "SSL key group check skipped on Debian oldstable packages", 4 if ($version <= 9.4 and $pkgversion !~ /pgdg/); chown 0, 0, $snakekey; chmod 0644, $snakekey; like_program_out 'postgres', "pg_ctlcluster $version main start", 1, @@ -35,6 +43,7 @@ like_program_out 'postgres', "pg_ctlcluster $version main start", 1, qr/private key file.*has group or world access/, 'ssl key with permissions postgres:postgres 0640 refused'; +} chown 0, $ssl_cert_gid, $snakekey; @@ -44,3 +53,4 @@ is ((stat $snakekey)[2], 0100640, "$snakekey mode is 0640"); check_clean; } +} diff -Nru postgresql-common-173+ppa1/t/040_upgrade.t postgresql-common-190~ubuntu16.04.1/t/040_upgrade.t --- postgresql-common-173+ppa1/t/040_upgrade.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/040_upgrade.t 2018-01-12 14:08:47.000000000 +0000 @@ -3,7 +3,7 @@ use strict; -use File::Temp qw/tempdir/; +use File::Temp qw/tempfile tempdir/; use POSIX qw/dup2/; use Time::HiRes qw/usleep/; @@ -11,14 +11,15 @@ use TestLib; use PgCommon; -use Test::More tests => ($#MAJORS == 0) ? 1 : 111 * 3; +use Test::More tests => (@MAJORS == 1) ? 1 : 107 * 3; -if ($#MAJORS == 0) { +if (@MAJORS == 1) { pass 'only one major version installed, skipping upgrade tests'; exit 0; } foreach my $upgrade_options ('-m dump', '-m upgrade', '-m upgrade --link') { +next if ($ENV{UPGRADE_METHOD} and $upgrade_options !~ /$ENV{UPGRADE_METHOD}$/); # hack to ease debugging individual methods note ("upgrade method \"$upgrade_options\", $MAJORS[0] -> $MAJORS[-1]"); # create cluster @@ -61,8 +62,16 @@ is_program_out 'nobody', 'psql -Atc "SELECT nextval(\'odd10\')" test', 0, "3\n", 'check next sequence value'; +# create a large object +my ($fh, $filename) = tempfile("lo_import.XXXXXX", TMPDIR => 1, UNLINK => 1); +print $fh "Hello world"; +close $fh; +chmod 0644, $filename; +is_program_out 'postgres', "psql -Atc \"SELECT lo_import('$filename', 1234)\"", 0, "1234\n", + 'create large object'; + # create stored procedures -if ($MAJORS[0] < '9.0') { +if ($MAJORS[0] < 9.0) { is_program_out 'postgres', 'createlang plpgsql test', 0, '', 'createlang plpgsql test'; } else { pass '>= 9.0 enables PL/pgsql by default'; @@ -130,35 +139,6 @@ chmod 0100, '/tmp/pgtest/'; chdir '/tmp/pgtest'; -# upgrade attempt fails cleanly if the server is busy -my $psql = fork; -if (!$psql) { - my @pw = getpwnam 'nobody'; - change_ugid $pw[2], $pw[3]; - # suppress 'could not change directory to "/tmp/pgtest"' - chdir '/tmp'; - # pg_upgradecluster below will timeout after 5s - exec 'psql', '-c', 'select pg_sleep(15)', 'postgres' or die "could not exec psql process: $!"; -} -usleep $delay; - -like_program_out 0, "pg_upgradecluster -v $MAJORS[-1] $upgrade_options $MAJORS[0] upgr", 1, - qr/Error: Could not stop old cluster/, - 'pg_upgradecluster fails on busy cluster'; -like_program_out 'nobody', 'pg_lsclusters -h', 0, - qr/^$MAJORS[0]\s+upgr\s+5432 online postgres/; - -kill 9, $psql; -waitpid $psql, 0; - -# now that the connection went away, postmaster shuts down; so restart it -# properly -system "pg_ctlcluster $MAJORS[0] upgr stop"; -sleep 5; -like_program_out 'nobody', 'pg_lsclusters -h', 0, - qr/^$MAJORS[0]\s+upgr\s+5432 down\s+postgres/; -is ((system "pg_ctlcluster $MAJORS[0] upgr start"), 0, 'Starting upgr cluster'); - # Upgrade to latest version my $outref; is ((exec_as 0, "(pg_upgradecluster -v $MAJORS[-1] $upgrade_options $MAJORS[0] upgr | sed -e 's/^/STDOUT: /')", $outref, 0), 0, 'pg_upgradecluster succeeds'); @@ -177,10 +157,8 @@ rmdir '/tmp/pgtest/'; # Check clusters -is_program_out 'nobody', 'pg_lsclusters -h', 0, - "$MAJORS[0] upgr 5433 down postgres /var/lib/postgresql/$MAJORS[0]/upgr /var/log/postgresql/postgresql-$MAJORS[0]-upgr.log -$MAJORS[-1] upgr 5432 online postgres /var/lib/postgresql/$MAJORS[-1]/upgr /var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log -", 'pg_lsclusters output'; +like_program_out 'nobody', 'pg_lsclusters -h', 0, + qr"$MAJORS[0] +upgr 5433 down postgres /var/lib/postgresql/$MAJORS[0]/upgr +/var/log/postgresql/postgresql-$MAJORS[0]-upgr.log\n$MAJORS[-1] +upgr 5432 online postgres /var/lib/postgresql/$MAJORS[-1]/upgr +/var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log", 'pg_lsclusters output'; # Check that SELECT output is identical is_program_out 'nobody', 'psql -tAc "SELECT * FROM phone ORDER BY name" test', 0, @@ -198,6 +176,10 @@ is_program_out 'nobody', 'psql -Atc "SELECT nextval(\'odd10\')" test', 0, "1\n", 'check next sequence value (wrap)'; +# check large objects +is_program_out 'postgres', 'psql -Atc "SET bytea_output = \'escape\'; SELECT data FROM pg_largeobject WHERE loid = 1234"', 0, "Hello world\n", + 'check large object'; + # check stored procedures is_program_out 'nobody', 'psql -Atc "SELECT inc2(-3)" test', 0, "-1\n", 'call function inc2'; @@ -241,6 +223,10 @@ # check DB parameter is_program_out 'postgres', 'psql -Atc "SHOW DateStyle" test', 0, 'ISO, YMD ', 'check database parameter'; +SKIP: { + skip "cluster name not supported in $MAJORS[0]", 1 if ($MAJORS[0] < 9.5); + is (PgCommon::get_conf_value ($MAJORS[-1], 'upgr', 'postgresql.conf', 'cluster_name'), "$MAJORS[-1]/upgr", "cluster_name is updated"); +} # check tablespace is_program_out 'postgres', "psql -Atc 'SELECT spcname FROM pg_tablespace ORDER BY spcname'", diff -Nru postgresql-common-173+ppa1/t/041_upgrade_custompaths.t postgresql-common-190~ubuntu16.04.1/t/041_upgrade_custompaths.t --- postgresql-common-173+ppa1/t/041_upgrade_custompaths.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/041_upgrade_custompaths.t 2018-01-12 14:08:47.000000000 +0000 @@ -5,9 +5,9 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => ($#MAJORS == 0) ? 1 : 30; +use Test::More tests => (@MAJORS == 1) ? 1 : 28; -if ($#MAJORS == 0) { +if (@MAJORS == 1) { pass 'only one major version installed, skipping upgrade tests'; exit 0; } @@ -21,10 +21,8 @@ like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; # Check clusters -is_program_out 'nobody', 'pg_lsclusters -h', 0, - "$MAJORS[0] upgr 5433 down postgres /tmp/postgresql-test /tmp/postgresql-test.log -$MAJORS[-1] upgr 5432 online postgres /var/lib/postgresql/$MAJORS[-1]/upgr /var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log -", 'pg_lsclusters output'; +like_program_out 'nobody', 'pg_lsclusters -h', 0, + qr"$MAJORS[0] +upgr 5433 down postgres /tmp/postgresql-test +/tmp/postgresql-test.log\n$MAJORS[-1] +upgr 5432 online postgres /var/lib/postgresql/$MAJORS[-1]/upgr +/var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log", 'pg_lsclusters output'; # clean away new cluster and restart the old one is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster'); @@ -41,10 +39,8 @@ like $$outref, qr/Starting target cluster/, 'pg_upgradecluster reported cluster startup'; like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; -is_program_out 'nobody', 'pg_lsclusters -h', 0, - "$MAJORS[0] upgr 5432 down postgres /tmp/postgresql-test /tmp/postgresql-test.log -$MAJORS[-1] upgr 5433 online postgres /tmp/psql-common-testsuite /var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log -", 'pg_lsclusters output'; +like_program_out 'nobody', 'pg_lsclusters -h', 0, + qr"$MAJORS[0] +upgr 5432 down postgres /tmp/postgresql-test +/tmp/postgresql-test.log\n$MAJORS[-1] +upgr 5433 online postgres /tmp/psql-common-testsuite +/var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log", 'pg_lsclusters output'; # stop servers, clean up is ((system "pg_dropcluster $MAJORS[0] upgr"), 0, 'Dropping original cluster'); diff -Nru postgresql-common-173+ppa1/t/043_upgrade_ssl_cert.t postgresql-common-190~ubuntu16.04.1/t/043_upgrade_ssl_cert.t --- postgresql-common-173+ppa1/t/043_upgrade_ssl_cert.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/043_upgrade_ssl_cert.t 2018-01-12 14:08:47.000000000 +0000 @@ -5,9 +5,9 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => ($#MAJORS == 0 or $PgCommon::rpm) ? 1 : 24; +use Test::More tests => (@MAJORS == 1 or $PgCommon::rpm) ? 1 : 22; -if ($#MAJORS == 0) { +if (@MAJORS == 1) { pass 'only one major version installed, skipping upgrade tests'; exit 0; } diff -Nru postgresql-common-173+ppa1/t/050_encodings.t postgresql-common-190~ubuntu16.04.1/t/050_encodings.t --- postgresql-common-173+ppa1/t/050_encodings.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/050_encodings.t 2018-01-12 14:08:47.000000000 +0000 @@ -5,7 +5,7 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => ($#MAJORS+1) * 52 + 10; +use Test::More tests => @MAJORS * 52 + 8; # create a test cluster with given locale, check the locale/encoding, and # remove it diff -Nru postgresql-common-173+ppa1/t/051_inconsistent_encoding_upgrade.t postgresql-common-190~ubuntu16.04.1/t/051_inconsistent_encoding_upgrade.t --- postgresql-common-173+ppa1/t/051_inconsistent_encoding_upgrade.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/051_inconsistent_encoding_upgrade.t 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -# Starting from 8.3, postgresql enforces DB encoding/server locale matching; -# Check that upgrades from broken combinations get fixed on upgrade, and that -# the upgrade succeeds. - -use strict; - -use lib 't'; -use TestLib; -use PgCommon; -use Test::More tests => ($#MAJORS == 0 || $MAJORS[0] >= '8.3') ? 1 : 19 * 3 + 10; - -if ($#MAJORS == 0) { - pass 'only one major version installed, skipping upgrade tests'; - exit 0; -} - -if ($MAJORS[0] >= '8.3') { - pass 'test only relevant for oldest version < 8.3, skipping'; - exit 0; -} - -# Arguments: [] [] -sub test_upgrade { - my $outref; - my $locale = $_[0]; - my $oldv = $_[1] || $MAJORS[0]; - my $newv = $_[2] || $MAJORS[-1]; - - is ((exec_as 0, "pg_createcluster --start --locale=$locale $oldv main", $outref), 0, - "creating $locale $oldv cluster"); - - is ((exec_as 'postgres', 'psql -c "create user latinuser; - create user utf8user; - create database utf8test owner = utf8user encoding = \'UTF8\'; - create database latintest owner = latinuser encoding = \'iso-8859-5\';" template1', $outref), 0, - "creating DBs with different encodings"); - - # encodings should be automatic with a proper locale, but not in C - my $eu = ($locale eq 'C') ? "set client_encoding='UTF8'; " : ''; - my $el = ($locale eq 'C') ? "set client_encoding='iso-8859-5'; " : ''; - - is ((exec_as 'postgres', "printf 'A\\320\\264B' | psql -c \"$eu create table t(x varchar); copy t from stdin\" utf8test", $outref), - 0, 'write UTF8 database content'); - is ((exec_as 'postgres', "printf 'A\\324B' | psql -c \"$el create table t(x varchar); copy t from stdin\" latintest", $outref), - 0, 'write LATIN database content'); - - is_program_out 'postgres', "echo \"$eu select * from t\" | psql -Atq utf8test", 0, "AдB\n", - 'old utf8test DB has correctly encoded string'; - is_program_out 'postgres', "echo \"$el select * from t\" | psql -Atq latintest", - 0, "A\324B\n", 'old latintest DB has correctly encoded string'; - - like_program_out 0, "pg_upgradecluster -v $newv $oldv main", 0, qr/^Success/im; - - is ((system "pg_dropcluster --stop $oldv main"), 0, 'dropping old cluster'); - - # in C we cannot change encoding, thus it will be what we put in; in proper - # locales it defaults to the server encoding, so we have to specify it - # explicitly - my $el = ($locale eq 'C') ? '' : "set client_encoding='iso-8859-5'; "; - my $eu = ($locale eq 'C') ? '' : "set client_encoding='UTF-8'; "; - is_program_out 'postgres', "echo \"$eu select * from t\" | psql -Atq utf8test", 0, "AдB\n", - 'upgraded utf8test DB has correctly encoded string'; - is_program_out 'postgres', "echo \"$el select * from t\" | psql -Atq latintest", - 0, "A\324B\n", 'upgraded latintest DB has correctly encoded string'; - - is ((exec_as 'postgres', 'psql -Atl', $outref), 0, 'psql -Atl on upgraded cluster'); - if ($locale eq 'C') { - # verify ownership; encodings should be retained in C - ok ((index $$outref, 'latintest|latinuser|ISO_8859_5') >= 0, - 'latintest is owned by latinuser and is ISO8859-5 encoded'); - ok ($$outref =~ qr/^utf8test\|utf8user\|(UTF8|UNICODE)$/m, - 'utf8test is owned by utf8user and is UTF8 encoded'); - } else { - # verify ownership; encodings have been corrected on upgrade - ok ((index $$outref, 'latintest|latinuser') >= 0, 'latinuser is owned by latintest'); - ok ((index $$outref, 'utf8test|utf8user') >= 0, 'utf8user is owned by utf8test'); - } - - is ((system "pg_dropcluster --stop $newv main"), 0, 'dropping upgraded cluster'); -} - -test_upgrade 'C'; -test_upgrade 'ru_RU.UTF-8'; -test_upgrade 'ru_RU', $MAJORS[0], $MAJORS[1]; - -check_clean; - -# vim: filetype=perl diff -Nru postgresql-common-173+ppa1/t/052_upgrade_encodings.t postgresql-common-190~ubuntu16.04.1/t/052_upgrade_encodings.t --- postgresql-common-173+ppa1/t/052_upgrade_encodings.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/052_upgrade_encodings.t 2018-01-12 14:08:47.000000000 +0000 @@ -5,9 +5,9 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => ($#MAJORS == 0) ? 1 : 45; +use Test::More tests => (@MAJORS == 1) ? 1 : 43; -if ($#MAJORS == 0) { +if (@MAJORS == 1) { pass 'only one major version installed, skipping upgrade tests'; exit 0; } diff -Nru postgresql-common-173+ppa1/t/060_obsolete_confparams.t postgresql-common-190~ubuntu16.04.1/t/060_obsolete_confparams.t --- postgresql-common-173+ppa1/t/060_obsolete_confparams.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/060_obsolete_confparams.t 2018-01-12 14:08:47.000000000 +0000 @@ -7,9 +7,9 @@ use lib 't'; use TestLib; -use Test::More tests => ($#MAJORS == 0) ? 1 : (23 + $#MAJORS * 9); +use Test::More tests => (@MAJORS == 1) ? 1 : (12 + @MAJORS * 9); -if ($#MAJORS == 0) { +if (@MAJORS == 1) { pass 'only one major version installed, skipping upgrade tests'; exit 0; } @@ -62,7 +62,7 @@ is ((system "pg_createcluster $MAJORS[0] main >/dev/null"), 0, "pg_createcluster $MAJORS[0] main"); # Loop over all but the latest major version, testing N->N+1 upgrades -my @testversions = sort @MAJORS; +my @testversions = sort { $a <=> $b } @MAJORS; while ($#testversions) { my $cur = shift @testversions; my $new = $testversions[0]; diff -Nru postgresql-common-173+ppa1/t/070_non_postgres_clusters.t postgresql-common-190~ubuntu16.04.1/t/070_non_postgres_clusters.t --- postgresql-common-173+ppa1/t/070_non_postgres_clusters.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/070_non_postgres_clusters.t 2018-01-12 14:08:47.000000000 +0000 @@ -6,7 +6,7 @@ use lib 't'; use TestLib; -use Test::More tests => 52; +use Test::More tests => 40; $ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1; # FIXME: testsuite is hanging otherwise @@ -30,9 +30,8 @@ qr/^$v\s+main\s+5432\s+online\s+$owner/, 'pg_lsclusters shows running cluster'; -my $master_process = ($v >= '8.2') ? 'postgres' : 'postmaster'; -like ((ps $master_process), qr/^$owner.*bin\/$master_process .*\/var\/lib\/postgresql\/$v\/main/m, - "$master_process is running as user $owner"); +like ((ps 'postgres'), qr/^$owner.*bin\/postgres .*\/var\/lib\/postgresql\/$v\/main/m, + "postgres is running as user $owner"); is_program_out $owner, 'ls /tmp/.s.PGSQL.*', 0, "/tmp/.s.PGSQL.5432\n/tmp/.s.PGSQL.5432.lock\n", 'socket is in /tmp'; @@ -45,13 +44,23 @@ @st = stat $confdir; is $st[4], $owneruid, 'conf dir is owned by user'; is $st[5], $ownergid, 'conf dir is owned by user\'s primary group'; +my ($ok_uid, $ok_gid) = (1, 1); opendir D, $confdir or die "opendir: $!"; for my $f (readdir D) { next if $f eq '.' or $f eq '..'; @st = stat "$confdir/$f" or die "stat: $!"; - is $st[4], $owneruid, "$f is owned by user"; - is $st[5], $ownergid, "$f is owned by user\'s primary group"; + if ($st[4] != $owneruid) { + note "$f is not owned by user"; + $ok_uid = 0; + } + if ($st[5] != $ownergid) { + note "$f is not owned by user's primary group"; + $ok_gid = 0; + } } +closedir D; +is $ok_uid, 1, "files are owned by user"; +is $ok_gid, 1, "files are owned by user's primary group"; # verify log file properties @st = stat "/var/log/postgresql/postgresql-$v-main.log"; @@ -100,7 +109,7 @@ # Check proper cleanup is ((system "pg_dropcluster $v main --stop"), 0, 'pg_dropcluster'); is_program_out $owner, 'pg_lsclusters -h', 0, '', 'No clusters left'; -is ((ps $master_process), '', "No $master_process processes left"); +is ((ps 'postgres'), '', "No postgres processes left"); check_clean; diff -Nru postgresql-common-173+ppa1/t/080_start.conf.t postgresql-common-190~ubuntu16.04.1/t/080_start.conf.t --- postgresql-common-173+ppa1/t/080_start.conf.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/080_start.conf.t 2018-01-12 14:08:47.000000000 +0000 @@ -6,7 +6,7 @@ use TestLib; use PgCommon; -use Test::More tests => 75; +use Test::More tests => 73; my $systemd = -d '/var/run/systemd/system'; diff -Nru postgresql-common-173+ppa1/t/085_pg_ctl.conf.t postgresql-common-190~ubuntu16.04.1/t/085_pg_ctl.conf.t --- postgresql-common-173+ppa1/t/085_pg_ctl.conf.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/085_pg_ctl.conf.t 2018-01-12 14:08:47.000000000 +0000 @@ -6,7 +6,7 @@ use TestLib; use PgCommon; -use Test::More tests => $MAJORS[-1] >= '8.3' ? 31 : 1; +use Test::More tests => $MAJORS[-1] >= '8.3' ? 29 : 1; # Do test with newest version my $v = $MAJORS[-1]; diff -Nru postgresql-common-173+ppa1/t/090_multicluster.t postgresql-common-190~ubuntu16.04.1/t/090_multicluster.t --- postgresql-common-173+ppa1/t/090_multicluster.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/090_multicluster.t 2018-01-12 14:08:47.000000000 +0000 @@ -7,7 +7,7 @@ use Socket; use PgCommon; -use Test::More tests => 127; +use Test::More tests => 125; # Replace all md5 and password authentication methods with 'trust' in given # pg_hba.conf file. @@ -66,11 +66,11 @@ qr/^createdb \(PostgreSQL\) $MAJORS[-1]/, 'pg_wrapper --cluster works'; like_program_out 0, "createdb --cluster $MAJORS[-1]/foo --version", 1, - qr/Specified cluster does not exist/, + qr/Cluster .* does not exist/, 'pg_wrapper --cluster errors out for invalid cluster'; # create a database in new1 and check that it doesn't appear in new2 -is_program_out 'postgres', "createdb --cluster $new1 test", 0, ''; +is_program_out 'postgres', "createdb --cluster $new1 test", 0, ($MAJORS[-1] < 8.3 ? "CREATE DATABASE\n" : ''); like_program_out 'postgres', "psql -Atl --cluster $new1", 0, qr/test\|postgres\|/, 'test db appears in cluster new1'; @@ -95,9 +95,9 @@ like_program_out 'postgres', "LC_MESSAGES=C psql -Atl --cluster $MAJORS[-1]/localhost:5435", 2, qr/could not connect/, "psql --cluster $MAJORS[-1]/localhost:5435 fails due to nonexisting port"; like_program_out 'postgres', "LC_MESSAGES=C psql -Atl --cluster $MAJORS[-1]/localhost:a", 1, - qr/Specified cluster does not exist/, "psql --cluster $MAJORS[-1]/localhost:a fails due to invalid syntax"; + qr/Cluster .* does not exist/, "psql --cluster $MAJORS[-1]/localhost:a fails due to invalid syntax"; like_program_out 'postgres', "LC_MESSAGES=C psql -Atl --cluster $MAJORS[-1]/doesnotexi.st", 1, - qr/Specified cluster does not exist/, "psql --cluster $MAJORS[-1]/doesnotexi.st fails due to invalid syntax"; + qr/Cluster .* does not exist/, "psql --cluster $MAJORS[-1]/doesnotexi.st fails due to invalid syntax"; like_program_out 'postgres', "psql -Atl --cluster 6.4/localhost:", 1, qr/Invalid version/, "psql --cluster 6.4/localhost: fails due to invalid version"; @@ -110,7 +110,7 @@ 'PGCLUSTER selection (2)'; $ENV{'PGCLUSTER'} = 'foo'; like_program_out 'postgres', "psql -l", 1, - qr/Invalid version specified with \$PGCLUSTER/, + qr/Invalid version .* specified in PGCLUSTER/, 'invalid PGCLUSTER value'; $ENV{'PGCLUSTER'} = "$MAJORS[-1]/127.0.0.1:"; like_program_out 0, 'createdb --version', 0, qr/^createdb \(PostgreSQL\) $MAJORS[-1]/, @@ -189,8 +189,8 @@ 'pg_wrapper selects correct cluster with per-user user_clusters'; like_program_out 'nobody', 'createdb --version', 0, qr/^createdb \(PostgreSQL\) $MAJORS[0]/, 'pg_wrapper selects correct cluster with per-user user_clusters'; -like_program_out 0, 'createdb --version', 1, qr/user_clusters.*line 3.*version.*not exist/i, - 'pg_wrapper error for invalid per-user user_clusters line'; +like_program_out 0, 'createdb --version', 0, qr/user_clusters.*line 3.*version.*not exist/i, + 'pg_wrapper warning for invalid per-user user_clusters line'; # check by-user network cluster selection with user_clusters # (also check invalid cluster reporting) @@ -202,8 +202,8 @@ 'pg_wrapper selects correct version with per-user user_clusters'; like_program_out 'nobody', 'createdb --version', 0, qr/^createdb \(PostgreSQL\) $MAJORS[-1]/, 'pg_wrapper selects correct version with per-user user_clusters'; -like_program_out 0, 'createdb --version', 1, qr/user_clusters.*line 3.*cluster.*not exist/i, - 'pg_wrapper error for invalid per-user user_clusters line'; +like_program_out 0, 'createdb --version', 0, qr/user_clusters.*line 3.*cluster.*not exist/i, + 'pg_wrapper warning for invalid per-user user_clusters line'; # check PGHOST environment variable precedence $ENV{'PGHOST'} = '127.0.0.2'; like_program_out 'postgres', 'psql -Atl', 2, qr/127.0.0.2/, '$PGHOST overrides user_clusters'; @@ -263,9 +263,9 @@ is ((system "pg_ctlcluster $MAJORS[0] old start >/dev/null"), 0, "restarting cluster $old"); like_program_out 'postgres', 'pg_lsclusters -h | sort -k3', 0, qr/.*5434.*5435.*5440.*/s, 'port of first cluster was successfully changed'; -like_program_out 'postgres', "psql -l", 1, - qr/no.*default.*man pg_wrapper/i, - 'proper pg_wrapper error message if no cluster is suitable as target'; +like_program_out 'postgres', "psql -l", 2, + qr/no.*default.*man pg_wrapper.*psql:.*\.s\.PGSQL.5432/is, + 'proper pg_wrapper warning and psql error if no cluster is suitable as default target'; like_program_out 'postgres', "psql -Atl --cluster $new1", 0, qr/test\|postgres\|/, '--cluster selects appropriate cluster'; diff -Nru postgresql-common-173+ppa1/t/100_upgrade_scripts.t postgresql-common-190~ubuntu16.04.1/t/100_upgrade_scripts.t --- postgresql-common-173+ppa1/t/100_upgrade_scripts.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/100_upgrade_scripts.t 2018-01-12 14:08:47.000000000 +0000 @@ -7,7 +7,7 @@ my @versions = ($MAJORS[-1]); -use Test::More tests => 29; +use Test::More tests => 27; use PgCommon; # get_cluster_databases here and indirectly in run-upgrade-scripts is @@ -44,8 +44,8 @@ # create clusters foreach my $v (@versions) { is ((system "pg_createcluster $v main --start >/dev/null"), 0, "pg_createcluster $v main"); - is_program_out 'postgres', "createdb --cluster $v/main db1", 0, ''; - is_program_out 'postgres', "createdb --cluster $v/main db2", 0, ''; + is_program_out 'postgres', "createdb --cluster $v/main db1", 0, ($v < 8.3 ? "CREATE DATABASE\n" : ''); + is_program_out 'postgres', "createdb --cluster $v/main db2", 0, ($v < 8.3 ? "CREATE DATABASE\n" : ''); is_program_out 'postgres', "psql -q --cluster $v/main db1 -c 'CREATE TABLE log (str varchar)'", 0, ''; my @dbs = get_cluster_databases $v, 'main'; my @expected = ('template0', 'template1', 'db1', 'db2', 'postgres'); diff -Nru postgresql-common-173+ppa1/t/110_integrate_cluster.t postgresql-common-190~ubuntu16.04.1/t/110_integrate_cluster.t --- postgresql-common-173+ppa1/t/110_integrate_cluster.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/110_integrate_cluster.t 2018-01-12 14:08:47.000000000 +0000 @@ -8,7 +8,7 @@ my $version = $MAJORS[-1]; -use Test::More tests => 34; +use Test::More tests => 32; use PgCommon; delete $ENV{'LANG'}; diff -Nru postgresql-common-173+ppa1/t/120_pg_upgradecluster_scripts.t postgresql-common-190~ubuntu16.04.1/t/120_pg_upgradecluster_scripts.t --- postgresql-common-173+ppa1/t/120_pg_upgradecluster_scripts.t 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/120_pg_upgradecluster_scripts.t 2018-01-12 14:08:47.000000000 +0000 @@ -6,9 +6,9 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => ($#MAJORS == 0) ? 1 : 35; +use Test::More tests => (@MAJORS == 1) ? 1 : 31; -if ($#MAJORS == 0) { +if (@MAJORS == 1) { pass 'only one major version installed, skipping upgrade tests'; exit 0; } @@ -29,19 +29,17 @@ 'psql test -qc "create schema s; create table s.auxdata (x varchar(10)); insert into s.auxdata values (\'schema1\')"', 0, '', 'adding schema s and s.auxdata to test and fill in some values'; -# move current pg_upgradecluster.d aside for the test -if (-d '/etc/postgresql-common/pg_upgradecluster.d' and not -d '/etc/postgresql-common/pg_upgradecluster.d.psqltestsuite') { - ok ((rename '/etc/postgresql-common/pg_upgradecluster.d', - '/etc/postgresql-common/pg_upgradecluster.d.psqltestsuite'), - 'Temporarily moving away /etc/postgresql-common/pg_upgradecluster.d'); -} else { - pass '/etc/postgresql-common/pg_upgradecluster.d does not exist'; -} - -# create test scripts if (not -d '/etc/postgresql-common/pg_upgradecluster.d') { mkdir '/etc/postgresql-common/pg_upgradecluster.d' or die "mkdir: $!"; } + +# move existing files away +for my $f (glob("/etc/postgresql-common/pg_upgradecluster.d/*")) { + next if ($f =~ /\.disabled$/); + rename $f, "$f.disabled"; +} + +# create test scripts chmod 0755, '/etc/postgresql-common/pg_upgradecluster.d' or die "chmod: $!"; open F, '>/etc/postgresql-common/pg_upgradecluster.d/auxdata' or die "open: $!"; print F < 36; +use Test::More tests => 32; use PgCommon; my $testuser = 'postgres'; diff -Nru postgresql-common-173+ppa1/t/140_pg_config.t postgresql-common-190~ubuntu16.04.1/t/140_pg_config.t --- postgresql-common-173+ppa1/t/140_pg_config.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/140_pg_config.t 2018-01-31 12:29:59.000000000 +0000 @@ -5,7 +5,7 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => 8 * ($#MAJORS+2); +use Test::More tests => 14 * @MAJORS + ($PgCommon::rpm ? 1 : 2) * 12; my $multiarch = ''; unless ($PgCommon::rpm) { @@ -19,7 +19,7 @@ foreach $version (@MAJORS) { if ($version < '8.2') { pass "Skipping known-broken pg_config check for version $version"; - for (my $i = 0; $i < 7; ++$i) { pass '...'; } + for (my $i = 0; $i < 13; ++$i) { pass '...'; } next; } is_program_out 'postgres', "$PgCommon::binroot$version/bin/pg_config --pgxs", 0, @@ -32,17 +32,47 @@ "$PgCommon::binroot$version/lib\n"; is_program_out 'postgres', "$PgCommon::binroot$version/bin/pg_config --bindir", 0, "$PgCommon::binroot$version/bin\n"; + # mkdir should be in /bin on Debian. If /bin was linked to /usr/bin at build time, usrmerge was installed + SKIP: { + skip 'MKDIR_P not present before 9.0', 2 if ($version < 9.0); + my $mkdir_path = $PgCommon::rpm ? '/usr/bin' : '/bin'; + is_program_out 'postgres', "grep ^MKDIR_P $PgCommon::binroot$version/lib/pgxs/src/Makefile.global", 0, + "MKDIR_P = $mkdir_path/mkdir -p\n"; + } + SKIP: { + skip 'build path not canonicalized on RedHat', 4 if ($PgCommon::rpm); + my $pkgversion = `dpkg-query -f '\${Version}' -W postgresql-server-dev-$version`; + # check that we correctly canonicalized the build paths + SKIP: { + skip 'abs_top_builddir introduced in 9.5', 2 if ($version < 9.5); + skip 'abs_top_builddir not patched in Debian (old)stable', 2 if ($version < 10 and $pkgversion !~ /pgdg/); + is_program_out 'postgres', "grep ^abs_top_builddir $PgCommon::binroot$version/lib/pgxs/src/Makefile.global", 0, + "abs_top_builddir = /build/postgresql-$version/build\n"; + } + SKIP: { + skip 'abs_top_srcdir not patched before 9.3', 2 if ($version < 9.3); + skip 'abs_top_srcdir not patched in Debian (old)stable', 2 if ($version < 10 and $pkgversion !~ /pgdg/); + is_program_out 'postgres', "grep ^abs_top_srcdir $PgCommon::binroot$version/lib/pgxs/src/Makefile.global", 0, + "abs_top_srcdir = /build/postgresql-$version/build/..\n"; + } + } } # check client-side output (should behave like latest server-side one) $version = $ALL_MAJORS[-1]; -is_program_out 'postgres', "pg_config --pgxs", 0, - "$PgCommon::binroot$version/lib/pgxs/src/makefiles/pgxs.mk\n"; -my $libdir = "/usr/lib" . ($version >= 9.3 and $multiarch ? "/$multiarch" : "") . "\n"; -$libdir = "$PgCommon::binroot$version/lib\n" if ($PgCommon::rpm); -is_program_out 'postgres', "pg_config --libdir", 0, - $libdir; -is_program_out 'postgres', "pg_config --pkglibdir", 0, - "$PgCommon::binroot$version/lib\n"; -is_program_out 'postgres', "pg_config --bindir", 0, - "$PgCommon::binroot$version/bin\n"; +my $full_output = `$PgCommon::binroot$version/bin/pg_config`; +my @pg_configs = $PgCommon::rpm ? qw(pg_config) : qw(pg_config pg_config.libpq-dev); +for my $pg_config (@pg_configs) { + is_program_out 'postgres', "$pg_config", 0, $full_output; + like_program_out 'postgres', "$pg_config --help", 0, qr/--includedir-server/; + is_program_out 'postgres', "$pg_config --pgxs", 0, + "$PgCommon::binroot$version/lib/pgxs/src/makefiles/pgxs.mk\n"; + my $libdir = "/usr/lib" . ($version >= 9.3 and $multiarch ? "/$multiarch" : "") . "\n"; + $libdir = "$PgCommon::binroot$version/lib\n" if ($PgCommon::rpm); + is_program_out 'postgres', "$pg_config --libdir", 0, + $libdir; + is_program_out 'postgres', "$pg_config --pkglibdir", 0, + "$PgCommon::binroot$version/lib\n"; + is_program_out 'postgres', "$pg_config --bindir", 0, + "$PgCommon::binroot$version/bin\n"; +} diff -Nru postgresql-common-173+ppa1/t/150_tsearch_stemming.t postgresql-common-190~ubuntu16.04.1/t/150_tsearch_stemming.t --- postgresql-common-173+ppa1/t/150_tsearch_stemming.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/150_tsearch_stemming.t 2018-01-31 11:36:05.000000000 +0000 @@ -8,7 +8,11 @@ my $version = $MAJORS[-1]; -use Test::More tests => $PgCommon::rpm ? 1 : 39; +use Test::More tests => ($MAJORS[-1] < 8.3 or $PgCommon::rpm) ? 1 : 37; +if ($version < 8.3) { + pass 'tsearch dictionaries not tested before 8.3'; + exit; +} if ($PgCommon::rpm) { pass 'tsearch dictionaries not handled by postgresql-common on RedHat'; exit; diff -Nru postgresql-common-173+ppa1/t/160_alternate_confroot.t postgresql-common-190~ubuntu16.04.1/t/160_alternate_confroot.t --- postgresql-common-173+ppa1/t/160_alternate_confroot.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/160_alternate_confroot.t 2018-01-12 14:08:47.000000000 +0000 @@ -7,7 +7,7 @@ my $version = $MAJORS[0]; -use Test::More tests => 30; +use Test::More tests => 28; # prepare nobody-owned root dir for $PG_CLUSTER_CONF_ROOT my $rootdir=`su -s /bin/sh -c 'mktemp -d' nobody`; diff -Nru postgresql-common-173+ppa1/t/180_ecpg.t postgresql-common-190~ubuntu16.04.1/t/180_ecpg.t --- postgresql-common-173+ppa1/t/180_ecpg.t 2015-05-06 21:25:15.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/180_ecpg.t 2018-01-12 14:08:47.000000000 +0000 @@ -5,7 +5,7 @@ use lib 't'; use TestLib; use PgCommon; -use Test::More tests => 19; +use Test::More tests => 17; my $v = $MAJORS[-1]; diff -Nru postgresql-common-173+ppa1/t/9.5.conf postgresql-common-190~ubuntu16.04.1/t/9.5.conf --- postgresql-common-173+ppa1/t/9.5.conf 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/9.5.conf 2018-01-12 14:08:47.000000000 +0000 @@ -0,0 +1,217 @@ +listen_addresses = 'localhost' +port = 5432 +max_connections = 100 +superuser_reserved_connections = 3 +unix_socket_directories = '/var/run/postgresql' +unix_socket_group = '' +unix_socket_permissions = 0777 +bonjour = off +bonjour_name = '' +authentication_timeout = 1min +ssl = true +ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' +ssl_prefer_server_ciphers = on +ssl_ecdh_curve = 'prime256v1' +ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' +ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' +ssl_ca_file = '' +ssl_crl_file = '' +password_encryption = on +db_user_namespace = off +row_security = on +krb_server_keyfile = '' +krb_caseins_users = off +tcp_keepalives_idle = 0 +tcp_keepalives_interval = 0 +tcp_keepalives_count = 0 +shared_buffers = 128MB +huge_pages = try +temp_buffers = 8MB +max_prepared_transactions = 0 +work_mem = 4MB +maintenance_work_mem = 64MB +autovacuum_work_mem = -1 +max_stack_depth = 2MB +dynamic_shared_memory_type = posix +temp_file_limit = -1 +max_files_per_process = 1000 +shared_preload_libraries = '' +vacuum_cost_delay = 0 +vacuum_cost_page_hit = 1 +vacuum_cost_page_miss = 10 +vacuum_cost_page_dirty = 20 +vacuum_cost_limit = 200 +bgwriter_delay = 200ms +bgwriter_lru_maxpages = 100 +bgwriter_lru_multiplier = 2.0 +effective_io_concurrency = 1 +max_worker_processes = 8 +wal_level = minimal +fsync = on +synchronous_commit = on +wal_sync_method = fsync +full_page_writes = on +wal_compression = off +wal_log_hints = off +wal_buffers = -1 +wal_writer_delay = 200ms +commit_delay = 0 +commit_siblings = 5 +checkpoint_timeout = 5min +max_wal_size = 1GB +min_wal_size = 80MB +checkpoint_completion_target = 0.5 +checkpoint_warning = 30s +archive_mode = off +archive_command = '' +archive_timeout = 0 +max_wal_senders = 0 +wal_keep_segments = 0 +wal_sender_timeout = 60s +max_replication_slots = 0 +track_commit_timestamp = off +synchronous_standby_names = '' +vacuum_defer_cleanup_age = 0 +hot_standby = off +max_standby_archive_delay = 30s +max_standby_streaming_delay = 30s +wal_receiver_status_interval = 10s +hot_standby_feedback = off +wal_receiver_timeout = 60s +wal_retrieve_retry_interval = 5s +enable_bitmapscan = on +enable_hashagg = on +enable_hashjoin = on +enable_indexscan = on +enable_indexonlyscan = on +enable_material = on +enable_mergejoin = on +enable_nestloop = on +enable_seqscan = on +enable_sort = on +enable_tidscan = on +seq_page_cost = 1.0 +random_page_cost = 4.0 +cpu_tuple_cost = 0.01 +cpu_index_tuple_cost = 0.005 +cpu_operator_cost = 0.0025 +effective_cache_size = 4GB +geqo = on +geqo_threshold = 12 +geqo_effort = 5 +geqo_pool_size = 0 +geqo_generations = 0 +geqo_selection_bias = 2.0 +geqo_seed = 0.0 +default_statistics_target = 100 +constraint_exclusion = partition +cursor_tuple_fraction = 0.1 +from_collapse_limit = 8 +join_collapse_limit = 8 +log_destination = 'stderr' +logging_collector = off +log_directory = 'pg_log' +log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' +log_file_mode = 0600 +log_truncate_on_rotation = off +log_rotation_age = 1d +log_rotation_size = 10MB +syslog_facility = 'LOCAL0' +syslog_ident = 'postgres' +event_source = 'PostgreSQL' +client_min_messages = notice +log_min_messages = warning +log_min_error_statement = error +log_min_duration_statement = -1 +debug_print_parse = off +debug_print_rewritten = off +debug_print_plan = off +debug_pretty_print = on +log_checkpoints = off +log_connections = off +log_disconnections = off +log_duration = off +log_error_verbosity = default +log_hostname = off +log_line_prefix = '%t [%p-%l] %q%u@%d ' +log_lock_waits = off +log_statement = 'none' +log_replication_commands = off +log_temp_files = -1 +log_timezone = 'CET' +cluster_name = '9.5/main' +update_process_title = on +track_activities = on +track_counts = on +track_io_timing = off +track_functions = none +track_activity_query_size = 1024 +stats_temp_directory = '/var/run/postgresql/9.5-main.pg_stat_tmp' +log_parser_stats = off +log_planner_stats = off +log_executor_stats = off +log_statement_stats = off +autovacuum = on +log_autovacuum_min_duration = -1 +autovacuum_max_workers = 3 +autovacuum_naptime = 1min +autovacuum_vacuum_threshold = 50 +autovacuum_analyze_threshold = 50 +autovacuum_vacuum_scale_factor = 0.2 +autovacuum_analyze_scale_factor = 0.1 +autovacuum_freeze_max_age = 200000000 +autovacuum_multixact_freeze_max_age = 400000000 +autovacuum_vacuum_cost_delay = 20ms +autovacuum_vacuum_cost_limit = -1 +search_path = '"$user", public' +default_tablespace = '' +temp_tablespaces = '' +check_function_bodies = on +default_transaction_isolation = 'read committed' +default_transaction_read_only = off +default_transaction_deferrable = off +session_replication_role = 'origin' +statement_timeout = 0 +lock_timeout = 0 +vacuum_freeze_min_age = 50000000 +vacuum_freeze_table_age = 150000000 +vacuum_multixact_freeze_min_age = 5000000 +vacuum_multixact_freeze_table_age = 150000000 +bytea_output = 'hex' +xmlbinary = 'base64' +xmloption = 'content' +gin_fuzzy_search_limit = 0 +gin_pending_list_limit = 4MB +datestyle = 'iso, dmy' +intervalstyle = 'postgres' +timezone = 'CET' +timezone_abbreviations = 'Default' +extra_float_digits = 0 +client_encoding = sql_ascii +lc_messages = 'C' +lc_monetary = 'C' +lc_numeric = 'C' +lc_time = 'C' +default_text_search_config = 'pg_catalog.german' +dynamic_library_path = '$libdir' +local_preload_libraries = '' +session_preload_libraries = '' +deadlock_timeout = 1s +max_locks_per_transaction = 64 +max_pred_locks_per_transaction = 64 +array_nulls = on +backslash_quote = safe_encoding +default_with_oids = off +escape_string_warning = on +lo_compat_privileges = off +operator_precedence_warning = off +quote_all_identifiers = off +sql_inheritance = on +standard_conforming_strings = on +synchronize_seqscans = on +transform_null_equals = off +exit_on_error = off +restart_after_crash = on +#include_dir = 'conf.d' +include_if_exists = 'exists.conf' +#include = 'special.conf' diff -Nru postgresql-common-173+ppa1/t/9.6.conf postgresql-common-190~ubuntu16.04.1/t/9.6.conf --- postgresql-common-173+ppa1/t/9.6.conf 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/9.6.conf 2018-01-12 14:08:47.000000000 +0000 @@ -0,0 +1,231 @@ +listen_addresses = 'localhost' +port = 5432 +max_connections = 100 +superuser_reserved_connections = 3 +unix_socket_directories = '/var/run/postgresql' +unix_socket_group = '' +unix_socket_permissions = 0777 +bonjour = off +bonjour_name = '' +authentication_timeout = 1min +ssl = true +ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' +ssl_prefer_server_ciphers = on +ssl_ecdh_curve = 'prime256v1' +ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' +ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' +ssl_ca_file = '' +ssl_crl_file = '' +password_encryption = on +db_user_namespace = off +row_security = on +krb_server_keyfile = '' +krb_caseins_users = off +tcp_keepalives_idle = 0 +tcp_keepalives_interval = 0 +tcp_keepalives_count = 0 +shared_buffers = 128MB +huge_pages = try +temp_buffers = 8MB +max_prepared_transactions = 0 +work_mem = 4MB +maintenance_work_mem = 64MB +replacement_sort_tuples = 150000 +autovacuum_work_mem = -1 +max_stack_depth = 2MB +dynamic_shared_memory_type = posix +temp_file_limit = -1 +max_files_per_process = 1000 +shared_preload_libraries = '' +vacuum_cost_delay = 0 +vacuum_cost_page_hit = 1 +vacuum_cost_page_miss = 10 +vacuum_cost_page_dirty = 20 +vacuum_cost_limit = 200 +bgwriter_delay = 200ms +bgwriter_lru_maxpages = 100 +bgwriter_lru_multiplier = 2.0 +bgwriter_flush_after = 0 +effective_io_concurrency = 1 +max_worker_processes = 8 +max_parallel_workers_per_gather = 2 +old_snapshot_threshold = -1 +backend_flush_after = 0 +wal_level = minimal +fsync = on +synchronous_commit = on +wal_sync_method = fsync +full_page_writes = on +wal_compression = off +wal_log_hints = off +wal_buffers = -1 +wal_writer_delay = 200ms +wal_writer_flush_after = 1MB +commit_delay = 0 +commit_siblings = 5 +checkpoint_timeout = 5min +max_wal_size = 1GB +min_wal_size = 80MB +checkpoint_completion_target = 0.5 +checkpoint_flush_after = 0 +checkpoint_warning = 30s +archive_mode = off +archive_command = '' +archive_timeout = 0 +max_wal_senders = 0 +wal_keep_segments = 0 +wal_sender_timeout = 60s +max_replication_slots = 0 +track_commit_timestamp = off +synchronous_standby_names = '' +vacuum_defer_cleanup_age = 0 +hot_standby = off +max_standby_archive_delay = 30s +max_standby_streaming_delay = 30s +wal_receiver_status_interval = 10s +hot_standby_feedback = off +wal_receiver_timeout = 60s +wal_retrieve_retry_interval = 5s +enable_bitmapscan = on +enable_hashagg = on +enable_hashjoin = on +enable_indexscan = on +enable_indexonlyscan = on +enable_material = on +enable_mergejoin = on +enable_nestloop = on +enable_seqscan = on +enable_sort = on +enable_tidscan = on +seq_page_cost = 1.0 +random_page_cost = 4.0 +cpu_tuple_cost = 0.01 +cpu_index_tuple_cost = 0.005 +cpu_operator_cost = 0.0025 +parallel_tuple_cost = 0.1 +parallel_setup_cost = 1000.0 +min_parallel_relation_size = 8MB +effective_cache_size = 4GB +geqo = on +geqo_threshold = 12 +geqo_effort = 5 +geqo_pool_size = 0 +geqo_generations = 0 +geqo_selection_bias = 2.0 +geqo_seed = 0.0 +default_statistics_target = 100 +constraint_exclusion = partition +cursor_tuple_fraction = 0.1 +from_collapse_limit = 8 +join_collapse_limit = 8 +force_parallel_mode = off +log_destination = 'stderr' +logging_collector = off +log_directory = 'pg_log' +log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' +log_file_mode = 0600 +log_truncate_on_rotation = off +log_rotation_age = 1d +log_rotation_size = 10MB +syslog_facility = 'LOCAL0' +syslog_ident = 'postgres' +syslog_sequence_numbers = on +syslog_split_messages = on +event_source = 'PostgreSQL' +client_min_messages = notice +log_min_messages = warning +log_min_error_statement = error +log_min_duration_statement = -1 +debug_print_parse = off +debug_print_rewritten = off +debug_print_plan = off +debug_pretty_print = on +log_checkpoints = off +log_connections = off +log_disconnections = off +log_duration = off +log_error_verbosity = default +log_hostname = off +log_line_prefix = '%t [%p-%l] %q%u@%d ' +log_lock_waits = off +log_statement = 'none' +log_replication_commands = off +log_temp_files = -1 +log_timezone = 'CET' +cluster_name = '9.6/main' +update_process_title = on +track_activities = on +track_counts = on +track_io_timing = off +track_functions = none +track_activity_query_size = 1024 +stats_temp_directory = '/var/run/postgresql/9.6-main.pg_stat_tmp' +log_parser_stats = off +log_planner_stats = off +log_executor_stats = off +log_statement_stats = off +autovacuum = on +log_autovacuum_min_duration = -1 +autovacuum_max_workers = 3 +autovacuum_naptime = 1min +autovacuum_vacuum_threshold = 50 +autovacuum_analyze_threshold = 50 +autovacuum_vacuum_scale_factor = 0.2 +autovacuum_analyze_scale_factor = 0.1 +autovacuum_freeze_max_age = 200000000 +autovacuum_multixact_freeze_max_age = 400000000 +autovacuum_vacuum_cost_delay = 20ms +autovacuum_vacuum_cost_limit = -1 +search_path = '"$user", public' +default_tablespace = '' +temp_tablespaces = '' +check_function_bodies = on +default_transaction_isolation = 'read committed' +default_transaction_read_only = off +default_transaction_deferrable = off +session_replication_role = 'origin' +statement_timeout = 0 +lock_timeout = 0 +idle_in_transaction_session_timeout = 0 +vacuum_freeze_min_age = 50000000 +vacuum_freeze_table_age = 150000000 +vacuum_multixact_freeze_min_age = 5000000 +vacuum_multixact_freeze_table_age = 150000000 +bytea_output = 'hex' +xmlbinary = 'base64' +xmloption = 'content' +gin_fuzzy_search_limit = 0 +gin_pending_list_limit = 4MB +datestyle = 'iso, dmy' +intervalstyle = 'postgres' +timezone = 'CET' +timezone_abbreviations = 'Default' +extra_float_digits = 0 +client_encoding = sql_ascii +lc_messages = 'C' +lc_monetary = 'C' +lc_numeric = 'C' +lc_time = 'C' +default_text_search_config = 'pg_catalog.german' +dynamic_library_path = '$libdir' +local_preload_libraries = '' +session_preload_libraries = '' +deadlock_timeout = 1s +max_locks_per_transaction = 64 +max_pred_locks_per_transaction = 64 +array_nulls = on +backslash_quote = safe_encoding +default_with_oids = off +escape_string_warning = on +lo_compat_privileges = off +operator_precedence_warning = off +quote_all_identifiers = off +sql_inheritance = on +standard_conforming_strings = on +synchronize_seqscans = on +transform_null_equals = off +exit_on_error = off +restart_after_crash = on +#include_dir = 'conf.d' +include_if_exists = 'exists.conf' +#include = 'special.conf' diff -Nru postgresql-common-173+ppa1/t/TestLib.pm postgresql-common-190~ubuntu16.04.1/t/TestLib.pm --- postgresql-common-173+ppa1/t/TestLib.pm 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/t/TestLib.pm 2018-01-31 12:29:59.000000000 +0000 @@ -1,7 +1,7 @@ # Common functionality for postgresql-common self tests # # (C) 2005-2009 Martin Pitt -# (C) 2013-2015 Christoph Berg +# (C) 2013-2016 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ pidof pid_env check_clean @ALL_MAJORS @MAJORS $delay/; -our @ALL_MAJORS = sort (get_versions()); # not affected by PG_VERSIONS/-v +our @ALL_MAJORS = get_versions(); # not affected by PG_VERSIONS/-v our @MAJORS = $ENV{PG_VERSIONS} ? split (/\s+/, $ENV{PG_VERSIONS}) : @ALL_MAJORS; our $delay = 500_000; # 500ms @@ -98,12 +98,14 @@ return `ps h -o user,group,args -C $_[0] | grep '$_[0]' | sort -u`; } -# Return array of pids that match the given command line +# Return array of pids that match the given command name (we require a leading +# slash so the postgres children are filtered out) sub pidof { - open F, '-|', 'ps', 'h', '-C', $_[0], '-o', 'pid,cmd' or die "open: $!"; + my $prg = shift; + open F, '-|', 'ps', 'h', '-C', $prg, '-o', 'pid,cmd' or die "open: $!"; my @pids; while () { - if ((index $_, $_[0]) >= 0 && (index $_, '/') >= 0) { + if ((index $_, "/$prg") >= 0) { push @pids, (split)[0]; } } @@ -121,9 +123,10 @@ # Return environment of given PID sub pid_env { - my $path = "/proc/$_[0]/environ"; + my ($user, $pid) = @_; + my $path = "/proc/$pid/environ"; my @lines; - open E, $path or die "open $path: $!"; + open E, "su -c 'cat $path' $user |" or warn "open $path: $!"; { local $/; @lines = split '\0', ; @@ -219,13 +222,11 @@ } # Check that all PostgreSQL related directories are empty and no -# postmaster processes are running. Should be called at the end +# postgres processes are running. Should be called at the end # of all tests. Does 10 tests. sub check_clean { - is (`pg_lsclusters -h`, '', 'No existing clusters'); - is ((ps 'postmaster'), '', 'No postmaster processes left behind'); + is (`pg_lsclusters -h`, '', 'Cleanup: No clusters left behind'); is ((ps 'postgres'), '', 'No postgres processes left behind'); - pass ''; # this was pg_autovacuum in the past, which is obsolete my @check_dirs = ('/etc/postgresql', '/var/lib/postgresql', '/var/run/postgresql'); @@ -240,7 +241,7 @@ # complain about missing directories ok_dir '/var/log/postgresql', [], "No files in /var/log/postgresql left behind"; - is_program_out 0, 'netstat -avptn | grep ":543[2-9]\\b"', 1, '', + is_program_out 0, 'netstat -avptn 2>/dev/null | grep ":543[2-9]\\b"', 1, '', 'PostgreSQL TCP ports are closed'; } diff -Nru postgresql-common-173+ppa1/testsuite postgresql-common-190~ubuntu16.04.1/testsuite --- postgresql-common-173+ppa1/testsuite 2016-03-29 08:53:13.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/testsuite 2018-01-31 12:29:59.000000000 +0000 @@ -3,7 +3,7 @@ # Run integration tests (on the installed packages). # # (C) 2005-2012 Martin Pitt -# (C) 2012-2015 Christoph Berg +# (C) 2012-2018 Christoph Berg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ # default config TESTSDIR="$(dirname $0)/t" -: ${PG_UMASKS="022 077"} +: ${PG_UMASKS="077"} # default umask(s) to try help () { @@ -30,7 +30,7 @@ echo " -i install packages for versions specified by -v" echo " -M don't mount tmpfses, run in the host system" echo " -s start a shell in the testbed on failure" - echo " -u 'umask ...' umasks to run testsuite with [default: 022 077]" + echo " -u 'umask ...' umasks to run testsuite with [default: 077]" echo " -v 'version ...' PostgreSQL versions to test [default: client versions installed]" echo " -V debug output" exit ${1:-0} @@ -43,7 +43,7 @@ f) FROM="$OPTARG" ;; i) INSTALL=1 ;; h) help ;; - M) NO_TMPFS=1 ;; + M) export NO_TMPFS=1 ;; s) export FAILURE="shell" ;; u) PG_UMASKS="$OPTARG" ;; v) export PG_VERSIONS="$OPTARG" ;; # used in t/TestLib.pm @@ -57,33 +57,52 @@ exit 1 fi +# use the local pgcommon.sh (either in the build tree or /usr/share/postgresql-common) +. ./pgcommon.sh +get_release + # install packages for versions specified by -v # needs network for apt, so run before unshare if [ "${INSTALL:-}" ] && [ -z "${UNSHARED:-}" ]; then - for v in $PG_VERSIONS; do - apt-get install -y postgresql-contrib-$v \ - postgresql-plperl-$v \ - postgresql-plpython-$v \ - postgresql-plpython3-$v \ - postgresql-pltcl-$v \ - postgresql-server-dev-$v - done - apt-get install -y libecpg-dev \ - locales \ - logrotate \ - procps \ - netcat-openbsd \ - hunspell-en-us + case $DISTRO in + debian|ubuntu) + for v in $PG_VERSIONS; do + apt-get install -y \ + postgresql-contrib-$v \ + postgresql-plperl-$v \ + postgresql-plpython-$v \ + postgresql-plpython3-$v \ + postgresql-pltcl-$v \ + postgresql-server-dev-$v + done + apt-get install -y libecpg-dev \ + locales \ + procps systemd \ + netcat-openbsd \ + hunspell-en-us \ + gcc + ;; + redhat|centos) + for v in $PG_VERSIONS; do + vv=$(echo $v | tr -d .) + yum install -y \ + postgresql$vv-contrib \ + postgresql$vv-plperl \ + postgresql$vv-plpython \ + postgresql$vv-pltcl \ + postgresql$vv-devel + done + yum install -y \ + nmap-ncat \ + perl-Test-Simple perl-Time-HiRes \ + gcc + ;; + esac fi -# requirements on RedHat: -# perl-Test-Simple perl-Time-HiRes # shift away args shift $(($OPTIND - 1)) -# use the local pgcommon.sh (either in the build tree or /usr/share/postgresql-common) -. ./pgcommon.sh - # install locales locale_gen \ en_US.UTF-8 UTF-8 \ @@ -166,13 +185,7 @@ fi for U in $PG_UMASKS; do - case $U in - 022) TYPE="default" ;; - 077) TYPE="tight" ;; - *) TYPE="custom" ;; - esac - - echo "====== Running all tests with $TYPE umask $U =======" + echo "====== Running all tests with umask $U =======" umask $U for T; do TBASE=${T##*/} diff -Nru postgresql-common-173+ppa1/.travis.yml postgresql-common-190~ubuntu16.04.1/.travis.yml --- postgresql-common-173+ppa1/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ postgresql-common-190~ubuntu16.04.1/.travis.yml 2018-01-29 13:13:52.000000000 +0000 @@ -0,0 +1,46 @@ +# run the testsuite on travis-ci.com +--- +# versions to run on +env: + - PG_SUPPORTED_VERSIONS=pgdg + - PG_SUPPORTED_VERSIONS=11 + +language: C +dist: trusty +sudo: required + +before_install: + # remove the travis-provided clusters + - sudo service postgresql stop && sudo apt-get remove --purge postgresql-client-common + - | + sudo tee /etc/apt/preferences.d/pgdg.pref <