Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc404d91

Browse files
author
Thomas G. Lockhart
committed
From Zoltan Kovacs back in April (sorry for the delay Zoltan!):
I modified the current ODBC driver for* referential integrity error reporting,* SELECT in transactions and* disabling autocommit.I tested these changes with Borland C++ Builder -> ODBCExpress ->WinODBC driver (DLL) -> Postgres 7.0beta1 and Borland C++ Builder -> BDE ->WinODBC driver (DLL) -> Postgres 7.0beta1. The patch is based on snapshot of22th April (I don't think that someone has modified it since that: Byronhasn't gave any sign of living for about a month and I didn't find anycomments about the ODBC driver on the list).
1 parent48f0490 commitc404d91

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

‎src/interfaces/odbc/connection.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,19 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];/* QR_set_command() dups this string so dont
947947
case'E':
948948
SOCK_get_string(sock,cmdbuffer,ERROR_MSG_LENGTH);
949949
qlog("ERROR from backend during clear: '%s'\n",cmdbuffer);
950+
/* We must report this type of error as well
951+
(practically for reference integrity violation
952+
error reporting, from PostgreSQL 7.0).
953+
(Zoltan Kovacs, 04/26/2000)
954+
*/
955+
self->errormsg=cmdbuffer;
956+
if ( !strncmp(self->errormsg,"FATAL",5)) {
957+
self->errornumber=CONNECTION_SERVER_REPORTED_ERROR;
958+
CC_set_no_trans(self);
959+
}
960+
else
961+
self->errornumber=CONNECTION_SERVER_REPORTED_WARNING;
962+
QR_set_status(res,PGRES_NONFATAL_ERROR);
950963
break;
951964
}
952965
}
@@ -1001,14 +1014,20 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];/* QR_set_command() dups this string so dont
10011014
mylog("send_query: 'E' - %s\n",self->errormsg);
10021015
qlog("ERROR from backend during send_query: '%s'\n",self->errormsg);
10031016

1017+
/* We should report that an error occured. Zoltan */
1018+
res=QR_Constructor();
1019+
10041020
if ( !strncmp(self->errormsg,"FATAL",5)) {
10051021
self->errornumber=CONNECTION_SERVER_REPORTED_ERROR;
10061022
CC_set_no_trans(self);
1023+
QR_set_status(res,PGRES_FATAL_ERROR);
10071024
}
1008-
else
1025+
else {
10091026
self->errornumber=CONNECTION_SERVER_REPORTED_WARNING;
1027+
QR_set_status(res,PGRES_NONFATAL_ERROR);
1028+
}
10101029

1011-
returnNULL;
1030+
returnres;/* instead of NULL. Zoltan */
10121031

10131032
case'P' :/* get the Portal name */
10141033
SOCK_get_string(sock,msgbuffer,MAX_MESSAGE_LEN);

‎src/interfaces/odbc/options.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ int i;
330330
switch(vParam) {
331331
caseSQL_AUTOCOMMIT_OFF:
332332
CC_set_autocommit_off(conn);
333+
/* The following two lines are new.
334+
With this modification the SELECT statements
335+
are also included in the transactions.
336+
Error handling should be written,
337+
this is missing yet, see
338+
SC_execute in statement.c for details. Zoltan
339+
*/
340+
CC_send_query(conn,"BEGIN",NULL);
341+
CC_set_in_trans(conn);
333342
break;
334343

335344
caseSQL_AUTOCOMMIT_ON:

‎src/interfaces/odbc/statement.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,14 @@ QueryInfo qi;
748748
/*Begin a transaction if one is not already in progress */
749749
/*The reason is because we can't use declare/fetch cursors without
750750
starting a transaction first.
751+
752+
A transaction should be begun if and only if
753+
we use declare/fetch and the statement is SELECT.
754+
We assume that the Postgres backend has an autocommit
755+
feature as default. (Zoltan Kovacs, 04/26/2000)
751756
*/
752-
if ( !self->internal&& !CC_is_in_trans(conn)&& (globals.use_declarefetch||STMT_UPDATE(self))) {
757+
// if ( ! self->internal && ! CC_is_in_trans(conn) && (globals.use_declarefetch || STMT_UPDATE(self))) {
758+
if ( !self->internal&& !CC_is_in_trans(conn)&&globals.use_declarefetch&&self->statement_type==STMT_TYPE_SELECT) {
753759

754760
mylog(" about to begin a transaction on statement = %u\n",self);
755761
res=CC_send_query(conn,"BEGIN",NULL);
@@ -826,11 +832,14 @@ QueryInfo qi;
826832
self->result=CC_send_query(conn,self->stmt_with_params,NULL);
827833

828834
/*If we are in autocommit, we must send the commit. */
829-
if ( !self->internal&&CC_is_in_autocommit(conn)&&STMT_UPDATE(self)) {
835+
/*No, we shouldn't. Postgres backend does the
836+
autocommit if neccessary. (Zoltan, 04/26/2000)
837+
*/
838+
/*if ( ! self->internal && CC_is_in_autocommit(conn) && STMT_UPDATE(self)) {
830839
res = CC_send_query(conn, "COMMIT", NULL);
831840
QR_Destructor(res);
832841
CC_set_no_trans(conn);
833-
}
842+
}*/
834843

835844
}
836845

@@ -889,10 +898,12 @@ QueryInfo qi;
889898
if (self->errornumber==STMT_OK)
890899
returnSQL_SUCCESS;
891900

892-
elseif (self->errornumber==STMT_INFO_ONLY)
893-
returnSQL_SUCCESS_WITH_INFO;
894-
895901
else {
902+
// Modified, 04/29/2000, Zoltan
903+
if (self->errornumber==STMT_INFO_ONLY)
904+
self->errormsg="Error while executing the query (non-fatal)";
905+
else
906+
self->errormsg="Unknown error";
896907
SC_log_error(func,"",self);
897908
returnSQL_ERROR;
898909
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp