pgpool2.git / summary / log / commit / refs

commit    c555fc20baf1b9ecfe0cef5ff2af816775d873bf
Author:   Toshihiro Kitagawa <kitagawa@sraoss.co.jp>
Date:     Wed Feb 29 09:20:26 2012 +0000

    Fix hangup when PREPARE statement causes error.
    
    Query example to reproduce:
    PREPARE q4(nonexistenttype) AS select $1;
    
    This issue was reported by Tomonari Katsumata:
    Subject: [pgpool-general: 121] question of pgpool's behavior


pool_proto_modules.c | 40 ++++++++++++++++++++++++---------------- pool_session_context.h | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/pool_proto_modules.c b/pool_proto_modules.c index 603a3f050..7b2718335 100644 --- a/pool_proto_modules.c +++ b/pool_proto_modules.c @@ -1529,6 +1529,20 @@ POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, pool_handle_query_cache(backend, query, node, state); } } + /* + * If PREPARE or extended query protocol commands caused error, + * remove the temporary saved message. + */ + else + { + if (session_context->uncompleted_message) + { + pool_add_sent_message(session_context->uncompleted_message); + pool_remove_sent_message(session_context->uncompleted_message->kind, + session_context->uncompleted_message->name); + session_context->uncompleted_message = NULL; + } + } pool_unset_query_in_progress(); } @@ -1933,7 +1947,6 @@ POOL_STATUS ErrorResponse3(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { POOL_STATUS ret; - POOL_SESSION_CONTEXT *session_context; ret = SimpleForwardToFrontend('E', frontend, backend); if (ret != POOL_CONTINUE) @@ -1998,21 +2011,6 @@ POOL_STATUS ErrorResponse3(POOL_CONNECTION *frontend, } #endif - /* An error occurred with PREPARE or DEALLOCATE command. - * Free pending portal object. - */ - session_context = pool_get_session_context(); - if (session_context) - { - if (session_context->uncompleted_message) - { - pool_add_sent_message(session_context->uncompleted_message); - pool_remove_sent_message(session_context->uncompleted_message->kind, - session_context->uncompleted_message->name); - session_context->uncompleted_message = NULL; - } - } - return POOL_CONTINUE; } @@ -2159,7 +2157,15 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, return POOL_END; if (fkind != 'S' && pool_is_ignore_till_sync()) + { + /* + * Flag setting for calling ProcessBackendResponse() + * in pool_process_query(). + */ + if (!pool_is_query_in_progress()) + pool_set_query_in_progress(); return POOL_CONTINUE; + } pool_unset_doing_extended_query_message(); @@ -2284,6 +2290,8 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend, if (pool_is_ignore_till_sync()) { + if (pool_is_query_in_progress()) + pool_unset_query_in_progress(); return POOL_CONTINUE; } diff --git a/pool_session_context.h b/pool_session_context.h index 63fe9eebe..2e427dc6c 100644 --- a/pool_session_context.h +++ b/pool_session_context.h @@ -89,7 +89,7 @@ typedef struct { /* If true, we are doing extended query message */ bool doing_extended_query_message; - /* If true, the command in progress has finished sucessfully. */ + /* If true, the command in progress has finished successfully. */ bool command_success; /* If true, write query has been appeared in this transaction */ [parent: e2c0222183ac]