no pg_hba.conf entries. Patches contributed by Kenji Kikuchi.
See [Pgpool-general] Small change for v3 formatted ErrorResponce
handling. on 2006/8/26 for more details.
extern POOL_STATUS ErrorResponse(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend);
+extern POOL_STATUS ErrorResponse2(POOL_CONNECTION *frontend,
+ POOL_CONNECTION_POOL *backend);
extern POOL_STATUS NoticeResponse(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend);
extern int pool_read_message_length(POOL_CONNECTION_POOL *cp);
extern int *pool_read_message_length2(POOL_CONNECTION_POOL *cp);
extern signed char pool_read_kind(POOL_CONNECTION_POOL *cp);
+extern signed char pool_read_kind2(POOL_CONNECTION_POOL *cp);
extern POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
extern POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
protoMajor = MAJOR(cp);
- kind = pool_read_kind(cp);
+ if (protoMajor == PROTO_MAJOR_V3)
+ {
+ kind = pool_read_kind2(cp);
+ }
+ else
+ {
+ kind = pool_read_kind(cp);
+ }
+
if (kind < 0)
{
return -1;
* will negotiate again using v2 protocol.
*/
pool_log("pool_do_auth: maybe protocol version mismatch (current version %d)", protoMajor);
- ErrorResponse(frontend, cp);
+ if (protoMajor == PROTO_MAJOR_V3)
+ {
+ ErrorResponse2(frontend, cp);
+ }
+ else
+ {
+ ErrorResponse(frontend, cp);
+ }
return -1;
}
else if (kind != 'R')
return kind;
}
+
+signed char pool_read_kind2(POOL_CONNECTION_POOL *cp)
+{
+ int status;
+ char kind, kind1;
+ char *buf;
+
+ buf = pool_read2(MASTER(cp), sizeof(kind));
+ if (buf == NULL)
+ {
+ pool_error("read_kind2: error while reading message kind");
+ return -1;
+ }
+
+ kind = *buf;
+
+ if (DUAL_MODE)
+ {
+ status = pool_read(SECONDARY(cp), &kind1, sizeof(kind1));
+ if (status < 0)
+ {
+ pool_error("read_kind2: error while reading message kind from secondary backend");
+ return -1;
+ }
+
+ if (kind != kind1)
+ {
+ pool_error("read_kind2: kind does not match between backends master(%d) secondary(%d)",
+ kind, kind1);
+ return -1;
+ }
+ }
+
+ return kind;
+}
return POOL_CONTINUE;
}
+POOL_STATUS ErrorResponse2(POOL_CONNECTION *frontend,
+ POOL_CONNECTION_POOL *backend)
+{
+ char *buf;
+ int len;
+
+ /* forward to the frontend */
+ pool_write(frontend, "E", 1);
+
+ /* read error message length */
+ if ((buf = pool_read2(MASTER(backend), sizeof(len))) == NULL)
+ return POOL_END;
+
+ /* forward to the frontend */
+ if (pool_write_and_flush(frontend, buf, sizeof(len)) < 0)
+ return POOL_END;
+
+ len = ntohl(*(int *)buf) - sizeof(len);
+ if(len < 8 || len > 30000)
+ {
+ /* Handle error from a pre-3.0 server */
+ /* read error message */
+ if ((buf = pool_read_string(MASTER(backend), &len, 0)) == NULL)
+ return POOL_END;
+
+ /* forward to the frontend */
+ if (pool_write_and_flush(frontend, buf, len) < 0)
+ return POOL_END;
+ }
+ else
+ {
+ /* read rest of error message */
+ if ((buf = pool_read2(MASTER(backend), len)) == NULL)
+ return POOL_END;
+
+ /* forward to the frontend */
+ if (pool_write_and_flush(frontend, buf, len) < 0)
+ return POOL_END;
+ }
+
+ return POOL_CONTINUE;
+}
+
POOL_STATUS NoticeResponse(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend)
{