]> granicus.if.org Git - postgresql/commitdiff
Remove useless PGRES_COPY_BOTH "support" in psql.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 4 Apr 2012 20:15:04 +0000 (16:15 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 4 Apr 2012 20:15:04 +0000 (16:15 -0400)
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

index 715e23167de82709da99b8c8afa58d81935eb25c..33dc97e95f249576165adb28d7c59b556a2ea08b 100644 (file)
@@ -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;