summaryrefslogtreecommitdiff
path: root/src/include/libpq/pqcomm.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-04-17 22:26:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-04-17 22:26:02 +0000
commitcb7fb3ca958ec8bd5a14e740c067f1d096af3454 (patch)
tree3494f623627ebebb9590c0ab993297a719bfe7f2 /src/include/libpq/pqcomm.h
parent76fd678c06b826ae50aac5c4afb2e01e69d2b405 (diff)
downloadpostgresql-cb7fb3ca958ec8bd5a14e740c067f1d096af3454.tar.gz
First phase of FE/BE protocol modifications: new StartupPacket layout
with variable-width fields. No more truncation of long user names. Also, libpq can now send its environment-variable-driven SET commands as part of the startup packet, saving round trips to server.
Diffstat (limited to 'src/include/libpq/pqcomm.h')
-rw-r--r--src/include/libpq/pqcomm.h54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index 7c476699f0..fabfb0cb25 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -9,14 +9,13 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.75 2003/01/06 09:58:36 petere Exp $
+ * $Id: pqcomm.h,v 1.76 2003/04/17 22:26:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PQCOMM_H
#define PQCOMM_H
-#include <sys/types.h>
#ifdef WIN32
#include <winsock.h>
/* workaround for clashing defines of "ERROR" */
@@ -93,7 +92,7 @@ typedef union SockAddr
* functionality).
*
* If a backend supports version m.n of the protocol it must actually support
- * versions m.0..n]. Backend support for version m-1 can be dropped after a
+ * versions m.[0..n]. Backend support for version m-1 can be dropped after a
* `reasonable' length of time.
*
* A frontend isn't required to support anything other than the current
@@ -107,27 +106,26 @@ typedef union SockAddr
/* The earliest and latest frontend/backend protocol version supported. */
#define PG_PROTOCOL_EARLIEST PG_PROTOCOL(1,0)
-#define PG_PROTOCOL_LATEST PG_PROTOCOL(2,0)
+#define PG_PROTOCOL_LATEST PG_PROTOCOL(3,100) /* XXX temporary value */
-/*
- * All packets sent to the postmaster start with the length. This is omitted
- * from the different packet definitions specified below.
- */
+typedef uint32 ProtocolVersion; /* FE/BE protocol version number */
-typedef uint32 PacketLen;
+typedef ProtocolVersion MsgType;
/*
- * Startup message parameters sizes. These must not be changed without changing
- * the protocol version. These are all strings that are '\0' terminated only if
- * there is room.
+ * Packet lengths are 4 bytes in network byte order.
+ *
+ * The initial length is omitted from the packet layouts appearing below.
*/
+typedef uint32 PacketLen;
+
+
/*
- * FIXME: remove the fixed size limitations on the database name, user
- * name, and options fields and use a variable length field instead. The
- * actual limits on database & user name will then be NAMEDATALEN, which
- * can be changed without changing the FE/BE protocol. -neilc,2002/08/27
+ * Old-style startup packet layout with fixed-width fields. This is used in
+ * protocol 1.0 and 2.0, but not in later versions. Note that the fields
+ * in this layout are '\0' terminated only if there is room.
*/
#define SM_DATABASE 64
@@ -138,11 +136,6 @@ typedef uint32 PacketLen;
#define SM_UNUSED 64
#define SM_TTY 64
-typedef uint32 ProtocolVersion; /* Fe/Be protocol version number */
-
-typedef ProtocolVersion MsgType;
-
-
typedef struct StartupPacket
{
ProtocolVersion protoVersion; /* Protocol version */
@@ -156,7 +149,16 @@ typedef struct StartupPacket
extern bool Db_user_namespace;
-/* These are the authentication requests sent by the backend. */
+/*
+ * In protocol 3.0 and later, the startup packet length is not fixed, but
+ * we set an arbitrary limit on it anyway. This is just to prevent simple
+ * denial-of-service attacks via sending enough data to run the server
+ * out of memory.
+ */
+#define MAX_STARTUP_PACKET_LENGTH 10000
+
+
+/* These are the authentication request codes sent by the backend. */
#define AUTH_REQ_OK 0 /* User is authenticated */
#define AUTH_REQ_KRB4 1 /* Kerberos V4 */
@@ -169,12 +171,12 @@ extern bool Db_user_namespace;
typedef uint32 AuthRequest;
-/* A client can also send a cancel-current-operation request to the postmaster.
+/*
+ * A client can also send a cancel-current-operation request to the postmaster.
* This is uglier than sending it directly to the client's backend, but it
* avoids depending on out-of-band communication facilities.
- */
-
-/* The cancel request code must not match any protocol version number
+ *
+ * The cancel request code must not match any protocol version number
* we're ever likely to use. This random choice should do.
*/
#define CANCEL_REQUEST_CODE PG_PROTOCOL(1234,5678)