Fix sanity-check code that mistakenly assumed error and notice messages
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Dec 2003 17:44:05 +0000 (17:44 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Dec 2003 17:44:05 +0000 (17:44 +0000)
could never exceed 30K.  Per report from Andreas Pflug.

src/interfaces/libpq/fe-protocol3.c

index bd9bd12d966a628e163cb4507d9797d1e60020dd..ddc01aff585210805693f5304d8fea80101b3989 100644 (file)
 #endif
 
 
+/*
+ * This macro lists the backend message types that could be "long" (more
+ * than a couple of kilobytes).
+ */
+#define VALID_LONG_MESSAGE_TYPE(id) \
+       ((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'V' || \
+        (id) == 'E' || (id) == 'N' || (id) == 'A')
+
+
 static void handleSyncLoss(PGconn *conn, char id, int msgLength);
 static int     getRowDescriptions(PGconn *conn);
 static int     getAnotherTuple(PGconn *conn, int msgLength);
@@ -83,8 +92,7 @@ pqParseInput3(PGconn *conn)
                        handleSyncLoss(conn, id, msgLength);
                        return;
                }
-               if (msgLength > 30000 &&
-                       !(id == 'T' || id == 'D' || id == 'd'))
+               if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
                {
                        handleSyncLoss(conn, id, msgLength);
                        return;
@@ -1257,8 +1265,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
                        handleSyncLoss(conn, id, msgLength);
                        break;
                }
-               if (msgLength > 30000 &&
-                       !(id == 'T' || id == 'D' || id == 'd' || id == 'V'))
+               if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
                {
                        handleSyncLoss(conn, id, msgLength);
                        break;