Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bsSW9-0007nl-HA for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Oct 2016 10:36:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bsSW8-0006tN-T4 for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Oct 2016 10:36:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bsSW7-0006sf-Nl for pgsql-hackers@postgresql.org; Fri, 07 Oct 2016 10:36:39 +0000 Received: from mout.gmx.net ([212.227.15.15]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84_2) (envelope-from ) id 1bsSW4-0003nZ-NN for pgsql-hackers@postgresql.org; Fri, 07 Oct 2016 10:36:38 +0000 Received: from nighthawk.chemicalconnection.dyndns.org ([46.244.186.126]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MCcja-1bj4Zt1EKQ-009Ppa; Fri, 07 Oct 2016 12:36:27 +0200 Received: from mbanck by nighthawk.chemicalconnection.dyndns.org with local (Exim 4.84) (envelope-from ) id 1bsSTm-0007Iu-WA; Fri, 07 Oct 2016 12:34:15 +0200 Date: Fri, 7 Oct 2016 12:34:14 +0200 From: Michael Banck To: pgsql-hackers@postgresql.org Subject: pg_rewind: Should abort if both --source-pgdata and --source-server are specified Message-ID: <20161007103414.GD12247@nighthawk.caipicrew.dd-dns.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="GRPZ8SYKNexpdSJ7" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:4r3nnJmChHnGtAOzyXnngi5TbO+mNoBRsH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help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --GRPZ8SYKNexpdSJ7 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, ISTM that pg_rewind's --source-pgdata and --source-server options are mutually exclusive, and the synopsis in the documentation seems to indicate that as well: |pg_rewind [option...] {-D | --target-pgdata} directory |{--source-pgdata=directory | --source-server=connstr} However, there is no such check in the code. I've seen people assume --source-pgdata is supposed to be the data directory location on the remote server if they specify --source-server as well, and are then confused by error messages. So I think pg_rewind should abort in this case. Patch for that attached. Thoughts? Michael -- Michael Banck Projektleiter / Senior Berater Tel.: +49 2166 9901-171 Fax: +49 2166 9901-100 Email: michael.banck@credativ.de credativ GmbH, HRB Mönchengladbach 12080 USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer --GRPZ8SYKNexpdSJ7 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_rewind.patch" diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 5fdd4c5..dd62dd0 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -162,6 +162,13 @@ main(int argc, char **argv) exit(1); } + if (datadir_source != NULL && connstr_source != NULL) + { + fprintf(stderr, _("%s: only one of --source-pgdata or --source-server can be specified\n"), progname); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + exit(1); + } + if (datadir_target == NULL) { fprintf(stderr, _("%s: no target data directory specified (--target-pgdata)\n"), progname); --GRPZ8SYKNexpdSJ7 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --GRPZ8SYKNexpdSJ7--