diff -Nru pgbouncer-1.5.4/debian/bzr-builder.manifest pgbouncer-1.5.4/debian/bzr-builder.manifest --- pgbouncer-1.5.4/debian/bzr-builder.manifest 2012-12-03 08:26:00.000000000 +0000 +++ pgbouncer-1.5.4/debian/bzr-builder.manifest 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# bzr-builder format 0.3 deb-version {debversion}~25 -lp:~stub/ubuntu/precise/pgbouncer/devel revid:stuart@stuartbishop.net-20121203082321-lghgvrafx24iuqo8 diff -Nru pgbouncer-1.5.4/debian/changelog pgbouncer-1.5.4/debian/changelog --- pgbouncer-1.5.4/debian/changelog 2012-12-03 08:26:00.000000000 +0000 +++ pgbouncer-1.5.4/debian/changelog 2013-12-01 23:49:57.000000000 +0000 @@ -1,32 +1,60 @@ -pgbouncer (1.5.4-1~25~lucid1) lucid; urgency=low +pgbouncer (1.5.4-4lp1) lucid; urgency=low - * Auto build. + * Backport to lucid. + * debian/patches/enable-disable.diff: Backport ENABLE/DISABLE support from + master. - -- Stuart Bishop Mon, 03 Dec 2012 08:26:00 +0000 + -- William Grant Mon, 02 Dec 2013 10:47:15 +1100 -pgbouncer (1.5.4-1) unstable; urgency=low +pgbouncer (1.5.4-4) unstable; urgency=low - * v1.5.4 + * Use PGUSER/PGPASSWORD in debian/tests/connect; unset TMPDIR. - -- Marko Kreen Wed, 28 Nov 2012 12:44:39 +0200 + -- Christoph Berg Tue, 18 Jun 2013 13:11:40 +0200 -pgbouncer (1.5.3-1) unstable; urgency=low +pgbouncer (1.5.4-3) experimental; urgency=low - * v1.5.3 + [ Peter Eisentraut ] + * Use log_daemon_msg and log_end_msg to print output from init script. + * Fix watch file (from Bart Martens via + qa.debian.org) + * Disable silent make rules, per buildd log scanner + + [ Christoph Berg ] + * On restart, loop until the PID of the process changed instead of sleeping + a fixed time. Closes: #698942. + * Do not use start-stop-daemon --status yet as it is not available in + squeeze. Use ssd --stop --signal 0 instead. + * debian/tests/connect: Test online restart. + + -- Christoph Berg Fri, 22 Mar 2013 15:27:42 +0100 + +pgbouncer (1.5.4-2) experimental; urgency=low + + * Add autopkgtest support. - -- Marko Kreen Wed, 12 Sep 2012 13:36:51 +0300 + -- Christoph Berg Mon, 07 Jan 2013 16:32:47 +0100 -pgbouncer (1.5.2-2+lp2) lucid; urgency=low +pgbouncer (1.5.4-1) experimental; urgency=low - * Version bump + * New upstream release. + * Add .gitignore file. + + -- Christoph Berg Tue, 11 Dec 2012 10:10:16 +0100 + +pgbouncer (1.5.3-1) experimental; urgency=low + + * New upstream release. - -- Stuart Bishop (Work) Wed, 12 Sep 2012 19:41:48 +0700 + -- Christoph Berg Sun, 07 Oct 2012 19:24:30 +0200 -pgbouncer (1.5.2-2+lp1) precise; urgency=low +pgbouncer (1.5.2-3) unstable; urgency=low - * Add patch to test ENABLE and DISABLE commands. + * Re-add check for START=0 in the init script. Spotted by Sergey Burladyan. + Closes: #687577. + * Repository moved to git. - -- Stuart Bishop (Work) Wed, 12 Sep 2012 18:33:20 +0700 + -- Christoph Berg Sun, 07 Oct 2012 19:16:34 +0200 pgbouncer (1.5.2-2) unstable; urgency=low diff -Nru pgbouncer-1.5.4/debian/control pgbouncer-1.5.4/debian/control --- pgbouncer-1.5.4/debian/control 2012-12-03 08:25:59.000000000 +0000 +++ pgbouncer-1.5.4/debian/control 2013-12-01 23:53:30.000000000 +0000 @@ -1,19 +1,20 @@ Source: pgbouncer -Maintainer: Christoph Berg +Maintainer: William Grant Uploaders: Bernd Zeimetz , Peter Eisentraut Section: database Priority: optional Standards-Version: 3.9.3 Build-Depends: cdbs, debhelper (>= 7), libevent-dev (>= 1.3b), asciidoc, xmlto, python Homepage: http://pgfoundry.org/projects/pgbouncer/ -Vcs-Svn: svn://svn.debian.org/pkg-postgresql/trunk/pgbouncer/ -Vcs-Browser: http://svn.debian.org/wsvn/pkg-postgresql/trunk/pgbouncer/ +Vcs-Git: git://anonscm.debian.org/pkg-postgresql/pgbouncer.git +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-postgresql/pgbouncer.git +XS-Testsuite: autopkgtest Package: pgbouncer -Provides: pgbouncer-with-disconnect Architecture: any Depends: lsb-base (>= 3.1), postgresql-common (>= 26), ${misc:Depends}, ${shlibs:Depends} Enhances: postgresql (>= 7.4) +Provides: pgbouncer-with-disconnect Description: lightweight connection pooler for PostgreSQL PgBouncer is a lightweight connection pooler for PostgreSQL providing the following features: diff -Nru pgbouncer-1.5.4/debian/init pgbouncer-1.5.4/debian/init --- pgbouncer-1.5.4/debian/init 2012-12-03 08:25:59.000000000 +0000 +++ pgbouncer-1.5.4/debian/init 2013-06-18 11:11:26.000000000 +0000 @@ -31,59 +31,59 @@ # Check if configuration exists test -f $CONF || exit 0 -SSD="start-stop-daemon --pidfile $PIDFILE --exec $DAEMON" +. /lib/lsb/init-functions + +SSD="start-stop-daemon --pidfile $PIDFILE --exec $DAEMON --quiet" case "$1" in start) - echo -n "Starting server: $NAME" + # Check if we are still disabled in /etc/default/pgbouncer + [ "${START:-}" = "0" ] && exit 0 + log_daemon_msg "Starting PgBouncer" $NAME test -d $PIDDIR || install -d -o postgres -g postgres -m 2775 $PIDDIR $SSD --start --chuid $RUNASUSER --oknodo -- $OPTS 2> /dev/null + log_end_msg $? ;; stop) - echo -n "Stopping server: $NAME" + log_daemon_msg "Stopping PgBouncer" $NAME $SSD --stop --retry 30 --oknodo + log_end_msg $? ;; reload | force-reload) - echo -n "Reloading $NAME configuration" + log_daemon_msg "Reloading PgBouncer configuration" $NAME $SSD --stop --signal HUP --oknodo + log_end_msg $? ;; restart) - $SSD --status + # we would use "$SSD --status" here if it were available in squeeze + $SSD --stop --signal 0 if [ $? -eq 0 ] ; then - echo -n "Invoking $NAME restart" + OLDPID=$(cat $PIDFILE) + log_daemon_msg "Invoking PgBouncer restart" $NAME su -c "$DAEMON -R $OPTS 2> /dev/null" - $RUNASUSER - sleep 5 - $SSD --status + # sleep until the process has changed PID + for t in 0.1 0.2 0.2 0.5 1.0 1.0 2.0; do # 5s in total + NEWPID=$(cat $PIDFILE 2>/dev/null) + [ "$NEWPID" ] && [ "$NEWPID" != "$OLDPID" ] && break + echo sleep $t + sleep $t + done + $SSD --stop --signal 0 + log_end_msg $? else $0 start fi ;; status) - $SSD --status - status=$? - if [ $status -eq 0 ]; then - echo "pgbouncer is running" - else - echo "pgbouncer is not running" - fi - exit $status + status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? ;; *) - echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart}" + echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}" exit 1 ;; esac - -if [ $? -eq 0 ]; then - echo . - exit 0 -else - echo " failed" - exit 1 -fi - diff -Nru pgbouncer-1.5.4/debian/patches/disable.diff pgbouncer-1.5.4/debian/patches/disable.diff --- pgbouncer-1.5.4/debian/patches/disable.diff 2012-12-03 08:25:59.000000000 +0000 +++ pgbouncer-1.5.4/debian/patches/disable.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ -diff --git a/doc/usage.txt b/doc/usage.txt -index 3d544cb..e8ed162 100644 ---- a/doc/usage.txt -+++ b/doc/usage.txt -@@ -448,6 +448,14 @@ at the time of database restart. - - If database name is given, only that database will be paused. - -+==== DISABLE db; ==== -+ -+Reject all new client connections on the given database. -+ -+==== ENABLE db; ==== -+ -+Allow new client connections after a previous +DISABLE+ command. -+ - ==== KILL db; ==== - - Immediately drop all client and server connections on given database. -diff --git a/include/bouncer.h b/include/bouncer.h -index 687126a..5dc47eb 100644 ---- a/include/bouncer.h -+++ b/include/bouncer.h -@@ -253,6 +253,7 @@ struct PgDatabase { - bool db_paused; /* PAUSE ; was issued */ - bool db_dead; /* used on RELOAD/SIGHUP to later detect removed dbs */ - bool db_auto; /* is the database auto-created by autodb_connstr */ -+ bool db_disabled; /* is the database accepting new connections? */ - bool admin; /* internal console db */ - - struct PktBuf *startup_params; /* partial StartupMessage (without user) be sent to server */ -diff --git a/src/admin.c b/src/admin.c -index 7bf9e80..6d1fd20 100644 ---- a/src/admin.c -+++ b/src/admin.c -@@ -355,6 +355,19 @@ static bool show_fds_from_list(PgSocket *admin, struct StatList *list) - return res; - } - -+static PgDatabase *find_or_register_database(PgSocket *admin, const char *name) -+{ -+ PgDatabase *db = find_database(name); -+ if (db == NULL) { -+ db = register_auto_database(name); -+ if (db != NULL) { -+ slog_info(admin, -+ "registered new auto-database: %s", name); -+ } -+ } -+ return db; -+} -+ - /* - * Command: SHOW FDS - * -@@ -959,15 +972,9 @@ static bool admin_cmd_pause(PgSocket *admin, const char *arg) - } else { - PgDatabase *db; - log_info("PAUSE '%s' command issued", arg); -- db = find_database(arg); -- if (db == NULL) { -- db = register_auto_database(arg); -- if (db == NULL) { -- return admin_error(admin, "no such database: %s", arg); -- } else { -- slog_info(admin, "registered new auto-database for PAUSE: %s", arg); -- } -- } -+ db = find_or_register_database(admin, arg); -+ if (db == NULL) -+ return admin_error(admin, "no such database: %s", arg); - if (db == admin->pool->db) - return admin_error(admin, "cannot pause admin db: %s", arg); - db->db_paused = 1; -@@ -980,6 +987,50 @@ static bool admin_cmd_pause(PgSocket *admin, const char *arg) - return true; - } - -+/* Command: DISABLE */ -+static bool admin_cmd_disable(PgSocket *admin, const char *arg) -+{ -+ PgDatabase *db; -+ -+ if (!admin->admin_user) -+ return admin_error(admin, "admin access needed"); -+ -+ if (!arg[0]) -+ return admin_error(admin, "a database is required"); -+ -+ log_info("DISABLE '%s' command issued", arg); -+ db = find_or_register_database(admin, arg); -+ if (db == NULL) -+ return admin_error(admin, "no such database: %s", arg); -+ if (db == admin->pool->db) -+ return admin_error(admin, "cannot disable admin db: %s", arg); -+ -+ db->db_disabled = 1; -+ return admin_ready(admin, "DISABLE"); -+} -+ -+/* Command: ENABLE */ -+static bool admin_cmd_enable(PgSocket *admin, const char *arg) -+{ -+ PgDatabase *db; -+ -+ if (!admin->admin_user) -+ return admin_error(admin, "admin access needed"); -+ -+ if (!arg[0]) -+ return admin_error(admin, "a database is required"); -+ -+ log_info("ENABLE '%s' command issued", arg); -+ db = find_database(arg); -+ if (db == NULL) -+ return admin_error(admin, "no such database: %s", arg); -+ if (db == admin->pool->db) -+ return admin_error(admin, "cannot disable admin db: %s", arg); -+ -+ db->db_disabled = 0; -+ return admin_ready(admin, "ENABLE"); -+} -+ - /* Command: KILL */ - static bool admin_cmd_kill(PgSocket *admin, const char *arg) - { -@@ -997,15 +1048,9 @@ static bool admin_cmd_kill(PgSocket *admin, const char *arg) - return admin_error(admin, "a database is required"); - - log_info("KILL '%s' command issued", arg); -- db = find_database(arg); -- if (db == NULL) { -- db = register_auto_database(arg); -- if (db == NULL) { -- return admin_error(admin, "no such database: %s", arg); -- } else { -- slog_info(admin, "registered new auto-database for KILL: %s", arg); -- } -- } -+ db = find_or_register_database(admin, arg); -+ if (db == NULL) -+ return admin_error(admin, "no such database: %s", arg); - if (db == admin->pool->db) - return admin_error(admin, "cannot kill admin db: %s", arg); - -@@ -1074,6 +1119,8 @@ static bool admin_show_help(PgSocket *admin, const char *arg) - "\tRELOAD\n" - "\tPAUSE []\n" - "\tRESUME []\n" -+ "\tDISABLE \n" -+ "\tENABLE \n" - "\tKILL \n" - "\tSUSPEND\n" - "\tSHUTDOWN", ""); -@@ -1133,6 +1180,8 @@ static bool admin_cmd_show(PgSocket *admin, const char *arg) - } - - static struct cmd_lookup cmd_list [] = { -+ {"disable", admin_cmd_disable}, -+ {"enable", admin_cmd_enable}, - {"kill", admin_cmd_kill}, - {"pause", admin_cmd_pause}, - {"reload", admin_cmd_reload}, -diff --git a/src/client.c b/src/client.c -index 056fb96..c28bd7f 100644 ---- a/src/client.c -+++ b/src/client.c -@@ -105,6 +105,10 @@ bool set_pool(PgSocket *client, const char *dbname, const char *username) - disconnect_client(client, true, "no memory for pool"); - return false; - } -+ if (client->pool->db->db_disabled) { -+ disconnect_client(client, true, "pgbouncer database is disabled"); -+ return false; -+ } - - return check_fast_fail(client); - } diff -Nru pgbouncer-1.5.4/debian/patches/enable-disable.diff pgbouncer-1.5.4/debian/patches/enable-disable.diff --- pgbouncer-1.5.4/debian/patches/enable-disable.diff 1970-01-01 00:00:00.000000000 +0000 +++ pgbouncer-1.5.4/debian/patches/enable-disable.diff 2013-12-01 23:46:44.000000000 +0000 @@ -0,0 +1,215 @@ +Index: pgbouncer-1.5.4/doc/usage.txt +=================================================================== +--- pgbouncer-1.5.4.orig/doc/usage.txt 2012-10-29 03:45:50.000000000 +1100 ++++ pgbouncer-1.5.4/doc/usage.txt 2013-12-02 10:46:18.963231772 +1100 +@@ -450,6 +450,14 @@ + + If database name is given, only that database will be paused. + ++==== DISABLE db; ==== ++ ++Reject all new client connections on the given database. ++ ++==== ENABLE db; ==== ++ ++Allow new client connections after a previous +DISABLE+ command. ++ + ==== KILL db; ==== + + Immediately drop all client and server connections on given database. +Index: pgbouncer-1.5.4/include/bouncer.h +=================================================================== +--- pgbouncer-1.5.4.orig/include/bouncer.h 2012-08-16 21:03:34.000000000 +1000 ++++ pgbouncer-1.5.4/include/bouncer.h 2013-12-02 10:46:18.963231772 +1100 +@@ -253,6 +253,7 @@ + bool db_paused; /* PAUSE ; was issued */ + bool db_dead; /* used on RELOAD/SIGHUP to later detect removed dbs */ + bool db_auto; /* is the database auto-created by autodb_connstr */ ++ bool db_disabled; /* is the database accepting new connections? */ + bool admin; /* internal console db */ + + struct PktBuf *startup_params; /* partial StartupMessage (without user) be sent to server */ +Index: pgbouncer-1.5.4/src/admin.c +=================================================================== +--- pgbouncer-1.5.4.orig/src/admin.c 2012-08-16 21:03:34.000000000 +1000 ++++ pgbouncer-1.5.4/src/admin.c 2013-12-02 10:46:41.595507742 +1100 +@@ -355,6 +355,19 @@ + return res; + } + ++static PgDatabase *find_or_register_database(PgSocket *admin, const char *name) ++{ ++ PgDatabase *db = find_database(name); ++ if (db == NULL) { ++ db = register_auto_database(name); ++ if (db != NULL) { ++ slog_info(admin, ++ "registered new auto-database: %s", name); ++ } ++ } ++ return db; ++} ++ + /* + * Command: SHOW FDS + * +@@ -959,15 +972,9 @@ + } else { + PgDatabase *db; + log_info("PAUSE '%s' command issued", arg); +- db = find_database(arg); +- if (db == NULL) { +- db = register_auto_database(arg); +- if (db == NULL) { +- return admin_error(admin, "no such database: %s", arg); +- } else { +- slog_info(admin, "registered new auto-database for PAUSE: %s", arg); +- } +- } ++ db = find_or_register_database(admin, arg); ++ if (db == NULL) ++ return admin_error(admin, "no such database: %s", arg); + if (db == admin->pool->db) + return admin_error(admin, "cannot pause admin db: %s", arg); + db->db_paused = 1; +@@ -980,6 +987,50 @@ + return true; + } + ++/* Command: DISABLE */ ++static bool admin_cmd_disable(PgSocket *admin, const char *arg) ++{ ++ PgDatabase *db; ++ ++ if (!admin->admin_user) ++ return admin_error(admin, "admin access needed"); ++ ++ if (!arg[0]) ++ return admin_error(admin, "a database is required"); ++ ++ log_info("DISABLE '%s' command issued", arg); ++ db = find_or_register_database(admin, arg); ++ if (db == NULL) ++ return admin_error(admin, "no such database: %s", arg); ++ if (db->admin) ++ return admin_error(admin, "cannot disable admin db: %s", arg); ++ ++ db->db_disabled = 1; ++ return admin_ready(admin, "DISABLE"); ++} ++ ++/* Command: ENABLE */ ++static bool admin_cmd_enable(PgSocket *admin, const char *arg) ++{ ++ PgDatabase *db; ++ ++ if (!admin->admin_user) ++ return admin_error(admin, "admin access needed"); ++ ++ if (!arg[0]) ++ return admin_error(admin, "a database is required"); ++ ++ log_info("ENABLE '%s' command issued", arg); ++ db = find_database(arg); ++ if (db == NULL) ++ return admin_error(admin, "no such database: %s", arg); ++ if (db->admin) ++ return admin_error(admin, "cannot disable admin db: %s", arg); ++ ++ db->db_disabled = 0; ++ return admin_ready(admin, "ENABLE"); ++} ++ + /* Command: KILL */ + static bool admin_cmd_kill(PgSocket *admin, const char *arg) + { +@@ -997,15 +1048,9 @@ + return admin_error(admin, "a database is required"); + + log_info("KILL '%s' command issued", arg); +- db = find_database(arg); +- if (db == NULL) { +- db = register_auto_database(arg); +- if (db == NULL) { +- return admin_error(admin, "no such database: %s", arg); +- } else { +- slog_info(admin, "registered new auto-database for KILL: %s", arg); +- } +- } ++ db = find_or_register_database(admin, arg); ++ if (db == NULL) ++ return admin_error(admin, "no such database: %s", arg); + if (db == admin->pool->db) + return admin_error(admin, "cannot kill admin db: %s", arg); + +@@ -1074,6 +1119,8 @@ + "\tRELOAD\n" + "\tPAUSE []\n" + "\tRESUME []\n" ++ "\tDISABLE \n" ++ "\tENABLE \n" + "\tKILL \n" + "\tSUSPEND\n" + "\tSHUTDOWN", ""); +@@ -1133,6 +1180,8 @@ + } + + static struct cmd_lookup cmd_list [] = { ++ {"disable", admin_cmd_disable}, ++ {"enable", admin_cmd_enable}, + {"kill", admin_cmd_kill}, + {"pause", admin_cmd_pause}, + {"reload", admin_cmd_reload}, +Index: pgbouncer-1.5.4/src/client.c +=================================================================== +--- pgbouncer-1.5.4.orig/src/client.c 2012-08-16 21:03:34.000000000 +1000 ++++ pgbouncer-1.5.4/src/client.c 2013-12-02 10:46:41.595507742 +1100 +@@ -76,6 +76,12 @@ + } + } + ++ /* are new connections allowed? */ ++ if (db->db_disabled) { ++ disconnect_client(client, true, "database does not allow connections: %s", dbname); ++ return false; ++ } ++ + /* find user */ + if (cf_auth_type == AUTH_ANY) { + /* ignore requested user */ +Index: pgbouncer-1.5.4/test/test.sh +=================================================================== +--- pgbouncer-1.5.4.orig/test/test.sh 2012-06-11 05:57:01.000000000 +1000 ++++ pgbouncer-1.5.4/test/test.sh 2013-12-02 10:46:41.595507742 +1100 +@@ -331,6 +331,23 @@ + test `wc -l <$LOGDIR/test.tmp` -eq 50 + } + ++# test pause/resume ++test_enable_disable() { ++ rm -f $LOGDIR/test.tmp ++ psql -tAq p0 -c "select 'enabled 1'" >>$LOGDIR/test.tmp 2>&1 ++ ++ admin "disable p0" ++ psql -tAq p0 -c "select 'disabled 1'" >>$LOGDIR/test.tmp 2>&1 ++ admin "enable p0" ++ psql -tAq p0 -c "select 'enabled 2'" >>$LOGDIR/test.tmp 2>&1 ++ ++ grep -q "enabled 1" $LOGDIR/test.tmp || return 1 ++ grep -q "enabled 2" $LOGDIR/test.tmp || return 1 ++ grep -q "disabled 1" $LOGDIR/test.tmp && return 1 ++ grep -q "does not allow" $LOGDIR/test.tmp || return 1 ++ return 0 ++} ++ + # test pool database restart + test_database_restart() { + admin "set server_login_retry=1" +@@ -396,6 +413,7 @@ + test_online_restart + test_pause_resume + test_suspend_resume ++test_enable_disable + test_database_restart + test_database_change + " diff -Nru pgbouncer-1.5.4/debian/patches/series pgbouncer-1.5.4/debian/patches/series --- pgbouncer-1.5.4/debian/patches/series 2012-12-03 08:25:59.000000000 +0000 +++ pgbouncer-1.5.4/debian/patches/series 2013-12-01 23:45:33.000000000 +0000 @@ -1,2 +1,2 @@ debian-config -disable.diff +enable-disable.diff diff -Nru pgbouncer-1.5.4/debian/rules pgbouncer-1.5.4/debian/rules --- pgbouncer-1.5.4/debian/rules 2012-12-03 08:25:59.000000000 +0000 +++ pgbouncer-1.5.4/debian/rules 2013-06-18 11:11:26.000000000 +0000 @@ -4,6 +4,7 @@ include /usr/share/cdbs/1/class/autotools.mk DEB_CONFIGURE_EXTRA_FLAGS := --bindir=/usr/sbin +DEB_MAKE_EXTRA_ARGS += V=1 DEB_DH_INSTALLINIT_ARGS := -R clean:: diff -Nru pgbouncer-1.5.4/debian/tests/connect pgbouncer-1.5.4/debian/tests/connect --- pgbouncer-1.5.4/debian/tests/connect 1970-01-01 00:00:00.000000000 +0000 +++ pgbouncer-1.5.4/debian/tests/connect 2013-06-18 11:24:06.000000000 +0000 @@ -0,0 +1,51 @@ +#!/bin/sh + +# autopkgtest script for pgbouncer: starts a pgbouncer instance and connects +# through it to a postgres server running on port 5432 + +# autopkgtest's TMPDIR is not readable for postgres +unset TMPDIR + +if [ -z "$WRAPPED" ]; then + WRAPPED=1 pg_virtualenv $0 "$@" + exit +fi + +/etc/init.d/pgbouncer stop + +set -e + +# prepare cleanup at exit +CLEAN_FILES="/etc/pgbouncer/pgbouncer.ini /etc/pgbouncer/userlist.txt /etc/default/pgbouncer" +cleanup () { + /etc/init.d/pgbouncer stop || : + for f in $CLEAN_FILES; do + test -f $f.adt-save && mv -f $f.adt-save $f + done +} +trap cleanup 0 2 3 15 + +# set up minimal pgbouncer config +sed -i.adt-save -e '/\[databases\]/ apostgres =' /etc/pgbouncer/pgbouncer.ini +cp -a /etc/pgbouncer/userlist.txt /etc/pgbouncer/userlist.txt.adt-save +echo "\"$PGUSER\" \"$PGPASSWORD\"" >> /etc/pgbouncer/userlist.txt +sed -i.adt-save -e 's/START=0/START=1/' /etc/default/pgbouncer + +# start pgbouncer and test connection +/etc/init.d/pgbouncer start +echo "Trying simple SELECT ..." +result=$(psql -p 6432 -d postgres -c "SELECT 1+2" -tA) +echo "$result" +[ "$result" = "3" ] +echo "Result OK" + +echo "Trying online restart ..." +( + echo "SELECT 3+4;" + /etc/init.d/pgbouncer restart > /dev/null + echo "SELECT 5+6;" +) | psql -p 6432 -d postgres -tA > output +[ "$(cat output)" = "7 +11" ] +echo "Result OK" +rm -f output diff -Nru pgbouncer-1.5.4/debian/tests/control pgbouncer-1.5.4/debian/tests/control --- pgbouncer-1.5.4/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ pgbouncer-1.5.4/debian/tests/control 2013-06-18 11:11:26.000000000 +0000 @@ -0,0 +1,3 @@ +Tests: connect +Depends: @, postgresql +Restrictions: needs-root diff -Nru pgbouncer-1.5.4/debian/watch pgbouncer-1.5.4/debian/watch --- pgbouncer-1.5.4/debian/watch 2012-12-03 08:25:59.000000000 +0000 +++ pgbouncer-1.5.4/debian/watch 2013-06-18 11:11:26.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://pgfoundry.org/frs/?group_id=1000258 /frs/download.php/[0-9]+/pgbouncer-([0-9.]+).(?:tgz|tar.gz) +http://pgfoundry.org/frs/?group_id=1000258 .*/[0-9]+/pgbouncer-([0-9.]+).(?:tgz|tar.gz)