├── .gitignore ├── .vimrc ├── Makefile ├── PgCommon.pm ├── README.md ├── TODO ├── cleanpg ├── createcluster.conf ├── debhelper ├── Debian │ └── Debhelper │ │ ├── Buildsystem │ │ ├── pgxs.pm │ │ └── pgxs_loop.pm │ │ ├── Sequence │ │ ├── pgxs.pm │ │ └── pgxs_loop.pm │ │ └── pgxs.pm ├── dh_pgxs_test └── dh_pgxs_test.pod ├── debian ├── .gitignore ├── README.Debian ├── changelog ├── clean ├── control ├── copyright ├── gitlab-ci.yml ├── init.d-functions ├── maintscripts-functions ├── po │ ├── POTFILES.in │ ├── ca.po │ ├── cs.po │ ├── da.po │ ├── de.po │ ├── es.po │ ├── eu.po │ ├── fi.po │ ├── fr.po │ ├── gl.po │ ├── it.po │ ├── ja.po │ ├── nl.po │ ├── pt.po │ ├── pt_BR.po │ ├── ro.po │ ├── ru.po │ ├── sv.po │ ├── templates.pot │ ├── tr.po │ └── vi.po ├── postgresql-client-common.dirs ├── postgresql-client-common.install ├── postgresql-client-common.links ├── postgresql-client-common.lintian-overrides ├── postgresql-client-common.manpages ├── postgresql-client-common.postrm ├── postgresql-common.NEWS ├── postgresql-common.config ├── postgresql-common.dirs ├── postgresql-common.docs ├── postgresql-common.install ├── postgresql-common.links ├── postgresql-common.lintian-overrides ├── postgresql-common.logrotate ├── postgresql-common.maintscript ├── postgresql-common.manpages ├── postgresql-common.postgresql.init ├── postgresql-common.postinst ├── postgresql-common.postrm ├── postgresql-common.preinst ├── postgresql-common.templates ├── postgresql-common.tmpfile ├── postgresql-common.triggers ├── postgresql-server-dev-all.install ├── postgresql-server-dev-all.manpages ├── rules ├── source │ └── format ├── supported-versions └── tests │ ├── control │ ├── default-psql │ └── run-testsuite ├── dh_make_pgxs ├── debian │ ├── control.in │ ├── copyright │ ├── gitlab-ci.yml │ ├── pgversions │ ├── rules │ ├── source │ │ └── format │ ├── tests │ │ ├── control │ │ └── installcheck │ └── watch ├── dh_make_pgxs └── dh_make_pgxs.pod ├── doc ├── dependencies.dia ├── dependencies.svg └── postgresql-debian-packaging.md ├── gitlab └── gitlab-ci.yml ├── pg_backupcluster ├── pg_buildext ├── pg_buildext.pod ├── pg_checksystem ├── pg_config ├── pg_conftool ├── pg_createcluster ├── pg_ctlcluster ├── pg_dropcluster ├── pg_getwal ├── pg_hba ├── pg_lsclusters ├── pg_renamecluster ├── pg_restorecluster ├── pg_updateaptconfig ├── pg_updatedicts ├── pg_upgradecluster ├── pg_upgradecluster.d └── analyze ├── pg_virtualenv ├── pg_virtualenv.pod ├── pg_wrapper ├── pgdg ├── Makefile ├── apt.postgresql.org.asc ├── apt.postgresql.org.gpg ├── apt.postgresql.org.sh └── update ├── pgxs_debian_control.mk ├── postgresqlrc.5 ├── rpm ├── .gitignore ├── README ├── init-functions-compat └── postgresql-common.spec ├── server ├── README ├── catversion ├── pg_config.pl ├── postgresql.mk └── test-with-jit.conf ├── systemd ├── README.systemd ├── system-generators │ └── postgresql-generator └── system │ ├── pg_basebackup@.service │ ├── pg_basebackup@.timer │ ├── pg_compresswal@.service │ ├── pg_compresswal@.timer │ ├── pg_dump@.service │ ├── pg_dump@.timer │ ├── pg_receivewal@.service │ ├── postgresql.service │ └── postgresql@.service ├── t ├── 001_packages.t ├── 002_existing_clusters.t ├── 003_alternatives.t ├── 005_PgCommon.t ├── 006_next_free_port.t ├── 007_pg_conftool.t ├── 010_defaultport_cluster.t ├── 015_start_stop.t ├── 020_create_sql_remove.t ├── 021_pg_renamecluster.t ├── 022_recovery.t ├── 025_logging.t ├── 027_jit.t ├── 030_errors.t ├── 031_errors_disk_full.t ├── 032_ssl_key_permissions.t ├── 040_upgrade.t ├── 041_upgrade_custompaths.t ├── 042_upgrade_rename.t ├── 043_upgrade_ssl_cert.t ├── 045_backup.t ├── 050_encodings.t ├── 052_upgrade_encodings.t ├── 060_obsolete_confparams.t ├── 070_non_postgres_clusters.t ├── 080_start.conf.t ├── 085_pg_ctl.conf.t ├── 090_multicluster.t ├── 110_integrate_cluster.t ├── 120_pg_upgradecluster_scripts.t ├── 130_nonroot_admin.t ├── 135_pg_virtualenv.t ├── 140_pg_config.t ├── 150_tsearch_stemming.t ├── 160_alternate_confroot.t ├── 170_extensions.t ├── 180_ecpg.t ├── 190_pg_buildext.t ├── 200_maintscripts.t ├── TestLib.pm ├── bar │ └── debian │ │ ├── control.in │ │ └── pgversions ├── foo │ ├── Makefile │ └── foo-123 │ │ ├── Makefile │ │ ├── README.md │ │ ├── expected │ │ ├── foo.out │ │ └── upgrade.out │ │ ├── foo--100--123.sql │ │ ├── foo--100.sql │ │ ├── foo--123.sql │ │ ├── foo.c │ │ ├── foo.control │ │ └── sql │ │ ├── foo.sql │ │ └── upgrade.sql └── template ├── testsuite ├── user_clusters └── user_clusters.5 /.gitignore: -------------------------------------------------------------------------------- 1 | *.1 2 | *.8 3 | supported_versions 4 | t/bar/debian/control 5 | t/foo/foo_123*.* 6 | t/foo/foo-123/build-*/ 7 | t/foo/foo-123/debian/ 8 | t/foo/postgresql-*-foo*.deb 9 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | set expandtab 2 | set shiftwidth=4 3 | set smarttab 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | POD2MAN=pod2man --center "Debian PostgreSQL infrastructure" -r "Debian" 2 | POD1PROGS = pg_backupcluster.1 \ 3 | pg_conftool.1 \ 4 | pg_createcluster.1 \ 5 | pg_ctlcluster.1 \ 6 | pg_dropcluster.1 \ 7 | pg_getwal.1 \ 8 | pg_lsclusters.1 \ 9 | pg_renamecluster.1 \ 10 | pg_restorecluster.1 \ 11 | pg_upgradecluster.1 \ 12 | pg_wrapper.1 13 | POD1PROGS_POD = pg_buildext.1 \ 14 | pg_virtualenv.1 \ 15 | debhelper/dh_pgxs_test.1 \ 16 | dh_make_pgxs/dh_make_pgxs.1 17 | POD8PROGS = pg_updatedicts.8 18 | 19 | all: man sub-pgdg 20 | 21 | man: $(POD1PROGS) $(POD1PROGS_POD) $(POD8PROGS) 22 | 23 | %.1: %.pod 24 | $(POD2MAN) --quotes=none --section 1 $< $@ 25 | 26 | %.1: % 27 | $(POD2MAN) --quotes=none --section 1 $< $@ 28 | 29 | %.8: % 30 | $(POD2MAN) --quotes=none --section 8 $< $@ 31 | 32 | clean: 33 | rm -f *.1 *.8 debhelper/*.1 dh_make_pgxs/*.1 34 | 35 | sub-pgdg: 36 | $(MAKE) -C pgdg 37 | 38 | # rpm 39 | 40 | DPKG_VERSION=$(shell sed -ne '1s/.*(//; 1s/).*//p' debian/changelog) 41 | RPMDIR=$(CURDIR)/rpm 42 | TARNAME=postgresql-common_$(DPKG_VERSION).tar.xz 43 | TARBALL=$(RPMDIR)/SOURCES/$(TARNAME) 44 | 45 | rpmbuild: $(TARBALL) 46 | rpmbuild -D"%_topdir $(RPMDIR)" --define='version $(DPKG_VERSION)' -ba rpm/postgresql-common.spec 47 | 48 | $(TARBALL): 49 | mkdir -p $(dir $(TARBALL)) 50 | if test -f ../$(TARNAME); then \ 51 | cp -v ../$(TARNAME) $(TARBALL); \ 52 | else \ 53 | git archive --prefix=postgresql-common-$(DPKG_VERSION)/ HEAD | xz > $(TARBALL); \ 54 | fi 55 | 56 | rpminstall: 57 | sudo yum install -y perl-JSON 58 | sudo rpm --upgrade --replacefiles --replacepkgs -v $(RPMDIR)/RPMS/noarch/*-$(DPKG_VERSION)-*.rpm 59 | 60 | rpmremove: 61 | -sudo rpm -e postgresql-common postgresql-client-common postgresql-server-dev-all 62 | 63 | rpmclean: 64 | rm -rf $(RPMDIR)/*/ 65 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | postgresql TODO 2 | =============== 3 | 4 | Bugs: 5 | - pg_createcluster with existing cluster: respect symlinks to shared 6 | postgresql.conf files, never remove symlinks in already existing 7 | cluster dirs 8 | - Clean up at purging if /etc/ is there without /var, or vice versa 9 | 10 | Transition bugs: 11 | 12 | Missing selftest: 13 | - --force option for pg_ctlcluster 14 | 15 | Important features: 16 | 17 | Wishlist: 18 | - Add pg_conf to change startup and possibly other things 19 | - add program for web applications, which configure pg_hba.conf: 20 | 21 | pg_hba add|remove|test [options] yourwebappdb yourwebappuser 22 | 23 | Options: 24 | 25 | --cluster: self-explanatory, defaults to default cluster 26 | --ip: IP and netmask for host socket; if not given, defaults to Unix 27 | socket (local) 28 | --method: defaults to "md5" for TCP connections, and "ident sameuser" for 29 | Unix socket connections 30 | --force-ssl: If given, create a "hostssl" entry, otherwise a "host" 31 | entry 32 | 33 | For remove, only --cluster is allowed; it will remove all hba 34 | entries that refer to the given db/user pair. test checks whether the 35 | given connection is allowed; if so, it exits with 0, otherwise it prints the 36 | required pg_hba.conf line to stdout and exits with 1. If pg_hba.conf has a 37 | scrambled format that cannot be parsed by pg_*_hba, the scripts exit with 2. 38 | 39 | Add libnet-cidr-perl dependency! 40 | -------------------------------------------------------------------------------- /cleanpg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Clean all traces of PostgreSQL data/configuration from the current system. 4 | # Use with caution, for development/testing only! (This is not installed into 5 | # packages.) 6 | # 7 | # (C) 2008-2009 Martin Pitt 8 | # (C) 2018 Christoph Berg 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | set -ux 21 | 22 | /etc/init.d/postgresql stop 23 | killall postgres 24 | rm -rf /etc/postgresql/* /var/lib/postgresql/* /var/log/postgresql/* /tmp/postgresql-testsuite/ /var/run/postgresql/* 25 | -------------------------------------------------------------------------------- /createcluster.conf: -------------------------------------------------------------------------------- 1 | # Default values for pg_createcluster(8) 2 | # Occurrences of '%v' are replaced by the major version number, 3 | # and '%c' by the cluster name. Use '%%' for a literal '%'. 4 | 5 | # Create a "main" cluster when a new postgresql-x.y server package is installed 6 | #create_main_cluster = true 7 | 8 | # Default start.conf value, must be one of "auto", "manual", and "disabled". 9 | # See pg_createcluster(8) for more documentation. 10 | #start_conf = 'auto' 11 | 12 | # Default data directory. 13 | #data_directory = '/var/lib/postgresql/%v/%c' 14 | 15 | # Default directory for transaction logs 16 | # Unset by default, i.e. transaction logs remain in the data directory. 17 | #waldir = '/var/lib/postgresql/wal/%v/%c/pg_wal' 18 | 19 | # Options to pass to initdb. 20 | #initdb_options = '' 21 | 22 | # The following options are copied into the new cluster's postgresql.conf: 23 | 24 | # Enable SSL by default (using the "snakeoil" certificates installed by the 25 | # ssl-cert package, unless configured otherwise here) 26 | ssl = on 27 | 28 | # Show cluster name in process title 29 | cluster_name = '%v/%c' 30 | 31 | # Put stats_temp_directory on tmpfs (PG <= 14) 32 | stats_temp_directory = '/var/run/postgresql/%v-%c.pg_stat_tmp' 33 | 34 | # Add prefix to log lines 35 | log_line_prefix = '%%m [%%p] %%q%%u@%%d ' 36 | 37 | # Add "include_dir" in postgresql.conf 38 | add_include_dir = 'conf.d' 39 | 40 | # Directory for additional createcluster config 41 | include_dir '/etc/postgresql-common/createcluster.d' 42 | -------------------------------------------------------------------------------- /debhelper/Debian/Debhelper/Buildsystem/pgxs.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for building PostgreSQL extension modules using PGXS 2 | # 3 | # Per PostgreSQL major version, a `build-$version` subdirectory is created. 4 | # 5 | # Copyright: © 2020 Christoph Berg 6 | # License: GPL-2+ 7 | 8 | package Debian::Debhelper::Buildsystem::pgxs; 9 | 10 | use strict; 11 | use warnings; 12 | use parent qw(Debian::Debhelper::Buildsystem); 13 | use Cwd; 14 | use Debian::Debhelper::Dh_Lib; 15 | use Debian::Debhelper::pgxs; 16 | 17 | sub DESCRIPTION { 18 | "PGXS (PostgreSQL extensions), building in subdirectory per PostgreSQL version" 19 | } 20 | 21 | sub check_auto_buildable { 22 | my $this=shift; 23 | unless (-e $this->get_sourcepath("debian/pgversions")) { 24 | error("debian/pgversions is required to build with PGXS"); 25 | } 26 | return (-e $this->get_sourcepath("Makefile")) ? 1 : 0; 27 | } 28 | 29 | sub new { 30 | my $class=shift; 31 | my $this=$class->SUPER::new(@_); 32 | $this->enforce_in_source_building(); 33 | return $this; 34 | } 35 | 36 | sub build { 37 | my $this=shift; 38 | $this->doit_in_sourcedir(qw(pg_buildext build build-%v)); 39 | } 40 | 41 | sub install { 42 | my $this=shift; 43 | my $pattern = package_pattern(); 44 | $this->doit_in_sourcedir(qw(pg_buildext install build-%v), $pattern); 45 | } 46 | 47 | sub test { 48 | my $this=shift; 49 | verbose_print("Postponing tests to install stage"); 50 | } 51 | 52 | sub clean { 53 | my $this=shift; 54 | my $pattern = package_pattern(); 55 | $this->doit_in_sourcedir(qw(pg_buildext clean build-%v), $pattern); 56 | } 57 | 58 | 1; 59 | -------------------------------------------------------------------------------- /debhelper/Debian/Debhelper/Buildsystem/pgxs_loop.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for building PostgreSQL extension modules using PGXS 2 | # 3 | # For packages not supporting building in subdirectories, the pgxs_loop variant builds 4 | # for each PostgreSQL major version in turn in the top-level directory. 5 | # 6 | # Copyright: © 2020 Christoph Berg 7 | # License: GPL-2+ 8 | 9 | package Debian::Debhelper::Buildsystem::pgxs_loop; 10 | 11 | use strict; 12 | use warnings; 13 | use parent qw(Debian::Debhelper::Buildsystem::pgxs); 14 | use Cwd; 15 | use Debian::Debhelper::Dh_Lib; 16 | use Debian::Debhelper::pgxs; 17 | 18 | sub DESCRIPTION { 19 | "PGXS (PostgreSQL extensions), building for each PostgreSQL version in top level directory" 20 | } 21 | 22 | sub build { 23 | my $this=shift; 24 | verbose_print("Postponing build to install stage; if this package supports out-of-tree builds, replace --buildsystem=pgxs_loop by --buildsystem=pgxs to build in the build stage"); 25 | } 26 | 27 | sub install { 28 | my $this=shift; 29 | my $pattern = package_pattern(); 30 | $this->doit_in_sourcedir(qw(pg_buildext loop), $pattern); 31 | } 32 | 33 | 1; 34 | -------------------------------------------------------------------------------- /debhelper/Debian/Debhelper/Sequence/pgxs.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use strict; 5 | use Debian::Debhelper::Dh_Lib; 6 | 7 | # check if debian/control needs updating from debian/control.in 8 | insert_after("dh_clean", "pg_buildext"); 9 | add_command_options("pg_buildext", "checkcontrol"); 10 | 11 | # use PGXS for clean, build, and install 12 | add_command_options("dh_auto_clean", "--buildsystem=pgxs"); 13 | add_command_options("dh_auto_build", "--buildsystem=pgxs"); 14 | add_command_options("dh_auto_install", "--buildsystem=pgxs"); 15 | 16 | # move tests from dh_auto_test to dh_pgxs_test 17 | remove_command("dh_auto_test"); 18 | if (! get_buildoption("nocheck")) { 19 | insert_after("dh_link", "dh_pgxs_test"); 20 | } 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /debhelper/Debian/Debhelper/Sequence/pgxs_loop.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use strict; 5 | use Debian::Debhelper::Dh_Lib; 6 | 7 | # check if debian/control needs updating from debian/control.in 8 | insert_after("dh_clean", "pg_buildext"); 9 | add_command_options("pg_buildext", "checkcontrol"); 10 | 11 | # use PGXS for clean, build, and install 12 | add_command_options("dh_auto_clean", "--buildsystem=pgxs_loop"); 13 | add_command_options("dh_auto_build", "--buildsystem=pgxs_loop"); 14 | add_command_options("dh_auto_install", "--buildsystem=pgxs_loop"); 15 | 16 | # move tests from dh_auto_test to dh_pgxs_test 17 | remove_command("dh_auto_test"); 18 | if (! get_buildoption("nocheck")) { 19 | insert_after("dh_link", "dh_pgxs_test"); 20 | add_command_options("dh_pgxs_test", "loop"); 21 | } 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /debhelper/Debian/Debhelper/pgxs.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for building PostgreSQL extension modules using PGXS 2 | # 3 | # Copyright: © 2020 Christoph Berg 4 | # License: GPL-2+ 5 | 6 | package Debian::Debhelper::pgxs; 7 | 8 | use strict; 9 | use warnings; 10 | use Exporter 'import'; 11 | our @EXPORT = qw(package_pattern); 12 | 13 | =head1 package_pattern() 14 | 15 | From C, look for the package name containing the 16 | B placeholder, and return it in the format suitable for passing to 17 | B, i.e. with B replaced by B<%v>. 18 | 19 | For B it will return B. 20 | 21 | Errors out if more than one package with the B placeholder is found. 22 | 23 | =cut 24 | 25 | sub package_pattern () { 26 | open F, "debian/control.in" or die "debian/control.in: $!"; 27 | my $pattern; 28 | while () { 29 | if (/^Package: (.*)PGVERSION(.*)/) { 30 | die "More than one Package with PGVERSION placeholder found in debian/control.in, cannot build with dh --buildsystem=pgxs. Use pg_buildext manually." if ($pattern); 31 | $pattern = "$1%v$2"; 32 | } 33 | } 34 | close F; 35 | return $pattern; 36 | } 37 | 38 | 1; 39 | -------------------------------------------------------------------------------- /debhelper/dh_pgxs_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use strict; 5 | use Debian::Debhelper::Dh_Lib; 6 | use Debian::Debhelper::pgxs; 7 | 8 | my $target = (@ARGV and $ARGV[0] eq 'loop') ? "." : "build-%v"; 9 | my $pattern = package_pattern(); 10 | 11 | print_and_doit(qw(pg_buildext installcheck .), $target, $pattern); 12 | -------------------------------------------------------------------------------- /debhelper/dh_pgxs_test.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | dh_pgxs_test - Run testsuite during a PGXS PostgreSQL extension build 4 | 5 | =head1 SYNOPSIS 6 | 7 | B [B] 8 | 9 | =head1 DESCRIPTION 10 | 11 | B extensions need to be installed before they can be tested and 12 | hence the usual B way of invoking tests from dh_auto_test(1) does 13 | not work. 14 | 15 | B is a dh(1) sequence point created by the B and 16 | B B extensions that is executed after dh_auto_install(1). 17 | It calls B after a B extension module has 18 | been built and installed into the CI directory. 19 | 20 | Users wishing to change the action called by B should call 21 | B or similar commands. 22 | 23 | override_dh_pgxs_test: 24 | echo "CREATE EXTENSION foo" | pg_buildext psql . . postgresql-%v-foo 25 | 26 | =head1 OPTIONS 27 | 28 | =over 4 29 | 30 | =item B 31 | 32 | B builds packages in C subdirectories. The B 33 | options corresponds to B and builds in the top-level 34 | directory. 35 | 36 | =back 37 | 38 | =head1 SEE ALSO 39 | 40 | debhelper(7), dh(1), dh_make_pgxs(1), pg_buildext(1). 41 | 42 | =head1 AUTHOR 43 | 44 | Christoph Berg Lmyon@debian.orgE> 45 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | *debhelper* 2 | files 3 | *.log 4 | postgresql*/ 5 | *.substvars 6 | tmp/ 7 | -------------------------------------------------------------------------------- /debian/clean: -------------------------------------------------------------------------------- 1 | supported_versions 2 | tags 3 | t/bar/debian/control 4 | t/foo/foo-123/build-*/ 5 | t/foo/foo-123/debian/ 6 | t/foo/foo_* 7 | rpm/BUILD/ 8 | rpm/BUILDROOT/ 9 | rpm/RPMS/ 10 | rpm/SOURCES/ 11 | rpm/SPECS/ 12 | rpm/SRPMS/ 13 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Contact: Debian PostgreSQL Maintainers 3 | 4 | Files: * 5 | Copyright: 2005-2014 Martin Pitt 6 | 2009 Cyril Bouthors 7 | 2010 Dimitri Fontaine 8 | 2011-2020 Christoph Berg 9 | 2013 Peter Eisentraut 10 | License: GPL-2+ 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | . 16 | The full text of the GPL is distributed as in 17 | /usr/share/common-licenses/GPL-2 on Debian systems. 18 | -------------------------------------------------------------------------------- /debian/gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml 3 | -------------------------------------------------------------------------------- /debian/init.d-functions: -------------------------------------------------------------------------------- 1 | # This file contains common functionality for all postgresql server 2 | # package init.d scripts. It is usually included by 3 | # /etc/init.d/postgresql 4 | 5 | init_functions=/lib/lsb/init-functions 6 | #redhat# init_functions=/usr/share/postgresql-common/init-functions-compat 7 | . $init_functions 8 | 9 | PGBINROOT="/usr/lib/postgresql/" 10 | #redhat# PGBINROOT="/usr/pgsql-" 11 | 12 | # do pg_ctlcluster action $1 to all clusters of version $2 with command 13 | # description $3; output according to Debian Policy for init scripts 14 | do_ctl_all() { 15 | [ "$1" ] || { echo "Error: invalid command '$1'" >&2; exit 1; } 16 | [ "$2" ] || { echo "Error: invalid version '$2'" >&2; exit 1; } 17 | [ -d "/etc/postgresql/$2" ] || return 0 18 | [ "$(ls /etc/postgresql/$2)" ] || return 0 19 | [ -x "$PGBINROOT$2/bin/postgres" ] || return 0 20 | 21 | status=0 22 | log_daemon_msg "$3" 23 | for c in /etc/postgresql/"$2"/*; do 24 | [ -e "$c/postgresql.conf" ] || continue 25 | name=$(basename "$c") 26 | 27 | # evaluate start.conf 28 | if [ -e "$c/start.conf" ]; then 29 | start=$(sed 's/#.*$//; /^[[:space:]]*$/d; s/^\s*//; s/\s*$//' "$c/start.conf") 30 | else 31 | start=auto 32 | fi 33 | [ "$start" = "auto" ] || continue 34 | 35 | log_progress_msg "$name" 36 | set +e 37 | if [ "$1" = "stop" ] || [ "$1" = "restart" ]; then 38 | ERRMSG=$(pg_ctlcluster --force "$2" "$name" $1 2>&1) 39 | else 40 | ERRMSG=$(pg_ctlcluster "$2" "$name" $1 2>&1) 41 | fi 42 | res=$? 43 | set -e 44 | # Do not fail on success or if cluster is already/not running 45 | [ $res -eq 0 ] || [ $res -eq 2 ] || status=$(($status || $res)) 46 | done 47 | if [ $status -ne 0 -a -n "$ERRMSG" ]; then 48 | log_failure_msg "$ERRMSG" 49 | fi 50 | log_end_msg $status 51 | return $status 52 | } 53 | 54 | # create /var/run/postgresql 55 | create_socket_directory() { 56 | if [ -d /var/run/postgresql ]; then 57 | chmod 2775 /var/run/postgresql 58 | else 59 | install -d -m 2775 -o postgres -g postgres /var/run/postgresql 60 | [ -x /sbin/restorecon ] && restorecon -R /var/run/postgresql || true 61 | fi 62 | } 63 | 64 | # start all clusters of version $1 65 | # output according to Debian Policy for init scripts 66 | start() { 67 | do_ctl_all start "$1" "Starting PostgreSQL $1 database server" 68 | } 69 | 70 | # stop all clusters of version $1 71 | # output according to Debian Policy for init scripts 72 | stop() { 73 | do_ctl_all stop "$1" "Stopping PostgreSQL $1 database server" 74 | } 75 | 76 | # restart all clusters of version $1 77 | # output according to Debian Policy for init scripts 78 | restart() { 79 | do_ctl_all restart "$1" "Restarting PostgreSQL $1 database server" 80 | } 81 | 82 | # reload all clusters of version $1 83 | # output according to Debian Policy for init scripts 84 | reload() { 85 | do_ctl_all reload "$1" "Reloading PostgreSQL $1 database server" 86 | } 87 | 88 | status() { 89 | CLUSTERS=`pg_lsclusters -h | grep "^$1[[:space:]]"` 90 | # no clusters -> unknown status 91 | [ -n "$CLUSTERS" ] || exit 4 92 | echo "$CLUSTERS" | awk 'BEGIN {rc=0; printf("Running clusters: ")} {if (match($4, "online")) printf ("%s/%s ", $1, $2); else rc=3} END { printf("\n"); exit rc }' 93 | } 94 | 95 | # return all installed versions which do not have their own init script 96 | get_versions() { 97 | versions='' 98 | local v dir skipinit 99 | 100 | skipinit=continue 101 | #redhat# skipinit=true # RedHat systems will have /etc/init.d/postgresql-* provided by the yum.pg.o package 102 | dir=$PGBINROOT 103 | #redhat# dir="-d /usr/pgsql-*" 104 | 105 | for v in `ls $dir 2>/dev/null`; do 106 | #redhat# v=${v#*-} 107 | [ -x /etc/init.d/postgresql-$v ] && $skipinit 108 | if [ -x $PGBINROOT$v/bin/pg_ctl ]; then 109 | versions="$versions $v" 110 | fi 111 | done 112 | } 113 | -------------------------------------------------------------------------------- /debian/po/POTFILES.in: -------------------------------------------------------------------------------- 1 | [type: gettext/rfc822deb] postgresql-common.templates 2 | -------------------------------------------------------------------------------- /debian/po/cs.po: -------------------------------------------------------------------------------- 1 | # Czech translation of postgresql-common debconf messages. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the postgresql-common package. 4 | # Miroslav Kure , 2006-2009. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: postgresql-common\n" 9 | "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" 10 | "POT-Creation-Date: 2016-03-05 11:47+0100\n" 11 | "PO-Revision-Date: 2009-06-27 10:34+0200\n" 12 | "Last-Translator: Miroslav Kure \n" 13 | "Language-Team: Czech \n" 14 | "Language: cs\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #. Type: error 20 | #. Description 21 | #: ../postgresql-common.templates:1001 22 | msgid "Obsolete major version ${old}" 23 | msgstr "Zastaralá hlavní verze ${old}" 24 | 25 | #. Type: error 26 | #. Description 27 | #: ../postgresql-common.templates:1001 28 | msgid "" 29 | "The PostgreSQL version ${old} is obsolete, but the server or client packages " 30 | "are still installed. Please install the latest packages (postgresql-" 31 | "${latest} and postgresql-client-${latest}) and upgrade the existing " 32 | "${oldversion} clusters with pg_upgradecluster (see manpage)." 33 | msgstr "" 34 | "PostgreSQL verze ${old} je již zastaralá, ale v systému se stále nachází " 35 | "balík se serverem a/nebo klientem. Nainstalujte prosím nejnovější balíky " 36 | "(postgresql-${latest} a postgresql-client-${latest}) a aktualizujte své " 37 | "klastry ${oldversion} pomocí pg_upgradecluster (viz manuálová stránka)." 38 | 39 | #. Type: error 40 | #. Description 41 | #: ../postgresql-common.templates:1001 42 | msgid "" 43 | "Please be aware that the installation of postgresql-${latest} will " 44 | "automatically create a default cluster ${latest}/main. If you want to " 45 | "upgrade the ${old}/main cluster, you need to remove the already existing " 46 | "${latest} cluster (pg_dropcluster --stop ${latest} main, see manpage for " 47 | "details)." 48 | msgstr "" 49 | "Vemte prosím na vědomí, že instalací postgresql-${latest} se automaticky " 50 | "vytvoří výchozí klastr ${latest}/main. Chcete-li aktualizovat klastr ${old}/" 51 | "main, musíte odstranit nově vytvořený klastr ${latest} (pg_dropcluster --" 52 | "stop ${latest} main, viz manuálová stránka)." 53 | 54 | #. Type: error 55 | #. Description 56 | #: ../postgresql-common.templates:1001 57 | msgid "" 58 | "The old server and client packages are no longer supported. After the " 59 | "existing clusters are upgraded, the postgresql-${old} and postgresql-client-" 60 | "${old} packages should be removed." 61 | msgstr "" 62 | "Staré balíky serveru a klienta již nejsou podporovány. Po aktualizaci " 63 | "stávajících klastrů byste měli balíky postgresql-${old} a postgresql-client-" 64 | "${old} odstranit." 65 | 66 | #. Type: error 67 | #. Description 68 | #: ../postgresql-common.templates:1001 69 | msgid "" 70 | "Please see /usr/share/doc/postgresql-common/README.Debian.gz for details." 71 | msgstr "" 72 | "Podrobnosti naleznete v /usr/share/doc/postgresql-common/README.Debian.gz." 73 | 74 | #. Type: boolean 75 | #. Description 76 | #: ../postgresql-common.templates:2001 77 | msgid "Enable SSL by default in new PostgreSQL clusters?" 78 | msgstr "" 79 | 80 | #. Type: boolean 81 | #. Description 82 | #: ../postgresql-common.templates:2001 83 | msgid "" 84 | "PostgreSQL supports SSL-encrypted connections. This is usually a good thing. " 85 | "However, if the database is solely accessed using TCP connections on " 86 | "localhost, SSL can be turned off without introducing security issues." 87 | msgstr "" 88 | 89 | #. Type: boolean 90 | #. Description 91 | #: ../postgresql-common.templates:2001 92 | msgid "" 93 | "UNIX domain socket connections (called \"local\" in pg_hba.conf) are not " 94 | "affected by this setting. This setting concerns new PostgreSQL clusters " 95 | "created during package install, or by using the pg_createcluster command. It " 96 | "does not reconfigure existing clusters." 97 | msgstr "" 98 | 99 | #. Type: boolean 100 | #. Description 101 | #: ../postgresql-common.templates:2001 102 | msgid "If unsure, enable SSL." 103 | msgstr "" 104 | 105 | #. Type: note 106 | #. Description 107 | #: ../postgresql-common.templates:3001 108 | msgid "PostgreSQL ${version} catalog version changed" 109 | msgstr "" 110 | 111 | #. Type: note 112 | #. Description 113 | #: ../postgresql-common.templates:3001 114 | msgid "" 115 | "The PostgreSQL cluster ${version} ${cluster} was created using catalog " 116 | "version ${db_catversion}, but the currently being installed package " 117 | "postgresql-${version} is using catalog version ${new_catversion}. You will " 118 | "not be able to use this cluster until it was upgraded to the new catalog " 119 | "version." 120 | msgstr "" 121 | 122 | #. Type: note 123 | #. Description 124 | #: ../postgresql-common.templates:3001 125 | msgid "" 126 | "The necessary subset of binaries from the old version was saved in " 127 | "${vartmpdir}. To upgrade the cluster, execute these commands:" 128 | msgstr "" 129 | -------------------------------------------------------------------------------- /debian/po/fi.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: postgres-common\n" 4 | "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" 5 | "POT-Creation-Date: 2016-03-05 11:47+0100\n" 6 | "PO-Revision-Date: 2008-02-29 15:05+0200\n" 7 | "Last-Translator: Esko Arajärvi \n" 8 | "Language-Team: Finnish \n" 9 | "Language: fi\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | "X-Poedit-Language: Finnish\n" 14 | "X-Poedit-Country: FINLAND\n" 15 | 16 | #. Type: error 17 | #. Description 18 | #: ../postgresql-common.templates:1001 19 | msgid "Obsolete major version ${old}" 20 | msgstr "Vanhentunut pääversio ${old}" 21 | 22 | #. Type: error 23 | #. Description 24 | #: ../postgresql-common.templates:1001 25 | msgid "" 26 | "The PostgreSQL version ${old} is obsolete, but the server or client packages " 27 | "are still installed. Please install the latest packages (postgresql-" 28 | "${latest} and postgresql-client-${latest}) and upgrade the existing " 29 | "${oldversion} clusters with pg_upgradecluster (see manpage)." 30 | msgstr "" 31 | "Ohjelman PostgreSQL versio ${old} on vanhentunut, mutta palvelin- tai " 32 | "asiakaspaketteja on vielä asennettuna. Asenna uusimmat paketit (postgresql-" 33 | "${latest} ja postgresql-client-${latest}) ja päivitä olemassa olevat version " 34 | "${oldversion} klusterit ohjelmalla pg_upgradecluster (katso man-ohjesivu)." 35 | 36 | #. Type: error 37 | #. Description 38 | #: ../postgresql-common.templates:1001 39 | msgid "" 40 | "Please be aware that the installation of postgresql-${latest} will " 41 | "automatically create a default cluster ${latest}/main. If you want to " 42 | "upgrade the ${old}/main cluster, you need to remove the already existing " 43 | "${latest} cluster (pg_dropcluster --stop ${latest} main, see manpage for " 44 | "details)." 45 | msgstr "" 46 | "Version postgresql-${latest} asennus luo automaattisesti oletusklusterin " 47 | "${latest}/main. Jos haluat päivittää klusterin ${old}/main, sinun tulee " 48 | "poistaa jo olemassa oleva klusteri ${latest} (komennolla pg_dropcluster --" 49 | "stop ${latest} main, lisätietoja man-ohjesivulta)." 50 | 51 | #. Type: error 52 | #. Description 53 | #: ../postgresql-common.templates:1001 54 | msgid "" 55 | "The old server and client packages are no longer supported. After the " 56 | "existing clusters are upgraded, the postgresql-${old} and postgresql-client-" 57 | "${old} packages should be removed." 58 | msgstr "" 59 | "Vanhoja palvelin- ja asiakaspaketteja ei enää tueta. Kun olemassa olevat " 60 | "klusterit on päivitetty, paketit postgresql-${old} ja postgresql-client-" 61 | "${old} tulisi poistaa." 62 | 63 | #. Type: error 64 | #. Description 65 | #: ../postgresql-common.templates:1001 66 | msgid "" 67 | "Please see /usr/share/doc/postgresql-common/README.Debian.gz for details." 68 | msgstr "" 69 | "Tiedostosta /usr/share/doc/postgresql-common/README.Debian.gz löytyy " 70 | "lisätietoja (englanniksi)." 71 | 72 | #. Type: boolean 73 | #. Description 74 | #: ../postgresql-common.templates:2001 75 | msgid "Enable SSL by default in new PostgreSQL clusters?" 76 | msgstr "" 77 | 78 | #. Type: boolean 79 | #. Description 80 | #: ../postgresql-common.templates:2001 81 | msgid "" 82 | "PostgreSQL supports SSL-encrypted connections. This is usually a good thing. " 83 | "However, if the database is solely accessed using TCP connections on " 84 | "localhost, SSL can be turned off without introducing security issues." 85 | msgstr "" 86 | 87 | #. Type: boolean 88 | #. Description 89 | #: ../postgresql-common.templates:2001 90 | msgid "" 91 | "UNIX domain socket connections (called \"local\" in pg_hba.conf) are not " 92 | "affected by this setting. This setting concerns new PostgreSQL clusters " 93 | "created during package install, or by using the pg_createcluster command. It " 94 | "does not reconfigure existing clusters." 95 | msgstr "" 96 | 97 | #. Type: boolean 98 | #. Description 99 | #: ../postgresql-common.templates:2001 100 | msgid "If unsure, enable SSL." 101 | msgstr "" 102 | 103 | #. Type: note 104 | #. Description 105 | #: ../postgresql-common.templates:3001 106 | msgid "PostgreSQL ${version} catalog version changed" 107 | msgstr "" 108 | 109 | #. Type: note 110 | #. Description 111 | #: ../postgresql-common.templates:3001 112 | msgid "" 113 | "The PostgreSQL cluster ${version} ${cluster} was created using catalog " 114 | "version ${db_catversion}, but the currently being installed package " 115 | "postgresql-${version} is using catalog version ${new_catversion}. You will " 116 | "not be able to use this cluster until it was upgraded to the new catalog " 117 | "version." 118 | msgstr "" 119 | 120 | #. Type: note 121 | #. Description 122 | #: ../postgresql-common.templates:3001 123 | msgid "" 124 | "The necessary subset of binaries from the old version was saved in " 125 | "${vartmpdir}. To upgrade the cluster, execute these commands:" 126 | msgstr "" 127 | -------------------------------------------------------------------------------- /debian/po/gl.po: -------------------------------------------------------------------------------- 1 | # Galician translation of postgresql-common's debconf templates 2 | # This file is distributed under the same license as the postgresql-common package. 3 | # Jacobo Tarrio , 2007, 2008. 4 | # 5 | msgid "" 6 | msgstr "" 7 | "Project-Id-Version: postgresql-common\n" 8 | "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" 9 | "POT-Creation-Date: 2016-03-05 11:47+0100\n" 10 | "PO-Revision-Date: 2008-05-13 00:18+0100\n" 11 | "Last-Translator: Jacobo Tarrio \n" 12 | "Language-Team: Galician \n" 13 | "Language: gl\n" 14 | "MIME-Version: 1.0\n" 15 | "Content-Type: text/plain; charset=UTF-8\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | 18 | #. Type: error 19 | #. Description 20 | #: ../postgresql-common.templates:1001 21 | msgid "Obsolete major version ${old}" 22 | msgstr "Versión ${old} obsoleta" 23 | 24 | #. Type: error 25 | #. Description 26 | #: ../postgresql-common.templates:1001 27 | msgid "" 28 | "The PostgreSQL version ${old} is obsolete, but the server or client packages " 29 | "are still installed. Please install the latest packages (postgresql-" 30 | "${latest} and postgresql-client-${latest}) and upgrade the existing " 31 | "${oldversion} clusters with pg_upgradecluster (see manpage)." 32 | msgstr "" 33 | "A versión ${old} de PostgreSQL está obsoleta, pero aínda ten instalado os " 34 | "paquetes do servidor ou do cliente. Instale os últimos paquetes (postgresql-" 35 | "${latest} e postgresql-client-${latest}) e actualice os clusters que teñan " 36 | "${oldversion} mediante pg_upgradecluster (consulte a páxina de manual)." 37 | 38 | #. Type: error 39 | #. Description 40 | #: ../postgresql-common.templates:1001 41 | msgid "" 42 | "Please be aware that the installation of postgresql-${latest} will " 43 | "automatically create a default cluster ${latest}/main. If you want to " 44 | "upgrade the ${old}/main cluster, you need to remove the already existing " 45 | "${latest} cluster (pg_dropcluster --stop ${latest} main, see manpage for " 46 | "details)." 47 | msgstr "" 48 | "Teña en conta que a instalación de postgresql-${latest} ha crear " 49 | "automaticamente un cluster ${latest}/main por defecto. Se quere actualizar o " 50 | "cluster ${old}/mail ha ter que eliminar o cluster ${latest} que xa existe " 51 | "(pg_dropcluster --stop ${latest} main, consulte a páxina man para máis " 52 | "detalles)." 53 | 54 | #. Type: error 55 | #. Description 56 | #: ../postgresql-common.templates:1001 57 | msgid "" 58 | "The old server and client packages are no longer supported. After the " 59 | "existing clusters are upgraded, the postgresql-${old} and postgresql-client-" 60 | "${old} packages should be removed." 61 | msgstr "" 62 | "Xa non hai soporte dos paquetes de servidor e cliente vellos. Despois de " 63 | "actualizar os clusters existentes debería eliminar os paquetes postgresql-" 64 | "${old} e postgresql-client-${old}." 65 | 66 | #. Type: error 67 | #. Description 68 | #: ../postgresql-common.templates:1001 69 | msgid "" 70 | "Please see /usr/share/doc/postgresql-common/README.Debian.gz for details." 71 | msgstr "" 72 | "Consulte /usr/share/doc/postgresql-common/README.Debian.gz para ter máis " 73 | "detalles." 74 | 75 | #. Type: boolean 76 | #. Description 77 | #: ../postgresql-common.templates:2001 78 | msgid "Enable SSL by default in new PostgreSQL clusters?" 79 | msgstr "" 80 | 81 | #. Type: boolean 82 | #. Description 83 | #: ../postgresql-common.templates:2001 84 | msgid "" 85 | "PostgreSQL supports SSL-encrypted connections. This is usually a good thing. " 86 | "However, if the database is solely accessed using TCP connections on " 87 | "localhost, SSL can be turned off without introducing security issues." 88 | msgstr "" 89 | 90 | #. Type: boolean 91 | #. Description 92 | #: ../postgresql-common.templates:2001 93 | msgid "" 94 | "UNIX domain socket connections (called \"local\" in pg_hba.conf) are not " 95 | "affected by this setting. This setting concerns new PostgreSQL clusters " 96 | "created during package install, or by using the pg_createcluster command. It " 97 | "does not reconfigure existing clusters." 98 | msgstr "" 99 | 100 | #. Type: boolean 101 | #. Description 102 | #: ../postgresql-common.templates:2001 103 | msgid "If unsure, enable SSL." 104 | msgstr "" 105 | 106 | #. Type: note 107 | #. Description 108 | #: ../postgresql-common.templates:3001 109 | msgid "PostgreSQL ${version} catalog version changed" 110 | msgstr "" 111 | 112 | #. Type: note 113 | #. Description 114 | #: ../postgresql-common.templates:3001 115 | msgid "" 116 | "The PostgreSQL cluster ${version} ${cluster} was created using catalog " 117 | "version ${db_catversion}, but the currently being installed package " 118 | "postgresql-${version} is using catalog version ${new_catversion}. You will " 119 | "not be able to use this cluster until it was upgraded to the new catalog " 120 | "version." 121 | msgstr "" 122 | 123 | #. Type: note 124 | #. Description 125 | #: ../postgresql-common.templates:3001 126 | msgid "" 127 | "The necessary subset of binaries from the old version was saved in " 128 | "${vartmpdir}. To upgrade the cluster, execute these commands:" 129 | msgstr "" 130 | -------------------------------------------------------------------------------- /debian/po/templates.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the postgresql-common package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: postgresql-common\n" 10 | "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" 11 | "POT-Creation-Date: 2016-03-05 11:47+0100\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=CHARSET\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #. Type: error 21 | #. Description 22 | #: ../postgresql-common.templates:1001 23 | msgid "Obsolete major version ${old}" 24 | msgstr "" 25 | 26 | #. Type: error 27 | #. Description 28 | #: ../postgresql-common.templates:1001 29 | msgid "" 30 | "The PostgreSQL version ${old} is obsolete, but the server or client packages " 31 | "are still installed. Please install the latest packages (postgresql-" 32 | "${latest} and postgresql-client-${latest}) and upgrade the existing " 33 | "${oldversion} clusters with pg_upgradecluster (see manpage)." 34 | msgstr "" 35 | 36 | #. Type: error 37 | #. Description 38 | #: ../postgresql-common.templates:1001 39 | msgid "" 40 | "Please be aware that the installation of postgresql-${latest} will " 41 | "automatically create a default cluster ${latest}/main. If you want to " 42 | "upgrade the ${old}/main cluster, you need to remove the already existing " 43 | "${latest} cluster (pg_dropcluster --stop ${latest} main, see manpage for " 44 | "details)." 45 | msgstr "" 46 | 47 | #. Type: error 48 | #. Description 49 | #: ../postgresql-common.templates:1001 50 | msgid "" 51 | "The old server and client packages are no longer supported. After the " 52 | "existing clusters are upgraded, the postgresql-${old} and postgresql-client-" 53 | "${old} packages should be removed." 54 | msgstr "" 55 | 56 | #. Type: error 57 | #. Description 58 | #: ../postgresql-common.templates:1001 59 | msgid "" 60 | "Please see /usr/share/doc/postgresql-common/README.Debian.gz for details." 61 | msgstr "" 62 | 63 | #. Type: boolean 64 | #. Description 65 | #: ../postgresql-common.templates:2001 66 | msgid "Enable SSL by default in new PostgreSQL clusters?" 67 | msgstr "" 68 | 69 | #. Type: boolean 70 | #. Description 71 | #: ../postgresql-common.templates:2001 72 | msgid "" 73 | "PostgreSQL supports SSL-encrypted connections. This is usually a good thing. " 74 | "However, if the database is solely accessed using TCP connections on " 75 | "localhost, SSL can be turned off without introducing security issues." 76 | msgstr "" 77 | 78 | #. Type: boolean 79 | #. Description 80 | #: ../postgresql-common.templates:2001 81 | msgid "" 82 | "UNIX domain socket connections (called \"local\" in pg_hba.conf) are not " 83 | "affected by this setting. This setting concerns new PostgreSQL clusters " 84 | "created during package install, or by using the pg_createcluster command. It " 85 | "does not reconfigure existing clusters." 86 | msgstr "" 87 | 88 | #. Type: boolean 89 | #. Description 90 | #: ../postgresql-common.templates:2001 91 | msgid "If unsure, enable SSL." 92 | msgstr "" 93 | 94 | #. Type: note 95 | #. Description 96 | #: ../postgresql-common.templates:3001 97 | msgid "PostgreSQL ${version} catalog version changed" 98 | msgstr "" 99 | 100 | #. Type: note 101 | #. Description 102 | #: ../postgresql-common.templates:3001 103 | msgid "" 104 | "The PostgreSQL cluster ${version} ${cluster} was created using catalog " 105 | "version ${db_catversion}, but the currently being installed package " 106 | "postgresql-${version} is using catalog version ${new_catversion}. You will " 107 | "not be able to use this cluster until it was upgraded to the new catalog " 108 | "version." 109 | msgstr "" 110 | 111 | #. Type: note 112 | #. Description 113 | #: ../postgresql-common.templates:3001 114 | msgid "" 115 | "The necessary subset of binaries from the old version was saved in " 116 | "${vartmpdir}. To upgrade the cluster, execute these commands:" 117 | msgstr "" 118 | -------------------------------------------------------------------------------- /debian/po/vi.po: -------------------------------------------------------------------------------- 1 | # Vietnamese translation for PostgreSQL Common. 2 | # Copyright © 2007 Free Software Foundation, Inc. 3 | # Clytie Siddall , 2007 4 | # 5 | msgid "" 6 | msgstr "" 7 | "Project-Id-Version: postgresql-common 88+nmu1\n" 8 | "Report-Msgid-Bugs-To: postgresql-common@packages.debian.org\n" 9 | "POT-Creation-Date: 2016-03-05 11:47+0100\n" 10 | "PO-Revision-Date: 2008-07-16 17:00+0930\n" 11 | "Last-Translator: Clytie Siddall \n" 12 | "Language-Team: Vietnamese \n" 13 | "Language: vi\n" 14 | "MIME-Version: 1.0\n" 15 | "Content-Type: text/plain; charset=UTF-8\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | "Plural-Forms: nplurals=1; plural=0;\n" 18 | "X-Generator: LocFactoryEditor 1.7b1\n" 19 | 20 | #. Type: error 21 | #. Description 22 | #: ../postgresql-common.templates:1001 23 | msgid "Obsolete major version ${old}" 24 | msgstr "Phiên bản chính cũ ${old}" 25 | 26 | #. Type: error 27 | #. Description 28 | #: ../postgresql-common.templates:1001 29 | msgid "" 30 | "The PostgreSQL version ${old} is obsolete, but the server or client packages " 31 | "are still installed. Please install the latest packages (postgresql-" 32 | "${latest} and postgresql-client-${latest}) and upgrade the existing " 33 | "${oldversion} clusters with pg_upgradecluster (see manpage)." 34 | msgstr "" 35 | "Phiên bản PostgreSQL ${old} quá cũ, các gói trình phục vụ hay gói trình " 36 | "khách vẫn còn được cài đặt. Hãy cài đặt các gói mới nhất (postgresql-" 37 | "${latest} và postgresql-client-${latest}) rồi nâng cấp các tập hợp " 38 | "${oldversion} tồn tại bằng chức năng pg_upgradecluster (xem trang hướng dẫn " 39 | "[man])." 40 | 41 | #. Type: error 42 | #. Description 43 | #: ../postgresql-common.templates:1001 44 | msgid "" 45 | "Please be aware that the installation of postgresql-${latest} will " 46 | "automatically create a default cluster ${latest}/main. If you want to " 47 | "upgrade the ${old}/main cluster, you need to remove the already existing " 48 | "${latest} cluster (pg_dropcluster --stop ${latest} main, see manpage for " 49 | "details)." 50 | msgstr "" 51 | "Ghi chú rằng tiến trình cài đặt postgresql-${latest} sẽ tự động tạo một tập " 52 | "hợp mặc định ${latest}/main. Muốn nâng cấp tập hợp ${old}/main thì bạn cần " 53 | "phải gỡ bỏ tập hợp ${latest} cluster đã tồn tại (pg_dropcluster --stop " 54 | "${latest} main, xem trang hướng dẫn để tìm chi tiết)." 55 | 56 | #. Type: error 57 | #. Description 58 | #: ../postgresql-common.templates:1001 59 | msgid "" 60 | "The old server and client packages are no longer supported. After the " 61 | "existing clusters are upgraded, the postgresql-${old} and postgresql-client-" 62 | "${old} packages should be removed." 63 | msgstr "" 64 | "Không còn hỗ trợ lại các gói trình phục vụ và gói trình khách. Sau khi nâng " 65 | "cấp các tập hợp đã tồn tại, khuyên bạn gỡ bỏ các gói postgresql-${old} và " 66 | "postgresql-client-${old}." 67 | 68 | #. Type: error 69 | #. Description 70 | #: ../postgresql-common.templates:1001 71 | msgid "" 72 | "Please see /usr/share/doc/postgresql-common/README.Debian.gz for details." 73 | msgstr "" 74 | "Xem tài liệu Đọc Đi « /usr/share/doc/postgresql-common/README.Debian.gz » để " 75 | "tìm chi tiết." 76 | 77 | #. Type: boolean 78 | #. Description 79 | #: ../postgresql-common.templates:2001 80 | msgid "Enable SSL by default in new PostgreSQL clusters?" 81 | msgstr "" 82 | 83 | #. Type: boolean 84 | #. Description 85 | #: ../postgresql-common.templates:2001 86 | msgid "" 87 | "PostgreSQL supports SSL-encrypted connections. This is usually a good thing. " 88 | "However, if the database is solely accessed using TCP connections on " 89 | "localhost, SSL can be turned off without introducing security issues." 90 | msgstr "" 91 | 92 | #. Type: boolean 93 | #. Description 94 | #: ../postgresql-common.templates:2001 95 | msgid "" 96 | "UNIX domain socket connections (called \"local\" in pg_hba.conf) are not " 97 | "affected by this setting. This setting concerns new PostgreSQL clusters " 98 | "created during package install, or by using the pg_createcluster command. It " 99 | "does not reconfigure existing clusters." 100 | msgstr "" 101 | 102 | #. Type: boolean 103 | #. Description 104 | #: ../postgresql-common.templates:2001 105 | msgid "If unsure, enable SSL." 106 | msgstr "" 107 | 108 | #. Type: note 109 | #. Description 110 | #: ../postgresql-common.templates:3001 111 | msgid "PostgreSQL ${version} catalog version changed" 112 | msgstr "" 113 | 114 | #. Type: note 115 | #. Description 116 | #: ../postgresql-common.templates:3001 117 | msgid "" 118 | "The PostgreSQL cluster ${version} ${cluster} was created using catalog " 119 | "version ${db_catversion}, but the currently being installed package " 120 | "postgresql-${version} is using catalog version ${new_catversion}. You will " 121 | "not be able to use this cluster until it was upgraded to the new catalog " 122 | "version." 123 | msgstr "" 124 | 125 | #. Type: note 126 | #. Description 127 | #: ../postgresql-common.templates:3001 128 | msgid "" 129 | "The necessary subset of binaries from the old version was saved in " 130 | "${vartmpdir}. To upgrade the cluster, execute these commands:" 131 | msgstr "" 132 | -------------------------------------------------------------------------------- /debian/postgresql-client-common.dirs: -------------------------------------------------------------------------------- 1 | etc/postgresql-common 2 | -------------------------------------------------------------------------------- /debian/postgresql-client-common.install: -------------------------------------------------------------------------------- 1 | PgCommon.pm usr/share/perl5 2 | debian/maintscripts-functions usr/share/postgresql-common 3 | debian/supported-versions usr/share/postgresql-common 4 | pg_wrapper usr/share/postgresql-common 5 | supported_versions etc/postgresql-common 6 | user_clusters etc/postgresql-common 7 | -------------------------------------------------------------------------------- /debian/postgresql-client-common.links: -------------------------------------------------------------------------------- 1 | usr/share/man/man1/pg_wrapper.1.gz usr/share/man/man7/postgresql-common.7.gz 2 | usr/share/postgresql-common/pg_wrapper usr/bin/clusterdb 3 | usr/share/postgresql-common/pg_wrapper usr/bin/createdb 4 | usr/share/postgresql-common/pg_wrapper usr/bin/createlang 5 | usr/share/postgresql-common/pg_wrapper usr/bin/createuser 6 | usr/share/postgresql-common/pg_wrapper usr/bin/dropdb 7 | usr/share/postgresql-common/pg_wrapper usr/bin/droplang 8 | usr/share/postgresql-common/pg_wrapper usr/bin/dropuser 9 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_basebackup 10 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_dump 11 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_dumpall 12 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_isready 13 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_receivewal 14 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_receivexlog 15 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_recvlogical 16 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_restore 17 | usr/share/postgresql-common/pg_wrapper usr/bin/pgbench 18 | usr/share/postgresql-common/pg_wrapper usr/bin/psql 19 | usr/share/postgresql-common/pg_wrapper usr/bin/reindexdb 20 | usr/share/postgresql-common/pg_wrapper usr/bin/vacuumdb 21 | usr/share/postgresql-common/pg_wrapper usr/bin/vacuumlo 22 | -------------------------------------------------------------------------------- /debian/postgresql-client-common.lintian-overrides: -------------------------------------------------------------------------------- 1 | # the manpages for those are in the PostgreSQL packages 2 | postgresql-client-common: binary-without-manpage *usr/bin/clusterdb* 3 | postgresql-client-common: binary-without-manpage *usr/bin/create* 4 | postgresql-client-common: binary-without-manpage *usr/bin/drop* 5 | postgresql-client-common: binary-without-manpage *usr/bin/pg_basebackup* 6 | postgresql-client-common: binary-without-manpage *usr/bin/pg_dump* 7 | postgresql-client-common: binary-without-manpage *usr/bin/pg_isready* 8 | postgresql-client-common: binary-without-manpage *usr/bin/pg_receivewal* 9 | postgresql-client-common: binary-without-manpage *usr/bin/pg_receivexlog* 10 | postgresql-client-common: binary-without-manpage *usr/bin/pg_recvlogical* 11 | postgresql-client-common: binary-without-manpage *usr/bin/pg_restore* 12 | postgresql-client-common: binary-without-manpage *usr/bin/pgbench* 13 | postgresql-client-common: binary-without-manpage *usr/bin/psql* 14 | postgresql-client-common: binary-without-manpage *usr/bin/reindexdb* 15 | postgresql-client-common: binary-without-manpage *usr/bin/vacuum* 16 | -------------------------------------------------------------------------------- /debian/postgresql-client-common.manpages: -------------------------------------------------------------------------------- 1 | *.5 2 | pg_wrapper.1 3 | -------------------------------------------------------------------------------- /debian/postgresql-client-common.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ "$1" = purge ]; then 6 | # remove psql history file 7 | rm -f /var/lib/postgresql/.psql_history 8 | rmdir /var/lib/postgresql/ 2>/dev/null || true 9 | fi 10 | 11 | #DEBHELPER# 12 | 13 | -------------------------------------------------------------------------------- /debian/postgresql-common.NEWS: -------------------------------------------------------------------------------- 1 | postgresql-common (161) unstable; urgency=medium 2 | 3 | pg_ctlcluster is now enforcing stricter file ownership on the cluster config 4 | when invoked as root, including operation via the init.d script or the 5 | systemd unit: 6 | 7 | The postgresql.conf owner needs match the data directory owner, or the 8 | postgresql.conf file needs to be owned by root. 9 | 10 | Default setups are not affected by this change. 11 | 12 | -- Christoph Berg Fri, 05 Sep 2014 15:48:13 +0200 13 | 14 | postgresql-common (159) unstable; urgency=low 15 | 16 | PostgreSQL clusters managed by postgresql-common are now systemd enabled. For 17 | each cluster, a service "postgresql@-" is created that can be 18 | started/stopped/restarted/reloaded. A parent service "postgresql" acts on 19 | all installed (start.conf has "auto") clusters in parallel like the init.d 20 | script used to do. /etc/init.d/postgresql can still be used, though the mode 21 | of starting individual versions ("/e/i/p start 9.3") no longer works. 22 | 23 | pg_ctlcluster can be used to control clusters, but for start and restart the 24 | operation via systemd (using systemctl or the init.d script) is preferred, or 25 | else the clusters will not run in cgroups. (Unfortunately this requires 26 | root.) 27 | 28 | If the system is not running systemd, nothing changes. 29 | 30 | -- Christoph Berg Fri, 18 Jul 2014 23:52:09 +0300 31 | 32 | postgresql-common (158) experimental; urgency=medium 33 | 34 | This postgresql-common release introduces several changes in the defaults 35 | used for newly created database clusters, all configurable in 36 | /etc/postgresql-common/createcluster.conf: 37 | 38 | * The default log_line_prefix is now '%t [%p-%l] %q%u@%d ' instead of '%t '. 39 | * stats_temp_directory aka pg_stat_tmp is set to a subdirectory of 40 | /var/run/postgresql by default. 41 | * The use of SSL by default is (pre-)configurable via debconf and 42 | createcluster.conf. 43 | 44 | If the logging_collector or syslog is being used, pg_lsclusters will show 45 | the filename (or "syslog") instead of just "custom" in the Log file column. 46 | 47 | -- Christoph Berg Sat, 05 Jul 2014 16:40:16 +0200 48 | -------------------------------------------------------------------------------- /debian/postgresql-common.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | . /usr/share/debconf/confmodule 6 | 7 | # If we have no versions, we do not need to worry about obsolete ones 8 | if ! [ -d /usr/lib/postgresql ] || \ 9 | [ ! -e /usr/share/postgresql-common/supported-versions ]; then 10 | db_stop 11 | exit 0 12 | fi 13 | 14 | # at some points we obsolete major versions within unstable; force the 15 | # obsoletion notifications when upgrading over those 16 | if dpkg --compare-versions "$2" lt-nl 71 2>/dev/null; then 17 | db_fset postgresql-common/obsolete-major seen false 18 | fi 19 | 20 | # determine versions 21 | for v in `ls /usr/lib/postgresql/`; do 22 | # Ignore old libraries, etc. 23 | if [ -x /usr/lib/postgresql/$v/bin/psql ]; then 24 | AVAILABLE="$AVAILABLE $v" 25 | fi 26 | done 27 | 28 | SUPPORTED=`sh /usr/share/postgresql-common/supported-versions` 29 | LATEST=`echo "$SUPPORTED" | sort -g | tail -1` 30 | 31 | db_fget postgresql-common/obsolete-major seen || true 32 | 33 | if [ "$RET" != "true" ]; then 34 | for v in $AVAILABLE; do 35 | unset sup 36 | for s in $SUPPORTED; do 37 | if dpkg --compare-versions "$v" ge "$s"; then 38 | sup=1 39 | break 40 | fi 41 | done 42 | if [ "$sup" ]; then 43 | continue 44 | fi 45 | 46 | if dpkg -s "postgresql-client-$v" 2>/dev/null | grep -q ^Version: ; then 47 | db_fset postgresql-common/obsolete-major seen false 48 | db_subst postgresql-common/obsolete-major old $v 49 | db_subst postgresql-common/obsolete-major latest $LATEST 50 | db_input high postgresql-common/obsolete-major || true 51 | db_go || true 52 | fi 53 | done 54 | fi 55 | 56 | # createcluster.conf 57 | db_input medium postgresql-common/ssl || true 58 | db_go || true 59 | 60 | db_stop 61 | -------------------------------------------------------------------------------- /debian/postgresql-common.dirs: -------------------------------------------------------------------------------- 1 | /etc/postgresql 2 | /var/lib/postgresql 3 | /var/log/postgresql 4 | -------------------------------------------------------------------------------- /debian/postgresql-common.docs: -------------------------------------------------------------------------------- 1 | README.md 2 | doc/dependencies.svg 3 | systemd/README.systemd 4 | -------------------------------------------------------------------------------- /debian/postgresql-common.install: -------------------------------------------------------------------------------- 1 | createcluster.conf usr/share/postgresql-common 2 | debian/init.d-functions usr/share/postgresql-common 3 | pg_backupcluster usr/bin 4 | pg_buildext usr/bin 5 | pg_checksystem usr/share/postgresql-common 6 | pg_config usr/bin 7 | pg_conftool usr/bin 8 | pg_createcluster usr/bin 9 | pg_ctlcluster usr/bin 10 | pg_dropcluster usr/bin 11 | pg_getwal usr/share/postgresql-common 12 | pg_lsclusters usr/bin 13 | pg_renamecluster usr/bin 14 | pg_restorecluster usr/bin 15 | pg_updateaptconfig usr/share/postgresql-common 16 | pg_updatedicts usr/sbin 17 | pg_upgradecluster usr/bin 18 | pg_upgradecluster.d etc/postgresql-common 19 | pg_virtualenv usr/bin 20 | pgdg/apt.postgresql.org.* usr/share/postgresql-common/pgdg 21 | server usr/share/postgresql-common 22 | systemd/system* lib/systemd 23 | t/* usr/share/postgresql-common/t 24 | testsuite usr/share/postgresql-common 25 | -------------------------------------------------------------------------------- /debian/postgresql-common.links: -------------------------------------------------------------------------------- 1 | usr/share/postgresql-common/pg_wrapper usr/bin/pg_archivecleanup 2 | -------------------------------------------------------------------------------- /debian/postgresql-common.lintian-overrides: -------------------------------------------------------------------------------- 1 | # the manpages for those are in the PostgreSQL packages 2 | postgresql-common: binary-without-manpage *usr/bin/pg_archivecleanup* 3 | postgresql-common: binary-without-manpage *usr/bin/pg_config* 4 | # the init-functions are sourced via /usr/share/postgresql-common/init.d-functions 5 | postgresql-common: init.d-script-does-not-source-init-functions *etc/init.d/postgresql* 6 | # pg_receivewal@ is an add-on service of postgresql@ 7 | postgresql-common: systemd-service-file-refers-to-unusual-wantedby-target *lib/systemd/system/pg_receivewal@.service* 8 | # debian/rules template 9 | postgresql-common: script-not-executable *usr/share/postgresql-common/server/postgresql.mk* 10 | # part of the testsuite 11 | package-contains-documentation-outside-usr-share-doc *usr/share/postgresql-common/t/foo/foo-123/README.md* 12 | -------------------------------------------------------------------------------- /debian/postgresql-common.logrotate: -------------------------------------------------------------------------------- 1 | /var/log/postgresql/*.log { 2 | weekly 3 | rotate 10 4 | copytruncate 5 | delaycompress 6 | compress 7 | notifempty 8 | missingok 9 | su root root 10 | } 11 | -------------------------------------------------------------------------------- /debian/postgresql-common.maintscript: -------------------------------------------------------------------------------- 1 | # file is now managed by pg_updateaptconfig 2 | rm_conffile /etc/apt/apt.conf.d/01autoremove-postgresql 229~ postgresql-common 3 | -------------------------------------------------------------------------------- /debian/postgresql-common.manpages: -------------------------------------------------------------------------------- 1 | pg_backupcluster.1 2 | pg_buildext.1 3 | pg_conftool.1 4 | pg_createcluster.1 5 | pg_ctlcluster.1 6 | pg_dropcluster.1 7 | pg_getwal.1 8 | pg_lsclusters.1 9 | pg_renamecluster.1 10 | pg_restorecluster.1 11 | pg_updatedicts.8 12 | pg_upgradecluster.1 13 | pg_virtualenv.1 14 | -------------------------------------------------------------------------------- /debian/postgresql-common.postgresql.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: postgresql 6 | # Required-Start: $local_fs $remote_fs $network $time 7 | # Required-Stop: $local_fs $remote_fs $network $time 8 | # Should-Start: $syslog 9 | # Should-Stop: $syslog 10 | # Default-Start: 2 3 4 5 11 | # Default-Stop: 0 1 6 12 | # Short-Description: PostgreSQL RDBMS server 13 | ### END INIT INFO 14 | 15 | # Setting environment variables for the postmaster here does not work; please 16 | # set them in /etc/postgresql///environment instead. 17 | 18 | [ -r /usr/share/postgresql-common/init.d-functions ] || exit 0 19 | 20 | . /usr/share/postgresql-common/init.d-functions 21 | 22 | # versions can be specified explicitly 23 | if [ -n "$2" ]; then 24 | versions="$2 $3 $4 $5 $6 $7 $8 $9" 25 | else 26 | get_versions 27 | fi 28 | 29 | case "$1" in 30 | start|stop|restart|reload) 31 | if [ "$1" = "start" ]; then 32 | create_socket_directory 33 | fi 34 | if [ -z "`pg_lsclusters -h`" ]; then 35 | log_warning_msg 'No PostgreSQL clusters exist; see "man pg_createcluster"' 36 | exit 0 37 | fi 38 | for v in $versions; do 39 | $1 $v || EXIT=$? 40 | done 41 | exit ${EXIT:-0} 42 | ;; 43 | status) 44 | LS=`pg_lsclusters -h` 45 | # no clusters -> unknown status 46 | [ -n "$LS" ] || exit 4 47 | echo "$LS" | awk 'BEGIN {rc=0} {if (match($4, "down")) rc=3; printf ("%s/%s (port %s): %s\n", $1, $2, $3, $4)}; END {exit rc}' 48 | ;; 49 | force-reload) 50 | for v in $versions; do 51 | reload $v 52 | done 53 | ;; 54 | *) 55 | echo "Usage: $0 {start|stop|restart|reload|force-reload|status} [version ..]" 56 | exit 1 57 | ;; 58 | esac 59 | 60 | exit 0 61 | 62 | -------------------------------------------------------------------------------- /debian/postgresql-common.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then 6 | dpkg-divert --package postgresql-common --remove --rename --divert /usr/bin/pg_config.libpq-dev /usr/bin/pg_config 7 | fi 8 | 9 | if [ "$1" = purge ]; then 10 | # remove socket directory 11 | rm -rf /var/run/postgresql 12 | 13 | # remove SSL keys 14 | rm -rf /etc/postgresql-common/root.crt 15 | 16 | [ -d /etc/postgresql-common ] && rmdir --ignore-fail-on-non-empty /etc/postgresql-common || true 17 | 18 | rm -rf /var/cache/postgresql 19 | 20 | # unregister and remove files maintained by ucf 21 | CCCONFIG="/etc/postgresql-common/createcluster.conf" 22 | if command -v ucf >/dev/null; then 23 | ucf --purge $CCCONFIG 24 | fi 25 | if command -v ucfr >/dev/null; then 26 | ucfr --purge postgresql-common $CCCONFIG 27 | fi 28 | rm -f $CCCONFIG $CCCONFIG.ucf-* 29 | 30 | # remove file created by pg_updateaptconfig 31 | rm -f /etc/apt/apt.conf.d/02autoremove-postgresql* 32 | 33 | # remove pgdg key symlink 34 | rm -f /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg 35 | fi 36 | 37 | #DEBHELPER# 38 | 39 | -------------------------------------------------------------------------------- /debian/postgresql-common.preinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | install|upgrade) 7 | dpkg-divert --package postgresql-common --rename --divert /usr/bin/pg_config.libpq-dev --add /usr/bin/pg_config 8 | ;; 9 | 10 | abort-upgrade) 11 | ;; 12 | 13 | *) 14 | echo "$0 called with unknown argument \`$1'" 1>&2 15 | exit 1 16 | ;; 17 | esac 18 | 19 | #DEBHELPER# 20 | -------------------------------------------------------------------------------- /debian/postgresql-common.templates: -------------------------------------------------------------------------------- 1 | Template: postgresql-common/obsolete-major 2 | Type: error 3 | _Description: Obsolete major version ${old} 4 | The PostgreSQL version ${old} is obsolete, but the server 5 | or client packages are still installed. Please install the latest packages 6 | (postgresql-${latest} and postgresql-client-${latest}) and upgrade the 7 | existing ${oldversion} clusters with pg_upgradecluster (see manpage). 8 | . 9 | Please be aware that the installation of postgresql-${latest} will 10 | automatically create a default cluster ${latest}/main. If you want to upgrade 11 | the ${old}/main cluster, you need to remove the already existing ${latest} 12 | cluster (pg_dropcluster --stop ${latest} main, see manpage for 13 | details). 14 | . 15 | The old server and client packages are no longer supported. After the 16 | existing clusters are upgraded, the postgresql-${old} and 17 | postgresql-client-${old} packages should be removed. 18 | . 19 | Please see /usr/share/doc/postgresql-common/README.Debian.gz for details. 20 | 21 | Template: postgresql-common/ssl 22 | Type: boolean 23 | Default: true 24 | _Description: Enable SSL by default in new PostgreSQL clusters? 25 | PostgreSQL supports SSL-encrypted connections. This is usually a good thing. 26 | However, if the database is solely accessed using TCP connections on 27 | localhost, SSL can be turned off without introducing security issues. 28 | . 29 | UNIX domain socket connections (called "local" in pg_hba.conf) are not 30 | affected by this setting. This setting concerns new PostgreSQL clusters 31 | created during package install, or by using the pg_createcluster command. It 32 | does not reconfigure existing clusters. 33 | . 34 | If unsure, enable SSL. 35 | 36 | # The last paragraph of this note does not appear in PO files. 37 | # It contains shell commands and should not be translated. 38 | Template: postgresql-common/catversion-bump 39 | Type: note 40 | #flag:translate:1,2,3 41 | _Description: PostgreSQL ${version} catalog version changed 42 | The PostgreSQL cluster ${version} ${cluster} was created using catalog 43 | version ${db_catversion}, but the currently being installed package 44 | postgresql-${version} is using catalog version ${new_catversion}. You will not 45 | be able to use this cluster until it was upgraded to the new catalog version. 46 | . 47 | The necessary subset of binaries from the old version was saved in 48 | ${vartmpdir}. To upgrade the cluster, execute these commands: 49 | . 50 | pg_renamecluster ${version} ${cluster} ${cluster}.old 51 | pg_upgradecluster ${version} ${cluster}.old --rename ${cluster} \ 52 | -m upgrade -v ${version} --old-bindir=${vartmpdir}/bin 53 | pg_dropcluster ${version} ${cluster}.old 54 | rm -rf ${vartmpdir} 55 | -------------------------------------------------------------------------------- /debian/postgresql-common.tmpfile: -------------------------------------------------------------------------------- 1 | # Directory for PostgreSQL sockets, lockfiles and stats tempfiles 2 | d /run/postgresql 2775 postgres postgres - - 3 | # Log directory 4 | d /var/log/postgresql 1775 root postgres - - 5 | -------------------------------------------------------------------------------- /debian/postgresql-common.triggers: -------------------------------------------------------------------------------- 1 | # trigger pg_updatedicts on installation of new myspell/hunspell dictionaries 2 | interest-noawait /usr/share/myspell/dicts 3 | interest-noawait /usr/share/hunspell 4 | # also trigger on installation of new server versions so pg_updatedicts can update the symlinks 5 | interest-noawait /usr/share/postgresql 6 | -------------------------------------------------------------------------------- /debian/postgresql-server-dev-all.install: -------------------------------------------------------------------------------- 1 | debhelper/Debian /usr/share/perl5 2 | debhelper/dh_pgxs_test /usr/bin 3 | dh_make_pgxs/debian /usr/share/postgresql-common/dh_make_pgxs 4 | dh_make_pgxs/dh_make_pgxs /usr/bin 5 | gitlab usr/share/postgresql-common 6 | pgxs_debian_control.mk /usr/share/postgresql-common/ 7 | -------------------------------------------------------------------------------- /debian/postgresql-server-dev-all.manpages: -------------------------------------------------------------------------------- 1 | debhelper/dh_pgxs_test.1 2 | dh_make_pgxs/dh_make_pgxs.1 3 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | include /usr/share/dpkg/pkg-info.mk 4 | 5 | ifneq ($(findstring bpo,$(DEB_VERSION)),) 6 | FLAVOR := debian-backports 7 | else ifneq ($(findstring pgdg,$(DEB_VERSION)),) 8 | FLAVOR := pgdg 9 | else 10 | FLAVOR := default 11 | endif 12 | SUPPORTED_VERSIONS := $(shell PG_SUPPORTED_VERSIONS="$(FLAVOR)" debian/supported-versions) 13 | DEFAULT_VER := $(lastword $(SUPPORTED_VERSIONS)) 14 | 15 | #py2#PYTHON2_PACKAGE=postgresql-plpython-$v 16 | 17 | %: 18 | dh $@ 19 | 20 | override_dh_auto_configure: 21 | @echo "### Building postgresql-common flavor $(FLAVOR)" 22 | @echo "### Supported PostgreSQL versions: $(SUPPORTED_VERSIONS) (default version: $(DEFAULT_VER))" 23 | echo "# See /usr/share/postgresql-common/supported-versions for documentation of this file" > supported_versions 24 | echo "$(FLAVOR)" >> supported_versions 25 | 26 | # do not restart postgresql.service on postgresql-common upgrades 27 | override_dh_installinit: 28 | dh_installinit -ppostgresql-common --name=postgresql -u'defaults 19 21' --no-stop-on-upgrade 29 | override_dh_installsystemd: 30 | dh_installsystemd --no-stop-on-upgrade 31 | # move unit files to /usr on systems that support it 32 | if test -x /usr/bin/dh_movetousr; then dh_movetousr; fi 33 | 34 | override_dh_gencontrol: 35 | dh_gencontrol -ppostgresql-server-dev-all -- -Vserver-dev-all-depends="$(foreach v,$(SUPPORTED_VERSIONS),postgresql-server-dev-$v,)" 36 | 37 | # the versionless metapackages need to have version numbers which match 38 | # the server version, not the p-common version 39 | dh_gencontrol -ppostgresql -ppostgresql-client -ppostgresql-doc -ppostgresql-contrib -- \ 40 | -Vdefault-version="$(DEFAULT_VER)" -v'$(DEFAULT_VER)+$${source:Version}' 41 | 42 | dh_gencontrol -ppostgresql-all -- \ 43 | -Vpostgresql-all-depends="$(foreach v,$(SUPPORTED_VERSIONS),postgresql-contrib-$v,postgresql-plperl-$v,$(if $(filter 8.% 9.% 10 11, $v), $(PYTHON2_PACKAGE)),postgresql-plpython3-$v,postgresql-pltcl-$v,)" 44 | 45 | dh_gencontrol --remaining-packages 46 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /debian/supported-versions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # print a list of PostgreSQL versions that are supported for the platform this 4 | # script runs on. 5 | # Note: Newer installed versions than the highest one listed here are always 6 | # considered supported, so that backports will not cause an "obsolete" warning. 7 | # 8 | # /usr/share/postgresql-common/supported-versions decides which PostgreSQL 9 | # server versions are supported. This information is used 10 | # 1) for notifying users of obsolete versions, suggesting to upgrade 11 | # 2) by postgresql-common itself (in debian/rules) to determine the 12 | # dependencies of the postgresql meta packages (default version), and to 13 | # generate the list of postgresql-server-dev-* packages 14 | # postgresql-server-dev-all depends on 15 | # 3) by the pg_buildext tool to decide which server versions to build extension 16 | # modules for 17 | # 18 | # The *last* version returned here will be considered the default version, the 19 | # remaining lines list other supported versions in an undefined order. 20 | # 21 | # * PG_SUPPORTED_VERSIONS 22 | # * DEB_PG_SUPPORTED_VERSIONS 23 | # * ~/.pg_supported_versions 24 | # * /etc/postgresql-common/supported_versions 25 | # (in that order) can be used to override the defaults. (Tokens separated by 26 | # newlines.) 27 | # 28 | # Recognized tokens: 29 | # default: use the appropiate defaults for the current distribution 30 | # (as determined by os-release) 31 | # debian: use Debian defaults 32 | # debian-backports: use Debian Backports defaults 33 | # ubuntu: use Ubuntu defaults 34 | # pgdg: use defaults for apt.postgresql.org 35 | # installed: consider all installed versions supported (determined by 36 | # postgresql-server-dev-X packages) 37 | # X: consider this version supported 38 | # 39 | # (C) 2005-2016 Martin Pitt 40 | # (C) 2012-2023 Christoph Berg 41 | 42 | set -eu 43 | 44 | DEFAULT="16" 45 | 46 | # functions 47 | 48 | default() { 49 | . /etc/os-release 50 | case "$ID" in 51 | [uU]buntu) 52 | ubuntu 53 | ;; 54 | [dD]ebian) 55 | debian 56 | ;; 57 | *) 58 | echo "supported-versions: WARNING! Unknown distribution ID in /etc/os-release: $ID" >&2 59 | if echo $ID_LIKE | grep -E '(^| )ubuntu($| )' > /dev/null; then 60 | echo "ubuntu found in ID_LIKE, treating as Ubuntu" >&2 61 | ubuntu 62 | elif echo $ID_LIKE | grep -E '(^| )debian($| )' > /dev/null; then 63 | echo "debian found in ID_LIKE, treating as Debian" >&2 64 | debian 65 | else 66 | echo "Please submit this as a bug report to your distribution." >&2 67 | /bin/echo -e "$DEFAULT" 68 | fi 69 | ;; 70 | esac 71 | } 72 | 73 | ubuntu() { 74 | echo "$DEFAULT" 75 | } 76 | 77 | debian() { 78 | echo "$DEFAULT" 79 | } 80 | 81 | debian_backports() { 82 | echo "$DEFAULT" 83 | } 84 | 85 | pgdg() { 86 | cat <<-EOF 87 | 10 88 | 11 89 | 12 90 | 13 91 | 14 92 | 15 93 | 16 94 | EOF 95 | } 96 | 97 | installed() { 98 | dpkg -l 'postgresql-server-dev-[1-9]*' | \ 99 | sed -ne 's/^ii *postgresql-server-dev-\([^ ]*\).*/\1/p' | \ 100 | sort -V 101 | } 102 | 103 | # main 104 | 105 | if [ "${PG_SUPPORTED_VERSIONS:-}" ] ; then 106 | SUPPORTED_VERSIONS=$(echo "$PG_SUPPORTED_VERSIONS" | xargs -n1) 107 | elif [ "${DEB_PG_SUPPORTED_VERSIONS:-}" ] ; then 108 | SUPPORTED_VERSIONS=$(echo "$DEB_PG_SUPPORTED_VERSIONS" | xargs -n1) 109 | elif [ -f ${HOME:-}/.pg_supported_versions ] ; then 110 | SUPPORTED_VERSIONS="$(cat ${HOME:-}/.pg_supported_versions)" 111 | elif [ -f ${PGSYSCONFDIR:-/etc/postgresql-common}/supported_versions ] ; then 112 | SUPPORTED_VERSIONS="$(cat ${PGSYSCONFDIR:-/etc/postgresql-common}/supported_versions)" 113 | else 114 | SUPPORTED_VERSIONS="default" 115 | fi 116 | 117 | echo "$SUPPORTED_VERSIONS" | while read version release; do 118 | COMMENT="#" 119 | case $version in 120 | "") ;; 121 | $COMMENT*) ;; 122 | default) 123 | default 124 | ;; 125 | debian) 126 | debian 127 | ;; 128 | debian-backports) 129 | debian_backports 130 | ;; 131 | ubuntu) 132 | ubuntu 133 | ;; 134 | pgdg) # apt.postgresql.org 135 | pgdg 136 | ;; 137 | installed) 138 | installed 139 | ;; 140 | *) 141 | /bin/echo -e "$version" 142 | ;; 143 | esac 144 | done 145 | 146 | exit 0 147 | -------------------------------------------------------------------------------- /debian/tests/control: -------------------------------------------------------------------------------- 1 | Tests: default-psql 2 | Depends: 3 | postgresql, 4 | Restrictions: needs-root, skippable 5 | 6 | Tests: run-testsuite 7 | Depends: 8 | build-essential, 9 | debhelper, 10 | fakeroot, 11 | hunspell-en-us, 12 | iproute2, 13 | locales-all, 14 | logrotate, 15 | netcat-openbsd, 16 | perl, 17 | postgresql-all, 18 | postgresql-doc, 19 | procps, 20 | Restrictions: needs-root 21 | -------------------------------------------------------------------------------- /debian/tests/default-psql: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # autopkgtest to check that installing the "postgresql" metapackage results in 3 | # a working cluster 4 | set -e 5 | 6 | # disabled default cluster creation? 7 | if grep -rq '^create_main_cluster\b.*\bfalse\b' /etc/postgresql-common/createcluster.*; then 8 | echo "SKIP: default cluster creation disabled in createcluster.conf" 9 | exit 77 10 | fi 11 | 12 | if ! pg_lsclusters | grep -q 'main .* online'; then 13 | echo "No running cluster!" >&2 14 | pg_lsclusters >&2 15 | fi 16 | 17 | # check that we can connect to template1 on the default cluster 18 | OUT=$(su - -c 'psql -Atc "select 21*2" template1' postgres) 19 | [ "$OUT" = "42" ] || { echo "$OUT"; exit 1; } 20 | -------------------------------------------------------------------------------- /debian/tests/run-testsuite: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ./testsuite 5 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/control.in: -------------------------------------------------------------------------------- 1 | Source: @SOURCE@ 2 | Section: database 3 | Priority: optional 4 | Maintainer: Debian PostgreSQL Maintainers 5 | Uploaders: 6 | @MAINTAINER_NAME@ <@DEBEMAIL@>, 7 | Build-Depends: 8 | debhelper-compat (= @COMPAT@), 9 | postgresql-all (>= 217~), 10 | Standards-Version: @STANDARDS_VERSION@ 11 | Rules-Requires-Root: no 12 | Homepage: @URL@ 13 | Vcs-Browser: https://salsa.debian.org/postgresql/@SOURCE@ 14 | Vcs-Git: https://salsa.debian.org/postgresql/@SOURCE@.git 15 | 16 | Package: postgresql-PGVERSION-@EXTNAME@ 17 | Architecture: any 18 | Depends: 19 | ${misc:Depends}, 20 | ${postgresql:Depends}, 21 | ${shlibs:Depends}, 22 | Description: FIXME PostgreSQL extension @SOURCE@ 23 | FIXME long description here 24 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: @NAME@ 3 | Source: @URL@ 4 | 5 | Files: * 6 | Copyright: Portions Copyright (c) 1996-@YEAR@, PostgreSQL Global Development Group 7 | Portions Copyright (c) 1994, The Regents of the University of California 8 | License: PostgreSQL 9 | Permission to use, copy, modify, and distribute this software and its 10 | documentation for any purpose, without fee, and without a written agreement 11 | is hereby granted, provided that the above copyright notice and this 12 | paragraph and the following two paragraphs appear in all copies. 13 | . 14 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 15 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING 16 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS 17 | DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE 18 | POSSIBILITY OF SUCH DAMAGE. 19 | . 20 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 21 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 22 | AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 23 | ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO 24 | PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 25 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: https://salsa.debian.org/postgresql/postgresql-common/raw/master/gitlab/gitlab-ci.yml 2 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/pgversions: -------------------------------------------------------------------------------- 1 | all 2 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh $@ --with pgxs 5 | 6 | override_dh_installdocs: 7 | dh_installdocs --all README.* 8 | 9 | # if the package does not support building from subdirectories, use 10 | # `--with pgxs_loop` above. 11 | # 12 | # change the way tests are run: 13 | # override_dh_pgxs_test: 14 | # +pg_buildext installcheck . . postgresql-%v-@EXTNAME@ 15 | 16 | # classic `pg_buildext` interface: 17 | 18 | #include /usr/share/postgresql-common/pgxs_debian_control.mk 19 | # 20 | #override_dh_auto_build: 21 | # +pg_buildext build build-%v 22 | # 23 | #override_dh_auto_test: 24 | # # nothing to do here, see debian/tests/* instead 25 | # 26 | #override_dh_auto_install: 27 | # +pg_buildext install build-%v postgresql-%v-@EXTNAME@ 28 | # 29 | #override_dh_installdocs: 30 | # dh_installdocs --all README.* 31 | # 32 | #override_dh_auto_clean: 33 | # +pg_buildext clean build-%v 34 | # 35 | #%: 36 | # dh $@ 37 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/tests/control: -------------------------------------------------------------------------------- 1 | Depends: 2 | make, 3 | @, 4 | Tests: installcheck 5 | Restrictions: allow-stderr 6 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/tests/installcheck: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | pg_buildext installcheck 4 | -------------------------------------------------------------------------------- /dh_make_pgxs/debian/watch: -------------------------------------------------------------------------------- 1 | version=4 2 | @URL@/tags .*/(.*).tar.gz 3 | -------------------------------------------------------------------------------- /dh_make_pgxs/dh_make_pgxs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # (C) 2015-2020 Christoph Berg 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | set -eu 16 | 17 | # basic variables 18 | 19 | template_dir="/usr/share/postgresql-common/dh_make_pgxs/debian" 20 | 21 | DIRECTORY="$(basename $PWD)" 22 | NAME="${DIRECTORY%-*}" # Upstream name 23 | VERSION="${DIRECTORY##*-}" 24 | URL="https://FIXME/$NAME" 25 | 26 | # options 27 | 28 | while getopts "fh:n:v:" opt ; do 29 | case $opt in 30 | f) FORCE=yes ;; 31 | h) URL="$OPTARG" ;; 32 | n) NAME="$OPTARG" ;; 33 | v) VERSION="$OPTARG" ;; 34 | *) exit 5 ;; 35 | esac 36 | done 37 | shift $((OPTIND - 1)) # shift away args 38 | 39 | # more variables 40 | 41 | SOURCE="${NAME//_/-}" # Debian name 42 | EXTNAME="$(echo $SOURCE | sed -e 's/^\(postgresql\|pgsql\|pg\)-//')" # binary package name suffix 43 | DHVERSION="$(dpkg-query --showformat '${Version}' --show debhelper)" 44 | COMPAT="${DHVERSION%%.*}" 45 | STANDARDS_VERSION="$(apt-cache show debian-policy | sed -n 's/Version: \(.*\)\..*/\1/p' | head -n1)" 46 | USERNAME=${LOGNAME:-${USER:-root}} 47 | MAINTAINER_NAME=$(getent passwd $USERNAME | cut -d : -f 5 | sed -e 's/,.*//') 48 | : ${DEBEMAIL:=$USERNAME@localhost} 49 | YEAR=$(date +%Y) 50 | 51 | echo "Upstream (-n): $NAME" 52 | echo "Version (-v): $VERSION" 53 | echo "Source: $SOURCE ($VERSION-1)" 54 | echo "Binaries: postgresql-PGVERSION-$EXTNAME ($VERSION-1)" 55 | echo "Uploader: $MAINTAINER_NAME <$DEBEMAIL>" 56 | echo "Homepage (-h): $URL" 57 | echo 58 | if [ -t 0 ]; then 59 | echo -n "Press Enter to continue, ^C to abort " 60 | read 61 | fi 62 | 63 | # install files 64 | 65 | install_dir () 66 | { 67 | local directory="debian/$1" 68 | #[ -z "$directory" ] && return 69 | [ -d "$directory" ] && return 70 | echo "Creating $directory/" 71 | mkdir "$directory" 72 | } 73 | 74 | install_template () 75 | { 76 | local template="$1" 77 | 78 | if [ "${FORCE:-}" ] || ! [ -e debian/$template ]; then 79 | echo "Installing debian/$template" 80 | sed -e "s/@COMPAT@/$COMPAT/g" \ 81 | -e "s/@EXTNAME@/$EXTNAME/g" \ 82 | -e "s/@NAME@/$NAME/g" \ 83 | -e "s/@STANDARDS_VERSION@/$STANDARDS_VERSION/g" \ 84 | -e "s/@SOURCE@/$SOURCE/g" \ 85 | -e "s/@MAINTAINER_NAME@/$MAINTAINER_NAME/g" \ 86 | -e "s/@DEBEMAIL@/$DEBEMAIL/g" \ 87 | -e "s;@URL@;$URL;g" \ 88 | -e "s/@YEAR@/$YEAR/g" \ 89 | "$template_dir/$template" > "debian/$template" 90 | if [ -x $template_dir/$template ]; then 91 | chmod +x "debian/$template" 92 | fi 93 | else 94 | echo "Keeping existing debian/$template" 95 | fi 96 | } 97 | 98 | mkdir -p debian 99 | 100 | for template in $(find $template_dir -mindepth 1 | sort); do 101 | case $template in 102 | *.swp|*~) continue ;; # skip vim stuff 103 | esac 104 | basename=${template##$template_dir/} 105 | if [ -d $template ]; then 106 | install_dir "$basename" 107 | else 108 | install_template "$basename" 109 | fi 110 | done 111 | 112 | if [ "$COMPAT" -lt "12" ]; then 113 | sed -i -e "s/debhelper-compat[^,]*/debhelper (>= $COMPAT)/" debian/control* 114 | echo "$COMPAT" > debian/compat 115 | fi 116 | 117 | echo "Updating debian/control from debian/control.in" 118 | pg_buildext updatecontrol 119 | 120 | if [ "${FORCE:-}" ] || ! [ -e debian/changelog ]; then 121 | rm -f debian/changelog 122 | echo "Creating debian/changelog" 123 | if [ -x /usr/bin/dch ]; then 124 | dch --create --package "$SOURCE" --newversion "$VERSION-1" 125 | else 126 | cat > debian/changelog <<-EOT 127 | $SOURCE ($VERSION-1) UNRELEASED; urgency=medium 128 | 129 | * Initial release. (Closes: #XXXXXX) 130 | 131 | -- $MAINTAINER_NAME <$DEBEMAIL> $(date -R) 132 | EOT 133 | fi 134 | else 135 | echo "Keeping existing debian/changelog" 136 | fi 137 | -------------------------------------------------------------------------------- /dh_make_pgxs/dh_make_pgxs.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | dh_make_pgxs - Create a new Debian source package for a PGXS PostgreSQL extension 4 | 5 | =head1 SYNOPSIS 6 | 7 | B [B<-f>] [B<-h> I] [B<-n> I] [B<-v> I] 8 | 9 | =head1 DESCRIPTION 10 | 11 | B creates a F directory tree for PostgreSQL extension 12 | packages using the PGXS build system. The B tool is used for the 13 | build process. 14 | 15 | =head1 OPTIONS 16 | 17 | =over 4 18 | 19 | =item B<-f> 20 | 21 | Overwrite existing files. 22 | 23 | =item B<-h> I 24 | 25 | Package upstream homepage. 26 | 27 | =item B<-n> I 28 | 29 | Package name to use. Default is to extract it from the current directory's name. 30 | 31 | =item B<-v> I 32 | 33 | Package version to use. Default is to extract it from the current directory's name. 34 | 35 | =back 36 | 37 | =head1 SEE ALSO 38 | 39 | dh_make(1), pg_buildext(1). 40 | 41 | =head1 AUTHOR 42 | 43 | Christoph Berg Lmyon@debian.orgE> 44 | -------------------------------------------------------------------------------- /doc/dependencies.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/credativ/postgresql-common/593fa32fa0c6d2a963a7b3b514d1d6a2423ef534/doc/dependencies.dia -------------------------------------------------------------------------------- /gitlab/gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # gitlab-ci.yml file for the Debian PostgreSQL packages 2 | # to be used in debian/gitlab-ci.yml: 3 | # include: https://salsa.debian.org/postgresql/postgresql-common/raw/master/gitlab/gitlab-ci.yml 4 | 5 | include: 6 | - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml 7 | - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml 8 | 9 | variables: 10 | PG_UPDATECONTROL: 'yes' # tell pg_buildext to automatically generate debian/control from debian/control.in (TODO: doesn't work this way yet) 11 | SALSA_CI_DISABLE_REPROTEST: 'yes' # too many packages fail because reprotest runs the build as root, disable for now 12 | SALSA_CI_REPROTEST_ENABLE_DIFFOSCOPE: 'yes' 13 | SALSA_CI_DISABLE_CROSSBUILD_ARM64: 'yes' # clang isn't ready for cross-building yet 14 | -------------------------------------------------------------------------------- /pg_checksystem: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -wT 2 | 3 | # Check various system parameters for PostgreSQL. This needs to be run as root. 4 | # 5 | # (C) 2005-2009 Martin Pitt 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | use strict; 18 | 19 | use PgCommon; 20 | 21 | # Check write cache setting for given drive. 22 | # Arguments: 23 | # Returns: 0 = disabled, 1 = enabled, -1: could not determine 24 | sub get_device_write_cache { 25 | open DRV, $_[0] or return -1; 26 | sub HDIO_GET_WCACHE () {0x30e;} 27 | my $pval = pack 'l', 0; 28 | ioctl DRV, &HDIO_GET_WCACHE, $pval or return -1; 29 | my ($val) = unpack 'l', $pval; 30 | close DRV; 31 | return $val; 32 | } 33 | 34 | 35 | error 'This command needs to be executed as root' if $> != 0; 36 | 37 | # collect write cache-enabled drives with databases 38 | my %drive_wcache; 39 | my %seen; 40 | for my $v (get_versions) { 41 | for my $c (get_version_clusters $v) { 42 | my $datadir = PgCommon::cluster_data_directory $v, $c; 43 | my $drv = PgCommon::get_file_device $datadir; 44 | $drv =~ s/[0-9]+$//; 45 | unless (exists $seen{$drv}) { 46 | $drive_wcache{$drv} = 1 if (get_device_write_cache $drv) > 0; 47 | $seen{$drv} = 1; 48 | } 49 | } 50 | } 51 | my @unsave_drives = keys %drive_wcache; 52 | 53 | if (@unsave_drives) { 54 | print 'Warning: The following devices contain databases and have write 55 | caching enabled: ', (join ' ', @unsave_drives), ' 56 | This could destroy the integrity of your databases in the event of power 57 | failure. Consider disabling the write cache with "hdparm -W 0 ". 58 | '; 59 | } 60 | -------------------------------------------------------------------------------- /pg_config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # If postgresql-server-dev-* is installed, call pg_config from the latest 4 | # available one. Otherwise fall back to libpq-dev's version. 5 | # 6 | # (C) 2011 Martin Pitt 7 | # (C) 2014-2018 Christoph Berg 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | set -e 20 | PGBINROOT="/usr/lib/postgresql/" 21 | #redhat# PGBINROOT="/usr/pgsql-" 22 | LATEST_SERVER_DEV=`ls -v $PGBINROOT*/bin/pg_config 2>/dev/null|tail -n1` 23 | 24 | if [ -n "$LATEST_SERVER_DEV" ]; then 25 | exec "$LATEST_SERVER_DEV" "$@" 26 | else 27 | if [ -x /usr/bin/pg_config.libpq-dev ]; then 28 | exec /usr/bin/pg_config.libpq-dev "$@" 29 | else 30 | echo "You need to install postgresql-server-dev-NN for building a server-side extension or libpq-dev for building a client-side application." >&2 31 | exit 1 32 | fi 33 | fi 34 | -------------------------------------------------------------------------------- /pg_getwal: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # retrieve a WAL file from a pg_receivewal archive 4 | # 5 | # Copyright (C) 2021-2022 Christoph Berg 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | set -eu 18 | 19 | binroot="/usr/lib/postgresql/" 20 | #redhat# binroot="/usr/pgsql-" 21 | 22 | if [ -z "${2:-}" ]; then 23 | echo "Syntax: $0 /path/to/wal/%f %p" >&2 24 | exit 1 25 | fi 26 | 27 | file="$1" 28 | path="$2" 29 | 30 | # sanity-check the first argument 31 | waldir="$(dirname $file)" 32 | if ! [ -d "$waldir" ]; then 33 | echo "$0: $waldir is not a directory" >&2 34 | exit 129 35 | fi 36 | 37 | if [ -f "$file.gz" ]; then 38 | gunzip < "$file.gz" > "$path" || exit 129 39 | 40 | elif [ -f "$file.lz4" ]; then 41 | unlz4 < "$file.lz4" > "$path" || exit 129 42 | 43 | elif [ -f "$file" ]; then 44 | cp "$file" "$path" || exit 129 45 | 46 | elif [ -f "$file.gz.partial" ] || [ -f "$file.lz4.partial" ]; then 47 | if [ -s "$file.gz.partial" ]; then 48 | gunzip < "$file.gz.partial" > "$path" || exit 129 49 | elif [ -s "$file.lz4.partial" ]; then 50 | unlz4 < "$file.lz4.partial" > "$path" || exit 129 51 | else 52 | # .gz.partial starts completely empty, gunzip doesn't like that 53 | touch "$path" || exit 129 54 | fi 55 | 56 | # expand file to original size 57 | version=$(cat PG_VERSION) || exit 129 58 | wal_file_size=$(LC_ALL=C "$binroot$version/bin/pg_controldata" . | awk '/^Bytes per WAL segment:/ { print $5 }') || exit 129 59 | [ "$wal_file_size" -gt 0 ] || exit 129 60 | truncate --size="$wal_file_size" "$path" || exit 129 61 | 62 | elif [ -f "$file.partial" ]; then 63 | cp "$file.partial" "$path" || exit 129 64 | 65 | else 66 | # file not found, exit silently in order not to spam the server log with errors 67 | exit 1 68 | fi 69 | 70 | exit 0 71 | 72 | : <<=cut 73 | 74 | =head1 NAME 75 | 76 | pg_getwal - retrieve a WAL file from a pg_receivewal archive 77 | 78 | =head1 SYNOPSIS 79 | 80 | B I I<%p> 81 | 82 | =head1 DESCRIPTION 83 | 84 | B retrieves and decompresses files from a WAL archive maintained by 85 | B and B. It is put into PostgreSQL's 86 | B by B. 87 | 88 | =head1 SEE ALSO 89 | 90 | L, L. 91 | 92 | =head1 AUTHOR 93 | 94 | Christoph Berg Lmyon@debian.orgE> 95 | 96 | =cut 97 | -------------------------------------------------------------------------------- /pg_hba: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # Add, remove, or test a pg_hba.conf entry. 4 | # 5 | # (C) 2005-2009 Martin Pitt 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | use strict; 18 | use PgCommon; 19 | use Getopt::Long; 20 | use Net::CIDR; 21 | 22 | # global variables 23 | 24 | my $ip = ''; # default to local unix socket 25 | my $force_ssl = 0; 26 | my ($method, $ver_cluster, $db, $user); 27 | my $mode; 28 | my @hba; 29 | 30 | # Print an error message to stderr and exit with status 2 31 | sub error2 { 32 | print STDERR 'Error: ', $_[0], "\n"; 33 | exit 2; 34 | } 35 | 36 | # Check if s1 is equal to s2 or s2 is 'all'. 37 | # Arguments: 38 | sub match_all { 39 | return ($_[1] eq 'all' || $_[0] eq $_[1]); 40 | } 41 | 42 | # Check if given IP matches the specification in the HBA record. 43 | # Arguments: 44 | sub match_ip { 45 | my ($ip, $hba) = @_; 46 | 47 | # Don't try to mix IPv4 and IPv6 addresses since that will make cidrlookup 48 | # croak 49 | return 0 if ((index $ip, ':') < 0) ^ ((index $$hba{'ip'}, ':') < 0); 50 | 51 | return Net::CIDR::cidrlookup ($ip, $$hba{'ip'}); 52 | } 53 | 54 | # Check if arguments match any line 55 | # Return: 1 if match was found, 0 otherwise. 56 | sub mode_test { 57 | foreach my $hbarec (@hba) { 58 | if (!defined($$hbarec{'type'})) { 59 | next; 60 | } 61 | next if $$hbarec{'type'} eq 'comment'; 62 | next unless match_all ($user, $$hbarec{'user'}) && 63 | match_all ($db, $$hbarec{'db'}) && 64 | $$hbarec{'method'} eq $method; 65 | 66 | if ($ip) { 67 | return 1 if 68 | (($force_ssl && $$hbarec{'type'} eq 'hostssl') || 69 | $$hbarec{'type'} =~ /^host/) && 70 | match_ip ($ip, $hbarec); 71 | } else { 72 | return 1 if $$hbarec{'type'} eq 'local'; 73 | } 74 | } 75 | 76 | return 0; 77 | } 78 | 79 | # Print hba conf. 80 | sub mode_print { 81 | foreach my $hbarec (@hba) { 82 | print "$$hbarec{'line'}\n"; 83 | } 84 | } 85 | 86 | # Generate a pg_hba.conf line that matches the command line args. 87 | sub create_hba_line { 88 | if ($ip) { 89 | return sprintf "%-7s %-11s %-11s %-35s %s\n", 90 | $force_ssl ? 'hostssl' : 'host', $db, $user, $ip, $method; 91 | } else { 92 | return sprintf "%-7s %-11s %-47s %s\n", 'local', $db, $user, $method; 93 | } 94 | } 95 | 96 | # parse arguments 97 | 98 | my $ip_arg; 99 | exit 3 unless GetOptions ( 100 | 'cluster=s' => \$ver_cluster, 101 | 'ip=s' => \$ip_arg, 102 | 'method=s' => \$method, 103 | 'force-ssl' => \$force_ssl 104 | ); 105 | 106 | if ($#ARGV != 2) { 107 | print STDERR "Usage: $0 mode [options] \n"; 108 | exit 2; 109 | } 110 | ($mode, $db, $user) = @ARGV; 111 | 112 | error2 '--cluster must be specified' unless $ver_cluster; 113 | my ($version, $cluster) = split ('/', $ver_cluster); 114 | error2 'No version specified with --cluster' unless $version; 115 | error2 'No cluster specified with --cluster' unless $cluster; 116 | error2 'Cluster does not exist' unless cluster_exists $version, $cluster; 117 | if (defined $ip_arg) { 118 | $ip = Net::CIDR::cidrvalidate $ip_arg; 119 | error2 'Invalid --ip argument' unless defined $ip; 120 | } 121 | 122 | unless (defined $method) { 123 | $method = ($ip ? 'md5' : 'ident sameuser'); 124 | } 125 | error2 'Invalid --method argument' unless PgCommon::valid_hba_method($method); 126 | 127 | # parse file 128 | 129 | my $hbafile = "/etc/postgresql/$version/$cluster/pg_hba.conf"; 130 | @hba = read_pg_hba $hbafile; 131 | error2 "Could not read $hbafile" unless $#hba; 132 | 133 | if ($mode eq 'pg_test_hba') { 134 | if (mode_test) { 135 | exit 0; 136 | } else { 137 | print create_hba_line(); 138 | exit 1; 139 | } 140 | } elsif ($mode eq 'pg_print_hba') { 141 | mode_print(); 142 | } else { 143 | error2 "Unknown mode: $mode"; 144 | } 145 | -------------------------------------------------------------------------------- /pg_updateaptconfig: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Tell apt which PostgreSQL versions have clusters present 4 | 5 | set -eu 6 | 7 | APTCONFDIR="/etc/apt/apt.conf.d" 8 | [ -d "$APTCONFDIR" ] || exit 0 # skip generation on RPM systems 9 | APTCONF="$APTCONFDIR/02autoremove-postgresql" 10 | TMPCONF="$(mktemp --tmpdir pg_updateaptconfig.XXXXXX)" 11 | trap "rm -f $TMPCONF" EXIT 12 | 13 | cat > $TMPCONF <> $TMPCONF 31 | done 32 | 33 | cat >> $TMPCONF < 7 | # (C) 2012-2017 Christoph Berg 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | use strict; 20 | use warnings; 21 | my @srcdirs = ('/usr/share/hunspell', '/usr/share/myspell/dicts'); 22 | my $cachedir = '/var/cache/postgresql/dicts'; 23 | my $pgsharedir = '/usr/share/postgresql/'; 24 | 25 | use PgCommon; 26 | 27 | # determine encoding of an .aff file 28 | sub get_encoding { 29 | open my $fh, '<', $_[0] or die "cannot open $_[0]: $!"; 30 | while (<$fh>) { 31 | if (/^SET ([\w-]+)\s*$/) { return $1; } 32 | } 33 | return undef; 34 | } 35 | 36 | umask 022; 37 | if ((system 'mkdir', '-p', $cachedir) != 0) { 38 | exit 1; 39 | } 40 | 41 | # keep track of all up to date files, so that we can clean up cruft 42 | my %current; 43 | 44 | print "Building PostgreSQL dictionaries from installed myspell/hunspell packages...\n"; 45 | for my $d (@srcdirs) { 46 | for my $aff (glob "$d/*.aff") { 47 | next if -l $aff; # ignore symlinks 48 | my $dic = substr($aff, 0, -3) . 'dic'; 49 | if (! -f $dic) { 50 | print STDERR "ERROR: $aff does not have corresponding $dic, ignoring\n"; 51 | next; 52 | } 53 | 54 | my $enc = get_encoding $aff; 55 | if (!$enc) { 56 | print STDERR "ERROR: no encoding defined in $aff, ignoring\n"; 57 | next; 58 | } 59 | 60 | my $locale = substr ((split '/', $aff)[-1], 0, -4); 61 | $locale =~ tr /A-Z/a-z/; 62 | 63 | $current{"$cachedir/$locale.affix"} = undef; 64 | $current{"$cachedir/$locale.dict"} = undef; 65 | 66 | # convert to UTF-8 and write to cache dir 67 | print " $locale\n"; 68 | if ((system 'iconv', '-f', $enc, '-t', 'UTF-8', '-o', 69 | "$cachedir/$locale.affix", $aff) != 0) { 70 | unlink "$cachedir/$locale.affix"; 71 | print STDERR "ERROR: Conversion of $aff failed\n"; 72 | next; 73 | } 74 | if ((system 'iconv', '-f', $enc, '-t', 'UTF-8', '-o', 75 | "$cachedir/$locale.dict", $dic) != 0) { 76 | unlink "$cachedir/$locale.affix"; 77 | unlink "$cachedir/$locale.dict"; 78 | print STDERR "ERROR: Conversion of $dic failed\n"; 79 | next; 80 | } 81 | 82 | # install symlinks to all versions >= 8.3 83 | foreach my $v (get_versions) { 84 | next if $v < '8.3'; 85 | my $dest = "$pgsharedir/$v/tsearch_data"; 86 | next if ! -d $dest; 87 | $current{"$dest/$locale.affix"} = undef; 88 | $current{"$dest/$locale.dict"} = undef; 89 | next if -e "$dest/$locale.affix" && ! -l "$dest/$locale.affix"; 90 | next if -e "$dest/$locale.dict" && ! -l "$dest/$locale.dict"; 91 | unlink "$dest/$locale.affix"; 92 | unlink "$dest/$locale.dict"; 93 | symlink "$cachedir/$locale.affix", "$dest/$locale.affix"; 94 | symlink "$cachedir/$locale.dict", "$dest/$locale.dict"; 95 | } 96 | } 97 | } 98 | 99 | # clean up files for locales which do not exist any more 100 | print "Removing obsolete dictionary files:\n"; 101 | foreach my $f (glob "$cachedir/*") { 102 | next if exists $current{$f}; 103 | print " $f\n"; 104 | unlink $f; 105 | } 106 | foreach my $f ((glob "$pgsharedir/*/tsearch_data/*.affix"), 107 | (glob "$pgsharedir/*/tsearch_data/*.dict")) { 108 | next unless -l $f; 109 | next if exists $current{$f}; 110 | print " $f\n"; 111 | unlink $f; 112 | } 113 | 114 | __END__ 115 | 116 | =head1 NAME 117 | 118 | pg_updatedicts - build PostgreSQL dictionaries from myspell/hunspell ones 119 | 120 | =head1 SYNOPSIS 121 | 122 | B 123 | 124 | =head1 DESCRIPTION 125 | 126 | B makes dictionaries and affix files from installed myspell 127 | and hunspell dictionary packages available to PostgreSQL for usage with tsearch 128 | and word stem support. In particular, it takes all I<*.dic> and I<*.aff> files 129 | from /usr/share/myspell/dicts/, converts them to UTF-8, puts them into 130 | /var/cache/postgresql/dicts/ with I<*.dict> and I<*.affix> suffixes, and 131 | symlinks them into /usr/share/postgresql/I/tsearch_data/, where 132 | PostgreSQL looks for them. 133 | 134 | Through postgresql-common's dpkg trigger, this program is automatically run 135 | whenever a myspell or hunspell dictionary package is installed or upgraded. 136 | 137 | =head1 AUTHOR 138 | 139 | Martin Pitt Lmpitt@debian.orgE> 140 | -------------------------------------------------------------------------------- /pg_upgradecluster.d/analyze: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Run ANALYZE on all databases in the upgraded cluster 4 | 5 | set -eu 6 | 7 | oldversion="$1" 8 | cluster="$2" 9 | newversion="$3" 10 | phase="$4" 11 | 12 | case $newversion in 13 | 9.2|9.3) 14 | analyze="--analyze-only" 15 | ;; 16 | *) 17 | analyze="--analyze-in-stages" 18 | ;; 19 | esac 20 | 21 | case $newversion in 22 | 9.5|9.6|[1-7]*) 23 | [ "${PGJOBS:-}" ] && jobs="--jobs=$PGJOBS" 24 | ;; 25 | esac 26 | 27 | case $phase in 28 | finish) 29 | vacuumdb --cluster "$newversion/$cluster" --all $analyze ${jobs:-} 30 | ;; 31 | esac 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /pg_virtualenv.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | pg_virtualenv - Create a throw-away PostgreSQL environment for running regression tests 4 | 5 | =head1 SYNOPSIS 6 | 7 | B [I] [B<-v> 'I'] [I] 8 | 9 | =head1 DESCRIPTION 10 | 11 | B creates a virtual PostgreSQL server environment, and sets 12 | environment variables such that I can access the PostgreSQL database 13 | server(s). The servers are destroyed when I exits. 14 | 15 | The environment variables B, B, B, and 16 | B will be set. Per default, a single new cluster is created, 17 | using the newest PostgreSQL server version installed. The cluster will use the 18 | first available port number starting from B<5432>, and B will be set. 19 | B is set the the PostgreSQL major version number. 20 | 21 | When clusters for more than one versions are created, they will differ in the 22 | port number used, and B and B are not set. The clusters are 23 | named I/regress. To access a cluster, set 24 | BIB. For ease of access, the clusters are also 25 | registered in F, with the version 26 | number as cluster name. Clusters can be accessed by passing the connection 27 | string "BI", e.g. B. 28 | 29 | When invoked as root, the clusters are created in F as usual; 30 | for other users, B and B are 31 | set to a temporary directory where all files belonging to the clusters are 32 | created. 33 | 34 | If I fails, the tail of the PostgreSQL server log is shown. 35 | Additionally, if B is available, the backtrace from any PostgreSQL 36 | coredump is show. 37 | 38 | =head1 OPTIONS 39 | 40 | =over 4 41 | 42 | =item B<-a> 43 | 44 | Use all PostgreSQL server versions installed. 45 | 46 | =item B<-v> I 47 | 48 | Use these versions (space-separated list). 49 | 50 | =item B<-c> I 51 | 52 | Extra options to pass to B. 53 | 54 | =item B<-i> I 55 | 56 | Extra initdb options to pass to B. 57 | 58 | =item B<-o> IB<=>I 59 | 60 | Configuration option to set in the C file, passed to 61 | B. 62 | 63 | =item B<-p> I 64 | 65 | Set B and B in cluster to enable 66 | loading and testing extensions at build-time from BIB. 67 | 68 | This is a Debian-specific PostgreSQL patch. 69 | 70 | =item B<-s> 71 | 72 | Launch a shell inside the virtual environment when I fails. 73 | 74 | =item B<-t> 75 | 76 | Install clusters in a temporary directory, even when running as root. 77 | 78 | =item B<-h> 79 | 80 | Show program help. 81 | 82 | =back 83 | 84 | =head1 EXAMPLE 85 | 86 | # pg_virtualenv make check 87 | 88 | =head1 NOTES 89 | 90 | When run with fakeroot(1), B will fall back to the non-root mode 91 | of operation. Running "fakeroot pg_virtualenv" as root will fail, though. 92 | 93 | =head1 ENVIRONMENT 94 | 95 | =over 4 96 | 97 | =item B=yes 98 | 99 | When non-empty, B will re-exec itself using newpid(1). 100 | 101 | =item B=I 102 | 103 | When non-empty, B will re-exec itself using unshare(1) using 104 | these flags. 105 | 106 | =item B=I 107 | 108 | When set, the value is used for the (single) cluster created. 109 | 110 | =back 111 | 112 | =head1 COMPATIBILITY 113 | 114 | B is set in postgresql-common (>= 219~). 115 | 116 | =head1 SEE ALSO 117 | 118 | initdb(1), pg_createcluster(1). 119 | 120 | =head1 AUTHOR 121 | 122 | Christoph Berg Lmyon@debian.orgE> 123 | -------------------------------------------------------------------------------- /pgdg/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | if [ -f $(HOME)/apt.postgresql.org/pgapt.conf ]; then ./update; fi 3 | -------------------------------------------------------------------------------- /pgdg/apt.postgresql.org.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mQINBE6XR8IBEACVdDKT2HEH1IyHzXkb4nIWAY7echjRxo7MTcj4vbXAyBKOfjja 4 | UrBEJWHN6fjKJXOYWXHLIYg0hOGeW9qcSiaa1/rYIbOzjfGfhE4x0Y+NJHS1db0V 5 | G6GUj3qXaeyqIJGS2z7m0Thy4Lgr/LpZlZ78Nf1fliSzBlMo1sV7PpP/7zUO+aA4 6 | bKa8Rio3weMXQOZgclzgeSdqtwKnyKTQdXY5MkH1QXyFIk1nTfWwyqpJjHlgtwMi 7 | c2cxjqG5nnV9rIYlTTjYG6RBglq0SmzF/raBnF4Lwjxq4qRqvRllBXdFu5+2pMfC 8 | IZ10HPRdqDCTN60DUix+BTzBUT30NzaLhZbOMT5RvQtvTVgWpeIn20i2NrPWNCUh 9 | hj490dKDLpK/v+A5/i8zPvN4c6MkDHi1FZfaoz3863dylUBR3Ip26oM0hHXf4/2U 10 | A/oA4pCl2W0hc4aNtozjKHkVjRx5Q8/hVYu+39csFWxo6YSB/KgIEw+0W8DiTII3 11 | RQj/OlD68ZDmGLyQPiJvaEtY9fDrcSpI0Esm0i4sjkNbuuh0Cvwwwqo5EF1zfkVj 12 | Tqz2REYQGMJGc5LUbIpk5sMHo1HWV038TWxlDRwtOdzw08zQA6BeWe9FOokRPeR2 13 | AqhyaJJwOZJodKZ76S+LDwFkTLzEKnYPCzkoRwLrEdNt1M7wQBThnC5z6wARAQAB 14 | tBxQb3N0Z3JlU1FMIERlYmlhbiBSZXBvc2l0b3J5iQJOBBMBCAA4AhsDBQsJCAcD 15 | BRUKCQgLBRYCAwEAAh4BAheAFiEEuXsK/KoaR/BE8kSgf8x9RqzMTPgFAlhtCD8A 16 | CgkQf8x9RqzMTPgECxAAk8uL+dwveTv6eH21tIHcltt8U3Ofajdo+D/ayO53LiYO 17 | xi27kdHD0zvFMUWXLGxQtWyeqqDRvDagfWglHucIcaLxoxNwL8+e+9hVFIEskQAY 18 | kVToBCKMXTQDLarz8/J030Pmcv3ihbwB+jhnykMuyyNmht4kq0CNgnlcMCdVz0d3 19 | z/09puryIHJrD+A8y3TD4RM74snQuwc9u5bsckvRtRJKbP3GX5JaFZAqUyZNRJRJ 20 | Tn2OQRBhCpxhlZ2afkAPFIq2aVnEt/Ie6tmeRCzsW3lOxEH2K7MQSfSu/kRz7ELf 21 | Cz3NJHj7rMzC+76Rhsas60t9CjmvMuGONEpctijDWONLCuch3Pdj6XpC+MVxpgBy 22 | 2VUdkunb48YhXNW0jgFGM/BFRj+dMQOUbY8PjJjsmVV0joDruWATQG/M4C7O8iU0 23 | B7o6yVv4m8LDEN9CiR6r7H17m4xZseT3f+0QpMe7iQjz6XxTUFRQxXqzmNnloA1T 24 | 7VjwPqIIzkj/u0V8nICG/ktLzp1OsCFatWXh7LbU+hwYl6gsFH/mFDqVxJ3+DKQi 25 | vyf1NatzEwl62foVjGUSpvh3ymtmtUQ4JUkNDsXiRBWczaiGSuzD9Qi0ONdkAX3b 26 | ewqmN4TfE+XIpCPxxHXwGq9Rv1IFjOdCX0iG436GHyTLC1tTUIKF5xV4Y0+cXIOI 27 | RgQQEQgABgUCTpdI7gAKCRDFr3dKWFELWqaPAKD1TtT5c3sZz92Fj97KYmqbNQZP 28 | +ACfSC6+hfvlj4GxmUjp1aepoVTo3weJAhwEEAEIAAYFAk6XSQsACgkQTFprqxLS 29 | p64F8Q//cCcutwrH50UoRFejg0EIZav6LUKejC6kpLeubbEtuaIH3r2zMblPGc4i 30 | +eMQKo/PqyQrceRXeNNlqO6/exHozYi2meudxa6IudhwJIOn1MQykJbNMSC2sGUp 31 | 1W5M1N5EYgt4hy+qhlfnD66LR4G+9t5FscTJSy84SdiOuqgCOpQmPkVRm1HX5X1+ 32 | dmnzMOCk5LHHQuiacV0qeGO7JcBCVEIDr+uhU1H2u5GPFNHm5u15n25tOxVivb94 33 | xg6NDjouECBH7cCVuW79YcExH/0X3/9G45rjdHlKPH1OIUJiiX47OTxdG3dAbB4Q 34 | fnViRJhjehFscFvYWSqXo3pgWqUsEvv9qJac2ZEMSz9x2mj0ekWxuM6/hGWxJdB+ 35 | +985rIelPmc7VRAXOjIxWknrXnPCZAMlPlDLu6+vZ5BhFX0Be3y38f7GNCxFkJzl 36 | hWZ4Cj3WojMj+0DaC1eKTj3rJ7OJlt9S9xnO7OOPEUTGyzgNIDAyCiu8F4huLPaT 37 | ape6RupxOMHZeoCVlqx3ouWctelB2oNXcxxiQ/8y+21aHfD4n/CiIFwDvIQjl7dg 38 | mT3u5Lr6yxuosR3QJx1P6rP5ZrDTP9khT30t+HZCbvs5Pq+v/9m6XDmi+NlU7Zuh 39 | Ehy97tL3uBDgoL4b/5BpFL5U9nruPlQzGq1P9jj40dxAaDAX/WKJAj0EEwEIACcC 40 | GwMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AFAlB5KywFCQPDFt8ACgkQf8x9RqzM 41 | TPhuCQ//QAjRSAOCQ02qmUAikT+mTB6baOAakkYq6uHbEO7qPZkv4E/M+HPIJ4wd 42 | nBNeSQjfvdNcZBA/x0hr5EMcBneKKPDj4hJ0panOIRQmNSTThQw9OU351gm3YQct 43 | AMPRUu1fTJAL/AuZUQf9ESmhyVtWNlH/56HBfYjE4iVeaRkkNLJyX3vkWdJSMwC/ 44 | LO3Lw/0M3R8itDsm74F8w4xOdSQ52nSRFRh7PunFtREl+QzQ3EA/WB4AIj3VohIG 45 | kWDfPFCzV3cyZQiEnjAe9gG5pHsXHUWQsDFZ12t784JgkGyO5wT26pzTiuApWM3k 46 | /9V+o3HJSgH5hn7wuTi3TelEFwP1fNzI5iUUtZdtxbFOfWMnZAypEhaLmXNkg4zD 47 | kH44r0ss9fR0DAgUav1a25UnbOn4PgIEQy2fgHKHwRpCy20d6oCSlmgyWsR40EPP 48 | YvtGq49A2aK6ibXmdvvFT+Ts8Z+q2SkFpoYFX20mR2nsF0fbt1lfH65P64dukxeR 49 | GteWIeNakDD40bAAOH8+OaoTGVBJ2ACJfLVNM53PEoftavAwUYMrR910qvwYfd/4 50 | 6rh46g1Frr9SFMKYE9uvIJIgDsQB3QBp71houU4H55M5GD8XURYs+bfiQpJG1p7e 51 | B8e5jZx1SagNWc4XwL2FzQ9svrkbg1Y+359buUiP7T6QXX2zY++JAj0EEwEIACcC 52 | GwMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AFAlEqbZUFCQg2wEEACgkQf8x9RqzM 53 | TPhFMQ//WxAfKMdpSIA9oIC/yPD/dJpY/+DyouOljpE6MucMy/ArBECjFTBwi/j9 54 | NYM4ynAk34IkhuNexc1i9/05f5RM6+riLCLgAOsADDbHD4miZzoSxiVr6GQ3YXMb 55 | OGld9kV9Sy6mGNjcUov7iFcf5Hy5w3AjPfKuR9zXswyfzIU1YXObiiZT38l55pp/ 56 | BSgvGVQsvbNjsff5CbEKXS7q3xW+WzN0QWF6YsfNVhFjRGj8hKtHvwKcA02wwjLe 57 | LXVTm6915ZUKhZXUFc0vM4Pj4EgNswH8Ojw9AJaKWJIZmLyW+aP+wpu6YwVCicxB 58 | Y59CzBO2pPJDfKFQzUtrErk9irXeuCCLesDyirxJhv8o0JAvmnMAKOLhNFUrSQ2m 59 | +3EnF7zhfz70gHW+EG8X8mL/EN3/dUM09j6TVrjtw43RLxBzwMDeariFF9yC+5bL 60 | tnGgxjsB9Ik6GV5v34/NEEGf1qBiAzFmDVFRZlrNDkq6gmpvGnA5hUWNr+y0i01L 61 | jGyaLSWHYjgw2UEQOqcUtTFK9MNzbZze4mVaHMEz9/aMfX25R6qbiNqCChveIm8m 62 | Yr5Ds2zdZx+G5bAKdzX7nx2IUAxFQJEE94VLSp3npAaTWv3sHr7dR8tSyUJ9poDw 63 | gw4W9BIcnAM7zvFYbLF5FNggg/26njHCCN70sHt8zGxKQINMc6SJAj0EEwEIACcC 64 | GwMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AFAlLpFRkFCQ6EJy0ACgkQf8x9RqzM 65 | TPjOZA//Zp0e25pcvle7cLc0YuFr9pBv2JIkLzPm83nkcwKmxaWayUIG4Sv6pH6h 66 | m8+S/CHQij/yFCX+o3ngMw2J9HBUvafZ4bnbI0RGJ70GsAwraQ0VlkIfg7GUw3Tz 67 | voGYO42rZTru9S0K/6nFP6D1HUu+U+AsJONLeb6oypQgInfXQExPZyliUnHdipei 68 | 4WR1YFW6sjSkZT/5C3J1wkAvPl5lvOVthI9Zs6bZlJLZwusKxU0UM4Btgu1Sf3nn 69 | JcHmzisixwS9PMHE+AgPWIGSec/N27a0KmTTvImV6K6nEjXJey0K2+EYJuIBsYUN 70 | orOGBwDFIhfRk9qGlpgt0KRyguV+AP5qvgry95IrYtrOuE7307SidEbSnvO5ezNe 71 | mE7gT9Z1tM7IMPfmoKph4BfpNoH7aXiQh1Wo+ChdP92hZUtQrY2Nm13cmkxYjQ4Z 72 | gMWfYMC+DA/GooSgZM5i6hYqyyfAuUD9kwRN6BqTbuAUAp+hCWYeN4D88sLYpFh3 73 | paDYNKJ+Gf7Yyi6gThcV956RUFDH3ys5Dk0vDL9NiWwdebWfRFbzoRM3dyGP889a 74 | OyLzS3mh6nHzZrNGhW73kslSQek8tjKrB+56hXOnb4HaElTZGDvD5wmrrhN94kby 75 | Gtz3cydIohvNO9d90+29h0eGEDYti7j7maHkBKUAwlcPvMg5m3Y= 76 | =DA1T 77 | -----END PGP PUBLIC KEY BLOCK----- 78 | -------------------------------------------------------------------------------- /pgdg/apt.postgresql.org.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/credativ/postgresql-common/593fa32fa0c6d2a963a7b3b514d1d6a2423ef534/pgdg/apt.postgresql.org.gpg -------------------------------------------------------------------------------- /pgdg/update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . $HOME/apt.postgresql.org/pgapt.conf 4 | 5 | set -eux 6 | 7 | sed -i \ 8 | -e "s/^PG_BETA_VERSION=.*/PG_BETA_VERSION=\"${PG_BETA_VERSION:-}\"/" \ 9 | -e "s/^PG_DEVEL_VERSION=.*/PG_DEVEL_VERSION=\"$PG_DEVEL_VERSION\"/" \ 10 | -e "s/^PG_REPOSITORY_DISTS=.*/PG_REPOSITORY_DISTS=\"$PG_REPOSITORY_DISTS\"/" \ 11 | -e "s/^PG_ARCHIVE_DISTS=.*/PG_ARCHIVE_DISTS=\"$PG_ARCHIVE_DISTS\"/" \ 12 | apt.postgresql.org.sh 13 | -------------------------------------------------------------------------------- /pgxs_debian_control.mk: -------------------------------------------------------------------------------- 1 | # 2 | # produce a debian/control file from a debian/control.in 3 | # 4 | # In debian/rules, include /usr/share/postgresql-common/pgxs_debian_control.mk 5 | # 6 | # Author: Dimitri Fontaine 7 | # 8 | debian/control: debian/control.in debian/pgversions 9 | pg_buildext checkcontrol 10 | 11 | # run check when clean is invoked 12 | clean: debian/control 13 | .PHONY: debian/control 14 | -------------------------------------------------------------------------------- /postgresqlrc.5: -------------------------------------------------------------------------------- 1 | .TH POSTGRESQLRC 5 "Feburary 2005" "Debian" "Debian PostgreSQL infrastructure" 2 | 3 | .SH NAME 4 | ~/.postgresqlrc \- Per\-user PostgreSQL cluster configuration 5 | 6 | .SH DESCRIPTION 7 | The file 8 | .B ~/.postgresqlrc 9 | configures the default PostgreSQL version/cluster and the default 10 | database for an user. If it is not present, the system\-wide file 11 | .B /etc/postgresql\-common/user_clusters 12 | is used instead. 13 | 14 | .SH FORMAT 15 | .P 16 | Comments are introduced by the character 17 | .BR # . 18 | Comments may follow data on a line; the first comment character terminates 19 | the data. 20 | Leading whitespace and blank lines are ignored. 21 | 22 | The first uncommented, non\-blank line is used, all following lines are ignored. 23 | 24 | Fields must be given in the following order, separated by white space: 25 | 26 | .TP 27 | .B VERSION 28 | The major PostgreSQL version of the cluster to connect to. 29 | .TP 30 | .B CLUSTER 31 | The name of a cluster to connect to. A remote cluster is specified 32 | with \fIhost\fR:\fIport\fR. If port is empty, it defaults to 5432. 33 | .TP 34 | .B DATABASE 35 | Within the cluster, the database to which the user will connect by default 36 | if he does not specify a database on the command line. If this is 37 | .BR * , 38 | the default database will be the one named by the user's login id. 39 | 40 | .SH SEE ALSO 41 | .BR pg_wrapper (1), 42 | .BR user_clusters (5) 43 | -------------------------------------------------------------------------------- /rpm/.gitignore: -------------------------------------------------------------------------------- 1 | BUILD/ 2 | BUILDROOT/ 3 | RPMS/ 4 | SOURCES/ 5 | SPECS/ 6 | SRPMS/ 7 | -------------------------------------------------------------------------------- /rpm/README: -------------------------------------------------------------------------------- 1 | postgresql-common for RedHat 2 | ============================ 3 | 4 | The postgresql-common framework was written for Debian/Ubuntu, but most parts 5 | of it work as well on other operating systems. The RPM port changes little in 6 | the original code, and even uses many files from the debian/ directory for 7 | building the packages. 8 | 9 | No separate PostgreSQL client/server packages are provided; the port is backed 10 | by the PGDG RPM packages from yum.postgresql.org. 11 | 12 | The filesystem layout is unchanged, /etc/postgresql, /etc/postgresql-common, 13 | and /var/lib/postgresql are used as before. 14 | 15 | Differences between the Debian and RedHat operating modes are: 16 | 17 | * /var/run/postgresql/ is still used for external pid files, but the default 18 | unix socket directory is /tmp, to match the RPM packages' default. 19 | 20 | * The postgres system user home is /var/lib/pgsql. 21 | 22 | * The binroot is changed from /usr/lib/postgresql/ to /usr/pgsql-. (Note the 23 | missing trailing slash, the idea is that the version number can just be 24 | appended to the path, e.g. /usr/lib/postgresql/9.4/bin becomes 25 | /usr/pgsql-9.4/bin.) 26 | 27 | * The various symlinks for frontend programs in /usr/bin like psql are not 28 | direct symlinks to pg_wrapper, but are added as high-priority alternatives to 29 | the alternatives symlinks set up by the PostgreSQL RPM packages. 30 | 31 | * SSL is disabled by default because there is no easily available snakeoil 32 | certificate. Proper certificates can be configured in createcluster.conf. 33 | 34 | * No attempt is made to setup OOM killer protection for the postmaster process. 35 | 36 | * On Debian, the /etc/init.d/postgresql init script skips versions that have 37 | their own /etc/init.d/postgresql-x.y init script, mostly for compatibility 38 | with legacy packages before the advent of the postgresql-common framework. 39 | The RPM packages provide /etc/init.d/postgresql-x.y scripts, which are 40 | ignored by /etc/init.d/postgresql. The postgresql-x.y scripts will not do 41 | anything as long as the user does not use them to create clusters in 42 | /var/lib/pgsql. (In which case they continue to work as if postgresql-common 43 | was not present.) 44 | 45 | * Debian's pre/postinst/rm maintainer scripts are not used. Mostly this means 46 | there is no automatic integration of tsearch with system-provided 47 | dictionaries. 48 | 49 | The postgresql-common testsuite is supported if perl-Test-Simple and 50 | perl-Time-HiRes are installed. 51 | 52 | -- Christoph Berg Thu, 26 Jun 2014 16:59:47 +0200 53 | -------------------------------------------------------------------------------- /rpm/init-functions-compat: -------------------------------------------------------------------------------- 1 | # Functions missing in older /lib/lsb/init-functions scripts 2 | 3 | function_exists () { 4 | type $1 >/dev/null 2>&1 5 | } 6 | 7 | function_exists log_daemon_msg || log_daemon_msg () { echo -n "$1:${2:+ $2}"; } 8 | function_exists log_progress_msg || log_progress_msg () { echo -n " $1"; } 9 | function_exists log_end_msg || log_end_msg () { if [ $1 -eq 0 ]; then echo "."; else echo "failed!"; fi; } 10 | # this one exists, but we provide it anyway so we don't need to depend on redhat-lsb-core: 11 | function_exists log_warning_msg || log_warning_msg () { echo "$1"; } 12 | function_exists log_failure_msg || log_failure_msg () { echo "$1"; } 13 | -------------------------------------------------------------------------------- /server/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only used when compiling Debian packages of the 2 | PostgreSQL database server. They are not required at run time. 3 | -------------------------------------------------------------------------------- /server/catversion: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Extract server catalog and control file version numbers. 4 | # This information is stored in the packages and used at install time to 5 | # determine if an in-major-version pg_upgradecluster is required. 6 | 7 | set -eu 8 | 9 | CATVERSION=$(awk '/^#define CATALOG_VERSION_NO/ { print $3 }' src/include/catalog/catversion.h) 10 | CONTROLVERSION=$(awk '/^#define PG_CONTROL_VERSION/ { print $3 }' src/include/catalog/pg_control.h) 11 | 12 | case $CONTROLVERSION in 13 | # control file versions used in PG 9.6 .. 15 14 | # don't append to catversion to avoid spurious warnings for users of existing packages 15 | 960|1002|1100|1201|1300) echo "$CATVERSION" ;; 16 | *) echo "$CATVERSION-$CONTROLVERSION" ;; 17 | esac 18 | -------------------------------------------------------------------------------- /server/pg_config.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Perl reimplementation of PostgreSQL's pg_config binary. 4 | # We provide this as /usr/bin/pg_config to support cross-compilation using 5 | # libpq-dev. Also, this makes the two installed pg_config copies not conflict 6 | # via their debugging symbols. 7 | # 8 | # This code is released under the terms of the PostgreSQL License. 9 | # Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group 10 | # Author: Christoph Berg 11 | 12 | use strict; 13 | use warnings; 14 | 15 | # no arguments, print all items 16 | if (@ARGV == 0) { 17 | while () { 18 | last if /^$/; # begin of help section 19 | print; 20 | } 21 | exit 0; 22 | } 23 | 24 | # --help or -? 25 | if (grep {$_ =~ /^(--help|-\?)$/} @ARGV) { 26 | while () { 27 | last if /^$/; # begin of help section 28 | } 29 | print; # include empty line in output 30 | while () { 31 | next if /^Report bugs/; # Skip bug address in the perl version 32 | print; 33 | } 34 | exit 0; 35 | } 36 | 37 | # specific value(s) requested 38 | my %options; 39 | my $help; 40 | while () { 41 | last if /^$/; # begin of help section 42 | /^(\S+) = (.*)/ or die "malformatted data item"; 43 | $options{'--' . lc $1} = $2; 44 | } 45 | 46 | foreach my $arg (@ARGV) { 47 | unless ($options{$arg}) { 48 | print "pg_config: invalid argument: $arg\n"; 49 | print "Try \"pg_config --help\" for more information.\n"; 50 | exit 1; 51 | } 52 | print "$options{$arg}\n"; 53 | } 54 | 55 | exit 0; 56 | 57 | # The DATA section consists of the `pg_config` output (one KEY = value item per 58 | # line), and the `pg_config --help` text. The first --help line is empty, which 59 | # we use to detect the beginning of the help section. 60 | 61 | __DATA__ 62 | INCLUDEDIR = /usr/include/postgresql 63 | 64 | pg_config provides information about the installed version of PostgreSQL. 65 | 66 | Usage: 67 | pg_config [OPTION]... 68 | 69 | Options: 70 | --includedir show location of C header files of the client 71 | interfaces 72 | -?, --help show this help, then exit 73 | 74 | With no arguments, all known items are shown. 75 | 76 | Report bugs to . 77 | -------------------------------------------------------------------------------- /server/test-with-jit.conf: -------------------------------------------------------------------------------- 1 | # config used by pg_regress --temp-config 2 | 3 | fsync = off 4 | 5 | # force JITing of all queries in tests 6 | jit = on 7 | jit_above_cost = 0 8 | jit_optimize_above_cost = 1000 9 | -------------------------------------------------------------------------------- /systemd/README.systemd: -------------------------------------------------------------------------------- 1 | systemd unit files for PostgreSQL on Debian/Ubuntu 2 | -------------------------------------------------- 3 | 4 | Each cluster is run as a separate service, called postgresql@version-cluster. 5 | pg_ctlcluster is invoked with --skip-systemctl-redirect. Logging still goes to 6 | /var/log/postgresql. 7 | 8 | There is a parent service called postgresql.service, that starts/stops/restarts/ 9 | reloads all individual services that are configured as "auto" in 10 | /etc/postgresql/*/*/start.conf. 11 | 12 | The link between start.conf and postgresql.service is established by 13 | postgresql-generator, which creates symlinks in 14 | /run/systemd/generator/postgresql.service.wants/. 15 | 16 | Backup 17 | ------ 18 | 19 | Two backup mechanisms are being offered as systemd services: basebackups 20 | capable of point in time recovery (PITR, the preferred method), and SQL-level 21 | dumps. 22 | 23 | pg_basebackup@version-cluster.service 24 | pg_basebackup@version-cluster.timer 25 | 26 | Weekly basebackup in /var/backups/postgresql/version/cluster. 27 | By default, 3 copies are being kept. 28 | 29 | To enable, run 30 | systemctl enable --now pg_basebackup@version-cluster.timer 31 | systemctl start pg_basebackup@version-cluster.service 32 | 33 | pg_receivewal@version-cluster.service 34 | 35 | WAL archival to be used with pg_basebackup@.service for PITR. 36 | 37 | To enable, run 38 | systemctl enable --now pg_basebackup@version-cluster.timer pg_receivewal@version-cluster.service 39 | systemctl start pg_basebackup@version-cluster.service 40 | 41 | pg_dump@version-cluster.service 42 | pg_dump@version-cluster.timer 43 | 44 | Weekly SQL dump in /var/backups/postgresql/version/cluster. 45 | By default, 3 copies are being kept. 46 | 47 | To enable, run 48 | systemctl enable --now pg_dump@version-cluster.timer 49 | systemctl start pg_dump@version-cluster.service 50 | 51 | The mechanisms provided are meant to be used with low to medium size databases. 52 | For larger databases, or databases with high write volume, we advise to use a 53 | full-size backup solution such as pgbackrest or barman. 54 | 55 | -- Christoph Berg Mon, 08 Mar 2021 13:45:26 +0100 56 | -------------------------------------------------------------------------------- /systemd/system-generators/postgresql-generator: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This systemd generator creates dependency symlinks that make all PostgreSQL 4 | # clusters with "auto" in their start.conf file be started/stopped/reloaded 5 | # when postgresql.service is started/stopped/reloaded. 6 | 7 | set -eu 8 | 9 | gendir="$1" 10 | wantdir="$1/postgresql.service.wants" 11 | bindir="/usr/lib/postgresql/" 12 | #redhat# bindir="/usr/pgsql-" 13 | pgservice="/lib/systemd/system/postgresql@.service" 14 | 15 | mkdir -p "$wantdir" 16 | 17 | for conf in /etc/postgresql/*/*/postgresql.conf; do 18 | # abort loop if glob was not expanded (but accept dead symlinks) 19 | if ! test -e "$conf" && ! test -L "$conf"; then continue; fi 20 | 21 | dir="${conf%/*}" 22 | 23 | # evaluate start.conf 24 | if [ -e "$dir/start.conf" ]; then 25 | start=$(sed 's/#.*$//; /^[[:space:]]*$/d; s/^\s*//; s/\s*$//' "$dir/start.conf") 26 | else 27 | start=auto 28 | fi 29 | [ "$start" = "auto" ] || continue 30 | 31 | verdir="${dir%/*}" 32 | version="${verdir##*/}" 33 | test -x "$bindir$version/bin/postgres" || continue # package got removed 34 | cluster="${dir##*/}" 35 | ln -s "$pgservice" "$wantdir/postgresql@$version-$cluster.service" 36 | done 37 | 38 | exit 0 39 | -------------------------------------------------------------------------------- /systemd/system/pg_basebackup@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Basebackup of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | Wants=postgresql@%i.service 5 | After=postgresql@%i.service 6 | RequiresMountsFor=/var/backups/postgresql 7 | 8 | [Service] 9 | Type=oneshot 10 | User=postgres 11 | Environment="KEEP=3" 12 | ExecStartPre=+/usr/bin/pg_backupcluster %i createdirectory 13 | ExecStart=/usr/bin/pg_backupcluster %i basebackup 14 | ExecStart=/usr/bin/pg_backupcluster %i expirebasebackups $KEEP 15 | -------------------------------------------------------------------------------- /systemd/system/pg_basebackup@.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Weekly Basebackup of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | 5 | [Timer] 6 | OnCalendar=weekly 7 | RandomizedDelaySec=1h 8 | FixedRandomDelay=true 9 | 10 | [Install] 11 | # when enabled, start along with postgresql@%i 12 | WantedBy=postgresql@%i.service 13 | -------------------------------------------------------------------------------- /systemd/system/pg_compresswal@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Compress WAL of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | RequiresMountsFor=/var/backups/postgresql 5 | 6 | [Service] 7 | Type=oneshot 8 | User=postgres 9 | ExecStart=/usr/bin/pg_backupcluster %i compresswal 10 | -------------------------------------------------------------------------------- /systemd/system/pg_compresswal@.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Daily Compress WAL of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | 5 | [Timer] 6 | OnCalendar=daily 7 | RandomizedDelaySec=1h 8 | FixedRandomDelay=true 9 | 10 | [Install] 11 | # when enabled, start along with pg_receivewal@%i 12 | WantedBy=pg_receivewal@%i.service 13 | -------------------------------------------------------------------------------- /systemd/system/pg_dump@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Dump of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | Wants=postgresql@%i.service 5 | After=postgresql@%i.service 6 | RequiresMountsFor=/var/backups/postgresql 7 | 8 | [Service] 9 | Type=oneshot 10 | User=postgres 11 | Environment="KEEP=3" 12 | ExecStartPre=+/usr/bin/pg_backupcluster %i createdirectory 13 | ExecStart=/usr/bin/pg_backupcluster %i dump 14 | ExecStart=/usr/bin/pg_backupcluster %i expiredumps $KEEP 15 | -------------------------------------------------------------------------------- /systemd/system/pg_dump@.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Weekly Dump of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | 5 | [Timer] 6 | OnCalendar=weekly 7 | RandomizedDelaySec=1h 8 | FixedRandomDelay=true 9 | 10 | [Install] 11 | # when enabled, start along with postgresql@%i 12 | WantedBy=postgresql@%i.service 13 | -------------------------------------------------------------------------------- /systemd/system/pg_receivewal@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=WAL archival of PostgreSQL Cluster %i 3 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 4 | Wants=postgresql@%i.service 5 | After=postgresql@%i.service 6 | RequiresMountsFor=/var/backups/postgresql 7 | 8 | [Service] 9 | Type=simple 10 | User=postgres 11 | ExecStartPre=+/usr/bin/pg_backupcluster %i createdirectory 12 | ExecStart=/usr/bin/pg_backupcluster %i receivewal 13 | Restart=on-failure 14 | RestartSec=1min 15 | # pg_receivewal only flushes compressed output on SIGINT 16 | # (https://www.postgresql.org/message-id/flat/Yvo/5No5S0c4EFMj%40msg.df7cb.de) 17 | KillSignal=SIGINT 18 | 19 | [Install] 20 | # when enabled, start along with postgresql@%i 21 | WantedBy=postgresql@%i.service 22 | -------------------------------------------------------------------------------- /systemd/system/postgresql.service: -------------------------------------------------------------------------------- 1 | # postgresql.service is the meta unit for managing all PostgreSQL clusters on 2 | # the system at once. Conceptually, this unit is more like a systemd target, 3 | # but we are using a service since targets cannot be reloaded. 4 | # 5 | # The unit actually managing PostgreSQL clusters is postgresql@.service, 6 | # instantiated as postgresql@15-main.service for individual clusters. 7 | 8 | [Unit] 9 | Description=PostgreSQL RDBMS 10 | 11 | [Service] 12 | Type=oneshot 13 | ExecStart=/bin/true 14 | ExecReload=/bin/true 15 | RemainAfterExit=on 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /systemd/system/postgresql@.service: -------------------------------------------------------------------------------- 1 | # systemd service template for PostgreSQL clusters. The actual instances will 2 | # be called "postgresql@version-cluster", e.g. "postgresql@9.3-main". The 3 | # variable %i expands to "version-cluster", %I expands to "version/cluster". 4 | # (%I breaks for cluster names containing dashes.) 5 | 6 | [Unit] 7 | Description=PostgreSQL Cluster %i 8 | AssertPathExists=/etc/postgresql/%I/postgresql.conf 9 | RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/%I 10 | PartOf=postgresql.service 11 | ReloadPropagatedFrom=postgresql.service 12 | Before=postgresql.service 13 | # stop server before networking goes down on shutdown 14 | After=network.target 15 | 16 | [Service] 17 | Type=forking 18 | # -: ignore startup failure (recovery might take arbitrarily long) 19 | # the actual pg_ctl timeout is configured in pg_ctl.conf 20 | ExecStart=-/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i start 21 | # 0 is the same as infinity, but "infinity" needs systemd 229 22 | TimeoutStartSec=0 23 | ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast %i stop 24 | TimeoutStopSec=1h 25 | ExecReload=/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i reload 26 | PIDFile=/run/postgresql/%i.pid 27 | SyslogIdentifier=postgresql@%i 28 | # prevent OOM killer from choosing the postmaster (individual backends will 29 | # reset the score to 0) 30 | OOMScoreAdjust=-900 31 | # restarting automatically will prevent "pg_ctlcluster ... stop" from working, 32 | # so we disable it here. Also, the postmaster will restart by itself on most 33 | # problems anyway, so it is questionable if one wants to enable external 34 | # automatic restarts. 35 | #Restart=on-failure 36 | # (This should make pg_ctlcluster stop work, but doesn't:) 37 | #RestartPreventExitStatus=SIGINT SIGTERM 38 | 39 | [Install] 40 | WantedBy=multi-user.target 41 | -------------------------------------------------------------------------------- /t/001_packages.t: -------------------------------------------------------------------------------- 1 | # Check that the necessary packages are installed 2 | 3 | use warnings; 4 | use strict; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | use POSIX qw/setlocale LC_ALL LC_MESSAGES/; 9 | 10 | use Test::More tests => $PgCommon::rpm ? (3 + 9*@MAJORS) : (15 + 7*@MAJORS); 11 | 12 | ok (-f "/etc/os-release", "/etc/os-release exists"); 13 | my ($os, $osversion) = os_release(); 14 | ok (defined $os, "OS is $os"); 15 | ok (defined $osversion, "OS version is $osversion"); 16 | 17 | note "PostgreSQL versions installed: @MAJORS\n"; 18 | my $f = $ENV{'PG_FLAVOR'} // ''; 19 | 20 | if ($PgCommon::rpm) { 21 | foreach my $v (@MAJORS) { 22 | my $vv = $v; 23 | $vv =~ s/\.//; 24 | 25 | ok ((rpm_installed "postgresql$vv$f"), "postgresql$vv$f installed"); 26 | ok ((rpm_installed "postgresql$vv$f-libs"), "postgresql$vv$f-libs installed"); 27 | ok ((rpm_installed "postgresql$vv$f-server"), "postgresql$vv$f-server installed"); 28 | ok ((rpm_installed "postgresql$vv$f-contrib"), "postgresql$vv$f-contrib installed"); 29 | ok ((rpm_installed "postgresql$vv$f-plperl"), "postgresql$vv$f-plperl installed"); 30 | SKIP: { 31 | skip "No python2 support", 1 unless ($v <= 12); 32 | ok ((rpm_installed "postgresql$vv$f-plpython"), "postgresql$vv$f-plpython installed"); 33 | } 34 | ok ((rpm_installed "postgresql$vv$f-plpython3"), "postgresql$vv$f-plpython3 installed"); 35 | ok ((rpm_installed "postgresql$vv$f-pltcl"), "postgresql$vv$f-pltcl installed"); 36 | ok ((rpm_installed "postgresql$vv$f-devel"), "postgresql$vv$f-devel installed"); 37 | } 38 | exit; 39 | } 40 | 41 | my $docpkgs = 0; 42 | foreach my $v (@MAJORS) { 43 | ok ((deb_installed "postgresql-$v$f"), "postgresql-$v$f installed"); 44 | SKIP: { 45 | skip "No python2 support", 1 unless ($v <= 11 and $PgCommon::have_python2); 46 | ok ((deb_installed "postgresql-plpython-$v$f"), "postgresql-plpython-$v$f installed"); 47 | } 48 | SKIP: { 49 | skip "no Python 3 package for version $v", 1 if ($v < '9.1'); 50 | my $pyver = `python3 --version 2>/dev/null`; 51 | chomp $pyver; 52 | skip "$pyver is too new for PL/Python3 on $v", 1 if ($v < 10 and $pyver and $pyver =~ /3\.1[2-9]/); # distutils removed in Python 3.12 53 | ok ((deb_installed "postgresql-plpython3-$v$f"), "postgresql-plpython3-$v$f installed"); 54 | } 55 | ok ((deb_installed "postgresql-plperl-$v$f"), "postgresql-plperl-$v$f installed"); 56 | ok ((deb_installed "postgresql-pltcl-$v$f"), "postgresql-pltcl-$v$f installed"); 57 | ok ((deb_installed "postgresql-server-dev-$v$f"), "postgresql-server-dev-$v$f installed"); 58 | SKIP: { 59 | skip "No postgresql-contrib-$v$f package for version $v", 1 if ($v >= 10); 60 | ok ((deb_installed "postgresql-contrib-$v$f"), "postgresql-contrib-$v$f installed"); 61 | } 62 | my $docpkg = "postgresql-doc-$v$f"; 63 | if (deb_installed $docpkg) { 64 | note "$docpkg installed"; 65 | $docpkgs++; 66 | } 67 | } 68 | ok $docpkgs, "At least one doc package installed"; 69 | 70 | ok ((deb_installed 'libecpg-dev'), 'libecpg-dev installed'); 71 | ok ((deb_installed 'procps'), 'procps installed'); 72 | ok ((deb_installed 'netcat-openbsd'), 'netcat-openbsd installed'); 73 | 74 | ok ((deb_installed 'hunspell-en-us'), 'hunspell-en-us installed'); 75 | 76 | # check installed locales to fail tests early if they are missing 77 | ok ((setlocale(LC_MESSAGES, '') =~ /utf8|UTF-8/), 'system has a default UTF-8 locale'); 78 | ok (setlocale (LC_ALL, "ru_RU"), 'locale ru_RU exists'); 79 | ok (setlocale (LC_ALL, "ru_RU.UTF-8"), 'locale ru_RU.UTF-8 exists'); 80 | 81 | my $key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'; 82 | my $pem_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'; 83 | ok ((getgrnam('ssl-cert'))[3] =~ /postgres/, 84 | 'user postgres in the UNIX group ssl-cert'); 85 | ok (-e $key_file, "$key_file exists"); 86 | is (exec_as ('postgres', "cat $key_file > /dev/null"), 0, "$key_file is readable for postgres"); 87 | ok (-e $pem_file, "$pem_file exists"); 88 | 89 | # vim: filetype=perl 90 | -------------------------------------------------------------------------------- /t/002_existing_clusters.t: -------------------------------------------------------------------------------- 1 | # Check that no clusters and postgres processes are present for this test. 2 | 3 | use strict; 4 | use Test::More tests => 8; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | 9 | check_clean; 10 | 11 | # vim: filetype=perl 12 | -------------------------------------------------------------------------------- /t/003_alternatives.t: -------------------------------------------------------------------------------- 1 | # Check that alternatives symlinks point to the correct locations 2 | 3 | use warnings; 4 | use strict; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | 9 | use Test::More tests => $PgCommon::rpm ? 1 : 9; 10 | 11 | if ($PgCommon::rpm) { 12 | ok "No alternatives test on RedHat"; 13 | exit; 14 | } 15 | 16 | # server/client link group 17 | my $newest_version = $ALL_MAJORS[-1]; 18 | note "Newest PG version installed is $newest_version"; 19 | program_ok 0, 'update-alternatives --list psql.1.gz', 0, 'psql.1.gz link group'; 20 | program_ok 0, 'update-alternatives --list postmaster.1.gz', 2, 'postmaster.1.gz link group does not exist'; # removed in pg-common 248 21 | for my $name (qw(psql pg_dump postgres pg_ctl)) { 22 | is readlink "/etc/alternatives/$name.1.gz", "/usr/share/postgresql/$newest_version/man/man1/$name.1.gz", "$name.1.gz alternative"; 23 | } 24 | 25 | # doc link group 26 | my $newest_doc_version = `dpkg -l 'postgresql-doc-[1-9]*' | sed -ne 's/^ii postgresql-doc-\\([0-9.]*\\).*/\\1/p' | sort -g | tail -n 1`; 27 | note "Newest PG doc version installed is $newest_doc_version"; 28 | SKIP: { 29 | skip "No SPI_connect.3.gz link group on 8.x", 3 if ($newest_doc_version < 9.0); 30 | chomp $newest_doc_version; 31 | program_ok 0, 'update-alternatives --list SPI_connect.3.gz', 0, 'SPI_connect.3.gz link group'; 32 | for my $name (qw(SPI_connect SPI_exec)) { 33 | is readlink "/etc/alternatives/$name.3.gz", "/usr/share/postgresql/$newest_doc_version/man/man3/$name.3.gz", "$name.3.gz alternative"; 34 | } 35 | } 36 | 37 | # vim: filetype=perl 38 | -------------------------------------------------------------------------------- /t/006_next_free_port.t: -------------------------------------------------------------------------------- 1 | # Check PgCommon's next_free_port() 2 | 3 | use strict; 4 | 5 | use lib '.'; 6 | use PgCommon; 7 | 8 | use lib 't'; 9 | use TestLib; 10 | 11 | use Test::More tests => 5; 12 | 13 | # test next_free_port(). We are intentionally using nc as an external tool, 14 | # using perl would replicate what next_free_port is doing, and that would 15 | # be a pointless test. 16 | use IPC::Open2; 17 | use Time::HiRes qw(usleep); 18 | my @pids; 19 | # no ports open 20 | is (next_free_port, 5432, 'next_free_port is 5432'); 21 | 22 | # open a localhost ipv4 socket 23 | push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -l 127.0.0.1 5432)); 24 | usleep 2*$delay; 25 | is (next_free_port, 5433, 'next_free_port detects localhost ipv4 socket'); 26 | # open a wildcard ipv4 socket 27 | push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -4 -l 5433)); 28 | usleep 2*$delay; 29 | is (next_free_port, 5434, 'next_free_port detects wildcard ipv4 socket'); 30 | 31 | SKIP: { 32 | $^V =~ /^v(\d+\.\d+)/; # parse perl version 33 | skip "perl <= 5.10 does not have proper IPv6 support", 2 if ($1 <= 5.10); 34 | skip "skipping IPv6 tests", 2 if ($ENV{SKIP_IPV6}); 35 | 36 | # open a localhost ipv6 socket 37 | push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -l ::1 5434)); 38 | usleep 2*$delay; 39 | is (next_free_port, 5435, 'next_free_port detects localhost ipv6 socket'); 40 | # open a wildcard ipv6 socket 41 | push @pids, open2(\*CHLD_OUT, \*CHLD_IN, qw(nc -6 -l 5435)); 42 | usleep 2*$delay; 43 | is (next_free_port, 5436, 'next_free_port detects wildcard ipv6 socket'); 44 | } 45 | 46 | # clean up 47 | kill 15, @pids; 48 | 49 | # vim: filetype=perl 50 | -------------------------------------------------------------------------------- /t/007_pg_conftool.t: -------------------------------------------------------------------------------- 1 | # Test pg_conftool 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More tests => 41; 7 | use File::Temp qw/tempdir/; 8 | use lib '.'; 9 | use PgCommon; 10 | use lib 't'; 11 | use TestLib; 12 | 13 | my $tdir = tempdir (CLEANUP => 1); 14 | $ENV{'PG_CLUSTER_CONF_ROOT'} = $tdir; 15 | 16 | open F, "> $tdir/different.conf"; 17 | print F "a = '5'\n"; 18 | print F "#b = '6'\n"; 19 | close F; 20 | 21 | note 'test without cluster'; 22 | is_program_out 0, "pg_conftool show all", 1, "Error: No default cluster found\n"; 23 | is_program_out 0, "pg_conftool foo.conf show all", 1, "Error: No default cluster found\n"; 24 | is_program_out 0, "pg_conftool $tdir/different.conf show all", 0, "a = 5\n"; 25 | is_program_out 0, "pg_conftool 9.7 main show all", 1, "Error: Cluster 9.7 main does not exist\n"; 26 | 27 | my $version = $MAJORS[-1]; 28 | die "Tests past this point need PostgreSQL installed" unless ($version); 29 | mkdir "$tdir/$version"; 30 | mkdir "$tdir/$version/main"; 31 | 32 | open F, "> $tdir/$version/main/postgresql.conf"; 33 | print F "a = '1'\n"; 34 | print F "#b = '2'\n"; 35 | close F; 36 | 37 | open F, "> $tdir/$version/main/other.conf"; 38 | print F "a = '3'\n"; 39 | print F "#b = '4'\n"; 40 | close F; 41 | 42 | sub pgconf { 43 | undef $/; 44 | open F, "$tdir/$version/main/postgresql.conf"; 45 | my $f = ; 46 | close F; 47 | return $f; 48 | } 49 | 50 | sub differentconf { 51 | undef $/; 52 | open F, "$tdir/different.conf"; 53 | my $f = ; 54 | close F; 55 | return $f; 56 | } 57 | 58 | note 'test show'; 59 | is_program_out 0, "pg_conftool show all", 0, "a = 1\n"; 60 | is_program_out 0, "pg_conftool other.conf show all", 0, "a = 3\n"; 61 | is_program_out 0, "pg_conftool $tdir/different.conf show all", 0, "a = 5\n"; 62 | is_program_out 0, "pg_conftool $version main show all", 0, "a = 1\n"; 63 | is_program_out 0, "pg_conftool $version main other.conf show all", 0, "a = 3\n"; 64 | is_program_out 0, "pg_conftool show a", 0, "a = 1\n"; 65 | is_program_out 0, "pg_conftool -s show a", 0, "1\n"; 66 | 67 | note 'test set'; 68 | is_program_out 0, "pg_conftool set c 7", 0, ""; 69 | undef $/; # slurp mode 70 | is pgconf, "a = '1'\n#b = '2'\nc = 7\n", "file contains new setting"; 71 | is_program_out 0, "pg_conftool set a 8", 0, ""; 72 | is pgconf, "a = 8\n#b = '2'\nc = 7\n", "file contains updated setting"; 73 | is_program_out 0, "pg_conftool $tdir/different.conf set a 9", 0, ""; 74 | is differentconf, "a = 9\n#b = '6'\n", "file with path contains updated setting"; 75 | 76 | note 'test remove'; 77 | is_program_out 0, "pg_conftool remove a", 0, ""; 78 | is pgconf, "#a = 8\n#b = '2'\nc = 7\n", "setting removed from file"; 79 | is_program_out 0, "pg_conftool $tdir/different.conf remove a", 0, ""; 80 | is differentconf, "#a = 9\n#b = '6'\n", "setting removed from file with path"; 81 | 82 | note 'test edit'; 83 | $ENV{EDITOR} = 'cat'; 84 | is_program_out 0, "pg_conftool edit", 0, "#a = 8\n#b = '2'\nc = 7\n"; 85 | is_program_out 0, "pg_conftool $tdir/different.conf edit", 0, "#a = 9\n#b = '6'\n"; 86 | -------------------------------------------------------------------------------- /t/010_defaultport_cluster.t: -------------------------------------------------------------------------------- 1 | # We try to call psql with --version and then on localhost. Since there are no 2 | # clusters, we expect an error message that the connection to port 5432 is 3 | # refused. This checks that pg_wrapper correctly picks the default port and 4 | # uses the highest available version. 5 | 6 | use strict; 7 | use Test::More tests => 14; 8 | 9 | use lib 't'; 10 | use TestLib; 11 | 12 | like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $ALL_MAJORS[-1]/, 13 | 'pg_wrapper selects highest available version number'; 14 | 15 | like_program_out 0, 'env LC_MESSAGES=C psql -h 127.0.0.1 -l', 2, qr/could not connect|connection to server .* failed/, 16 | 'connecting to localhost fails with no clusters'; 17 | 18 | # We check if PGCLUSTER, --cluster, and native psql options are evaluated with 19 | # correct priority. (This is related to the checks in t/090_multicluster.t, but 20 | # easier to do here because no clusters are running.) 21 | 22 | like_program_out 0, "env LC_MESSAGES=C PGCLUSTER=$MAJORS[-1]/127.0.0.2:5431 psql -l", 23 | 2, qr/(could not connect|connection to server).*127.0.0.2.* port 5431/s, 'pg_wrapper uses host and port from PGCLUSTER'; 24 | like_program_out 0, "env LC_MESSAGES=C PGCLUSTER=$MAJORS[-1]/127.0.0.2:5431 psql --cluster $MAJORS[-1]/127.0.0.3:5430 -l", 25 | 2, qr/(could not connect|connection to server).*127.0.0.3.* port 5430/s, 'pg_wrapper uses --cluster from the command line'; 26 | like_program_out 0, "env LC_MESSAGES=C PGCLUSTER=$MAJORS[-1]/127.0.0.2:5431 psql -h 127.0.0.3 -l", 27 | 2, qr/(could not connect|connection to server).*127.0.0.3.* port 5432/s, 'pg_wrapper ignores PGCLUSTER with -h on the command line'; 28 | like_program_out 0, "env LC_MESSAGES=C PGCLUSTER=$MAJORS[-1]/127.0.0.2:5431 psql --host 127.0.0.3 -l", 29 | 2, qr/(could not connect|connection to server).*127.0.0.3.* port 5432/s, 'pg_wrapper ignores PGCLUSTER with --host on the command line'; 30 | like_program_out 0, "env LC_MESSAGES=C PGCLUSTER=$MAJORS[-1]/127.0.0.2:5431 PGHOST=127.0.0.3 psql -l", 31 | 2, qr/(could not connect|connection to server).*127.0.0.3.* port 5432/s, 'pg_wrapper ignores PGCLUSTER if PGHOST is set'; 32 | 33 | # vim: filetype=perl 34 | -------------------------------------------------------------------------------- /t/021_pg_renamecluster.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | 3 | use lib 't'; 4 | use TestLib; 5 | use PgCommon; 6 | 7 | use Test::More tests => 20; 8 | 9 | my $v = $MAJORS[-1]; 10 | 11 | # create cluster 12 | ok ((system "pg_createcluster $v main --start >/dev/null") == 0, 13 | "pg_createcluster $v main"); 14 | 15 | # test pg_renamecluster with a running cluster 16 | program_ok (0, "pg_renamecluster $v main donau"); 17 | is_program_out 'postgres', 'psql -tAc "show data_directory"', 0, 18 | "/var/lib/postgresql/$v/donau\n", 'cluster is running and data_directory was moved'; 19 | is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'hba_file'), 20 | "/etc/postgresql/$v/donau/pg_hba.conf", 'pg_hba.conf location updated'); 21 | is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'ident_file'), 22 | "/etc/postgresql/$v/donau/pg_ident.conf", 'pg_ident.conf location updated'); 23 | is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'external_pid_file'), 24 | "/var/run/postgresql/$v-donau.pid", 'external_pid_file location updated'); 25 | ok (-f "/var/run/postgresql/$v-donau.pid", 'external_pid_file exists'); 26 | SKIP: { 27 | skip "no stats_temp_directory in $v", 2 if ($v < 8.4 or $v >= 15); 28 | is ((PgCommon::get_conf_value $v, 'donau', 'postgresql.conf', 'stats_temp_directory'), 29 | "/var/run/postgresql/$v-donau.pg_stat_tmp", 'stats_temp_directory location updated'); 30 | ok (-d "/var/run/postgresql/$v-donau.pg_stat_tmp", 'stats_temp_directory exists'); 31 | } 32 | SKIP: { 33 | skip "cluster name not supported in $v", 1 if ($v < 9.5); 34 | is (PgCommon::get_conf_value ($v, 'donau', 'postgresql.conf', 'cluster_name'), "$v/donau", "cluster_name is updated"); 35 | } 36 | 37 | # stop server, clean up, check for leftovers 38 | ok ((system "pg_dropcluster $v donau --stop") == 0, 39 | 'pg_dropcluster removes cluster'); 40 | 41 | check_clean; 42 | 43 | # vim: filetype=perl 44 | -------------------------------------------------------------------------------- /t/022_recovery.t: -------------------------------------------------------------------------------- 1 | # We create a cluster, stop it ungracefully, and check if recovery works. 2 | 3 | use strict; 4 | 5 | use POSIX qw/dup2/; 6 | use Time::HiRes qw/usleep/; 7 | 8 | use lib 't'; 9 | use TestLib; 10 | use PgCommon; 11 | 12 | use Test::More tests => 17 * @MAJORS; 13 | 14 | sub check_major { 15 | my $v = $_[0]; 16 | note "Running tests for $v"; 17 | 18 | # create cluster 19 | program_ok (0, "pg_createcluster $v main --start >/dev/null"); 20 | 21 | # try an immediate shutdown and restart 22 | program_ok (0, "pg_ctlcluster $v main stop -m i"); 23 | program_ok (0, "pg_ctlcluster $v main start"); 24 | my $c = 0; # fallback for when pg_isready is missing (PG < 9.3) 25 | while (system ("pg_isready -q 2>&1") >> 8 == 1 and $c++ < 15) { 26 | sleep(1); 27 | } 28 | program_ok ('postgres', "psql -c ''"); 29 | 30 | # try again with an write-protected file 31 | program_ok (0, "pg_ctlcluster $v main stop -m i"); 32 | open F, ">/var/lib/postgresql/$v/main/foo"; 33 | print F "moo\n"; 34 | close F; 35 | ok ((chmod 0444, "/var/lib/postgresql/$v/main/foo"), 36 | "create write-protected file in data directory"); 37 | program_ok (0, "pg_ctlcluster $v main start"); 38 | $c = 0; 39 | while (system ("pg_isready -q 2>&1") >> 8 == 1 and $c++ < 15) { 40 | sleep(1); 41 | } 42 | program_ok ('postgres', "psql -c ''"); 43 | 44 | program_ok (0, "pg_dropcluster $v main --stop", 0, 45 | 'pg_dropcluster removes cluster'); 46 | 47 | check_clean; 48 | } 49 | 50 | foreach (@MAJORS) { 51 | check_major $_; 52 | } 53 | 54 | # vim: filetype=perl 55 | -------------------------------------------------------------------------------- /t/025_logging.t: -------------------------------------------------------------------------------- 1 | # Test various logging-related things 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Time::HiRes qw/usleep/; 9 | 10 | use Test::More tests => 55 * @MAJORS; 11 | 12 | my $syslog_works = 0; 13 | 14 | sub check_logging ($$) 15 | { 16 | my ($text, $msg) = @_; 17 | my $ls = `pg_lsclusters -h`; 18 | $ls =~ s/\s+/ /g; 19 | $ls =~ s/\s*$//; 20 | like $ls, $text, $msg; 21 | } 22 | 23 | sub check_major { 24 | my $v = $_[0]; 25 | note "Running tests for $v"; 26 | my $pgdata = "/var/lib/postgresql/$v/main"; 27 | 28 | # create cluster 29 | ok ((system "pg_createcluster $v main --start >/dev/null") == 0, 30 | "pg_createcluster $v main"); 31 | 32 | # default log setup 33 | my $default_log = "/var/log/postgresql/postgresql-$v-main.log"; 34 | check_logging qr($v main 5432 online postgres $pgdata $default_log), "pg_lscluster reports logfile $default_log"; 35 | like_program_out 'postgres', "psql -qc \"'foobar_${v}_$$'\"", 1, qr/syntax error.*foobar_${v}_$$/, 'log an error'; 36 | usleep $delay; 37 | like_program_out 'postgres', "grep --binary-files=text foobar_${v}_$$ $default_log", 0, qr/syntax error.*foobar_${v}_$$/, 'error appears in logfile'; 38 | 39 | # syslog 40 | is_program_out 0, "pg_conftool $v main set log_destination syslog", 0, "", "set log_destination syslog"; 41 | is_program_out 0, "pg_ctlcluster $v main reload", 0, "", "$v main reload"; 42 | is_program_out 'postgres', "psql -Atc \"show log_destination\"", 0, "syslog\n", 'log_destination is syslog'; 43 | check_logging qr($v main 5432 online postgres $pgdata syslog), "pg_lscluster reports syslog"; 44 | SKIP: { 45 | skip "/var/log/syslog not available", 2 unless ($syslog_works); 46 | usleep $delay; 47 | 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'; 48 | } 49 | 50 | # turn logging_collector on, csvlog 51 | my $pg_log = $v >= 10 ? 'log' : 'pg_log'; # log directory in PGDATA changed in PG 10 52 | SKIP: { 53 | skip "No logging collector in 8.2", 30 if ($v <= 8.2); 54 | is_program_out 0, "pg_conftool $v main set logging_collector on", 0, "", "set logging_collector on"; 55 | is_program_out 0, "pg_conftool $v main set log_destination csvlog", 0, "", "set log_destination csvlog"; 56 | is_program_out 0, "pg_ctlcluster $v main restart", 0, "", "$v main restart"; 57 | is_program_out 'postgres', "psql -Atc \"show logging_collector\"", 0, "on\n", 'logging_collector is on'; 58 | is_program_out 'postgres', "psql -Atc \"show log_destination\"", 0, "csvlog\n", 'log_destination is csvlog'; 59 | check_logging qr($v main 5432 online postgres $pgdata $pg_log/.*\.csv), "pg_lscluster reports csvlog"; 60 | like_program_out 'postgres', "psql -qc \"'barbaz_${v}_$$'\"", 1, qr/syntax error.*barbaz_${v}_$$/, 'log an error'; 61 | usleep $delay; 62 | 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"; 63 | 64 | # stderr,syslog,csvlog 65 | is_program_out 0, "pg_conftool $v main set log_destination stderr,syslog,csvlog", 0, "", "set log_destination stderr,syslog,csvlog"; 66 | is_program_out 0, "pg_ctlcluster $v main reload", 0, "", "$v main reload"; 67 | is_program_out 'postgres', "psql -Atc \"show log_destination\"", 0, "stderr,syslog,csvlog\n", 'log_destination is stderr,syslog,csvlog'; 68 | check_logging qr($v main 5432 online postgres $pgdata $pg_log/.*\.log,syslog,$pg_log/.*\.csv), "pg_lscluster reports stderr,syslog,csvlog"; 69 | like_program_out 'postgres', "psql -qc \"'moo_${v}_$$'\"", 1, qr/syntax error.*moo_${v}_$$/, 'log an error'; 70 | usleep $delay; 71 | 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"; 72 | SKIP: { 73 | skip "/var/log/syslog not available", 2 unless ($syslog_works); 74 | usleep $delay; 75 | like_program_out 0, "grep --binary-files=text 'postgres.*moo_${v}_$$' /var/log/syslog", 0, qr/moo_${v}_$$/, 'error appears in /var/log/syslog'; 76 | } 77 | 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"; 78 | } 79 | 80 | # stop server, clean up, check for leftovers 81 | is_program_out 0, "pg_dropcluster $v main --stop", 0, "", 'pg_dropcluster removes cluster'; 82 | 83 | check_clean; 84 | } 85 | 86 | system "logger -t '$0' 'test-logging-$$'"; 87 | usleep $delay; 88 | if (system ("grep --binary-files=text -q 'test-logging-$$' /var/log/syslog 2> /dev/null") == 0) { 89 | note 'Logging to /var/log/syslog works'; 90 | $syslog_works = 1; 91 | } else { 92 | note 'Logging to /var/log/syslog does not work, skipping some syslog tests'; 93 | } 94 | 95 | foreach (@MAJORS) { 96 | check_major $_; 97 | } 98 | 99 | # vim: filetype=perl 100 | -------------------------------------------------------------------------------- /t/027_jit.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | 3 | use lib 't'; 4 | use TestLib; 5 | 6 | use Test::More; 7 | 8 | my $arch = `dpkg --print-architecture`; 9 | chomp $arch; 10 | if (grep { $_ eq $arch} qw(alpha hppa hurd-i386 ia64 kfreebsd-amd64 kfreebsd-i386 loong64 m68k powerpc riscv64 sh4 sparc64 x32)) { 11 | ok 1, "No JIT tests on $arch"; 12 | done_testing(); 13 | exit; 14 | } 15 | 16 | foreach my $v (@MAJORS) { 17 | if ($v < 11) { 18 | ok 1, "No JIT support on $v"; 19 | next; 20 | } 21 | note "$v"; 22 | 23 | program_ok 'root', "pg_createcluster $v main --start", 0; 24 | 25 | my $jit_default = $v == '11' ? 'off' : 'on'; 26 | like_program_out 'postgres', "psql -Xatc 'show jit'", 0, qr/$jit_default/, "JIT is $jit_default by default"; 27 | program_ok 'root', "pg_conftool $v main set jit on", 0, "Turn on JIT on PG11" if ($v == 11); 28 | program_ok 'root', "pg_ctlcluster $v main reload", 0 if ($v == 11); 29 | 30 | unlike_program_out 'postgres', "psql -c 'explain (analyze) select count(*) from pg_class'", 0, qr/JIT/, 31 | "No JIT on cheap query"; 32 | program_ok 'root', "pg_conftool $v main set seq_page_cost 100000", 0; 33 | program_ok 'root', "pg_conftool $v main set random_page_cost 100000", 0; 34 | program_ok 'root', "pg_ctlcluster $v main reload", 0; 35 | like_program_out 'postgres', "psql -c 'explain (analyze) select count(*) from pg_class'", 0, qr/Timing: Generation .* ms/, 36 | "Expensive query is JITed"; 37 | 38 | program_ok 'root', "pg_dropcluster --stop $v main", 0; 39 | check_clean; 40 | } 41 | 42 | done_testing(); 43 | 44 | # vim: filetype=perl 45 | -------------------------------------------------------------------------------- /t/031_errors_disk_full.t: -------------------------------------------------------------------------------- 1 | # Check for proper ENOSPC handling 2 | 3 | use strict; 4 | 5 | require File::Temp; 6 | 7 | use lib 't'; 8 | use TestLib; 9 | use Test::More tests => $ENV{NO_TMPFS} ? 1 : 22; 10 | 11 | # skip tests if NO_TMPFS is set 12 | if ($ENV{NO_TMPFS}) { 13 | pass 'Skipping disk full tests, NO_TMPFS is set'; 14 | exit; 15 | } 16 | 17 | # we are using unshare here, won't work with systemd 18 | $ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1; 19 | 20 | my $outref; 21 | 22 | # 23 | note 'check that a failed pg_createcluster leaves no cruft behind: try creating a cluster on a 10 MB tmpfs'; 24 | my $cmd = <&1 26 | set -e 27 | mount --make-rprivate / 2> /dev/null || : 28 | mkdir -p /var/lib/postgresql 29 | trap "umount /var/lib/postgresql" 0 HUP INT QUIT ILL ABRT PIPE TERM 30 | mount -t tmpfs -o size=10000000 none /var/lib/postgresql 31 | # this is supposed to fail 32 | LC_MESSAGES=C pg_createcluster $MAJORS[-1] test && exit 1 || true 33 | echo -n "ls>" 34 | # should not output anything 35 | ls /etc/postgresql 36 | ls /var/lib/postgresql 37 | echo " /dev/null || : 55 | export LC_MESSAGES=C 56 | dirs="/etc/postgresql /var/lib/postgresql /var/log/postgresql" 57 | mkdir -p \$dirs 58 | trap "umount \$dirs" 0 HUP INT QUIT ILL ABRT PIPE TERM 59 | mount -t tmpfs -o size=1000000 none /etc/postgresql 60 | # an empty cluster needs 69MB on ppc64el, round up to 90 61 | mount -t tmpfs -o size=90000000 none /var/lib/postgresql 62 | mount -t tmpfs -o size=1000000 none /var/log/postgresql 63 | pg_createcluster $MAJORS[-1] test 64 | 65 | # fill up /var/lib/postgresql 66 | ! cat < /dev/zero > /var/lib/postgresql/cruft 2>/dev/null 67 | echo '-- full lib --' 68 | ! pg_ctlcluster $MAJORS[-1] test start 69 | echo '-- end full lib --' 70 | echo '-- full lib log --' 71 | cat /var/log/postgresql/postgresql-$MAJORS[-1]-test.log 72 | echo '-- end full lib log --' 73 | rm /var/lib/postgresql/cruft 74 | pg_dropcluster $MAJORS[-1] test --stop 75 | EOF 76 | 77 | $result = exec_as 'root', "echo '$cmd' | unshare -m sh", $outref; 78 | is $result, 0, 'script failed'; 79 | like $$outref, qr/^-- full lib --.*No space left on device.*^-- end full lib --/ims, 80 | 'pg_ctlcluster prints error message'; 81 | like $$outref, qr/^-- full lib log --.*No space left on device.*^-- end full lib log --/ims, 82 | 'log file has error message'; 83 | 84 | check_clean; 85 | 86 | # vim: filetype=perl 87 | -------------------------------------------------------------------------------- /t/032_ssl_key_permissions.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use lib 't'; 5 | use TestLib; 6 | use PgCommon; 7 | use Test::More tests => $PgCommon::rpm ? 1 : 3 + 19 * @MAJORS; 8 | 9 | if ($PgCommon::rpm) { pass 'No ssl key checks on RedHat'; exit; } 10 | 11 | my ($pg_uid, $pg_gid) = (getpwnam 'postgres')[2,3]; 12 | my $ssl_cert_gid = (getgrnam 'ssl-cert')[2]; # reset permissions 13 | die "Could not determine ssl-cert gid" unless ($ssl_cert_gid); 14 | 15 | my $snakekey = '/etc/ssl/private/ssl-cert-snakeoil.key'; 16 | is ((stat $snakekey)[4], 0, "$snakekey is owned by root"); 17 | is ((stat $snakekey)[5], $ssl_cert_gid, "$snakekey group is ssl-cert"); 18 | is ((stat $snakekey)[2], 0100640, "$snakekey mode is 0640"); 19 | 20 | foreach my $version (@MAJORS) { 21 | my $pkgversion = `dpkg-query -f '\${Version}' -W postgresql-$version`; 22 | note "$version ($pkgversion)"; 23 | if ($version <= 9.1) { 24 | pass "no SSL support on $version" foreach (1..19); 25 | next; 26 | } 27 | SKIP: { 28 | skip "No SSL key check on <= 9.0", 19 if ($version <= 9.0); 29 | program_ok (0, "pg_createcluster $version main"); 30 | 31 | my $nobody_uid = (getpwnam 'nobody')[2]; 32 | chown $nobody_uid, 0, $snakekey; 33 | like_program_out 'postgres', "pg_ctlcluster $version main start", 1, 34 | qr/private key file.*must be owned by the database user or root/s, 35 | 'ssl key owned by nobody refused'; 36 | 37 | SKIP: { 38 | skip "SSL key group check skipped on Debian oldstable packages", 4 if ($version <= 9.4 and $pkgversion !~ /pgdg/); 39 | chown 0, 0, $snakekey; 40 | chmod 0644, $snakekey; 41 | like_program_out 'postgres', "pg_ctlcluster $version main start", 1, 42 | qr/private key file.*has group or world access/, 43 | 'ssl key with permissions root:root 0644 refused'; 44 | 45 | chown $pg_uid, $pg_gid, $snakekey; 46 | chmod 0640, $snakekey; 47 | like_program_out 'postgres', "pg_ctlcluster $version main start", 1, 48 | qr/private key file.*has group or world access/, 49 | 'ssl key with permissions postgres:postgres 0640 refused'; 50 | } 51 | 52 | chown 0, $ssl_cert_gid, $snakekey; 53 | 54 | program_ok (0, "pg_dropcluster $version main --stop"); 55 | is ((stat $snakekey)[4], 0, "$snakekey is owned by root"); 56 | is ((stat $snakekey)[5], $ssl_cert_gid, "$snakekey group is ssl-cert"); 57 | is ((stat $snakekey)[2], 0100640, "$snakekey mode is 0640"); 58 | check_clean; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /t/041_upgrade_custompaths.t: -------------------------------------------------------------------------------- 1 | # Test cluster upgrade with a custom data directory and custom log file. 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More tests => (@MAJORS == 1) ? 1 : 28; 9 | 10 | if (@MAJORS == 1) { 11 | pass 'only one major version installed, skipping upgrade tests'; 12 | exit 0; 13 | } 14 | 15 | ok ((system "pg_createcluster --start --datadir /tmp/postgresql-test -l /tmp/postgresql-test.log $MAJORS[0] upgr >/dev/null") == 0); 16 | 17 | # Upgrade to latest version 18 | my $outref; 19 | is ((exec_as 0, "pg_upgradecluster -v $MAJORS[-1] $MAJORS[0] upgr", $outref, 0), 0, 'pg_upgradecluster succeeds'); 20 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 21 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 22 | 23 | # Check clusters 24 | like_program_out 'nobody', 'pg_lsclusters -h', 0, 25 | 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'; 26 | 27 | # clean away new cluster and restart the old one 28 | is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster'); 29 | is_program_out 0, "pg_ctlcluster $MAJORS[0] upgr start", 0, '', 'Restarting old cluster'; 30 | is_program_out 'nobody', 'pg_lsclusters -h', 0, 31 | "$MAJORS[0] upgr 5433 online postgres /tmp/postgresql-test /tmp/postgresql-test.log 32 | ", 'pg_lsclusters output'; 33 | 34 | # Do another upgrade with using a custom defined data directory (and in passing, test --keep-port) 35 | my $outref; 36 | is ((exec_as 0, "pg_upgradecluster --keep-port -v $MAJORS[-1] $MAJORS[0] upgr /tmp/psql-common-testsuite", $outref, 0), 0, 'pg_upgradecluster succeeds'); 37 | unlike $$outref, qr/^pg_restore: /m, 'no pg_restore error messages during upgrade'; 38 | unlike $$outref, qr/^[A-Z]+: /m, 'no server error messages during upgrade'; 39 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 40 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 41 | 42 | like_program_out 'nobody', 'pg_lsclusters -h', 0, 43 | qr"$MAJORS[0] +upgr 5433 down postgres /tmp/postgresql-test +/tmp/postgresql-test.log\n$MAJORS[-1] +upgr 5432 online postgres /tmp/psql-common-testsuite +/var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log", 'pg_lsclusters output'; 44 | 45 | # stop servers, clean up 46 | is ((system "pg_dropcluster $MAJORS[0] upgr"), 0, 'Dropping original cluster'); 47 | is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster'); 48 | 49 | check_clean; 50 | 51 | # vim: filetype=perl 52 | -------------------------------------------------------------------------------- /t/042_upgrade_rename.t: -------------------------------------------------------------------------------- 1 | # Test in-version upgrading (usually used after catalog version bumps) 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | 9 | use Test::More tests => 15 * @MAJORS; 10 | 11 | foreach my $v (@MAJORS) { 12 | SKIP: { 13 | skip "pg_upgrade not supported on $v", 15 if ($v < 9.2); 14 | note "PostgreSQL $v"; 15 | 16 | program_ok 0, "pg_createcluster $v main --start", 0; 17 | program_ok 0, "pg_upgradecluster -m upgrade --old-bindir=$PgCommon::binroot$v/bin -v $v --rename upgr $v main", 0; 18 | like_program_out 0, "pg_lsclusters -h", 0, qr/$v main 5433 down.*\n$v upgr 5432 online/; 19 | 20 | program_ok 0, "pg_dropcluster $v main --stop", 0; 21 | program_ok 0, "pg_dropcluster $v upgr --stop", 0; 22 | is ((system "rm -rf /var/log/postgresql/pg_upgradecluster-$v-$v-upgr.*"), 0, 'Cleaning pg_upgrade log files'); 23 | check_clean; 24 | } 25 | } 26 | 27 | # vim: filetype=perl 28 | -------------------------------------------------------------------------------- /t/043_upgrade_ssl_cert.t: -------------------------------------------------------------------------------- 1 | # Test cluster upgrade with a custom ssl certificate 2 | 3 | use strict; 4 | use File::Temp qw/tempdir/; 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More tests => (@MAJORS == 1 or $PgCommon::rpm) ? 1 : 22; 9 | 10 | if (@MAJORS == 1) { 11 | pass 'only one major version installed, skipping upgrade tests'; 12 | exit 0; 13 | } 14 | if ($PgCommon::rpm) { 15 | pass 'SSL certificates not handled on RedHat'; 16 | exit 0; 17 | } 18 | 19 | 20 | ok ((system "pg_createcluster $MAJORS[0] upgr >/dev/null") == 0); 21 | 22 | my $tdir = tempdir (CLEANUP => 1); 23 | my ($p_uid, $p_gid) = (getpwnam 'postgres')[2,3]; 24 | chown $p_uid, $p_gid, $tdir; 25 | 26 | my $tempcrt = "$tdir/ssl-cert-snakeoil.pem"; 27 | my $oldcrt = "/var/lib/postgresql/$MAJORS[0]/upgr/server.crt"; 28 | my $newcrt = "/var/lib/postgresql/$MAJORS[-1]/upgr/server.crt"; 29 | 30 | # First upgrade 31 | note "upgrade test: server.crt is a symlink"; 32 | (system "cp -p /etc/ssl/certs/ssl-cert-snakeoil.pem $tempcrt") == 0 or die "cp: $!"; 33 | unlink $oldcrt; # remove file installed by pg_createcluster 34 | symlink $tempcrt, $oldcrt or die "symlink: $!"; 35 | 36 | # Upgrade to latest version 37 | my $outref; 38 | is ((exec_as 0, "pg_upgradecluster --start -v $MAJORS[-1] $MAJORS[0] upgr", $outref, 0), 0, 'pg_upgradecluster succeeds'); 39 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 40 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 41 | 42 | if ($MAJORS[-1] >= 9.2) { 43 | is ((-e $newcrt), undef, "new data directory does not contain server.crt"); 44 | is ((PgCommon::get_conf_value $MAJORS[-1], 'upgr', 'postgresql.conf', 'ssl_cert_file'), 45 | $tempcrt, "symlink server.crt target is put into ssl_cert_file"); 46 | } else { 47 | is ((-l $newcrt), 1, "new data directory contains server.crt"); 48 | is ((readlink $newcrt), $tempcrt, "symlink server.crt points to correct location"); 49 | } 50 | 51 | # Clean away new cluster 52 | is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster'); 53 | unlink $oldcrt or die "unlink: $!"; 54 | 55 | # Second upgrade 56 | note "upgrade test: server.crt is a plain file"; 57 | (system "cp -p $tempcrt $oldcrt") == 0 or die "cp: $!"; 58 | 59 | # Upgrade to latest version 60 | my $outref; 61 | is ((exec_as 0, "pg_upgradecluster --start -v $MAJORS[-1] $MAJORS[0] upgr", $outref, 0), 0, 'pg_upgradecluster succeeds'); 62 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 63 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 64 | 65 | is ((-f $newcrt), 1, "new data directory contains server.crt file"); 66 | if ($MAJORS[-1] >= 9.2) { 67 | is ((PgCommon::get_conf_value $MAJORS[-1], 'upgr', 'postgresql.conf', 'ssl_cert_file'), 68 | $newcrt, "server.crt is put into ssl_cert_file"); 69 | } else { 70 | pass "..."; 71 | } 72 | 73 | # Stop servers, clean up 74 | is ((system "pg_dropcluster $MAJORS[0] upgr"), 0, 'Dropping original cluster'); 75 | is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster'); 76 | 77 | check_clean; 78 | 79 | # vim: filetype=perl 80 | -------------------------------------------------------------------------------- /t/052_upgrade_encodings.t: -------------------------------------------------------------------------------- 1 | # Test default and explicit encoding on upgrades 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More tests => (@MAJORS == 1) ? 1 : 46; 9 | 10 | if (@MAJORS == 1) { 11 | pass 'only one major version installed, skipping upgrade tests'; 12 | exit 0; 13 | } 14 | 15 | my $outref; 16 | my $oldv = $MAJORS[0]; 17 | my $newv = $MAJORS[-1]; 18 | 19 | is ((exec_as 0, "pg_createcluster --start --locale=ru_RU $oldv main", $outref), 0, 20 | "creating ru_RU $oldv cluster"); 21 | 22 | is ((exec_as 'postgres', 'psql -c "create database latintest" template1', $outref), 0, 23 | "creating latintest DB with LATIN encoding"); 24 | if ($oldv <= '8.3') { 25 | is ((exec_as 'postgres', 'psql -c "create database asctest encoding = \'SQL_ASCII\'" template1', $outref), 0, 26 | "creating asctest DB with ASCII encoding"); 27 | } else { 28 | is ((exec_as 'postgres', 'psql -c "create database asctest template = template0 lc_collate = \'C\' lc_ctype = \'C\' encoding = \'SQL_ASCII\'" template1', $outref), 0, 29 | "creating asctest DB with C locale"); 30 | } 31 | if ($oldv >= 15) { 32 | program_ok 'postgres', 'psql -c "create database icutest template template0 locale_provider icu icu_locale de"', 0, "creating database with ICU locale"; 33 | } else { 34 | program_ok 'postgres', 'psql -c "create database icutest"', 0, "creating placeholder icutest database"; 35 | } 36 | 37 | is ((exec_as 'postgres', "printf 'A\\324B' | psql -c \"create table t(x varchar); copy t from stdin\" latintest", $outref), 38 | 0, 'write LATIN database content to latintest'); 39 | is ((exec_as 'postgres', "printf 'A\\324B' | psql -c \"create table t(x varchar); copy t from stdin\" asctest", $outref), 40 | 0, 'write LATIN database content to asctest'); 41 | 42 | is_program_out 'postgres', "echo \"select * from t\" | psql -Atq latintest", 43 | 0, "A\324B\n", 'old latintest DB has correctly encoded string'; 44 | is_program_out 'postgres', "echo \"select * from t\" | psql -Atq asctest", 45 | 0, "A\324B\n", 'old asctest DB has correctly encoded string'; 46 | 47 | is ((exec_as 'postgres', 'psql -Atl', $outref), 0, 'psql -Atl on old cluster'); 48 | ok ((index $$outref, 'latintest|postgres|ISO_8859_5') >= 0, 'latintest is LATIN encoded'); 49 | ok ((index $$outref, 'asctest|postgres|SQL_ASCII') >= 0, 'asctest is ASCII encoded'); 50 | if ($oldv >= 15) { 51 | like $$outref, qr/icutest\|postgres\|ISO_8859_5\|icu\|ru_RU\|ru_RU\|de/, 'icutest has proper icu locale'; 52 | } else { 53 | like $$outref, qr/icutest\|postgres\|ISO_8859_5/, 'icutest is LATIN encoded'; 54 | } 55 | ok ((index $$outref, 'template1|postgres|ISO_8859_5') >= 0, 'template1 is LATIN encoded'); 56 | 57 | # upgrade without specifying locales, should be kept 58 | like_program_out 0, "pg_upgradecluster -v $newv $oldv main", 0, qr/^Success. Please check/m; 59 | 60 | is ((exec_as 'postgres', "psql --cluster $newv/main -Atl", $outref), 0, 'psql -Atl on upgraded cluster'); 61 | ok ((index $$outref, 'latintest|postgres|ISO_8859_5') >= 0, 'latintest is LATIN encoded'); 62 | ok ((index $$outref, 'asctest|postgres|SQL_ASCII') >= 0, 'asctest is ASCII encoded'); 63 | if ($oldv >= 15) { 64 | like $$outref, qr/icutest\|postgres\|ISO_8859_5\|icu\|ru_RU\|ru_RU\|de/, 'icutest has proper icu locale'; 65 | } else { 66 | like $$outref, qr/icutest\|postgres\|ISO_8859_5/, 'icutest is LATIN encoded'; 67 | } 68 | ok ((index $$outref, 'template1|postgres|ISO_8859_5') >= 0, 'template1 is LATIN encoded'); 69 | is_program_out 'postgres', "echo \"select * from t\" | psql --cluster $newv/main -Atq latintest", 70 | 0, "A\324B\n", 'new latintest DB has correctly encoded string'; 71 | 72 | is ((system "pg_dropcluster --stop $newv main"), 0, 'dropping upgraded cluster'); 73 | is ((system "pg_ctlcluster $oldv main start"), 0, 'restarting old cluster'); 74 | 75 | # upgrade with explicitly specifying other locale 76 | like_program_out 0, "pg_upgradecluster --locale ru_RU.UTF-8 -v $newv $oldv main", 0, qr/^Success. Please check/m; 77 | 78 | is ((exec_as 'postgres', "psql --cluster $newv/main -Atl", $outref), 0, 'psql -Atl on upgraded cluster'); 79 | if ($newv >= 11) { 80 | ok ((index $$outref, 'latintest|postgres|ISO_8859_5') >= 0, 'latintest is still LATIN encoded'); 81 | } else { 82 | like $$outref, qr/latintest\|postgres\|(UTF8|UNICODE)/, 'latintest is now UTF8 encoded'; 83 | } 84 | ok ((index $$outref, 'asctest|postgres|SQL_ASCII') >= 0, 'asctest is ASCII encoded'); 85 | like $$outref, qr/template1\|postgres\|(UTF8|UNICODE)/, 'template1 is UTF8 encoded'; 86 | is_program_out 'postgres', "echo \"select * from t\" | psql --cluster $newv/main -Atq latintest", 87 | 0, ($newv >= 11 ? "A\324B\n": "AдB\n"), 'new latintest DB has correctly encoded string'; 88 | # ASCII databases don't do automatic encoding conversion, so this remains LATIN 89 | is_program_out 'postgres', "echo \"select * from t\" | psql --cluster $newv/main -Atq asctest", 90 | 0, "A\324B\n", 'new asctest DB has correctly encoded string'; 91 | 92 | is ((system "pg_dropcluster --stop $newv main"), 0, 'dropping upgraded cluster'); 93 | 94 | is ((system "pg_dropcluster $oldv main"), 0, 'dropping old cluster'); 95 | 96 | check_clean; 97 | 98 | # vim: filetype=perl 99 | -------------------------------------------------------------------------------- /t/060_obsolete_confparams.t: -------------------------------------------------------------------------------- 1 | # Test upgrading from the oldest version to all majors with all possible 2 | # configuration parameters set. This checks that they are correctly 3 | # transitioned. 4 | 5 | use strict; 6 | 7 | use lib 't'; 8 | use TestLib; 9 | 10 | use Test::More; 11 | 12 | if (@MAJORS == 1) { 13 | pass 'only one major version installed, skipping upgrade tests'; 14 | done_testing(); 15 | exit 0; 16 | } 17 | 18 | $ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1; # FIXME: testsuite is hanging otherwise 19 | 20 | # Test one particular upgrade (old version, new version) 21 | sub do_upgrade { 22 | my $cur = $_[0]; 23 | my $new = $_[1]; 24 | note "Testing upgrade $cur -> $new"; 25 | 26 | # Upgrade cluster 27 | like_program_out 0, "env LC_MESSAGES=C pg_upgradecluster -v $new $cur main", 0, qr/^Success. Please check/m; 28 | like_program_out 'postgres', 'pg_lsclusters -h', 0, qr/$new.*online/, 29 | "New $new cluster is online"; 30 | } 31 | 32 | # create cluster for oldest version 33 | is_program_out 0, "pg_createcluster $MAJORS[0] main >/dev/null", 0, ""; 34 | 35 | # generate configuration file with all settings and start cluster 36 | is_program_out 0, "sed -i -e 's/^#\\([a-z]\\)/\\1/' /etc/postgresql/$MAJORS[0]/main/postgresql.conf", 37 | 0, "", "Enabling all settings in /etc/postgresql/$MAJORS[0]/main/postgresql.conf"; 38 | like PgCommon::get_conf_value($MAJORS[0], 'main', 'postgresql.conf', 'work_mem'), qr/MB/, "work_mem is set"; 39 | 40 | # tweak invalid settings 41 | PgCommon::set_conf_value $MAJORS[0], 'main', 'postgresql.conf', 'log_timezone', 'UTC'; 42 | PgCommon::set_conf_value $MAJORS[0], 'main', 'postgresql.conf', 'timezone', 'UTC'; 43 | PgCommon::disable_conf_value $MAJORS[0], 'main', 'postgresql.conf', 'include_dir', "Disable placeholder value"; 44 | PgCommon::disable_conf_value $MAJORS[0], 'main', 'postgresql.conf', 'include_if_exists', "Disable placeholder value"; 45 | PgCommon::disable_conf_value $MAJORS[0], 'main', 'postgresql.conf', 'include', "Disable placeholder value"; 46 | # older versions (<= 9.1 as of 2019-03) do not support ssl anymore 47 | my $postgres = PgCommon::get_program_path('postgres', $MAJORS[0]); 48 | my $ldd = `ldd $postgres 2>/dev/null`; 49 | if ($ldd and $ldd !~ /libssl/) { 50 | is_program_out 0, "sed -i -e 's/^ssl/#ssl/' /etc/postgresql/$MAJORS[0]/main/postgresql.conf", 51 | 0, "", "Disabling ssl settings on server that does not support SSL"; 52 | } 53 | 54 | # start server 55 | is_program_out 0, "pg_ctlcluster $MAJORS[0] main start", 0, ""; 56 | 57 | # Loop over all but the latest major version, testing N->N+1 upgrades 58 | for my $index (0 .. @MAJORS - 2) { 59 | do_upgrade $MAJORS[$index], $MAJORS[$index + 1] 60 | } 61 | # remove all clusters except for the first one 62 | for my $index (1 .. @MAJORS - 1) { 63 | is_program_out 0, "pg_dropcluster $MAJORS[$index] main --stop", 0, "", "Dropping $MAJORS[$index]/main"; 64 | } 65 | 66 | # now test a direct upgrade from oldest to newest, to also catch parameters 67 | # which changed several times, like syslog -> redirect_stderr -> 68 | # logging_collector 69 | if ($#MAJORS > 1) { 70 | is_program_out 0, "pg_ctlcluster $MAJORS[0] main start", 0, ""; 71 | do_upgrade $MAJORS[0], $MAJORS[-1]; 72 | is_program_out 0, "pg_dropcluster $MAJORS[-1] main --stop", 0, "", "Dropping $MAJORS[-1]/main"; 73 | } else { 74 | pass 'only two available versions, skipping tests...'; 75 | } 76 | 77 | # remove first cluster 78 | is_program_out 0, "pg_dropcluster $MAJORS[0] main --stop", 0, "", "Dropping $MAJORS[0]/main"; 79 | 80 | check_clean; 81 | done_testing(); 82 | 83 | # vim: filetype=perl 84 | -------------------------------------------------------------------------------- /t/070_non_postgres_clusters.t: -------------------------------------------------------------------------------- 1 | # Test successful operation of clusters which are not owned by 2 | # postgres. Only check the oldest and newest version. 3 | 4 | use strict; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | 9 | use Test::More tests => 40; 10 | 11 | $ENV{_SYSTEMCTL_SKIP_REDIRECT} = 1; # FIXME: testsuite is hanging otherwise 12 | 13 | my $owner = 'nobody'; 14 | my $v = $MAJORS[0]; 15 | 16 | # create cluster 17 | is ((system "pg_createcluster -u $owner $v main >/dev/null"), 0, 18 | "pg_createcluster $v main for owner $owner"); 19 | 20 | # check if start is refused when config and data owner do not match 21 | my $pgconf = "/etc/postgresql/$v/main/postgresql.conf"; 22 | my ($origuid, $origgid) = (stat $pgconf)[4,5]; 23 | chown 1, 1, $pgconf; 24 | like_program_out 0, "pg_ctlcluster $v main start", 1, qr/do not match/, "start refused when config and data owners mismatch"; 25 | chown $origuid, $origgid, $pgconf; 26 | is ((system "pg_ctlcluster $v main start"), 0, "pg_ctlcluster succeeds with owner $owner"); 27 | 28 | # Check cluster 29 | like_program_out $owner, 'pg_lsclusters -h', 0, 30 | qr/^$v\s+main\s+5432\s+online\s+$owner/, 31 | 'pg_lsclusters shows running cluster'; 32 | 33 | like ((ps 'postgres'), qr/^$owner.*bin\/postgres .*\/var\/lib\/postgresql\/$v\/main/m, 34 | "postgres is running as user $owner"); 35 | 36 | is_program_out $owner, 'ls /tmp/.s.PGSQL.*', 0, "/tmp/.s.PGSQL.5432\n/tmp/.s.PGSQL.5432.lock\n", 'socket is in /tmp'; 37 | 38 | ok_dir '/var/run/postgresql', [], '/var/run/postgresql is empty'; 39 | 40 | # verify owner of configuration files 41 | my @st; 42 | my $confdir = "/etc/postgresql/$v/main"; 43 | my ($owneruid, $ownergid) = (getpwnam $owner)[2,3]; 44 | @st = stat $confdir; 45 | is $st[4], $owneruid, 'conf dir is owned by user'; 46 | is $st[5], $ownergid, 'conf dir is owned by user\'s primary group'; 47 | my ($ok_uid, $ok_gid) = (1, 1); 48 | opendir D, $confdir or die "opendir: $!"; 49 | for my $f (readdir D) { 50 | next if $f eq '.' or $f eq '..'; 51 | @st = stat "$confdir/$f" or die "stat: $!"; 52 | if ($st[4] != $owneruid) { 53 | note "$f is not owned by user"; 54 | $ok_uid = 0; 55 | } 56 | if ($st[5] != $ownergid) { 57 | note "$f is not owned by user's primary group"; 58 | $ok_gid = 0; 59 | } 60 | } 61 | closedir D; 62 | is $ok_uid, 1, "files are owned by user"; 63 | is $ok_gid, 1, "files are owned by user's primary group"; 64 | 65 | # verify log file properties 66 | @st = stat "/var/log/postgresql/postgresql-$v-main.log"; 67 | is $st[2], 0100640, 'log file has 0640 permissions'; 68 | is $st[4], $owneruid, 'log file is owned by user'; 69 | # the log file gid setting works on RedHat, but nobody has gid 99 there (and 70 | # there's not good alternative for testing) 71 | my $loggid = $PgCommon::rpm ? (getgrnam 'adm')[2] : $ownergid; 72 | is $st[5], $loggid, 'log file is owned by user\'s primary group'; 73 | 74 | if ($#MAJORS > 0) { 75 | my $newv = $MAJORS[-1]; 76 | 77 | my $outref; 78 | is ((exec_as 0, "(pg_upgradecluster -v $newv $v main | sed -e 's/^/STDOUT: /')", $outref, 0), 0, 79 | 'pg_upgradecluster succeeds'); 80 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 81 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 82 | my @err = grep (!/^STDOUT: /, split (/\n/, $$outref)); 83 | if (@err) { 84 | fail 'no error messages during upgrade'; 85 | print (join ("\n", @err)); 86 | } else { 87 | pass "no error messages during upgrade"; 88 | } 89 | 90 | # verify file permissions 91 | @st = stat "/etc/postgresql/$newv/main"; 92 | is $st[4], $owneruid, 'upgraded conf dir is owned by user'; 93 | is $st[5], $ownergid, 'upgraded conf dir is owned by user\'s primary group'; 94 | @st = stat "/etc/postgresql/$newv/main/postgresql.conf"; 95 | is $st[4], $owneruid, 'upgraded postgresql.conf dir is owned by user'; 96 | is $st[5], $ownergid, 'upgraded postgresql.conf dir is owned by user\'s primary group'; 97 | @st = stat "/var/log/postgresql/postgresql-$v-main.log"; 98 | is $st[4], $owneruid, 'upgraded log file is owned by user'; 99 | is $st[5], $loggid, 'upgraded log file is owned by user\'s primary group'; 100 | 101 | is ((system "pg_dropcluster $newv main --stop"), 0, 'pg_dropcluster'); 102 | } else { 103 | pass 'only one major version installed, skipping upgrade test'; 104 | for (my $i = 0; $i < 10; ++$i) { 105 | pass '...'; 106 | } 107 | } 108 | 109 | # Check proper cleanup 110 | is ((system "pg_dropcluster $v main --stop"), 0, 'pg_dropcluster'); 111 | is_program_out $owner, 'pg_lsclusters -h', 0, '', 'No clusters left'; 112 | is ((ps 'postgres'), '', "No postgres processes left"); 113 | 114 | check_clean; 115 | 116 | # vim: filetype=perl 117 | -------------------------------------------------------------------------------- /t/085_pg_ctl.conf.t: -------------------------------------------------------------------------------- 1 | # Check pg_ctl.conf handling. 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | 9 | use Test::More tests => $MAJORS[-1] >= '8.3' ? 33 : 1; 10 | 11 | # Do test with newest version 12 | my $v = $MAJORS[-1]; 13 | if ($v < '8.3') { 14 | pass 'Skipping core limit tests for versions < 8.3'; 15 | exit 0; 16 | } 17 | 18 | # enable core dumps 19 | # sudo and salsa-ci set the hard limit to 0 by default, undo that 20 | is_program_out 0, "prlimit --core=0:unlimited --pid=$$", 0, '', "set core file size to unlimited"; 21 | is_program_out 'postgres', "sh -c 'ulimit -Hc'", 0, "unlimited\n", "core file size is unlimited"; 22 | 23 | # create cluster 24 | is ((system "pg_createcluster $v main >/dev/null"), 0, "pg_createcluster $v main"); 25 | ok (-f "/etc/postgresql/$v/main/pg_ctl.conf", "/etc/postgresql/$v/main/pg_ctl.conf exists"); 26 | 27 | # Default behaviour, core size=0 28 | is_program_out 0, "pg_ctlcluster $v main start", 0, '', "starting cluster as root"; 29 | is_program_out 'postgres', "xargs -i awk '/core/ {print \$5}' /proc/{}/limits < /var/run/postgresql/$v-main.pid", 0, "0\n", "soft core size is 0"; 30 | my $hard_limit = `xargs -i awk '/core/ {print \$6}' /proc/{}/limits < /var/run/postgresql/$v-main.pid`; 31 | chomp $hard_limit; 32 | note "hard core file size limit of root-started postgres process is $hard_limit"; 33 | 34 | # -c in pg_ctl.conf, core size=unlimited 35 | ok (set_cluster_pg_ctl_conf($v, 'main', '-c'), "set pg_ctl default option to -c"); 36 | is_program_out 0, "pg_ctlcluster $v main restart", 0, '', "restarting cluster as root"; 37 | is_program_out 'postgres', "xargs -i awk '/core/ {print \$5}' /proc/{}/limits < /var/run/postgresql/$v-main.pid", 0, "$hard_limit\n", "soft core size is $hard_limit"; 38 | 39 | # Back to default behaviour, core size=0 40 | is_program_out 0, "pg_ctlcluster $v main stop", 0, '', "stopping cluster"; 41 | ok (set_cluster_pg_ctl_conf($v, 'main', ''), "restored pg_ctl default option"); 42 | 43 | # pg_ctl -c, core size=unlimited 44 | is_program_out 'postgres', "pg_ctlcluster $v main start -- -c", 0, '', "starting cluster with -c on the command line as postgres"; 45 | is_program_out 'postgres', "xargs -i awk '/core/ {print \$5}' /proc/{}/limits < /var/run/postgresql/$v-main.pid", 0, "unlimited\n", "soft core size is unlimited"; 46 | is_program_out 'postgres', "pg_ctlcluster $v main stop", 0, '', "stopping cluster"; 47 | 48 | is ((system "pg_dropcluster $v main --stop"), 0, 'dropping cluster'); 49 | check_clean; 50 | 51 | # vim: filetype=perl 52 | -------------------------------------------------------------------------------- /t/110_integrate_cluster.t: -------------------------------------------------------------------------------- 1 | # Check integration of an already existing cluster 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use File::Temp qw/tempdir/; 8 | use Time::HiRes qw(usleep); 9 | 10 | my $version = $MAJORS[-1]; 11 | 12 | use Test::More tests => 32; 13 | use PgCommon; 14 | 15 | delete $ENV{'LANG'}; 16 | delete $ENV{'LANGUAGE'}; 17 | $ENV{'LC_ALL'} = 'C'; 18 | 19 | my $wdir = tempdir (CLEANUP => 1); 20 | chmod 0755, $wdir or die "Could not chmod $wdir: $!"; 21 | 22 | # create clusters for different owners and check their integration 23 | for my $o ('postgres', 'nobody') { 24 | my $cdir = "$wdir/c"; 25 | mkdir $cdir; 26 | my $oid = getpwnam $o; 27 | chown $oid, 0, $cdir or die "Could not chown $cdir to $oid: $!"; 28 | like_program_out $o, "$PgCommon::binroot$version/bin/initdb $cdir/$o", 29 | 0, qr/Success/, "creating raw initdb cluster for user $o"; 30 | like_program_out 0, "pg_createcluster $version $o -d $cdir/$o", 0, 31 | qr/Configuring already existing cluster/i, "integrating $o cluster"; 32 | like_program_out 0, "pg_lsclusters", 0, 33 | qr/$version\s+$o\s+5432\s+down\s+$o\s/, 'correct pg_lsclusters output'; 34 | is_program_out $o, "pg_ctlcluster $version $o start", 0, '', "starting cluster $o"; 35 | like_program_out 0, "pg_lsclusters", 0, 36 | qr/$version\s+$o\s+5432\s+online\s+$o\s/, 'correct pg_lsclusters output'; 37 | is ((system "pg_dropcluster $version $o --stop"), 0, "dropping cluster $o"); 38 | ok_dir $cdir, [], 'No files in temporary cluster dir left behind'; 39 | rmdir $cdir; 40 | } 41 | 42 | check_clean; 43 | 44 | # vim: filetype=perl 45 | -------------------------------------------------------------------------------- /t/120_pg_upgradecluster_scripts.t: -------------------------------------------------------------------------------- 1 | # Check /etc/p-c/pg_upgradecluster.d/ scripts and proper handling of already 2 | # existing tables in the target cluster. 3 | 4 | use strict; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | use PgCommon; 9 | use Test::More tests => (@MAJORS == 1) ? 1 : 31; 10 | 11 | if (@MAJORS == 1) { 12 | pass 'only one major version installed, skipping upgrade tests'; 13 | exit 0; 14 | } 15 | 16 | 17 | # create old cluster 18 | is ((system "pg_createcluster $MAJORS[0] main --start >/dev/null"), 0, "pg_createcluster $MAJORS[0] main"); 19 | 20 | # add data table, auxtable with 'old...' values, and an unrelated auxtable in 21 | # another schema 22 | is_program_out 'postgres', 23 | 'psql template1 -qc "create table auxdata (x varchar(10)); insert into auxdata values (\'old1\'); insert into auxdata values (\'old2\')"', 24 | 0, '', 'adding auxdata to template1 and fill in some "old..." values'; 25 | is_program_out 'postgres', "createdb test", 0, ''; 26 | is_program_out 'postgres', 'psql test -qc "create table userdata(x int); insert into userdata values(42); insert into userdata values(256)"', 27 | 0, '', 'creating userdata table'; 28 | is_program_out 'postgres', 29 | 'psql test -qc "create schema s; create table s.auxdata (x varchar(10)); insert into s.auxdata values (\'schema1\')"', 30 | 0, '', 'adding schema s and s.auxdata to test and fill in some values'; 31 | 32 | if (not -d '/etc/postgresql-common/pg_upgradecluster.d') { 33 | mkdir '/etc/postgresql-common/pg_upgradecluster.d' or die "mkdir: $!"; 34 | } 35 | 36 | # move existing files away 37 | for my $f (glob("/etc/postgresql-common/pg_upgradecluster.d/*")) { 38 | next if ($f =~ /\.disabled$/); 39 | rename $f, "$f.disabled"; 40 | } 41 | 42 | # create test scripts 43 | chmod 0755, '/etc/postgresql-common/pg_upgradecluster.d' or die "chmod: $!"; 44 | open F, '>/etc/postgresql-common/pg_upgradecluster.d/auxdata' or die "open: $!"; 45 | print F < 48 | oldver=\$1 49 | cluster=\$2 50 | newver=\$3 51 | phase=\$4 52 | 53 | if [ \$phase = init ]; then 54 | createdb --cluster \$newver/\$cluster idb 55 | fi 56 | 57 | if [ \$phase = finish ]; then 58 | psql --cluster \$newver/\$cluster template1 </etc/postgresql-common/pg_upgradecluster.d/badscript' or die "open: $!"; 71 | print F < 22; 13 | use PgCommon; 14 | 15 | my $testuser = 'postgres'; 16 | 17 | # pg_createcluster and pg_ctlcluster 18 | is ((exec_as $testuser, "pg_createcluster $version main --start"), 0, 19 | "pg_createcluster succeeds as user $testuser with appropriate owner permissions"); 20 | 21 | like_program_out $testuser, 'pg_lsclusters -h', 0, qr/^$version\s+main.*online/m; 22 | like_program_out 'postgres', 'psql -Atl', 0, qr/template1.*UTF8/; 23 | 24 | # pg_dropcluster 25 | is ((exec_as $testuser, "pg_dropcluster $version main --stop"), 0, 26 | "pg_dropcluster succeeds as user $testuser with appropriate directory owner permissions"); 27 | 28 | # pg_upgradecluster 29 | SKIP: { 30 | skip 'Only one major version installed, skipping pg_upgradecluster tests', 8 if ($oldversion eq $version); 31 | 32 | is ((exec_as $testuser, "pg_createcluster $oldversion main --start"), 0, 33 | "pg_createcluster succeeds as user $testuser with appropriate group permissions"); 34 | my $outref; 35 | is ((exec_as $testuser, "pg_upgradecluster -v $version $oldversion main", $outref, 0), 0, 36 | "pg_upgradecluster succeeds as user $testuser"); 37 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 38 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 39 | 40 | like_program_out $testuser, 'pg_lsclusters -h', 0, 41 | qr/^$oldversion\s+main.*down.*\n^$version\s+main.*online/m; 42 | 43 | # clean up 44 | is ((exec_as $testuser, "pg_dropcluster $oldversion main"), 0); 45 | is ((exec_as $testuser, "pg_dropcluster $version main --stop"), 0); 46 | } 47 | 48 | check_clean; 49 | 50 | # vim: filetype=perl 51 | -------------------------------------------------------------------------------- /t/135_pg_virtualenv.t: -------------------------------------------------------------------------------- 1 | # check if pg_virtualenv runs ok, even under fakeroot 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | 9 | use Test::More tests => 12 * @MAJORS + 8; 10 | 11 | foreach my $v (@MAJORS) { 12 | my $args = 'sh -c \'echo "id|$(id -un)"; psql -AtXxc "SELECT current_user"\''; 13 | my $virtualenv = "pg_virtualenv -v $v $args"; 14 | 15 | $ENV{USER} = 'root'; 16 | like_program_out 'root', $virtualenv, 0, qr!id.root\ncurrent_user.postgres!, "running pg_virtualenv as root"; 17 | $ENV{USER} = 'postgres'; 18 | like_program_out 'postgres', $virtualenv, 0, qr!id.postgres\ncurrent_user.postgres!, "running pg_virtualenv as postgres"; 19 | $ENV{USER} = 'nobody'; 20 | like_program_out 'nobody', $virtualenv, 0, qr!id.nobody\ncurrent_user.nobody!, "running pg_virtualenv as nobody"; 21 | 22 | SKIP: { 23 | skip "/usr/bin/fakeroot not available", 6 unless (-x "/usr/bin/fakeroot"); # CentOS doesn't have fakeroot 24 | $ENV{USER} = 'root'; 25 | like_program_out 'root', "fakeroot $virtualenv", 0, qr!id.root\ncurrent_user.postgres!, "running fakeroot pg_virtualenv as root"; 26 | $ENV{USER} = 'postgres'; 27 | like_program_out 'postgres', "fakeroot $virtualenv", 0, qr!id.root\ncurrent_user.postgres!, "running fakeroot pg_virtualenv as postgres"; 28 | $ENV{USER} = 'nobody'; 29 | like_program_out 'nobody', "fakeroot $virtualenv", 0, qr!id.root\ncurrent_user.nobody!, "running fakeroot pg_virtualenv as nobody"; 30 | } 31 | } 32 | 33 | check_clean; 34 | 35 | # vim: filetype=perl 36 | -------------------------------------------------------------------------------- /t/140_pg_config.t: -------------------------------------------------------------------------------- 1 | # Check pg_config output 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More tests => 14 * @MAJORS + ($PgCommon::rpm ? 1 : 2) * 12; 9 | 10 | my $multiarch = ''; 11 | unless ($PgCommon::rpm) { 12 | $multiarch = `dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null`; 13 | chomp $multiarch; 14 | } 15 | note "Multiarch is " . ($multiarch ? 'enabled' : 'disabled'); 16 | 17 | my $version; 18 | foreach $version (@MAJORS) { 19 | note "checking version specific output for $version"; 20 | if ($version < '8.2') { 21 | pass "Skipping known-broken pg_config check for version $version"; 22 | for (my $i = 0; $i < 13; ++$i) { pass '...'; } 23 | next; 24 | } 25 | is_program_out 'postgres', "$PgCommon::binroot$version/bin/pg_config --pgxs", 0, 26 | "$PgCommon::binroot$version/lib/pgxs/src/makefiles/pgxs.mk\n"; 27 | my $libdir = "/usr/lib" . ($version >= 9.3 and $multiarch ? "/$multiarch" : "") . "\n"; 28 | $libdir = "$PgCommon::binroot$version/lib\n" if ($PgCommon::rpm); 29 | is_program_out 'postgres', "$PgCommon::binroot$version/bin/pg_config --libdir", 0, 30 | $libdir; 31 | is_program_out 'postgres', "$PgCommon::binroot$version/bin/pg_config --pkglibdir", 0, 32 | "$PgCommon::binroot$version/lib\n"; 33 | is_program_out 'postgres', "$PgCommon::binroot$version/bin/pg_config --bindir", 0, 34 | "$PgCommon::binroot$version/bin\n"; 35 | # mkdir should be in /bin on Debian. If /bin was linked to /usr/bin at build time, usrmerge was installed 36 | SKIP: { 37 | skip 'MKDIR_P not present before 9.0', 2 if ($version < 9.0); 38 | skip 'MKDIR_P not checked on RedHat', 2 if ($PgCommon::rpm); # varies across builds/versions 39 | is_program_out 'postgres', "grep ^MKDIR_P $PgCommon::binroot$version/lib/pgxs/src/Makefile.global", 0, 40 | "MKDIR_P = /bin/mkdir -p\n"; 41 | } 42 | SKIP: { 43 | skip 'build path not canonicalized on RedHat', 4 if ($PgCommon::rpm); 44 | my $pkgversion = `dpkg-query -f '\${Version}' -W postgresql-server-dev-$version`; 45 | # check that we correctly canonicalized the build paths 46 | SKIP: { 47 | skip 'abs_top_builddir introduced in 9.5', 2 if ($version < 9.5); 48 | skip 'abs_top_builddir not patched in Debian (old)stable', 2 if ($version < 10 and $pkgversion !~ /pgdg/); 49 | is_program_out 'postgres', "grep ^abs_top_builddir $PgCommon::binroot$version/lib/pgxs/src/Makefile.global", 0, 50 | "abs_top_builddir = /build/postgresql-$version$ENV{PG_FLAVOR}/build\n"; 51 | } 52 | SKIP: { 53 | skip 'abs_top_srcdir not patched before 9.3', 2 if ($version < 9.3); 54 | skip 'abs_top_srcdir not patched in Debian (old)stable', 2 if ($version < 10 and $pkgversion !~ /pgdg/); 55 | is_program_out 'postgres', "grep ^abs_top_srcdir $PgCommon::binroot$version/lib/pgxs/src/Makefile.global", 0, 56 | "abs_top_srcdir = /build/postgresql-$version$ENV{PG_FLAVOR}/build/..\n"; 57 | } 58 | } 59 | } 60 | 61 | my @pg_configs = $PgCommon::rpm ? qw(pg_config) : qw(pg_config pg_config.libpq-dev); 62 | for my $pg_config (@pg_configs) { 63 | if ($pg_config eq 'pg_config' or $PgCommon::rpm) { # pg_config should point at newest installed postgresql-server-dev-$version 64 | $version = $ALL_MAJORS[-1]; 65 | } else { # pg_config.libpq-dev should point at postgresql-server-dev-$(version of libpq-dev) 66 | my $libpqdev_version = `dpkg-query --showformat '\${Version}' --show libpq-dev`; 67 | $libpqdev_version =~ /^([89].\d|1.)/ or die "could not determine libpq-dev version"; 68 | $version = $1; 69 | } 70 | note "checking $pg_config output (should behave like version $version)"; 71 | 72 | SKIP: { 73 | my $pgc = "$PgCommon::binroot$version/bin/pg_config"; 74 | skip "$pgc not installed, can't check full $pg_config output", 2 unless (-x $pgc); 75 | my $full_output = `$pgc`; 76 | is_program_out 'postgres', "$pg_config", 0, $full_output; 77 | } 78 | like_program_out 'postgres', "$pg_config --help", 0, qr/--includedir-server/; 79 | is_program_out 'postgres', "$pg_config --pgxs", 0, 80 | "$PgCommon::binroot$version/lib/pgxs/src/makefiles/pgxs.mk\n"; 81 | my $libdir = "/usr/lib" . ($version >= 9.3 and $multiarch ? "/$multiarch" : "") . "\n"; 82 | $libdir = "$PgCommon::binroot$version/lib\n" if ($PgCommon::rpm); 83 | is_program_out 'postgres', "$pg_config --libdir", 0, 84 | $libdir; 85 | is_program_out 'postgres', "$pg_config --pkglibdir", 0, 86 | "$PgCommon::binroot$version/lib\n"; 87 | is_program_out 'postgres', "$pg_config --bindir", 0, 88 | "$PgCommon::binroot$version/bin\n"; 89 | } 90 | -------------------------------------------------------------------------------- /t/150_tsearch_stemming.t: -------------------------------------------------------------------------------- 1 | # Check tsearch, and stemming with dynamic creation of .affix/.dict files 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | 9 | my $version = $MAJORS[-1]; 10 | 11 | use Test::More tests => ($MAJORS[-1] < 8.3 or $PgCommon::rpm) ? 1 : 37; 12 | if ($version < 8.3) { 13 | pass 'tsearch dictionaries not tested before 8.3'; 14 | exit; 15 | } 16 | if ($PgCommon::rpm) { 17 | pass 'tsearch dictionaries not handled by postgresql-common on RedHat'; 18 | exit; 19 | } 20 | 21 | # test pg_updatedicts 22 | unlink '/var/cache/postgresql/dicts/en_us.affix'; 23 | unlink '/var/cache/postgresql/dicts/en_us.dict'; 24 | unlink "/usr/share/postgresql/$version/tsearch_data/en_us.affix"; 25 | unlink "/usr/share/postgresql/$version/tsearch_data/en_us.dict"; 26 | is ((exec_as 0, 'pg_updatedicts'), 0, 'pg_updatedicts succeeded'); 27 | ok -f '/var/cache/postgresql/dicts/en_us.affix', 28 | 'pg_updatedicts created en_us.affix'; 29 | ok -f '/var/cache/postgresql/dicts/en_us.dict', 30 | 'pg_updatedicts created en_us.dict'; 31 | ok -l "/usr/share/postgresql/$version/tsearch_data/en_us.affix", 32 | "pg_updatedicts created $version en_us.affix symlink"; 33 | ok -l "/usr/share/postgresql/$version/tsearch_data/en_us.dict", 34 | "pg_updatedicts created $version en_us.dict symlink"; 35 | 36 | # create cluster 37 | is ((system "pg_createcluster $version main --start >/dev/null"), 0, "pg_createcluster $version main"); 38 | 39 | # create DB with en_US text search configuration 40 | is_program_out 'postgres', 'createdb fts', 0, ''; 41 | 42 | my $outref; 43 | 44 | is ((exec_as 'postgres', 'psql -qd fts -c " 45 | CREATE TEXT SEARCH CONFIGURATION public.sc_english ( COPY = pg_catalog.english ); 46 | CREATE TEXT SEARCH DICTIONARY english_ispell (TEMPLATE = ispell, DictFile = en_US, 47 | AffFile = en_US, StopWords = english); 48 | SET default_text_search_config = \'public.sc_english\'; 49 | ALTER TEXT SEARCH CONFIGURATION public.sc_english 50 | ALTER MAPPING FOR asciiword WITH english_ispell, english_stem;"', $outref), 51 | 0, 'creating en_US full text search configuration ' . $$outref); 52 | 53 | # create test table and index 54 | my $outref; 55 | is ((exec_as 'postgres', 'psql -qd fts -c " 56 | CREATE TABLE stuff (id SERIAL PRIMARY KEY, text TEXT, textsearch tsvector); 57 | UPDATE stuff SET textsearch = to_tsvector(\'public.sc_english\', coalesce(text, \'\')); 58 | CREATE INDEX textsearch_idx ON stuff USING gin(textsearch); 59 | CREATE TRIGGER textsearch_update_trigger BEFORE INSERT OR UPDATE 60 | ON stuff FOR EACH ROW EXECUTE PROCEDURE 61 | tsvector_update_trigger(textsearch, \'public.sc_english\', text); 62 | INSERT INTO stuff (text) VALUES (\'PostgreSQL rocks\'); 63 | INSERT INTO stuff (text) VALUES (\'Linux rocks\'); 64 | INSERT INTO stuff (text) VALUES (\'I am your father\'\'s nephew\'\'s former roommate\'); 65 | INSERT INTO stuff (text) VALUES (\'3 cafés\'); 66 | "'), 0, 'creating data table and search index'); 67 | 68 | # test stemming 69 | is_program_out 'postgres', 70 | 'psql -Atd fts -c "SELECT dictionary, lexemes FROM ts_debug(\'public.sc_english\', \'friendliest\')"', 71 | 0, "english_ispell|{friendly}\n", 'stem search of correct word'; 72 | is_program_out 'postgres', 73 | 'psql -Atd fts -c "SELECT dictionary, lexemes FROM ts_debug(\'public.sc_english\', \'father\'\'s\')"', 74 | 0, "english_ispell|{father}\n|\nenglish_ispell|{}\n", 'stem search of correct word'; 75 | is_program_out 'postgres', 76 | 'psql -Atd fts -c "SELECT dictionary, lexemes FROM ts_debug(\'public.sc_english\', \'duffles\')"', 77 | 0, "english_stem|{duffl}\n", 'stem search of unknown word'; 78 | 79 | # test searching 80 | is_program_out 'postgres', 81 | 'psql -Atd fts -c "SELECT text FROM stuff, to_tsquery(\'rocks\') query WHERE query @@ to_tsvector(text)"', 82 | 0, "PostgreSQL rocks\nLinux rocks\n", 'full text search, exact word'; 83 | 84 | is_program_out 'postgres', 85 | 'psql -Atd fts -c "SELECT text FROM stuff, to_tsquery(\'rock\') query WHERE query @@ to_tsvector(text)"', 86 | 0, "PostgreSQL rocks\nLinux rocks\n", 'full text search for word stem'; 87 | 88 | is_program_out 'postgres', 89 | 'psql -Atd fts -c "SELECT text FROM stuff, to_tsquery(\'roc\') query WHERE query @@ to_tsvector(text)"', 90 | 0, '', 'full text search for word substring fails'; 91 | 92 | is_program_out 'postgres', 93 | 'psql -Atd fts -c "SELECT text FROM stuff, to_tsquery(\'cafés\') query WHERE query @@ to_tsvector(text)"', 94 | 0, "3 cafés\n", 'full text search, exact unicode word'; 95 | 96 | is_program_out 'postgres', 97 | 'psql -Atd fts -c "SELECT text FROM stuff, to_tsquery(\'café\') query WHERE query @@ to_tsvector(text)"', 98 | 0, "3 cafés\n", 'full text search for unicode word stem'; 99 | 100 | is_program_out 'postgres', 101 | 'psql -Atd fts -c "SELECT text FROM stuff, to_tsquery(\'afé\') query WHERE query @@ to_tsvector(text)"', 102 | 0, '', 'full text search for unicode word substring fails'; 103 | 104 | # clean up 105 | is ((system "pg_dropcluster $version main --stop"), 0); 106 | check_clean; 107 | 108 | # vim: filetype=perl 109 | -------------------------------------------------------------------------------- /t/160_alternate_confroot.t: -------------------------------------------------------------------------------- 1 | # Check that we can do all operations using a per-user $PG_CLUSTER_CONF_ROOT 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | 8 | my $version = $MAJORS[0]; 9 | 10 | use Test::More tests => 28; 11 | 12 | # prepare nobody-owned root dir for $PG_CLUSTER_CONF_ROOT 13 | my $rootdir=`su -s /bin/sh -c 'mktemp -d' nobody`; 14 | chomp $rootdir; 15 | ($rootdir) = $rootdir =~ m!^([a-zA-Z0-9._/]+)$!; # untaint 16 | $ENV{'PG_CLUSTER_CONF_ROOT'} = "$rootdir/etc"; 17 | 18 | is ((exec_as 'nobody', "pg_createcluster $version test -d $rootdir/data/test -l $rootdir/test.log --start"), 0); 19 | 20 | is_program_out 'nobody', 'env -u PG_CLUSTER_CONF_ROOT pg_lsclusters -h', 0, ''; 21 | like_program_out 'nobody', "pg_lsclusters -h", 0, 22 | qr!^$version\s+test.*online\s+nobody\s+$rootdir/data/test\s+$rootdir/test.log$!; 23 | 24 | like_program_out 'nobody', "psql -Atl", 0, qr/template1.*UTF8/; 25 | 26 | # pg_upgradecluster 27 | if ($MAJORS[0] ne $MAJORS[-1]) { 28 | my $outref; 29 | is ((exec_as 'nobody', "pg_upgradecluster --logfile $rootdir/testupgr.log -v $MAJORS[-1] $version test $rootdir/data/testupgr", $outref, 0), 0); 30 | like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup'; 31 | like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation'; 32 | 33 | like_program_out 'nobody', 'pg_lsclusters -h', 0, 34 | qr!^$version\s+test.*down.*\n^$MAJORS[-1]\s+test.*online\s+nobody\s+$rootdir/data/testupgr\s+$rootdir/testupgr.log$!m; 35 | 36 | # clean up 37 | is_program_out 'nobody', "pg_dropcluster $version test", 0, ''; 38 | is_program_out 'nobody', "pg_dropcluster $MAJORS[-1] test --stop", 0, ''; 39 | } else { 40 | pass 'Only one major version installed, skipping pg_upgradecluster tests'; 41 | for (my $i = 0; $i < 6; ++$i) { pass '...'; } 42 | 43 | is_program_out 'nobody', "pg_dropcluster $version test --stop", 0, ''; 44 | } 45 | 46 | # pg_dropcluster 47 | is_program_out 'nobody', "pg_lsclusters -h", 0, ''; 48 | 49 | ok_dir "$rootdir/data", [], 'No files in root/data left behind'; 50 | ok_dir "$rootdir", ['etc', 'data'], 'No cruft in root dir left behind'; 51 | 52 | system "rm -rf $rootdir"; 53 | 54 | delete $ENV{'PG_CLUSTER_CONF_ROOT'}; 55 | check_clean; 56 | 57 | # vim: filetype=perl 58 | -------------------------------------------------------------------------------- /t/170_extensions.t: -------------------------------------------------------------------------------- 1 | # Check that all extensions install successfully. 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More 0.87; # needs libtest-simple-perl backport on lenny 9 | 10 | foreach my $v (@MAJORS) { 11 | note "Running tests for $v"; 12 | 13 | if ($v < '9.1') { 14 | pass 'No extensions for version < 9.1'; 15 | next; 16 | } 17 | 18 | # create cluster 19 | is ((system "pg_createcluster $v main --start >/dev/null"), 0, "pg_createcluster $v main"); 20 | 21 | # plpgsql is installed by default 22 | is_program_out 'postgres', "psql -Atc 'SELECT extname FROM pg_extension'", 0, "plpgsql\n"; 23 | 24 | my %depends = ( 25 | bool_plperl => [qw(plperl)], 26 | bool_plperlu => [qw(plperlu)], 27 | earthdistance => [qw(cube)], 28 | hstore_plperl => [qw(hstore plperl)], 29 | hstore_plperlu => [qw(hstore plperlu)], 30 | hstore_plpython2u => [qw(hstore plpython2u)], 31 | hstore_plpython3u => [qw(hstore plpython3u)], 32 | hstore_plpythonu => [qw(hstore plpythonu)], 33 | jsonb_plperl => [qw(plperl)], # PG 11 34 | jsonb_plperlu => [qw(plperlu)], # PG 11 35 | jsonb_plpython2u => [qw(plpython2u)], # PG 11 36 | jsonb_plpython3u => [qw(plpython3u)], # PG 11 37 | jsonb_plpythonu => [qw(plpythonu)], # PG 11 38 | ltree_plpython2u => [qw(ltree plpython2u)], 39 | ltree_plpython3u => [qw(ltree plpython3u)], 40 | ltree_plpythonu => [qw(ltree plpythonu)], 41 | ); 42 | 43 | foreach () { 44 | my ($extname) = $_ =~ /^.*\/(.*)\.control$/; 45 | next if ($extname eq 'plpgsql'); 46 | 47 | if ($depends{$extname}) { 48 | for my $dep (@{$depends{$extname}}) { 49 | is_program_out 'postgres', "psql -qc 'CREATE EXTENSION $dep'", 0, '', 50 | "$extname dependency $dep installs without error"; 51 | } 52 | } 53 | 54 | if ($extname eq 'hstore' && $v eq '9.1') { 55 | # EXFAIL: hstore in 9.1 throws a warning about obsolete => operator 56 | like_program_out 'postgres', "psql -qc 'CREATE EXTENSION \"$extname\"'", 0, 57 | qr/=>/, "extension $extname installs (with warning)"; 58 | } elsif ($extname eq 'chkpass' && $v >= '9.5') { 59 | # chkpass is slightly broken, see 60 | # http://www.postgresql.org/message-id/20141117162116.GA3565@msg.df7cb.de 61 | like_program_out 'postgres', "psql -qc 'CREATE EXTENSION \"$extname\"'", 0, 62 | qr/WARNING: type input function chkpass_in should not be volatile/, 63 | "extension $extname installs (with warning)"; 64 | } else { 65 | is_program_out 'postgres', "psql -qc 'CREATE EXTENSION \"$extname\"'", 0, '', 66 | "extension $extname installs without error"; 67 | } 68 | 69 | is_program_out 'postgres', "psql -qc 'DROP EXTENSION \"$extname\"'", 0, '', 70 | "extension $extname removes without error"; 71 | 72 | if ($depends{$extname}) { 73 | for my $dep (@{$depends{$extname}}) { 74 | is_program_out 'postgres', "psql -qc 'DROP EXTENSION $dep'", 0, '', 75 | "$extname dependency extension $dep removes without error"; 76 | } 77 | } 78 | } 79 | 80 | # clean up 81 | is ((system "pg_dropcluster $v main --stop"), 0, "pg_dropcluster $v main"); 82 | check_clean; 83 | } 84 | 85 | done_testing(); 86 | 87 | # vim: filetype=perl 88 | -------------------------------------------------------------------------------- /t/180_ecpg.t: -------------------------------------------------------------------------------- 1 | # Check that ecpg works 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More tests => 14; 9 | 10 | my $v = $MAJORS[-1]; 11 | 12 | # prepare nobody-owned work dir 13 | my $workdir=`su -s /bin/sh -c 'mktemp -d' nobody`; 14 | chomp $workdir; 15 | chdir $workdir or die "could not chdir to $workdir: $!"; 16 | 17 | # create test code 18 | open F, '>test.pgc' or die "Could not open $workdir/test.pgc: $!"; 19 | print F < 21 | #include 22 | 23 | EXEC SQL WHENEVER SQLWARNING SQLPRINT; 24 | EXEC SQL WHENEVER SQLERROR SQLPRINT; 25 | 26 | EXEC SQL BEGIN DECLARE SECTION; 27 | char output[1024]; 28 | EXEC SQL END DECLARE SECTION; 29 | 30 | int main() { 31 | ECPGdebug(1, stderr); 32 | EXEC SQL CONNECT TO template1; 33 | EXEC SQL SELECT 'Database is ' || current_database() INTO :output; 34 | puts(output); 35 | EXEC SQL DISCONNECT ALL; 36 | return 0; 37 | } 38 | EOF 39 | close F; 40 | chmod 0644, 'test.pgc'; 41 | 42 | is_program_out 'nobody', 'ecpg test.pgc', 0, '', 'ecpg processing'; 43 | 44 | is_program_out 'nobody', 'cc -I$(pg_config --includedir) -L$(pg_config --libdir) -o test test.c -lecpg', 45 | 0, '', 'compiling ecpg output'; 46 | chdir '/' or die "could not chdir to /: $!"; 47 | 48 | # run program 49 | like_program_out 'nobody', "pg_virtualenv $workdir/test", 0, qr/Database is template1/, 50 | 'test program runs and gives correct output'; 51 | 52 | # clean up 53 | system "rm -rf $workdir"; 54 | check_clean; 55 | 56 | # vim: filetype=perl 57 | -------------------------------------------------------------------------------- /t/190_pg_buildext.t: -------------------------------------------------------------------------------- 1 | # Check pg_buildext and that our debhelper integration works 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More; 9 | 10 | if ($PgCommon::rpm) { 11 | pass 'No pg_buildext tests on RedHat'; 12 | done_testing(); 13 | exit; 14 | } 15 | 16 | # when invoked from the postgresql-NN package tests, postgresql-server-dev-all is not installed 17 | if (! -x '/usr/bin/dh_make_pgxs') { 18 | pass "Skipping pg_buildext tests, /usr/bin/dh_make_pgxs is not installed"; 19 | done_testing(); 20 | exit; 21 | } 22 | 23 | my $arch = `dpkg-architecture -qDEB_HOST_ARCH`; 24 | chomp $arch; 25 | 26 | if ($ENV{PG_VERSIONS}) { 27 | note "PG_VERSIONS=$ENV{PG_VERSIONS}"; 28 | $ENV{PG_SUPPORTED_VERSIONS} = join ' ', (grep { $_ >= 9.1 } split /\s+/, $ENV{PG_VERSIONS}); 29 | unless ($ENV{PG_SUPPORTED_VERSIONS}) { 30 | ok 1, 'No versions with extension support to test'; 31 | done_testing(); 32 | exit; 33 | } 34 | note "PG_SUPPORTED_VERSIONS=$ENV{PG_SUPPORTED_VERSIONS}"; 35 | } 36 | my @versions = split /\s+/, `/usr/share/postgresql-common/supported-versions`; 37 | 38 | # prepare build environment 39 | chmod 0777, 't/foo', 't/foo/foo-123', 't/bar/debian'; 40 | umask 0022; 41 | chdir 't/foo'; 42 | 43 | program_ok 0, 'make clean'; 44 | program_ok 'nobody', 'make tar'; 45 | program_ok 'nobody', 'cd foo-123 && echo y | EDITOR=true dh_make_pgxs'; 46 | 47 | note "testing 'dh --with pgxs'"; 48 | program_ok 'nobody', 'cd foo-123 && DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc'; 49 | 50 | foreach my $ver (@versions) { 51 | my $deb = "postgresql-$ver-foo_123-1_$arch.deb"; 52 | ok (-f $deb, "$deb was built"); 53 | SKIP: { 54 | my $have_extension_destdir = `grep extension_destdir /usr/share/postgresql/$ver/postgresql.conf.sample`; 55 | skip "No in-tree installcheck on PG $ver (missing extension_destdir)", 2 unless ($have_extension_destdir); 56 | like_program_out 'nobody', "cd foo-123 && PG_SUPPORTED_VERSIONS=$ver dh_pgxs_test", 57 | 0, qr/PostgreSQL $ver installcheck.*(test foo * \.\.\. ok|ok 1 * - foo)/s; # old/new PG 16 syntax 58 | } 59 | program_ok 0, "dpkg -i $deb"; 60 | like_program_out 'nobody', "cd foo-123 && pg_buildext installcheck", 61 | 0, qr/PostgreSQL $ver installcheck.*(test foo * \.\.\. ok|ok 1 * - foo)/s; 62 | like_program_out 'nobody', "cd foo-123 && echo 'SELECT 3*41, version()' | pg_buildext psql", 0, qr/123.*PostgreSQL $ver/; 63 | like_program_out 'nobody', "cd foo-123 && echo 'echo --\$PGVERSION--' | pg_buildext virtualenv", 0, qr/--$ver--/; 64 | like_program_out 'nobody', "cd foo-123 && pg_buildext run echo --%v--", 0, qr/--$ver--/; 65 | program_ok 0, "dpkg -r postgresql-$ver-foo"; 66 | } 67 | 68 | note "testing 'dh --with pgxs_loop'"; 69 | system "rm -f postgresql-*.deb"; 70 | 71 | program_ok 'nobody', 'sed -i -e s/pgxs/pgxs_loop/ foo-123/debian/rules'; 72 | program_ok 'nobody', 'cd foo-123 && DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc'; 73 | 74 | foreach my $ver (@versions) { 75 | my $deb = "postgresql-$ver-foo_123-1_$arch.deb"; 76 | ok (-f $deb, "$deb was built"); 77 | } 78 | 79 | program_ok 'nobody', 'make clean'; 80 | 81 | note "testing pg_buildext updatecontrol"; 82 | chdir '../bar'; 83 | program_ok 'nobody', 'PG_SUPPORTED_VERSIONS="0.9 1.0 1.1 2 3" pg_buildext updatecontrol'; 84 | is `cat debian/control`, "Source: bar 85 | Build-Depends: whatever, postgresql-1.0-moo (>= 1), postgresql-1.1-moo (>= 1), postgresql-2-moo (>= 1), more, 86 | postgresql-2-new, 87 | postgresql-1.0, postgresql-1.1, postgresql-2 88 | 89 | Package: postgresql-1.0-bar 90 | Architecture: some 91 | Depends: postgresql-1.0-moo 92 | 93 | Package: postgresql-1.1-bar 94 | Architecture: some 95 | Depends: postgresql-1.1-moo 96 | 97 | Package: postgresql-2-bar 98 | Architecture: some 99 | Depends: postgresql-2-moo 100 | ", "PGVERSION and PGVERSIONS were correctly replaced"; 101 | 102 | done_testing(); 103 | 104 | # vim: filetype=perl 105 | -------------------------------------------------------------------------------- /t/200_maintscripts.t: -------------------------------------------------------------------------------- 1 | # This test runs last since we are reinstalling postgresql-common, and we want 2 | # to avoid spoiling the other tests with any version skew. 3 | 4 | use strict; 5 | 6 | use lib 't'; 7 | use TestLib; 8 | use PgCommon; 9 | 10 | use Test::More tests => $PgCommon::rpm ? 1 : 15; 11 | 12 | if ($PgCommon::rpm) { 13 | pass 'No maintainer script tests on rpm'; 14 | exit; 15 | } 16 | 17 | my $v = $MAJORS[-1]; 18 | 19 | note -d "/run/systemd/system" ? "We are running systemd" : "We are not running systemd"; 20 | 21 | # create cluster 22 | program_ok 0, "pg_createcluster $v main --start"; 23 | 24 | # get postmaster PID 25 | my $postmaster_pid = `head -1 /var/lib/postgresql/$v/main/postmaster.pid`; 26 | chomp $postmaster_pid; 27 | ok $postmaster_pid > 0, "postmaster PID is $postmaster_pid"; 28 | 29 | # "upgrade" postgresql-common to check if postgresql.service is left alone 30 | program_ok 0, 'apt-get update -q', 0, ''; 31 | note `apt-cache policy postgresql-common`; 32 | program_ok 0, 'apt-get install -y --reinstall -o DPkg::Options::=--force-confnew postgresql-common', 0, ''; 33 | note `apt-cache policy postgresql-common`; 34 | 35 | # get postmaster PID again, compare 36 | my $postmaster_pid2 = `head -1 /var/lib/postgresql/$v/main/postmaster.pid`; 37 | chomp $postmaster_pid2; 38 | ok $postmaster_pid2 > 0, "postmaster PID is $postmaster_pid2"; 39 | is $postmaster_pid, $postmaster_pid2, "postmaster was not restarted"; 40 | 41 | # stop server, clean up, check for leftovers 42 | program_ok 0, "pg_dropcluster $v main --stop"; 43 | 44 | check_clean; 45 | 46 | # vim: filetype=perl 47 | -------------------------------------------------------------------------------- /t/bar/debian/control.in: -------------------------------------------------------------------------------- 1 | Source: bar 2 | Build-Depends: whatever, postgresql-PGVERSIONS-moo (>= 1), more, 3 | postgresql-PGVERSION-new, 4 | postgresql-PGVERSIONS 5 | 6 | Package: postgresql-PGVERSION-bar 7 | Architecture: some 8 | Depends: postgresql-PGVERSION-moo 9 | -------------------------------------------------------------------------------- /t/bar/debian/pgversions: -------------------------------------------------------------------------------- 1 | 1.0 2 | 1.1 3 | 2 4 | -------------------------------------------------------------------------------- /t/foo/Makefile: -------------------------------------------------------------------------------- 1 | TAR = foo_123.orig.tar.gz 2 | 3 | test: $(TAR) 4 | cd foo-123 && echo y | EDITOR=true dh_make_pgxs 5 | cd foo-123 && dpkg-buildpackage -us -uc 6 | 7 | tar $(TAR): 8 | tar cfz $(TAR) foo-123/ 9 | 10 | clean: 11 | rm -f *.* 12 | rm -rf foo-123/build-* foo-123/debian foo-123/*.o* 13 | -------------------------------------------------------------------------------- /t/foo/foo-123/Makefile: -------------------------------------------------------------------------------- 1 | MODULE_big = foo 2 | OBJS = foo.o 3 | EXTENSION = foo 4 | DATA = foo--100.sql foo--100--123.sql foo--123.sql 5 | REGRESS = foo upgrade 6 | 7 | PG_CONFIG = pg_config 8 | PGXS := $(shell $(PG_CONFIG) --pgxs) 9 | include $(PGXS) 10 | 11 | -------------------------------------------------------------------------------- /t/foo/foo-123/README.md: -------------------------------------------------------------------------------- 1 | The PostgreSQL foo extension 2 | ============================ 3 | 4 | This extension exists for testing postgresql-common's `dh_make_pgxs` and 5 | `dh --with pgxs` mechanisms. 6 | -------------------------------------------------------------------------------- /t/foo/foo-123/expected/foo.out: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION foo; 2 | SELECT foo(); 3 | foo 4 | ----- 5 | bar 6 | (1 row) 7 | 8 | DROP EXTENSION foo; 9 | -------------------------------------------------------------------------------- /t/foo/foo-123/expected/upgrade.out: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION foo VERSION "100"; 2 | SELECT foo(); 3 | foo 4 | --------- 5 | old bar 6 | (1 row) 7 | 8 | ALTER EXTENSION foo UPDATE TO "123"; 9 | SELECT foo(); 10 | foo 11 | ----- 12 | bar 13 | (1 row) 14 | 15 | -------------------------------------------------------------------------------- /t/foo/foo-123/foo--100--123.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION foo () 2 | RETURNS text LANGUAGE C 3 | AS '$libdir/foo'; 4 | -------------------------------------------------------------------------------- /t/foo/foo-123/foo--100.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION foo () 2 | RETURNS text LANGUAGE SQL 3 | AS $$ SELECT 'old bar'::text $$; 4 | -------------------------------------------------------------------------------- /t/foo/foo-123/foo--123.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION foo () 2 | RETURNS text LANGUAGE C 3 | AS '$libdir/foo'; 4 | -------------------------------------------------------------------------------- /t/foo/foo-123/foo.c: -------------------------------------------------------------------------------- 1 | #include "postgres.h" 2 | #include "fmgr.h" 3 | #include "utils/builtins.h" 4 | 5 | PG_MODULE_MAGIC; 6 | 7 | PG_FUNCTION_INFO_V1 (foo); 8 | 9 | Datum 10 | foo (PG_FUNCTION_ARGS) 11 | { 12 | PG_RETURN_TEXT_P(cstring_to_text("bar")); 13 | } 14 | -------------------------------------------------------------------------------- /t/foo/foo-123/foo.control: -------------------------------------------------------------------------------- 1 | default_version = '123' 2 | comment = 'The foo extension' 3 | -------------------------------------------------------------------------------- /t/foo/foo-123/sql/foo.sql: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION foo; 2 | 3 | SELECT foo(); 4 | 5 | DROP EXTENSION foo; 6 | -------------------------------------------------------------------------------- /t/foo/foo-123/sql/upgrade.sql: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION foo VERSION "100"; 2 | 3 | SELECT foo(); 4 | 5 | ALTER EXTENSION foo UPDATE TO "123"; 6 | 7 | SELECT foo(); 8 | -------------------------------------------------------------------------------- /t/template: -------------------------------------------------------------------------------- 1 | # Check XXX 2 | 3 | use strict; 4 | 5 | use lib 't'; 6 | use TestLib; 7 | use PgCommon; 8 | use Test::More tests => 14; 9 | 10 | my @versions = ($MAJORS[-1]); 11 | 12 | # create clusters 13 | foreach (@versions) { 14 | is ((system "pg_createcluster $_ main --start >/dev/null"), 0, "pg_createcluster $_ main"); 15 | is_program_out 'postgres', "createdb --cluster $_/main XXX", 0, ''; 16 | } 17 | 18 | # XXX 19 | 20 | # clean up 21 | foreach (@versions) { 22 | is ((system "pg_dropcluster $_ main --stop"), 0, "pg_dropcluster $_ main"); 23 | } 24 | check_clean; 25 | 26 | # vim: filetype=perl 27 | -------------------------------------------------------------------------------- /user_clusters: -------------------------------------------------------------------------------- 1 | # This file maps users against the database clusters to which they 2 | # will connect by default. Any user may create ~/.postgresqlrc which 3 | # will supersede the defaults stored here. If a database is 4 | # specified, that will be the one connected to by client tools if none 5 | # is specified on the command line. If the database specified here is 6 | # "*", this is interpreted as the database whose name is the same as 7 | # the user's login. (Setting the database to "*" will provide the 8 | # current default upstream behaviour for command line tools.) 9 | # 10 | # When pg_wrapper scans this file, the first matching line is used. 11 | # It is a good idea to provide a default explicitly, with a final line 12 | # where both user and group are set to "*". If there is no default, 13 | # the implicit default is to connect to the cluster listening on 14 | # port 5432 and to the database matching the user's login name. 15 | # 16 | # In the context of this file, user and group refer to the Unix login 17 | # or group, not to PostgreSQL users and groups. 18 | # 19 | # Please see user_clusters(5) and postgresqlrc(5) for more information. 20 | # 21 | # USER GROUP VERSION CLUSTER DATABASE 22 | 23 | -------------------------------------------------------------------------------- /user_clusters.5: -------------------------------------------------------------------------------- 1 | .TH USER_CLUSTERS 5 "Feburary 2005" "Debian" "Debian PostgreSQL infrastructure" 2 | 3 | .SH NAME 4 | user_clusters \- File linking users to PostgreSQL clusters 5 | 6 | .SH DESCRIPTION 7 | The file 8 | .B /etc/postgresql-common/user_clusters 9 | maps users against the database clusters to which they will 10 | connect by default. However, every user can override these settings in 11 | .B ~/.postgresqlrc\fR. 12 | 13 | When scanning this file, the first matching line will be used. It is a 14 | good idea to provide a default explicitly, with a final line where both 15 | user and group are set to 16 | .BR * . 17 | 18 | If there is no default, the implicit default is to connect to the cluster 19 | listening on port 5432 and to the database matching the user's 20 | login name. 21 | 22 | .SH FORMAT 23 | Comments are introduced by the character 24 | .BR # . 25 | Comments may follow data on a line; the first comment character terminates 26 | the data. Leading whitespace and blank lines are ignored. 27 | 28 | Each uncommented, non\-blank line must describe a user, group or the 29 | default (where both user and group are set to \fB*\fR). 30 | 31 | Fields must be given in the following order, separated by white space: 32 | 33 | .TP 34 | .B USER 35 | The login id of the Unix user to whom this line applies. The wildcard character 36 | .B * 37 | means any user. 38 | .TP 39 | .B GROUP 40 | The group name of the Unix group to which this line applies. The wildcard character 41 | .B * 42 | means any group. 43 | .TP 44 | .B VERSION 45 | The major PostgreSQL version of the cluster to connect to. 46 | .TP 47 | .B CLUSTER 48 | The name of a cluster to connect to. A remote cluster is specified 49 | with \fIhost\fR:\fIport\fR. If port is empty, it defaults to 5432. 50 | .TP 51 | .B DATABASE 52 | Within the cluster, the database to which the user will connect by default 53 | if he does not specify a database on the command line. If this is 54 | .BR * , 55 | the default database will be the one named by the user's login id. 56 | 57 | .SH NOTES 58 | .P 59 | Since the first matching line is used, the default line must come last. 60 | .P 61 | 62 | .SH SEE ALSO 63 | .BR pg_wrapper (1), " postgresqlrc" (5) 64 | --------------------------------------------------------------------------------