Change CURSOR_TYPE or CONCURRENCY statement attribute to
authorHiroshi Inoue <inoue@tpf.co.jp>
Tue, 26 Nov 2002 05:48:22 +0000 (05:48 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Tue, 26 Nov 2002 05:48:22 +0000 (05:48 +0000)
be reset on cursor close per bug report from Glen Parker.

options.c
statement.c
statement.h

index 31170b6989a0e3be7fe4c64625ddf8506e1ee0f6..876783a2f3aeabf5e6a869c0da5f214ed845da53 100644 (file)
--- a/options.c
+++ b/options.c
@@ -75,7 +75,16 @@ set_statement_option(ConnectionClass *conn,
            if (conn)
                conn->stmtOptions.scroll_concurrency = setval;
            else if (stmt)
-               stmt->options.scroll_concurrency = setval;
+           {
+               if (SC_get_Result(stmt))
+               {
+                   SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "The attr can't be changed because the cursor is open.");
+                   SC_log_error(func, "", stmt);
+                   return SQL_ERROR;
+               }
+               stmt->options.scroll_concurrency =
+               stmt->options_orig.scroll_concurrency = setval;
+           }
            if (setval != vParam)
                changed = TRUE;
            mylog("-> %d\n", setval);
@@ -107,7 +116,16 @@ set_statement_option(ConnectionClass *conn,
            if (conn)
                conn->stmtOptions.cursor_type = setval;
            else if (stmt)
+           {
+               if (SC_get_Result(stmt))
+               {
+                   SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "The attr can't be changed because the cursor is open.");
+                   SC_log_error(func, "", stmt);
+                   return SQL_ERROR;
+               }
+               stmt->options_orig.cursor_type =
                stmt->options.cursor_type = setval;
+           }
            if (setval != vParam)
                changed = TRUE;
            mylog("-> %d\n", setval);
@@ -119,7 +137,13 @@ set_statement_option(ConnectionClass *conn,
            if (conn)
                conn->stmtOptions.keyset_size = vParam;
            if (stmt)
-               stmt->options.keyset_size = vParam;
+           {
+               stmt->options_orig.keyset_size = vParam;
+               if (!SC_get_Result(stmt)) 
+                   stmt->options.keyset_size = vParam;
+               if (stmt->options.keyset_size != (int)vParam)
+                   changed = TRUE;
+           }
 
            break;
 
@@ -141,7 +165,13 @@ set_statement_option(ConnectionClass *conn,
            if (conn)
                conn->stmtOptions.maxLength = vParam;
            if (stmt)
-               stmt->options.maxLength = vParam;
+           {
+               stmt->options_orig.maxLength = vParam;
+               if (!SC_get_Result(stmt)) 
+                   stmt->options.maxLength = vParam;
+               if (stmt->options.maxLength != (int)vParam)
+                   changed = TRUE;
+           }
            break;
 
        case SQL_MAX_ROWS:      /* ignored, but saved */
@@ -149,7 +179,13 @@ set_statement_option(ConnectionClass *conn,
            if (conn)
                conn->stmtOptions.maxRows = vParam;
            if (stmt)
-               stmt->options.maxRows = vParam;
+           {
+               stmt->options_orig.maxRows = vParam;
+               if (!SC_get_Result(stmt)) 
+                   stmt->options.maxRows = vParam;
+               if (stmt->options.maxRows != (int)vParam)
+                   changed = TRUE;
+           }
            break;
 
        case SQL_NOSCAN:        /* ignored */
index 646d99fc3f33cce692e0b6decea56a43db61c40d..b98fa0e28935250ba1a0508e11d9641c9d9588c5 100644 (file)
@@ -117,7 +117,7 @@ PGAPI_AllocStmt(HDBC hdbc,
    *phstmt = (HSTMT) stmt;
 
    /* Copy default statement options based from Connection options */
-   stmt->options = conn->stmtOptions;
+   stmt->options = stmt->options_orig = conn->stmtOptions;
    stmt->ardopts = conn->ardOptions;
    stmt->ardopts.bookmark = (BindInfoClass *) malloc(sizeof(BindInfoClass));
    stmt->ardopts.bookmark->buffer = NULL;
@@ -560,6 +560,14 @@ SC_recycle_statement(StatementClass *self)
    if (self->load_statement)
        free(self->load_statement);
    self->load_statement = NULL;
+   /*
+    *  reset the current attr setting to the original one.
+    */
+   self->options.scroll_concurrency = self->options_orig.scroll_concurrency;
+   self->options.cursor_type = self->options_orig.cursor_type;
+   self->options.keyset_size = self->options_orig.keyset_size;
+   self->options.maxLength = self->options_orig.maxLength;
+   self->options.maxRows = self->options_orig.maxRows;
 
    return TRUE;
 }
index 52dbf0d9cb84dfd1b930ee410ee7074127f5e1f5..84390a12d1cf6d1d9545a4ea9099a33b7b3f5b24 100644 (file)
@@ -133,6 +133,7 @@ struct StatementClass_
    QResultClass *curres;       /* the current result in the chain */
    HSTMT FAR  *phstmt;
    StatementOptions options;
+   StatementOptions options_orig;
    ARDFields ardopts;
    IRDFields irdopts;
    APDFields apdopts;