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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to