For debug, change SQLSetConnectAttr(.., SQL_ATTR_PGOPT_USE_DECLAREFETCH, ..) so that...
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sun, 1 May 2016 11:58:09 +0000 (20:58 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Tue, 6 Jun 2017 23:28:03 +0000 (08:28 +0900)
connection.c
connection.h
dlg_specific.c
dlg_specific.h
pgapi30.c
psqlodbc.h

index 52bc70f68a3cf8163bc7b2a097ba0ec7a2237fe9..2445bb86551f315ac27c14bd3d11110a05628d56 100644 (file)
@@ -1106,14 +1106,7 @@ CC_connect(ConnectionClass *self, char *salt_para)
            goto cleanup;
        }
 
-   ci->updatable_cursors = DISALLOW_UPDATABLE_CURSORS;
-   if (ci->allow_keyset)
-   {
-       if (ci->drivers.lie || !ci->drivers.use_declarefetch)
-           ci->updatable_cursors |= (ALLOW_STATIC_CURSORS | ALLOW_KEYSET_DRIVEN_CURSORS | ALLOW_BULK_OPERATIONS | SENSE_SELF_OPERATIONS);
-       else
-           ci->updatable_cursors |= (ALLOW_STATIC_CURSORS | ALLOW_BULK_OPERATIONS | SENSE_SELF_OPERATIONS);
-   }
+   ci_updatable_cursors_set(ci);
 
    if (CC_get_errornumber(self) > 0)
        CC_clear_error(self);       /* clear any initial command errors */
index fd1d81a1fd621316de5d0fd3c57358f43be70a20..596c09e8159ae15d92aaf319aaea0b5943541d17 100644 (file)
@@ -34,16 +34,6 @@ typedef enum
                 * statement */
 } CONN_Status;
 
-enum
-{
-   DISALLOW_UPDATABLE_CURSORS = 0, /* No cursors are updatable */
-   ALLOW_STATIC_CURSORS = 1L, /* Static cursors are updatable */
-   ALLOW_KEYSET_DRIVEN_CURSORS = (1L << 1), /* Keyset-driven cursors are updatable */
-   ALLOW_DYNAMIC_CURSORS = (1L << 2), /* Dynamic cursors are updatable */
-   ALLOW_BULK_OPERATIONS = (1L << 3), /* Bulk operations available */
-   SENSE_SELF_OPERATIONS = (1L << 4), /* Sense self update/delete/add */
-};
-
 /* These errors have general sql error state */
 #define CONNECTION_SERVER_NOT_REACHED              101
 #define CONNECTION_MSG_TOO_LONG                    103
index 760b122e63dc313174a7e5c110c7fc43f110f9e1..00a535a4e17303adce5d067297b377bd1ead1045 100644 (file)
@@ -1681,6 +1681,19 @@ char *extract_extra_attribute_setting(const pgNAME setting, const char *attr)
    return rptr;
 }
 
+signed char    ci_updatable_cursors_set(ConnInfo *ci)
+{
+   ci->updatable_cursors = DISALLOW_UPDATABLE_CURSORS;
+   if (ci->allow_keyset)
+   {
+       if (ci->drivers.lie || !ci->drivers.use_declarefetch)
+           ci->updatable_cursors |= (ALLOW_STATIC_CURSORS | ALLOW_KEYSET_DRIVEN_CURSORS | ALLOW_BULK_OPERATIONS | SENSE_SELF_OPERATIONS);
+       else
+           ci->updatable_cursors |= (ALLOW_STATIC_CURSORS | ALLOW_BULK_OPERATIONS | SENSE_SELF_OPERATIONS);
+   }
+   return  ci->updatable_cursors;
+}
+
 void
 CC_conninfo_release(ConnInfo *conninfo)
 {
index 4aacad9e384e2e33c6148850828eed11c6bd2823..bedb10371d5cea64aa0225caff344c6c60457c5e 100644 (file)
@@ -317,6 +317,7 @@ int getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen);
 UInt4  getExtraOptions(const ConnInfo *);
 BOOL   setExtraOptions(ConnInfo *, const char *str, const char *format);
 char   *extract_extra_attribute_setting(const pgNAME setting, const char *attr);
+signed char    ci_updatable_cursors_set(ConnInfo *ci);
 
 #ifdef __cplusplus
 }
index 591dbce30ec90890e4d8e2a4a065a980baeb1055..885cc491bdeaef425ad66ca5382ae8b723c40c38 100644 (file)
--- a/pgapi30.c
+++ b/pgapi30.c
@@ -27,6 +27,7 @@
 #include "qresult.h"
 #include "pgapifunc.h"
 #include "loadlib.h"
+#include "dlg_specific.h"
 
 
 /* SQLError -> SQLDiagRec */
@@ -1743,6 +1744,7 @@ PGAPI_SetConnectAttr(HDBC ConnectionHandle,
            break;
        case SQL_ATTR_PGOPT_USE_DECLAREFETCH:
            conn->connInfo.drivers.use_declarefetch = CAST_UPTR(SQLCHAR, Value);
+           ci_updatable_cursors_set(&conn->connInfo);
            qlog("declarefetch => %d\n", conn->connInfo.drivers.use_declarefetch);
            mylog("declarefetch => %d\n", conn->connInfo.drivers.use_declarefetch);
            break;
index 4b4d7ac3d7f5ba03250de759fb1579ea86026ba0..7dbf70f6ecba365d6c48c5c1388093466f046ccf 100644 (file)
@@ -645,6 +645,16 @@ CSTR   PRINT_NULL = "(null)";
 #define XMIN_NAME "xmin"
 #define TABLEOID_NAME "tableoid"
 
+enum
+{
+   DISALLOW_UPDATABLE_CURSORS = 0, /* No cursors are updatable */
+   ALLOW_STATIC_CURSORS = 1L, /* Static cursors are updatable */
+   ALLOW_KEYSET_DRIVEN_CURSORS = (1L << 1), /* Keyset-driven cursors are updatable */
+   ALLOW_DYNAMIC_CURSORS = (1L << 2), /* Dynamic cursors are updatable */
+   ALLOW_BULK_OPERATIONS = (1L << 3), /* Bulk operations available */
+   SENSE_SELF_OPERATIONS = (1L << 4), /* Sense self update/delete/add */
+};
+
 #ifdef __cplusplus
 }
 #endif