pgpool2.git / summary / log / commit / refs

commit    52a0221a30fd83f8628101e3edf2b338416bcf94
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Wed Jul 21 00:41:04 2010 +0000

    Fix ProcessFrontendResponse so that Function call request
    to be processed properly in master/slave mode.


pool_proto_modules.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pool_proto_modules.c b/pool_proto_modules.c index ed9950564..7ee3c2d1c 100644 --- a/pool_proto_modules.c +++ b/pool_proto_modules.c @@ -1435,6 +1435,33 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, (fkind == 'S' || fkind == 'H' || fkind == 'D' || fkind == 'f'|| fkind == 'C' || fkind == 'B' || fkind == 'F' || fkind == 'd' || fkind == 'c')) { + /* Function call? */ + if (fkind == 'F' && MASTER_SLAVE) + { + /* + * Send to primary/master node only. + * For this we treat function call as if INSERT. + */ + POOL_QUERY_CONTEXT *query_context; + char *query = "INSERT INTO foo VALUES(1)"; + Node *node; + List *parse_tree_list; + + /* Create query context */ + query_context = pool_init_query_context(); + if (!query_context) + { + pool_error("ProcessFrontendResponse: pool_init_query_context failed"); + return POOL_END; + } + parse_tree_list = raw_parser(query); + node = (Node *) lfirst(list_head(parse_tree_list)); + pool_start_query(query_context, query, node); + pool_where_to_send(query_context, query_context->original_query, + query_context->parse_tree); + } + +#ifdef NOT_USED if (MASTER_SLAVE && (TSTATE(backend, MASTER_NODE_ID) != 'I' || receive_extended_begin)) { @@ -1443,6 +1470,7 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, MASTER_SLAVE = 0; master_slave_dml = 1; } +#endif status = SimpleForwardToBackend(fkind, frontend, backend); for (i=0;i<NUM_BACKENDS;i++) @@ -1456,6 +1484,7 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, } else if (MAJOR(backend) == PROTO_MAJOR_V2 && fkind == 'F') status = FunctionCall(frontend, backend); + else { pool_error("ProcessFrontendResponse: unknown message type %c(%02x)", fkind, fkind); [parent: dd5fe2d7d429]