From 575bafae7f9ba5e5ee884a6eae2637c20a5945aa Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Wed, 18 Apr 2018 17:52:58 +0900 Subject: [PATCH] Put back the handling of lock_CC_for_rb variable. The variable lock_CC_for_rb should be held per connection. Per report from Ayman Samamry. --- connection.h | 1 - execute.c | 10 +++++----- statement.c | 6 ++++++ statement.h | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/connection.h b/connection.h index 2118957..317af45 100644 --- a/connection.h +++ b/connection.h @@ -315,7 +315,6 @@ struct ConnectionClass_ /* for per statement rollback */ char internal_svp; /* is set? */ char internal_op; /* operation being executed as to internal savepoint */ - unsigned char lock_CC_for_rb; unsigned char rbonerr; unsigned char opt_in_progress; unsigned char opt_previous; diff --git a/execute.c b/execute.c index 7e8d3b5..2679ff8 100644 --- a/execute.c +++ b/execute.c @@ -631,10 +631,10 @@ SetStatementSvp(StatementClass *stmt, unsigned int option) if (CC_is_in_error_trans(conn)) return ret; - if (0 == conn->lock_CC_for_rb) + if (!stmt->lock_CC_for_rb) { ENTER_CONN_CS(conn); - conn->lock_CC_for_rb++; + stmt->lock_CC_for_rb = TRUE; } MYLOG(DETAIL_LOG_LEVEL, " %p->accessed=%d opt=%u in_progress=%u prev=%u\n", conn, CC_accessed_db(conn), option, conn->opt_in_progress, conn->opt_previous); conn->opt_in_progress &= option; @@ -692,7 +692,7 @@ DiscardStatementSvp(StatementClass *stmt, RETCODE ret, BOOL errorOnly) MYLOG(DETAIL_LOG_LEVEL, "entering %p->accessed=%d is_in=%d is_rb=%d is_tc=%d\n", conn, CC_accessed_db(conn), CC_is_in_trans(conn), SC_is_rb_stmt(stmt), SC_is_tc_stmt(stmt)); - if (conn->lock_CC_for_rb > 0) + if (stmt->lock_CC_for_rb) MYLOG(0, "in_progress=%u previous=%d\n", conn->opt_in_progress, conn->opt_previous); switch (ret) { @@ -744,10 +744,10 @@ cleanup: conn->opt_previous = conn->opt_in_progress; CC_init_opt_in_progress(conn); } - while (conn->lock_CC_for_rb > 0) + if (stmt->lock_CC_for_rb) { + stmt->lock_CC_for_rb = FALSE; LEAVE_CONN_CS(conn); - conn->lock_CC_for_rb--; MYLOG(DETAIL_LOG_LEVEL, " release conn_lock\n"); } CC_start_stmt(conn); diff --git a/statement.c b/statement.c index 2b96655..6b11236 100644 --- a/statement.c +++ b/statement.c @@ -457,6 +457,7 @@ SC_Constructor(ConnectionClass *conn) rv->callbacks = NULL; GetDataInfoInitialize(SC_get_GDTI(rv)); PutDataInfoInitialize(SC_get_PDTI(rv)); + rv->lock_CC_for_rb = FALSE; INIT_STMT_CS(rv); } return rv; @@ -687,6 +688,11 @@ SC_initialize_stmts(StatementClass *self, BOOL initializeOriginal) ProcessedStmt *pstmt; ProcessedStmt *next_pstmt; + if (self->lock_CC_for_rb) + { + LEAVE_CONN_CS(SC_get_conn(self)); + self->lock_CC_for_rb = FALSE; + } if (initializeOriginal) { if (self->statement) diff --git a/statement.h b/statement.h index 45beac0..1f1ef8c 100644 --- a/statement.h +++ b/statement.h @@ -267,7 +267,7 @@ struct StatementClass_ po_ind_t discard_output_params; /* discard output parameters on parse stage */ po_ind_t cancel_info; /* cancel information */ po_ind_t ref_CC_error; /* refer to CC_error ? */ -// po_ind_t lock_CC_for_rb; /* lock CC for statement rollback ? */ + po_ind_t lock_CC_for_rb; /* lock CC for statement rollback ? */ po_ind_t join_info; /* have joins ? */ po_ind_t parse_method; /* parse_statement is forced or ? */ po_ind_t curr_param_result; /* current param result is set ? */ -- 2.39.5