Put back the handling of lock_CC_for_rb variable.
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Wed, 18 Apr 2018 08:52:58 +0000 (17:52 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Wed, 18 Apr 2018 11:31:37 +0000 (20:31 +0900)
The variable lock_CC_for_rb should be held per connection.
Per report from Ayman Samamry.

connection.h
execute.c
statement.c
statement.h

index 2118957510213bf0fdd3a90d5eb4fc356b01b31a..317af45eca860f1d7af8d62dcf0903935132e754 100644 (file)
@@ -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;
index 7e8d3b5482036facf3d7d0e89e2a0a4da387c7ea..2679ff86734425b6dfcdccc7edfea3f1da335e3e 100644 (file)
--- 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);
index 2b9665512208e6dd4edff36a3f12143a8b55231a..6b1123648d2aa0d7e7438096b4b58cfca3445ee2 100644 (file)
@@ -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)
index 45beac077a545eef881f7da990132cc6e2d1c47a..1f1ef8c2d89ebe2b1ec6a4eea556700700e5b745 100644 (file)
@@ -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 ? */