pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Julien Rouhaud <julien.rouhaud@dalibo.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Guillaume Lelarge <guillaume@lelarge.info>
Cc: mail@bwe.im, Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
Cc: PostgreSQL Bugs List <pgsql-bugs@postgresql.org>
Subject: Re: BUG #12379: pgbench should hint to pgbench -i
Date: Sat, 18 Jul 2015 13:05:04 +0200
Message-ID: <55AA32E0.7070006@dalibo.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1507060709030.7427@sto>
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>
	<alpine.DEB.2.10.1507051821230.27775@sto>
	<23314.1436142811@sss.pgh.pa.us>
	<alpine.DEB.2.10.1507060709030.7427@sto>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 06/07/2015 07:36, Fabien COELHO wrote:
> 
>> I looked at this a bit and have a few comments:
>>
>> * I think it might be best to restrict the hint to appear only in the
>> case that the SQLSTATE is ERRCODE_UNDEFINED_TABLE.  There are a lot of
>> possible failures here, and I'm not sure this hint is apropos for any
>> but that one.
> 
> Hmmm... the likelyhood of another kind of error is small on:
> 
>    "select count(*) from pgbench_branches;"
> 
> I think the only other possibility would be a permission issue.
> 
>> * I really don't care for "HINT pgbench: " as that's got pretty much
>> nothing to do with any other message formatting we have anywhere,
>> least of all the existing hint-like messages in pgbench.
> 
> It is kind of a copy of postgres hints, but not more than that:
> 
>   HINT:  Consider increasing the configuration parameter "max_wal_size"
> 
>> I've started a different thread at
>> http://www.postgresql.org/message-id/22280.1436139973@sss.pgh.pa.us to
>> discuss what the general message formatting in pgbench ought to be,
>> and probably this needs to wait for the outcome of that discussion.
> 
> Yep.
> 
>> * I'd be a bit inclined to reduce the message to something like
>>    Perhaps you need to do initialization ("pgbench -i") in database "foo"
>> so that we can avoid the question of formatting of multi-sentence hints.
> 
> Why not. This sentence hints at one possible error instead of two,
> though, but it may be enough.
> 

Here's a v7 patch which display the hint only if SQLSTATE is
ERRCODE_UNDEFINED_TABLE and use the message Tom suggested, as there
wasn't any better suggestion or strong objection with it in the other
thread.
-- 
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-bugs

Attachments:

pgbench-hint-7.patch (text/x-patch, 836B) download diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index e839fa3..c03a52e 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -55,6 +55,8 @@ #include "pgbench.h" +#define ERRCODE_UNDEFINED_TABLE "42P01" + /* * Multi-platform pthread implementations */ @@ -3251,7 +3253,14 @@ main(int argc, char **argv) res = PQexec(con, "select count(*) from pgbench_branches"); if (PQresultStatus(res) != PGRES_TUPLES_OK) { + char *sqlState = PQresultErrorField(res, PG_DIAG_SQLSTATE); + fprintf(stderr, "%s", PQerrorMessage(con)); + if (sqlState && strcmp(sqlState, ERRCODE_UNDEFINED_TABLE) == 0) + { + fprintf(stderr, "Perhaps you need to do initialization (\"pgbench -i\") in database \"%s\"\n", PQdb(con)); + } + exit(1); } scale = atoi(PQgetvalue(res, 0, 0));

view thread (23+ messages)  latest in thread

Message-ID: <55AA32E0.7070006@dalibo.com>
Permalink:  ../55AA32E0.7070006@dalibo.com/
Also on:    postgresql.org/message-id/55AA32E0.7070006@dalibo.com

 ·  · 

reply

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, coelho@cri.ensmp.fr, tgl@sss.pgh.pa.us, guillaume@lelarge.info, oleksandr.shulgin@zalando.de
  Subject: Re: BUG #12379: pgbench should hint to pgbench -i
  In-Reply-To: <55AA32E0.7070006@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> <alpine.DEB.2.10.1507051821230.27775@sto> <23314.1436142811@sss.pgh.pa.us> <alpine.DEB.2.10.1507060709030.7427@sto> <55AA32E0.7070006@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