{
int len, len1;
char *p, *p1;
+ int i;
POOL_SESSION_CONTEXT *session_context;
POOL_CONNECTION *con;
- int slot_id;
/* Get session context */
session_context = pool_get_session_context(false);
handle_query_context(backend);
/*
- * Read backend data from the first valid node using sync map if operated
- * in streaming replication mode with extended protocol.
+ * If operated in streaming replication mode and doing an extended query,
+ * read backend message according to the query context.
*/
- if (STREAM && pool_is_doing_extended_query_message())
+ if (STREAM && pool_is_doing_extended_query_message())
{
- slot_id = pool_get_nth_sync_map(0);
- if (slot_id < 0)
- return POOL_END; /* this should not happen */
+ for (i=0;i<NUM_BACKENDS;i++)
+ {
+ if (VALID_BACKEND(i))
+ {
+ con = CONNECTION(backend, i);
+
+ if (pool_read(con, &len, sizeof(len)) < 0)
+ return POOL_END;
+
+ len = ntohl(len);
+ len -= 4;
+ len1 = len;
- con = backend->slots[slot_id]->con;
+ p = pool_read2(con, len);
+ if (p == NULL)
+ return POOL_END;
+ p1 = palloc(len);
+ memcpy(p1, p, len);
+ }
+ }
}
/*
- * Oterwise read from "MASTER" node.
+ * Otherwise just read from master node.
*/
else
{
con = MASTER(backend);
- }
-
- if (pool_read(con, &len, sizeof(len)) < 0)
- return POOL_END;
-
- len = ntohl(len);
- len -= 4;
- len1 = len;
-
- p = pool_read2(con, len);
- if (p == NULL)
- return POOL_END;
- p1 = palloc(len);
- memcpy(p1, p, len);
- /*
- * If operated in streaming replication mode and extended query mode, we
- * may need to read data from other node if any (SET or transaction
- * statements).
- */
- if (STREAM && pool_is_doing_extended_query_message())
- {
- slot_id = pool_get_nth_sync_map(1);
- if (slot_id >= 0)
- {
- con = backend->slots[slot_id]->con;
+ if (pool_read(con, &len, sizeof(len)) < 0)
+ return POOL_END;
- if (pool_read(con, &len, sizeof(len)) < 0)
- return POOL_END;
+ len = ntohl(len);
+ len -= 4;
+ len1 = len;
- len = ntohl(len);
- len -= 4;
-
- p = pool_read2(con, len);
- if (p == NULL)
- return POOL_END;
- }
+ p = pool_read2(con, len);
+ if (p == NULL)
+ return POOL_END;
+ p1 = palloc(len);
+ memcpy(p1, p, len);
}
/*