Re: bugfix - contrib/pgbench - Mailing list pgsql-patches

From Neil Conway
Subject Re: bugfix - contrib/pgbench
Date
Msg-id 4292758E.9000308@samurai.com
Whole thread Raw
In response to Re: bugfix - contrib/pgbench  (ITAGAKI Takahiro <itagaki.takahiro@lab.ntt.co.jp>)
List pgsql-patches
ITAGAKI Takahiro wrote:
> But this code seems to be an idiom,
> "Check the result, but drop commands may be fail".
> Drop commands might be added to DDLAFTERs some time, so we may leave it.

Possibly, but I think checking for something that cannot occur is
confusing to the reader (and besides, it is not correct in general to
ignore errors from _all_ DDL commands that begin with "drop"). So I just
removed the strncmp(). Thanks for the report; this is fixed in HEAD.

BTW, there is probably room for some refactoring here: the pattern

     res = PQexec(con, "...");
     if (PQresultStatus(res) != PGRES_COMMAND_OK)
     {
         fprintf(stderr, "...");
         exit(1);
     }

occurs frequently. That could be refactored into an exec_sql_cmd()
function or similar that would only return on non-error. Or at the very
least, a fatal_error() function that takes the error message and then
does the exit(1).

-Neil

pgsql-patches by date:

Previous
From: "John Hansen"
Date:
Subject: Re: character type value is not padded with spaces
Next
From: Neil Conway
Date:
Subject: Re: plperl tests for currently untested features