]> granicus.if.org Git - postgresql/commitdiff
1) Change transaction boundary in autocommit off mode
authorHiroshi Inoue <inoue@tpf.co.jp>
Thu, 15 Feb 2001 05:32:00 +0000 (05:32 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Thu, 15 Feb 2001 05:32:00 +0000 (05:32 +0000)
   per recent discussion in pgsql-odbc. Now SELECT is
   a boundary but VACUUM isn't.
2) Put back the error handling behavior. When elog(ERROR)
   was detected the driver automatically issue "ABORT"
   if a transaction is in progress.
3) Driver version is 7.01.0003(Dave already set it but
   it was put back).

src/interfaces/odbc/connection.c
src/interfaces/odbc/psqlodbc.h
src/interfaces/odbc/psqlodbc.rc
src/interfaces/odbc/qresult.c
src/interfaces/odbc/qresult.h
src/interfaces/odbc/statement.c

index b528a69ea03ab2415677a2b99f05b6e2662d38a3..69e111e4c2110a6e893a065993b66ecd5216fcbd 100644 (file)
@@ -964,9 +964,10 @@ char cmdbuffer[MAX_MESSAGE_LEN+1]; /* QR_set_command() dups this string so dont
                                                    self->errornumber = CONNECTION_SERVER_REPORTED_ERROR;
                                                    CC_set_no_trans(self);
                                                    }
-                                               else 
+                                               else
                                                    self->errornumber = CONNECTION_SERVER_REPORTED_WARNING;
                                                QR_set_status(res, PGRES_NONFATAL_ERROR);
+                                               QR_set_aborted(res, TRUE);
                                                break;
                                        }
                                }
@@ -1033,6 +1034,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];        /* QR_set_command() dups this string so dont
                                self->errornumber = CONNECTION_SERVER_REPORTED_WARNING;
                                QR_set_status(res, PGRES_NONFATAL_ERROR);
                        }
+                       QR_set_aborted(res, TRUE);
 
                        return res; /* instead of NULL. Zoltan */
 
index 5226bb3fdac8c53e8f0fd2c523cb04174a99a760..ccefb1a05f0bf668405cac5b45b24b981f733351 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Comments:        See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.37 2001/02/14 05:45:46 momjian Exp $
+ * $Id: psqlodbc.h,v 1.38 2001/02/15 05:32:00 inoue Exp $
  */
 
 #ifndef __PSQLODBC_H__
@@ -41,7 +41,7 @@ typedef UInt4 Oid;
 #define DRIVERNAME             "PostgreSQL ODBC"
 #define DBMS_NAME              "PostgreSQL"
 
-#define POSTGRESDRIVERVERSION  "07.01.0002"
+#define POSTGRESDRIVERVERSION  "07.01.0003"
 
 #ifdef WIN32
 #define DRIVER_FILE_NAME               "PSQLODBC.DLL"
index d9538230fbca858ddb6f64976ec902566834108a..dbbfa34ef960563076fa56430fa36b214a6b72a8 100644 (file)
@@ -204,8 +204,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 7,1,0,2
- PRODUCTVERSION 7,1,0,2
+ FILEVERSION 7,1,0,3
+ PRODUCTVERSION 7,1,0,3
  FILEFLAGSMASK 0x3L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -223,14 +223,14 @@ BEGIN
             VALUE "Comments", "PostgreSQL ODBC driver\0"
             VALUE "CompanyName", "Insight Distribution Systems\0"
             VALUE "FileDescription", "PostgreSQL Driver\0"
-            VALUE "FileVersion", " 07.01.0002\0"
+            VALUE "FileVersion", " 07.01.0003\0"
             VALUE "InternalName", "psqlodbc\0"
             VALUE "LegalCopyright", "\0"
             VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation.  Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0"
             VALUE "OriginalFilename", "psqlodbc.dll\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Microsoft Open Database Connectivity\0"
-            VALUE "ProductVersion", " 07.01.0002\0"
+            VALUE "ProductVersion", " 07.01.0003\0"
             VALUE "SpecialBuild", "\0"
         END
     END
index de52884ff3cd562a3550fc98539a7029c8a96c26..56641d36b5c7078adf114686a99d7a88aee13416 100644 (file)
@@ -106,6 +106,7 @@ QResultClass *rv;
                rv->num_fields = 0;
                rv->tupleField = NULL;
                rv->cursor = NULL;
+               rv->aborted = FALSE;
 
                rv->cache_size = globals.fetch_max;
                rv->rowset_size = 1;
index 93f11cee1f4ac5243e1b46748392b6657a9e264b..d9362eb953b0d1f3ea8cd89f5c45766f231321f2 100644 (file)
@@ -62,6 +62,7 @@ struct QResultClass_ {
        TupleField *tupleField;                         /* current backend tuple being retrieved */
 
        char inTuples;                                          /* is a fetch of rows from the backend in progress? */
+       char aborted;                                   /* was aborted?*/
 };
 
 #define QR_get_fields(self)                            (self->fields)
@@ -91,11 +92,15 @@ struct QResultClass_ {
 #define QR_end_tuples(self)                            ( self->status == PGRES_END_TUPLES)
 #define QR_set_status(self, condition) ( self->status = condition )
 #define QR_set_message(self, message_) ( self->message = message_)
+#define QR_set_aborted(self, aborted_) ( self->aborted = aborted_)
 
 #define QR_get_message(self)                   (self->message)
 #define QR_get_command(self)                   (self->command)
 #define QR_get_notice(self)                            (self->notice)
 #define QR_get_status(self)                            (self->status)
+#define QR_get_aborted(self)                           (self->aborted)
+
+#define QR_aborted(self)               (!self || self->aborted)
 
 /*     Core Functions */
 QResultClass *QR_Constructor(void);
index 06d97f7457e99f97a991e45bd883900b440995f3..8a8d5523ad6db2afdc4201665e94740a18d8f7d3 100644 (file)
@@ -753,21 +753,19 @@ QueryInfo qi;
 
        /*      Begin a transaction if one is not already in progress */
        /*
-               Basically we don't have to begin a transaction in
-               autocommit mode because Postgres backend runs in
-               autocomit mode.  
-               We issue "BEGIN" in the following cases.
-               1) we use declare/fetch and the statement is SELECT
-                  (because declare/fetch must be called in a transaction).
-               2) we are not in autocommit state and the statement
-                  is of type UPDATE.
-       */ 
-       if ( ! self->internal && ! CC_is_in_trans(conn) &&
-           ((globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) || (! CC_is_in_autocommit(conn) && STMT_UPDATE(self)))) {
-
+        * Basically we don't have to begin a transaction in autocommit mode
+        * because Postgres backend runs in autocomit mode. We issue "BEGIN"
+        * in the following cases. 1) we use declare/fetch and the statement
+        * is SELECT (because declare/fetch must be called in a transaction).
+        * 2) we are in autocommit off state and the statement isn't of type
+        * OTHER.
+        */
+       if (!self->internal && !CC_is_in_trans(conn) &&
+               ((globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) || (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER)))
+       {
                mylog("   about to begin a transaction on statement = %u\n", self);
                res = CC_send_query(conn, "BEGIN", NULL);
-               if ( ! res) {
+               if (QR_aborted(res)) {
                        self->errormsg = "Could not begin a transaction";
                        self->errornumber = STMT_EXEC_ERROR;
                        SC_log_error(func, "", self);
@@ -843,10 +841,12 @@ QueryInfo qi;
                /*      We shouldn't send COMMIT. Postgres backend does the
                        autocommit if neccessary. (Zoltan, 04/26/2000)
                */
-               /*      Even in case of autocommit, started transactions
-                       must be committed. (Hiroshi, 09/02/2001)
+               /*      Above seems wrong.
+                       Even in case of autocommit, started transactions
+                       must be committed. (Hiroshi, 02/11/2001)
                 */ 
-               if ( ! self->internal && CC_is_in_autocommit(conn) && CC_is_in_trans(conn) && STMT_UPDATE(self)) {                   
+               if ( ! self->internal && CC_is_in_autocommit(conn) && CC_is_in_trans(conn))
+                {                   
                        res = CC_send_query(conn, "COMMIT", NULL); 
                        QR_Destructor(res);
                        CC_set_no_trans(conn);
@@ -885,8 +885,8 @@ QueryInfo qi;
                                return SQL_ERROR;
                        }
                }
-               /* in autocommit mode declare/fetch error must be aborted */ 
-               if ( ! was_ok && ! self->internal && CC_is_in_autocommit(conn) && CC_is_in_trans(conn))                   
+               /* issue "ABORT" when query aborted */ 
+               if (QR_get_aborted(self->result) && ! self->internal )                   
                        CC_abort(conn);
        } else {                /* Bad Error -- The error message will be in the Connection */