summaryrefslogtreecommitdiff
path: root/src/include/libpq
diff options
context:
space:
mode:
authorTom Lane1999-04-25 03:19:27 +0000
committerTom Lane1999-04-25 03:19:27 +0000
commit95cc41b81dd3917a1b9bb0b7c9cbe231d2557760 (patch)
tree528782b9d55a9ceb7acbe4cc55c0699514ab284d /src/include/libpq
parentfc08814e00c04cddad512494bb52d9266928619e (diff)
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/include/libpq')
-rw-r--r--src/include/libpq/libpq.h72
-rw-r--r--src/include/libpq/pqcomm.h22
-rw-r--r--src/include/libpq/pqformat.h31
3 files changed, 48 insertions, 77 deletions
diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h
index 99d408d9c1..873992739e 100644
--- a/src/include/libpq/libpq.h
+++ b/src/include/libpq/libpq.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq.h,v 1.27 1999/02/13 23:21:35 momjian Exp $
+ * $Id: libpq.h,v 1.28 1999/04/25 03:19:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -121,17 +121,6 @@ extern PortalEntry **portals;
extern size_t portals_array_size;
/*
- * Asynchronous notification
- */
-typedef struct PQNotifyList
-{
- char relname[NAMEDATALEN]; /* listen/notify name */
- int be_pid; /* process id of backend */
- int valid; /* has this already been handled by user. */
-/* SLNode Node; */
-} PQNotifyList;
-
-/*
* Exceptions.
*/
@@ -194,11 +183,6 @@ extern char *PQgetvalue(PortalBuffer *portal, int tuple_index, int field_number)
extern char *PQgetAttr(PortalBuffer *portal, int tuple_index, int field_number);
extern int PQgetlength(PortalBuffer *portal, int tuple_index, int field_number);
extern void PQclear(char *pname);
-extern void PQcleanNotify(void);
-extern void PQnotifies_init(void);
-extern PQNotifyList *PQnotifies(void);
-extern void PQremoveNotify(PQNotifyList *nPtr);
-extern void PQappendNotify(char *relname, int pid);
/*
* prototypes for functions in portalbuf.c
@@ -250,51 +234,19 @@ extern int32 pqtest(struct varlena * vlena);
/*
* prototypes for functions in pqcomm.c
*/
-extern void pq_init(int fd);
-extern void pq_gettty(char *tp);
-extern int pq_getport(void);
-extern void pq_close(void);
-extern int pq_flush(void);
-extern int pq_recvbuf(void);
-extern int pq_getstr(char *s, int maxlen);
-extern int PQgetline(char *s, int maxlen);
-extern int PQputline(char *s);
-extern int pq_getchar(void);
-extern int pq_peekchar(void);
-extern int pq_getnchar(char *s, int off, int maxlen);
-extern int pq_getint(int b);
-extern int pq_putchar(unsigned char c);
-extern void pq_putstr(char *s);
-extern void pq_putnchar(char *s, int n);
-extern void pq_putint(int i, int b);
-extern int pq_getinaddr(struct sockaddr_in * sin, char *host, int port);
-extern int pq_getinserv(struct sockaddr_in * sin, char *host, char *serv);
-
-#ifdef MULTIBYTE
-extern void pq_putncharlen(char *s, int n);
-
-#endif
-
-extern int pq_connect(char *dbname, char *user, char *args, char *hostName,
- char *debugTty, char *execFile, short portName);
-extern int StreamOpen(char *hostName, short portName, Port *port);
-extern void StreamDoUnlink(void);
extern int StreamServerPort(char *hostName, short portName, int *fdP);
extern int StreamConnection(int server_fd, Port *port);
extern void StreamClose(int sock);
-
-/*
- * Internal send/receive buffers in libpq.
- * These probably shouldn't be global at all, but unless we merge
- * pqcomm.c and pqcomprim.c they have to be...
- */
-
-#define PQ_BUFFER_SIZE 8192
-
-extern unsigned char PqSendBuffer[PQ_BUFFER_SIZE];
-extern int PqSendPointer; /* Next index to store a byte in PqSendBuffer */
-extern unsigned char PqRecvBuffer[PQ_BUFFER_SIZE];
-extern int PqRecvPointer; /* Next index to read a byte from PqRecvBuffer */
-extern int PqRecvLength; /* End of data available in PqRecvBuffer */
+extern void pq_init(void);
+extern int pq_getport(void);
+extern void pq_close(void);
+extern int pq_getbytes(char *s, size_t len);
+extern int pq_getstring(char *s, size_t len);
+extern int pq_peekbyte(void);
+extern int pq_putbytes(const char *s, size_t len);
+extern int pq_flush(void);
+extern int pq_putmessage(char msgtype, const char *s, size_t len);
+extern void pq_startcopyout(void);
+extern void pq_endcopyout(bool errorAbort);
#endif /* LIBPQ_H */
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index 2245b83d62..53542993d8 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -3,16 +3,20 @@
* pqcomm.h
* Definitions common to frontends and backends.
*
+ * NOTE: for historical reasons, this does not correspond to pqcomm.c.
+ * pqcomm.c's routines are declared in libpq.h.
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.33 1999/02/13 23:21:36 momjian Exp $
+ * $Id: pqcomm.h,v 1.34 1999/04/25 03:19:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PQCOMM_H
#define PQCOMM_H
+#include "postgres.h"
+
#include <stdio.h>
#include <sys/types.h>
#ifdef WIN32
@@ -23,8 +27,6 @@
#include <netinet/in.h>
#endif
-#include "postgres.h"
-
/* Define a generic socket address type. */
typedef union SockAddr
@@ -151,18 +153,4 @@ typedef struct CancelRequestPacket
uint32 cancelAuthCode; /* secret key to authorize cancel */
} CancelRequestPacket;
-
-/* in pqcomprim.c */
-int pqGetShort(int *);
-int pqGetLong(int *);
-int pqGetNBytes(char *, size_t);
-int pqGetString(char *, size_t);
-int pqGetByte(void);
-
-int pqPutShort(int);
-int pqPutLong(int);
-int pqPutNBytes(const char *, size_t);
-int pqPutString(const char *);
-int pqPutByte(int);
-
#endif /* PQCOMM_H */
diff --git a/src/include/libpq/pqformat.h b/src/include/libpq/pqformat.h
new file mode 100644
index 0000000000..2fe48539a2
--- /dev/null
+++ b/src/include/libpq/pqformat.h
@@ -0,0 +1,31 @@
+/*-------------------------------------------------------------------------
+ *
+ * pqformat.h
+ * Definitions for formatting and parsing frontend/backend messages
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: pqformat.h,v 1.1 1999/04/25 03:19:14 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PQFORMAT_H
+#define PQFORMAT_H
+
+#include "postgres.h"
+#include "lib/stringinfo.h"
+
+#define pq_beginmessage(buf) initStringInfo(buf)
+
+extern void pq_sendbyte(StringInfo buf, int byt);
+extern void pq_sendbytes(StringInfo buf, const char *data, int datalen);
+extern void pq_sendtext(StringInfo buf, const char *str, int slen);
+extern void pq_sendstring(StringInfo buf, const char *str, int slen);
+extern void pq_sendint(StringInfo buf, int i, int b);
+extern void pq_endmessage(StringInfo buf);
+
+extern int pq_getint(int *result, int b);
+extern int pq_getstr(char *s, int maxlen);
+extern int pq_getnchar(char *s, int len);
+
+#endif /* PQFORMAT_H */