From: Julien Rouhaud <julien.rouhaud@dalibo.com>
To: Guillaume Lelarge <guillaume@lelarge.info>
Cc: mail@bwe.im, Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
Cc: pgsql-bugs@postgresql.org, Fabien COELHO <coelho@cri.ensmp.fr>
Subject: Re: BUG #12379: pgbench should hint to pgbench -i
Date: Sun, 05 Jul 2015 12:37:08 +0200
Message-ID: <559908D4.7020901@dalibo.com> (raw)
In-Reply-To: <CAECtzeWOm0JmJpDwM=woq8mfqfjPHOxLvSAaPrs=qOHvbWzxkw@mail.gmail.com>
References: <20141231105955.8014.38426@wrigleys.postgresql.org>
<alpine.DEB.2.10.1503080851220.4406@sto>
<alpine.DEB.2.10.1504260845160.6827@sto>
<87oales6zm.fsf@ashulgin01.corp.ad.zalando.net>
<alpine.DEB.2.10.1505221131480.30229@sto>
<55984046.60901@dalibo.com>
<CAECtzeWOm0JmJpDwM=woq8mfqfjPHOxLvSAaPrs=qOHvbWzxkw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 05/07/2015 08:57, Guillaume Lelarge wrote:
> Le 4 juil. 2015 10:22 PM, "Julien Rouhaud" <julien.rouhaud@dalibo.com
> <mailto:julien.rouhaud@dalibo.com>> 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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:pgbench-hint-5.patch (text/x-patch, 701B) downloaddiff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex 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);
}
+ /* get the actual database name if it wasn't provided */+ if (strcmp(dbName, "") == 0)+ dbName = pg_strdup(PQdb(con));+
if (ttype != 3)
{
/*
@@ -3241,6 +3245,7 @@ main(int argc, char **argv)
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
fprintf(stderr, "%s", PQerrorMessage(con));
+ fprintf(stderr, "HINT pgbench: is \"%s\" the right database? did you initialize first (-i)?\n", dbName);
exit(1);
}
scale = atoi(PQgetvalue(res, 0, 0));
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: julien.rouhaud@dalibo.com, guillaume@lelarge.info, oleksandr.shulgin@zalando.de, coelho@cri.ensmp.fr
Subject: Re: BUG #12379: pgbench should hint to pgbench -i
In-Reply-To: <559908D4.7020901@dalibo.com>
References: <20141231105955.8014.38426@wrigleys.postgresql.org> <alpine.DEB.2.10.1503080851220.4406@sto> <alpine.DEB.2.10.1504260845160.6827@sto> <87oales6zm.fsf@ashulgin01.corp.ad.zalando.net> <alpine.DEB.2.10.1505221131480.30229@sto> <55984046.60901@dalibo.com> <CAECtzeWOm0JmJpDwM=woq8mfqfjPHOxLvSAaPrs=qOHvbWzxkw@mail.gmail.com> <559908D4.7020901@dalibo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox