From cb917e1544612c187c74fed1a990e26820514c8a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 4 Apr 2012 16:15:04 -0400 Subject: [PATCH] Remove useless PGRES_COPY_BOTH "support" in psql. There is no existing or foreseeable case in which psql should see a PGRES_COPY_BOTH PQresultStatus; and if such a case ever emerges, it's a pretty good bet that these code fragments wouldn't do the right thing anyway. Remove them, and let the existing default cases do the appropriate thing, namely emit an "unexpected PQresultStatus" bleat. Noted while working on libpq row processor patch, for which I was considering adding a PGRES_SUSPENDED status code --- the same default-case treatment would be appropriate for that. --- src/bin/psql/common.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 715e23167d..33dc97e95f 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -450,7 +450,6 @@ AcceptResult(const PGresult *result) case PGRES_EMPTY_QUERY: case PGRES_COPY_IN: case PGRES_COPY_OUT: - case PGRES_COPY_BOTH: /* Fine, do nothing */ OK = true; break; @@ -673,29 +672,17 @@ ProcessResult(PGresult **results) result_status = PQresultStatus(*results); switch (result_status) { - case PGRES_COPY_BOTH: - /* - * No now-existing SQL command can yield PGRES_COPY_BOTH, but - * defend against the future. PQexec() can't short-circuit - * it's way out of a PGRES_COPY_BOTH, so the connection will - * be useless at this point. XXX is there a method for - * clearing this status that's likely to work with every - * future command that can initiate it? - */ - psql_error("unexpected PQresultStatus (%d)", result_status); - return false; - - case PGRES_COPY_OUT: - case PGRES_COPY_IN: - is_copy = true; - break; - case PGRES_EMPTY_QUERY: case PGRES_COMMAND_OK: case PGRES_TUPLES_OK: is_copy = false; break; + case PGRES_COPY_OUT: + case PGRES_COPY_IN: + is_copy = true; + break; + default: /* AcceptResult() should have caught anything else. */ is_copy = false; @@ -817,7 +804,6 @@ PrintQueryResults(PGresult *results) case PGRES_COPY_OUT: case PGRES_COPY_IN: - case PGRES_COPY_BOTH: /* nothing to do here */ success = true; break;