Don't treat parameter status mismatch as fatal.
authorTatsuo Ishii <ishii at sraoss.co.jp>
Sat, 21 May 2005 11:31:47 +0000 (11:31 +0000)
committerTatsuo Ishii <ishii at sraoss.co.jp>
Sat, 21 May 2005 11:31:47 +0000 (11:31 +0000)
Some parameters such as TimeZone may not identical among servers
if they are located at different countries (or places).

pool.h
pool_auth.c
pool_process_query.c

diff --git a/pool.h b/pool.h
index 4b8242050b4f1187f782ccbf813107b0dfe103d0..027f2a53b125b044365ecd9a2387c1b2abba3929 100644 (file)
--- a/pool.h
+++ b/pool.h
@@ -288,6 +288,7 @@ extern void pool_disable_timeout(void);
 extern void pool_send_frontend_exits(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 POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
index 7c919f68413432a92582c6028c1fa2878ef98eaf..d4a1157ef1df9466b46f08d1f89954f9c59976e7 100644 (file)
@@ -895,6 +895,55 @@ int pool_read_message_length(POOL_CONNECTION_POOL *cp)
        return length;
 }
 
+/*
+ * read message length2 (V3 only)
+ * unlike pool_read_message_length, this returns an array of message length.
+ * the array is in the static storage, thus it will be destroyed by subsequent calls.
+ */
+int *pool_read_message_length2(POOL_CONNECTION_POOL *cp)
+{
+       int status;
+       int length, length1;
+       static int length_array[MAX_CONNECTION_SLOTS];
+
+       status = pool_read(MASTER(cp), &length, sizeof(length));
+       if (status < 0)
+       {
+               pool_error("read_message_length2: error while reading message length");
+               return NULL;
+       }
+       length = ntohl(length);
+
+       pool_debug("read_message_length2: master lenghth: %d", length);
+
+       if (DUAL_MODE)
+       {
+               status = pool_read(SECONDARY(cp), &length1, sizeof(length1));
+               if (status < 0)
+               {
+                       pool_error("read_message_length2: error while reading message length from secondary backend");
+                       return NULL;
+               }
+               length1 = ntohl(length1);
+
+               if (length != length1)
+               {
+                       pool_debug("read_message_length2: length does not match between backends master(%d) secondary(%d)",
+                                          length, length1);
+               }
+       }
+
+       if (length < 0 || length1 < 0)
+       {
+               pool_error("read_message_length2: invalid message length (%d) length1 (%d)", length, length1);
+               return NULL;
+       }
+
+       length_array[0] = length;
+       length_array[1] = length1;
+       return &length_array[0];
+}
+
 signed char pool_read_kind(POOL_CONNECTION_POOL *cp)
 {
        int status;
index 3b60dd63423e8b477f0c96eb0f687f6416b24e0c..58dd37ee9d668e8d0d7c4aa0135fe1da10401aed 100644 (file)
@@ -2005,6 +2005,7 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO
 POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
 {
        int len;
+       int *len_array;
        int sendlen;
        char *p;
        char *name;
@@ -2012,12 +2013,14 @@ POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
 
        pool_write(frontend, "S", 1);
 
-       len = pool_read_message_length(backend);
-       if (len < 0)
+       len_array = pool_read_message_length2(backend);
+
+       if (len_array == NULL)
        {
                return POOL_END;
        }
 
+       len = len_array[0];
        sendlen = htonl(len);
        pool_write(frontend, &sendlen, sizeof(sendlen));
 
@@ -2039,7 +2042,7 @@ POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
 #endif
 
        if (DUAL_MODE)
-               if (pool_read2(SECONDARY(backend), len) == NULL)
+               if (pool_read2(SECONDARY(backend), len_array[1]-4) == NULL)
                        return POOL_END;
 
        return pool_write(frontend, p, len);