1) Change transaction boundary in autocommit off mode

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).
This commit is contained in:
Hiroshi Inoue 2001-02-15 05:32:00 +00:00
parent 21deb42897
commit 462c13215a
6 changed files with 33 additions and 25 deletions

View File

@ -967,6 +967,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1]; /* QR_set_command() dups this string so dont
else else
self->errornumber = CONNECTION_SERVER_REPORTED_WARNING; self->errornumber = CONNECTION_SERVER_REPORTED_WARNING;
QR_set_status(res, PGRES_NONFATAL_ERROR); QR_set_status(res, PGRES_NONFATAL_ERROR);
QR_set_aborted(res, TRUE);
break; 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; self->errornumber = CONNECTION_SERVER_REPORTED_WARNING;
QR_set_status(res, PGRES_NONFATAL_ERROR); QR_set_status(res, PGRES_NONFATAL_ERROR);
} }
QR_set_aborted(res, TRUE);
return res; /* instead of NULL. Zoltan */ return res; /* instead of NULL. Zoltan */

View File

@ -6,7 +6,7 @@
* *
* Comments: See "notice.txt" for copyright and license information. * 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__ #ifndef __PSQLODBC_H__
@ -41,7 +41,7 @@ typedef UInt4 Oid;
#define DRIVERNAME "PostgreSQL ODBC" #define DRIVERNAME "PostgreSQL ODBC"
#define DBMS_NAME "PostgreSQL" #define DBMS_NAME "PostgreSQL"
#define POSTGRESDRIVERVERSION "07.01.0002" #define POSTGRESDRIVERVERSION "07.01.0003"
#ifdef WIN32 #ifdef WIN32
#define DRIVER_FILE_NAME "PSQLODBC.DLL" #define DRIVER_FILE_NAME "PSQLODBC.DLL"

View File

@ -204,8 +204,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 7,1,0,2 FILEVERSION 7,1,0,3
PRODUCTVERSION 7,1,0,2 PRODUCTVERSION 7,1,0,3
FILEFLAGSMASK 0x3L FILEFLAGSMASK 0x3L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -223,14 +223,14 @@ BEGIN
VALUE "Comments", "PostgreSQL ODBC driver\0" VALUE "Comments", "PostgreSQL ODBC driver\0"
VALUE "CompanyName", "Insight Distribution Systems\0" VALUE "CompanyName", "Insight Distribution Systems\0"
VALUE "FileDescription", "PostgreSQL Driver\0" VALUE "FileDescription", "PostgreSQL Driver\0"
VALUE "FileVersion", " 07.01.0002\0" VALUE "FileVersion", " 07.01.0003\0"
VALUE "InternalName", "psqlodbc\0" VALUE "InternalName", "psqlodbc\0"
VALUE "LegalCopyright", "\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 "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 "OriginalFilename", "psqlodbc.dll\0"
VALUE "PrivateBuild", "\0" VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Microsoft Open Database Connectivity\0" VALUE "ProductName", "Microsoft Open Database Connectivity\0"
VALUE "ProductVersion", " 07.01.0002\0" VALUE "ProductVersion", " 07.01.0003\0"
VALUE "SpecialBuild", "\0" VALUE "SpecialBuild", "\0"
END END
END END

View File

@ -106,6 +106,7 @@ QResultClass *rv;
rv->num_fields = 0; rv->num_fields = 0;
rv->tupleField = NULL; rv->tupleField = NULL;
rv->cursor = NULL; rv->cursor = NULL;
rv->aborted = FALSE;
rv->cache_size = globals.fetch_max; rv->cache_size = globals.fetch_max;
rv->rowset_size = 1; rv->rowset_size = 1;

View File

@ -62,6 +62,7 @@ struct QResultClass_ {
TupleField *tupleField; /* current backend tuple being retrieved */ TupleField *tupleField; /* current backend tuple being retrieved */
char inTuples; /* is a fetch of rows from the backend in progress? */ char inTuples; /* is a fetch of rows from the backend in progress? */
char aborted; /* was aborted?*/
}; };
#define QR_get_fields(self) (self->fields) #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_end_tuples(self) ( self->status == PGRES_END_TUPLES)
#define QR_set_status(self, condition) ( self->status = condition ) #define QR_set_status(self, condition) ( self->status = condition )
#define QR_set_message(self, message_) ( self->message = message_) #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_message(self) (self->message)
#define QR_get_command(self) (self->command) #define QR_get_command(self) (self->command)
#define QR_get_notice(self) (self->notice) #define QR_get_notice(self) (self->notice)
#define QR_get_status(self) (self->status) #define QR_get_status(self) (self->status)
#define QR_get_aborted(self) (self->aborted)
#define QR_aborted(self) (!self || self->aborted)
/* Core Functions */ /* Core Functions */
QResultClass *QR_Constructor(void); QResultClass *QR_Constructor(void);

View File

@ -753,21 +753,19 @@ QueryInfo qi;
/* Begin a transaction if one is not already in progress */ /* Begin a transaction if one is not already in progress */
/* /*
Basically we don't have to begin a transaction in * Basically we don't have to begin a transaction in autocommit mode
autocommit mode because Postgres backend runs in * because Postgres backend runs in autocomit mode. We issue "BEGIN"
autocomit mode. * in the following cases. 1) we use declare/fetch and the statement
We issue "BEGIN" in the following cases. * is SELECT (because declare/fetch must be called in a transaction).
1) we use declare/fetch and the statement is SELECT * 2) we are in autocommit off state and the statement isn't of type
(because declare/fetch must be called in a transaction). * OTHER.
2) we are not in autocommit state and the statement
is of type UPDATE.
*/ */
if (!self->internal && !CC_is_in_trans(conn) && 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)))) { ((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); mylog(" about to begin a transaction on statement = %u\n", self);
res = CC_send_query(conn, "BEGIN", NULL); res = CC_send_query(conn, "BEGIN", NULL);
if ( ! res) { if (QR_aborted(res)) {
self->errormsg = "Could not begin a transaction"; self->errormsg = "Could not begin a transaction";
self->errornumber = STMT_EXEC_ERROR; self->errornumber = STMT_EXEC_ERROR;
SC_log_error(func, "", self); SC_log_error(func, "", self);
@ -843,10 +841,12 @@ QueryInfo qi;
/* We shouldn't send COMMIT. Postgres backend does the /* We shouldn't send COMMIT. Postgres backend does the
autocommit if neccessary. (Zoltan, 04/26/2000) autocommit if neccessary. (Zoltan, 04/26/2000)
*/ */
/* Even in case of autocommit, started transactions /* Above seems wrong.
must be committed. (Hiroshi, 09/02/2001) 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); res = CC_send_query(conn, "COMMIT", NULL);
QR_Destructor(res); QR_Destructor(res);
CC_set_no_trans(conn); CC_set_no_trans(conn);
@ -885,8 +885,8 @@ QueryInfo qi;
return SQL_ERROR; return SQL_ERROR;
} }
} }
/* in autocommit mode declare/fetch error must be aborted */ /* issue "ABORT" when query aborted */
if ( ! was_ok && ! self->internal && CC_is_in_autocommit(conn) && CC_is_in_trans(conn)) if (QR_get_aborted(self->result) && ! self->internal )
CC_abort(conn); CC_abort(conn);
} else { /* Bad Error -- The error message will be in the Connection */ } else { /* Bad Error -- The error message will be in the Connection */