77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.26 1996/12/31 07:29:15 bryanh Exp $
10+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.27 1997/01/08 23:25:32 scrappy Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -380,6 +380,10 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
380380 responses, less the number of corresponding responses we have
381381 received.
382382 */
383+ int errors ;
384+ /* If an error is received, we must still drain out the empty
385+ queries sent. So we need another flag.
386+ */
383387char cmdStatus [MAX_MESSAGE_LEN ];
384388char pname [MAX_MESSAGE_LEN ];/* portal name */
385389
@@ -388,6 +392,7 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
388392 */
389393
390394emptiesSent = 0 ;/* No empty queries sent yet */
395+ errors = 0 ;/* No errors received yet */
391396pname [0 ]= '\0' ;
392397
393398done = false;/* initial value */
@@ -444,7 +449,10 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
444449"but attempt to read the error message failed." );
445450 }
446451* result_p = (PGresult * )NULL ;
447- done = true;
452+ errors ++ ;
453+ if (emptiesSent == 0 ) {
454+ done = true;
455+ }
448456break ;
449457case 'I' : {/* empty query */
450458/* read and throw away the closing '\0' */
@@ -458,13 +466,21 @@ process_response_from_backend(FILE *pfin, FILE *pfout, FILE *pfdebug,
458466 * If this is the result of a portal query command set the
459467 * command status and message accordingly. DZ - 31-8-1996
460468 */
461- * result_p = makeEmptyPGresult (conn ,PGRES_COMMAND_OK );
462- strncpy ((* result_p )-> cmdStatus ,cmdStatus ,CMDSTATUS_LEN - 1 );
469+ if (!errors ) {
470+ * result_p = makeEmptyPGresult (conn ,PGRES_COMMAND_OK );
471+ strncpy ((* result_p )-> cmdStatus ,cmdStatus ,CMDSTATUS_LEN - 1 );
472+ }else {
473+ * result_p = (PGresult * )NULL ;
474+ }
463475done = true;
464476 }
465477 }
466478else {
467- * result_p = makeEmptyPGresult (conn ,PGRES_EMPTY_QUERY );
479+ if (!errors ) {
480+ * result_p = makeEmptyPGresult (conn ,PGRES_EMPTY_QUERY );
481+ }else {
482+ * result_p = (PGresult * )NULL ;
483+ }
468484done = true;
469485 }
470486 }