Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4540a8b

Browse files
committed
Fix multiple "C" from backend.
1 parenta952d67 commit4540a8b

File tree

1 file changed

+20
-46
lines changed

1 file changed

+20
-46
lines changed

‎src/interfaces/libpq/fe-exec.c

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.21 1996/12/15 09:05:53 bryanh Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.22 1996/12/20 20:34:38 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -362,16 +362,13 @@ PGresult*
362362
PQexec(PGconn*conn,constchar*query)
363363
{
364364
PGresult*result;
365-
intid,clear,error;
365+
intid;
366366
charbuffer[MAX_MESSAGE_LEN];
367367
charcmdStatus[MAX_MESSAGE_LEN];
368368
charpname[MAX_MESSAGE_LEN];/* portal name */
369369
PGnotify*newNotify;
370370
FILE*pfin,*pfout,*pfdebug;
371-
372-
#ifdefPQ_NOTIFY_PATCH
373-
intisCommand=0;/* DZ - 31-8-1996 */
374-
#endif
371+
intemptiesSent=0;
375372

376373
pname[0]='\0';
377374

@@ -412,7 +409,7 @@ PQexec(PGconn* conn, const char* query)
412409
"-- fprintf to Pfout failed: errno=%d\n%s\n",
413410
query,errno,strerror(errno));
414411
returnNULL;
415-
}
412+
}
416413

417414
/* loop forever because multiple messages, especially NOTICES,
418415
can come back from the backend
@@ -458,38 +455,12 @@ PQexec(PGconn* conn, const char* query)
458455
// send an empty query down, and keep reading out of the pipe
459456
// until an 'I' is received.
460457
*/
461-
clear=0;
462-
error=0;
463-
464458
pqPuts("Q ",pfout,pfdebug);/* send an empty query */
465-
#ifdefPQ_NOTIFY_PATCH
466459
/*
467-
*Set a flag and process messages in the usual way because
460+
*Increment a flag and process messages in the usual way because
468461
* there may be async notifications pending. DZ - 31-8-1996
469462
*/
470-
isCommand=1;
471-
#else
472-
while (!clear)
473-
{
474-
if (pqGets(buffer,ERROR_MSG_LENGTH,pfin,pfdebug)==1)
475-
clear=1;
476-
/*
477-
// Rules can create error messages while we are waiting
478-
// for the 'I'.
479-
*/
480-
if (buffer[0]=='E') {
481-
strcpy(conn->errorMessage,&buffer[1]);
482-
error++;
483-
}
484-
clear= (buffer[0]=='I');
485-
}
486-
if (error) {
487-
return (PGresult*)NULL;
488-
}
489-
result=makeEmptyPGresult(conn,PGRES_COMMAND_OK);
490-
strncpy(result->cmdStatus,cmdStatus,CMDSTATUS_LEN-1);
491-
returnresult;
492-
#endif
463+
emptiesSent++;
493464
}
494465
break;
495466
case'E':/* error return */
@@ -507,17 +478,21 @@ PQexec(PGconn* conn, const char* query)
507478
if ((c=pqGetc(pfin,pfdebug))!='\0') {
508479
fprintf(stderr,"error!, unexpected character %c following 'I'\n",c);
509480
}
510-
if (isCommand) {
511-
/*
512-
* If this is the result of a portal query command set the
513-
* command status and message accordingly. DZ - 31-8-1996
514-
*/
515-
result=makeEmptyPGresult(conn,PGRES_COMMAND_OK);
516-
strncpy(result->cmdStatus,cmdStatus,CMDSTATUS_LEN-1);
481+
if (emptiesSent) {
482+
if (--emptiesSent==0) {/* is this the last one? */
483+
/*
484+
* If this is the result of a portal query command set the
485+
* command status and message accordingly. DZ - 31-8-1996
486+
*/
487+
result=makeEmptyPGresult(conn,PGRES_COMMAND_OK);
488+
strncpy(result->cmdStatus,cmdStatus,CMDSTATUS_LEN-1);
489+
returnresult;
490+
}
491+
}
492+
else {
493+
result=makeEmptyPGresult(conn,PGRES_EMPTY_QUERY);
517494
returnresult;
518495
}
519-
result=makeEmptyPGresult(conn,PGRES_EMPTY_QUERY);
520-
returnresult;
521496
}
522497
break;
523498
case'N':/* notices from the backend */
@@ -548,8 +523,7 @@ PQexec(PGconn* conn, const char* query)
548523
id);
549524
return (PGresult*)NULL;
550525
}/* switch */
551-
}/* while (1)*/
552-
526+
}/* while (1)*/
553527
}
554528

555529
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp