pgpool2.git / summary / log / commit / refs

commit    7294f169b2ee75e74c35e68917522674f2377f1b
Author:   Toshihiro Kitagawa <kitagawa at sraoss.co.jp>
Date:     Wed Sep 01 06:10:08 2010 +0000

    Fix where_to_send so that DEALLOCATE works properly in replication mode or
    parallel mode.


pool_query_context.c | 74 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/pool_query_context.c b/pool_query_context.c index 252673dda..e6c7c660d 100644 --- a/pool_query_context.c +++ b/pool_query_context.c @@ -43,6 +43,7 @@ typedef enum { } POOL_DEST; static POOL_DEST send_to_where(Node *node, char *query); +static void where_to_send_deallocate(POOL_QUERY_CONTEXT *query_context, Node *node); /* * Create and initialize per query session context @@ -451,34 +452,7 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no */ else if (IsA(node, DeallocateStmt)) { - DeallocateStmt *d = (DeallocateStmt *)node; - bool *wts; - - /* DELLOCATE ALL? */ - if (d->name == NULL) - { - pool_setall_node_to_be_sent(query_context); - } - else - { - wts = pool_get_prep_where(d->name); - if (wts) - { - /* Inherit same map from PREPARE */ - pool_copy_prep_where(wts, query_context->where_to_send); - } - else - { - PreparedStatement *ps; - - ps = pool_get_prepared_statement_by_pstmt_name(d->name); - if (ps) - { - if (ps->qctxt) - pool_copy_prep_where(ps->qctxt->where_to_send, query_context->where_to_send); - } - } - } + where_to_send_deallocate(query_context, node); } } else if (REPLICATION || PARALLEL_MODE) @@ -507,6 +481,13 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no pool_set_node_to_be_sent(query_context, REAL_MASTER_NODE_ID); } } + /* + * DEALLOCATE? + */ + else if (IsA(node, DeallocateStmt)) + { + where_to_send_deallocate(query_context, node); + } else { /* send to all nodes */ @@ -988,6 +969,43 @@ static POOL_DEST send_to_where(Node *node, char *query) return POOL_PRIMARY; } +static +void where_to_send_deallocate(POOL_QUERY_CONTEXT *query_context, Node *node) +{ + DeallocateStmt *d = (DeallocateStmt *)node; + bool *wts; + + /* DELLOCATE ALL? */ + if (d->name == NULL) + { + pool_setall_node_to_be_sent(query_context); + return; + } + else + { + wts = pool_get_prep_where(d->name); + if (wts) + { + /* Inherit same map from PREPARE */ + pool_copy_prep_where(wts, query_context->where_to_send); + return; + } + else + { + PreparedStatement *ps; + + ps = pool_get_prepared_statement_by_pstmt_name(d->name); + if (ps && ps->qctxt) + { + pool_copy_prep_where(ps->qctxt->where_to_send, query_context->where_to_send); + return; + } + } + } + /* prepared statement was not found */ + pool_setall_node_to_be_sent(query_context); +} + /* * Returns parse tree for current query. * Preconition: the query is in progress state. [parent: 00e00d227357]