Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZGPvo-0000pU-86 for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jul 2015 11:05:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZGPvn-0004KK-7W for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jul 2015 11:05:23 +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) (envelope-from ) id 1ZGPvl-0004Jv-6e for pgsql-bugs@postgresql.org; Sat, 18 Jul 2015 11:05:21 +0000 Received: from [212.85.157.144] (helo=mimolette.dalibo.net) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZGPvX-00080e-Cd for pgsql-bugs@postgresql.org; Sat, 18 Jul 2015 11:05: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 087D61F10399; Sat, 18 Jul 2015 13:05:05 +0200 (CEST) Message-ID: <55AA32E0.7070006@dalibo.com> Date: Sat, 18 Jul 2015 13:05:04 +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: Fabien COELHO , Tom Lane CC: Guillaume Lelarge , mail@bwe.im, Oleksandr Shulgin , PostgreSQL Bugs List 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> <559908D4.7020901@dalibo.com> <23314.1436142811@sss.pgh.pa.us> In-Reply-To: Content-Type: multipart/mixed; boundary="------------010108040700060303070401" X-Host-Lookup-Failed: Reverse DNS lookup failed for 212.85.157.144 (failed) X-Pg-Spam-Score: 0.2 (/) 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. --------------010108040700060303070401 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 --------------010108040700060303070401 Content-Type: text/x-patch; name="pgbench-hint-7.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pgbench-hint-7.patch" 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 @@ =20 #include "pgbench.h" =20 +#define ERRCODE_UNDEFINED_TABLE "42P01" + /* * Multi-platform pthread implementations */ @@ -3251,7 +3253,14 @@ main(int argc, char **argv) res =3D PQexec(con, "select count(*) from pgbench_branches"); if (PQresultStatus(res) !=3D PGRES_TUPLES_OK) { + char *sqlState =3D PQresultErrorField(res, PG_DIAG_SQLSTATE); + fprintf(stderr, "%s", PQerrorMessage(con)); + if (sqlState && strcmp(sqlState, ERRCODE_UNDEFINED_TABLE) =3D=3D 0) + { + fprintf(stderr, "Perhaps you need to do initialization (\"pgbench -i\"= ) in database \"%s\"\n", PQdb(con)); + } + exit(1); } scale =3D atoi(PQgetvalue(res, 0, 0)); --------------010108040700060303070401 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 --------------010108040700060303070401--