pgpool2.git / summary / log / commit / refs
commit 22183175582f80a4e055d59230966b60bed7b76f
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Sun Jun 20 10:31:03 2010 +0000
Fix pool_where_to_send in case of SELECT+transaction case.
pool_query_context.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/pool_query_context.c b/pool_query_context.c
index 725345509..425cbed68 100644
--- a/pool_query_context.c
+++ b/pool_query_context.c
@@ -262,13 +262,21 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no
else
{
if (pool_config->load_balance_mode &&
- MAJOR(backend) == PROTO_MAJOR_V3 &&
- TSTATE(backend) == 'I' &&
- is_select_query(node, query))
+ is_select_query(node, query) &&
+ MAJOR(backend) == PROTO_MAJOR_V3)
{
- /* load balance */
- pool_set_node_to_be_sent(query_context,
- session_context->load_balance_node_id);
+ /* Outside of an explicit transaction? */
+ if (TSTATE(backend) == 'I')
+ {
+ /* Load balance */
+ pool_set_node_to_be_sent(query_context,
+ session_context->load_balance_node_id);
+ }
+ else
+ {
+ /* Send to the primary only */
+ pool_set_node_to_be_sent(query_context, REAL_MASTER_NODE_ID);
+ }
}
else
{
[parent: 1c194b98c311]