pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marina Polyakova <m.polyakova@postgrespro.ru>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: pgsql-hackers@postgresql.org, Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>
Cc: Teodor Sigaev <teodor@sigaev.ru>
Subject: Re: [HACKERS] WIP Patch: Pgbench Serialization and deadlock errors
Date: Thu, 14 Jun 2018 15:11:13 +0300
Message-ID: <c89fcc380a19380260b5ea463efc1416@postgrespro.ru> (raw)

On 13-06-2018 22:59, Alvaro Herrera wrote:
> For context: in the backend, elog() is only used for internal messages
> (i.e. "can't-happen" conditions), and ereport() is used for user-facing
> messages.  There are many things ereport() has that elog() doesn't, 
> such
> as additional message fields (HINT, DETAIL, etc) that I think could 
> have
> some use in pgbench as well.  If you use elog() then you can't have 
> that.

AFAIU originally it was not supposed that the pgbench error messages 
have these fields, so will it be good to change the final output to 
stderr?.. For example:

-		fprintf(stderr, "%s", PQerrorMessage(con));
-		fprintf(stderr, "(ignoring this error and continuing anyway)\n");
+		ereport(LOG,
+				(errmsg("Ignoring the server error and continuing anyway"),
+				 errdetail("%s", PQerrorMessage(con))));

-			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);
+			ereport(ERROR,
+					(errmsg("Server error"),
+					 errdetail("%s", PQerrorMessage(con)),
+					 sqlState && strcmp(sqlState, ERRCODE_UNDEFINED_TABLE) == 0 ?
+					 errhint("Perhaps you need to do initialization (\"pgbench -i\") 
in database \"%s\"\n",
+							 PQdb(con)) : 0));

-- 
Marina Polyakova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company




view thread (137+ messages)  latest in thread

Message-ID: <c89fcc380a19380260b5ea463efc1416@postgrespro.ru>
Permalink:  ../c89fcc380a19380260b5ea463efc1416@postgrespro.ru/
Also on:    postgresql.org/message-id/c89fcc380a19380260b5ea463efc1416@postgrespro.ru

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: m.polyakova@postgrespro.ru, alvherre@2ndquadrant.com, coelho@cri.ensmp.fr, i.kurbangaliev@postgrespro.ru, teodor@sigaev.ru
  Subject: Re: [HACKERS] WIP Patch: Pgbench Serialization and deadlock errors
  In-Reply-To: <c89fcc380a19380260b5ea463efc1416@postgrespro.ru>

* 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