pgpool2.git / summary / log / commit / refs
commit 6ac7bb2c88986ab341cf25bcd5d4c491f18ff272
Author: Yoshiyuki Asaba <y-asaba at pgfoundry.org>
Date: Mon Nov 05 05:26:21 2007 +0000
Fix insert_lock with extended query protocol.
pool_process_query.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/pool_process_query.c b/pool_process_query.c
index 0b4b29dd9..c16904c6b 100644
--- a/pool_process_query.c
+++ b/pool_process_query.c
@@ -1554,6 +1554,8 @@ static POOL_STATUS Parse(POOL_CONNECTION *frontend,
List *parse_tree_list;
Node *node = NULL;
int deadlock_detected = 0;
+ int insert_stmt_with_lock = 0;
+ POOL_STATUS status;
/* read Parse packet */
if (pool_read(frontend, &len, sizeof(len)) < 0)
@@ -1576,6 +1578,8 @@ static POOL_STATUS Parse(POOL_CONNECTION *frontend,
{
node = (Node *) lfirst(list_head(parse_tree_list));
+ insert_stmt_with_lock = need_insert_lock(backend, stmt, node);
+
if (prepare_memory_context == NULL)
{
prepare_memory_context = pool_memory_create();
@@ -1616,6 +1620,16 @@ static POOL_STATUS Parse(POOL_CONNECTION *frontend,
free_parser();
}
+ if (REPLICATION && insert_stmt_with_lock)
+ {
+ /* start a transaction if needed and lock the table */
+ status = insert_lock(backend, stmt, (InsertStmt *)node);
+ if (status != POOL_CONTINUE)
+ {
+ return status;
+ }
+ }
+
/* send to master node */
if (send_extended_protocol_message(backend, MASTER_NODE_ID,
"P", len, string))
@@ -4372,6 +4386,7 @@ static POOL_STATUS do_command(POOL_CONNECTION *backend, char *query, int protoMa
/*
* Expecting CompleteCommand
*/
+retry_read_packet:
status = pool_read(backend, &kind, sizeof(kind));
if (status < 0)
{
@@ -4404,6 +4419,9 @@ static POOL_STATUS do_command(POOL_CONNECTION *backend, char *query, int protoMa
return POOL_END;
}
+ if (kind == 'N') /* warning? */
+ goto retry_read_packet;
+
/*
* Expecting ReadyForQuery
*/
[parent: d48f19b2e607]