aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-04-25 03:19:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-04-25 03:19:27 +0000
commit95cc41b81dd3917a1b9bb0b7c9cbe231d2557760 (patch)
tree528782b9d55a9ceb7acbe4cc55c0699514ab284d /src/backend/tcop/postgres.c
parentfc08814e00c04cddad512494bb52d9266928619e (diff)
downloadpostgresql-95cc41b81dd3917a1b9bb0b7c9cbe231d2557760.tar.gz
postgresql-95cc41b81dd3917a1b9bb0b7c9cbe231d2557760.zip
Revise backend libpq interfaces so that messages to the frontend
can be generated in a buffer and then sent to the frontend in a single libpq call. This solves problems with NOTICE and ERROR messages generated in the middle of a data message or COPY OUT operation.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 231b88d620a..5e82de3edaa 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.107 1999/04/20 02:19:53 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.108 1999/04/25 03:19:10 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -52,6 +52,7 @@
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "libpq/libpq.h"
+#include "libpq/pqformat.h"
#include "libpq/libpq-be.h"
#include "libpq/pqsignal.h"
#include "nodes/pg_list.h"
@@ -304,15 +305,15 @@ InteractiveBackend(char *inBuf)
static char
SocketBackend(char *inBuf)
{
- char qtype[2];
+ char qtype;
char result = '\0';
/* ----------------
* get input from the frontend
* ----------------
*/
- strcpy(qtype, "?");
- if (pq_getnchar(qtype, 0, 1) == EOF)
+ qtype = '?';
+ if (pq_getbytes(&qtype, 1) == EOF)
{
/* ------------
* when front-end applications quits/dies
@@ -321,7 +322,7 @@ SocketBackend(char *inBuf)
proc_exit(0);
}
- switch (*qtype)
+ switch (qtype)
{
/* ----------------
* 'Q': user entered a query
@@ -358,7 +359,7 @@ SocketBackend(char *inBuf)
* ----------------
*/
default:
- elog(FATAL, "Socket command type %c unknown\n", *qtype);
+ elog(FATAL, "Socket command type %c unknown", qtype);
break;
}
return result;
@@ -1461,7 +1462,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
Portfd = open(NULL_DEV, O_RDWR | O_BINARY, 0666);
#endif
}
- pq_init(Portfd);
+ pq_init(); /* reset libpq */
whereToSendOutput = Remote;
}
else
@@ -1521,16 +1522,19 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (whereToSendOutput == Remote &&
PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2)
{
- pq_putnchar("K", 1);
- pq_putint((int32) MyProcPid, sizeof(int32));
- pq_putint((int32) MyCancelKey, sizeof(int32));
+ StringInfoData buf;
+ pq_beginmessage(&buf);
+ pq_sendbyte(&buf, 'K');
+ pq_sendint(&buf, (int32) MyProcPid, sizeof(int32));
+ pq_sendint(&buf, (int32) MyCancelKey, sizeof(int32));
+ pq_endmessage(&buf);
/* Need not flush since ReadyForQuery will do it. */
}
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.107 $ $Date: 1999/04/20 02:19:53 $\n");
+ puts("$Revision: 1.108 $ $Date: 1999/04/25 03:19:10 $\n");
}
/* ----------------