Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZBhIY-0003xa-Cl for pgsql-bugs@arkaria.postgresql.org; Sun, 05 Jul 2015 10:37:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZBhIX-0006Th-SJ for pgsql-bugs@arkaria.postgresql.org; Sun, 05 Jul 2015 10:37:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZBhIW-0006SE-Om for pgsql-bugs@postgresql.org; Sun, 05 Jul 2015 10:37:20 +0000 Received: from mimolette.dalibo.net ([212.85.154.222]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZBhIN-0002rj-Bu for pgsql-bugs@postgresql.org; Sun, 05 Jul 2015 10:37:19 +0000 Received: from [192.168.0.4] (aur75-1-78-192-238-147.fbxo.proxad.net [78.192.238.147]) by mimolette.dalibo.net (Postfix) with ESMTPSA id 30DAB6094BB; Sun, 5 Jul 2015 12:37:09 +0200 (CEST) Message-ID: <559908D4.7020901@dalibo.com> Date: Sun, 05 Jul 2015 12:37:08 +0200 From: Julien Rouhaud User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Guillaume Lelarge CC: mail@bwe.im, Oleksandr Shulgin , pgsql-bugs@postgresql.org, Fabien COELHO Subject: Re: BUG #12379: pgbench should hint to pgbench -i References: <20141231105955.8014.38426@wrigleys.postgresql.org> <87oales6zm.fsf@ashulgin01.corp.ad.zalando.net> <55984046.60901@dalibo.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------040605050304000806020301" X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------040605050304000806020301 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 05/07/2015 08:57, Guillaume Lelarge wrote: > Le 4 juil. 2015 10:22 PM, "Julien Rouhaud" > a écrit : >> >> On 22/05/2015 11:33, Fabien COELHO wrote: >> > >> >>> HINT: is "foo" the right database? did you initialize first (pgbench >> >>> -i)? >> >> >> >> I don't think there is precedent for spitting out "HINT:" in client > code >> >> (at least grep didn't find it). So this message might look like it's >> >> coming from the server, while it doesn't. >> > >> > Here is a v3, which makes it clearer that the hint comes from pgbench. >> > >> > HINT pgbench: is "foo" the right database? did you initialize first > (-i)? >> > >> >> Hello, >> >> I've just reviewed this patch. First, I've attached a rebased version >> (v4), as the v3 doesn't apply anymore. >> >> The patch is pretty simple, so everything is ok. >> >> >> But I've noticed that if you don't specify any database to pgbench, you >> get an empty database information: >> >> HINT pgbench: is "" the right database? did you initialize >> first (-i)? >> >> >> This isn't related to this patch specifically, but it may be confusing >> for users. At least more than the other places it could already appear >> (debug mode and failed connection attempt). >> >> As the database name is optional, wouldn't it be better to fix this >> behavior? >> > > I can't look at the code right now, but doesn't it use PQdb() to get the > name of the database? If it doesn't, it probably should. > Well, it doesn't. I'm attaching a new version of the patch, which retrieves the actual database name once connected if needed. That only solves this message though, the other ones being displayed before the connection is available. -- Julien Rouhaud http://dalibo.com - http://dalibo.org --------------040605050304000806020301 Content-Type: text/x-patch; name="pgbench-hint-5.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pgbench-hint-5.patch" diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 95be62c..0fbc91d 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3231,6 +3231,10 @@ main(int argc, char **argv) exit(1); } =20 + /* get the actual database name if it wasn't provided */ + if (strcmp(dbName, "") =3D=3D 0) + dbName =3D pg_strdup(PQdb(con)); + if (ttype !=3D 3) { /* @@ -3241,6 +3245,7 @@ main(int argc, char **argv) if (PQresultStatus(res) !=3D PGRES_TUPLES_OK) { fprintf(stderr, "%s", PQerrorMessage(con)); + fprintf(stderr, "HINT pgbench: is \"%s\" the right database? did you i= nitialize first (-i)?\n", dbName); exit(1); } scale =3D atoi(PQgetvalue(res, 0, 0)); --------------040605050304000806020301 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --------------040605050304000806020301--