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

Commit6d7735e

Browse files
author
Byron Nikolaidis
committed
Update for version 6-40-0002 and re-merge Thomas' changes.
1 parentd73cf04 commit6d7735e

26 files changed

+1562
-566
lines changed

‎src/interfaces/odbc/bind.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ static char *func="SQLBindParameter";
128128
stmt->parameters[ipar].EXEC_buffer=NULL;
129129
}
130130

131-
if (pcbValue&&*pcbValue <=SQL_LEN_DATA_AT_EXEC_OFFSET)
131+
/*Data at exec macro only valid for C char/binary data */
132+
if ((fSqlType==SQL_LONGVARBINARY||fSqlType==SQL_LONGVARCHAR)&&pcbValue&&*pcbValue <=SQL_LEN_DATA_AT_EXEC_OFFSET)
132133
stmt->parameters[ipar].data_at_exec= TRUE;
133134
else
134135
stmt->parameters[ipar].data_at_exec= FALSE;
135136

136-
mylog("SQLBindParamater: ipar =%d, *pcbValue = %d, data_at_exec = %d\n",ipar,pcbValue ?*pcbValue:-777,stmt->parameters[ipar].data_at_exec);
137+
mylog("SQLBindParamater: ipar=%d, paramType=%d, fCType=%d,fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d,*pcbValue = %d, data_at_exec = %d\n",ipar,fParamType,fCType,fSqlType,cbColDef,ibScale,rgbValue,pcbValue ?*pcbValue:-777,stmt->parameters[ipar].data_at_exec);
137138

138139
returnSQL_SUCCESS;
139140
}
@@ -195,6 +196,9 @@ mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
195196

196197
icol--;/* use zero based col numbers from here out */
197198

199+
/*Reset for SQLGetData */
200+
stmt->bindings[icol].data_left=-1;
201+
198202
if (rgbValue==NULL) {
199203
/* we have to unbind the column */
200204
stmt->bindings[icol].buflen=0;
@@ -357,6 +361,7 @@ int i;
357361
new_bindings[i].buflen=0;
358362
new_bindings[i].buffer=NULL;
359363
new_bindings[i].used=NULL;
364+
new_bindings[i].data_left=-1;
360365
}
361366

362367
returnnew_bindings;

‎src/interfaces/odbc/bind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
structBindInfoClass_ {
1919
Int4buflen;/* size of buffer */
20+
Int4data_left;/* amount of data left to read (SQLGetData) */
2021
char*buffer;/* pointer to the buffer */
2122
Int4*used;/* used space in the buffer (for strings not counting the '\0') */
2223
Int2returntype;/* kind of conversion to be applied when returning (SQL_C_DEFAULT, SQL_C_CHAR...) */

‎src/interfaces/odbc/connection.c

Lines changed: 26 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
externGLOBAL_VALUESglobals;
3333

34-
// void CC_test(ConnectionClass *self);
3534

3635
RETCODESQL_APISQLAllocConnect(
3736
HENVhenv,
@@ -252,6 +251,14 @@ ConnectionClass *rv;
252251
rv->translation_handle=NULL;
253252
rv->DataSourceToDriver=NULL;
254253
rv->DriverToDataSource=NULL;
254+
255+
256+
/*Initialize statement options to defaults */
257+
/*Statements under this conn will inherit these options */
258+
259+
InitializeStatementOptions(&rv->stmtOptions);
260+
261+
255262
}
256263
returnrv;
257264
}
@@ -337,7 +344,7 @@ QResultClass *res;
337344

338345
mylog("CC_abort: sending ABORT!\n");
339346

340-
res=CC_send_query(self,"ABORT",NULL,NULL);
347+
res=CC_send_query(self,"ABORT",NULL);
341348
CC_set_no_trans(self);
342349

343350
if (res!=NULL)
@@ -664,7 +671,7 @@ static char *func="CC_connect";
664671
/* database really exists on the server machine */
665672
mylog("sending an empty query...\n");
666673

667-
res=CC_send_query(self," ",NULL,NULL);
674+
res=CC_send_query(self," ",NULL);
668675
if (res==NULL||QR_get_status(res)!=PGRES_EMPTY_QUERY) {
669676
mylog("got no result from the empty query. (probably database does not exist)\n");
670677
self->errornumber=CONNECTION_NO_SUCH_DATABASE;
@@ -691,8 +698,6 @@ static char *func="CC_connect";
691698
CC_send_settings(self);
692699
CC_lookup_lo(self);/* a hack to get the oid of our large object oid type */
693700

694-
// CC_test(self);
695-
696701
CC_clear_error(self);/* clear any initial command errors */
697702
self->status=CONN_CONNECTED;
698703

@@ -812,9 +817,9 @@ int rv;
812817
'declare cursor C3326857 for ...' and 'fetch 100 in C3326857' statements.
813818
*/
814819
QResultClass*
815-
CC_send_query(ConnectionClass*self,char*query,QResultClass*result_in,char*cursor)
820+
CC_send_query(ConnectionClass*self,char*query,QueryInfo*qi)
816821
{
817-
QResultClass*res=NULL;
822+
QResultClass*result_in,*res=NULL;
818823
charid,swallow;
819824
SocketClass*sock=self->sock;
820825
staticcharmsgbuffer[MAX_MESSAGE_LEN+1];
@@ -970,7 +975,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];// QR_set_command() dups this string so dont
970975
swallow=SOCK_get_char(sock);
971976
if ((swallow!='\0')||SOCK_get_errcode(sock)!=0) {
972977
self->errornumber=CONNECTION_BACKEND_CRAZY;
973-
self->errormsg="Unexpected protocol character from backend";
978+
self->errormsg="Unexpected protocol character from backend (send_query - I)";
974979
res=QR_Constructor();
975980
QR_set_status(res,PGRES_FATAL_ERROR);
976981
returnres;
@@ -1006,7 +1011,9 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];// QR_set_command() dups this string so dont
10061011
SOCK_get_string(sock,msgbuffer,MAX_MESSAGE_LEN);
10071012
break;
10081013
case'T':/* Tuple results start here */
1009-
if (result_in==NULL) {
1014+
result_in=qi ?qi->result_in :NULL;
1015+
1016+
if (result_in==NULL) {
10101017
result_in=QR_Constructor();
10111018
mylog("send_query: 'T' no result_in: res = %u\n",result_in);
10121019
if ( !result_in) {
@@ -1015,7 +1022,10 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];// QR_set_command() dups this string so dont
10151022
returnNULL;
10161023
}
10171024

1018-
if ( !QR_fetch_tuples(result_in,self,cursor)) {
1025+
if (qi)
1026+
QR_set_cache_size(result_in,qi->row_size);
1027+
1028+
if ( !QR_fetch_tuples(result_in,self,qi ?qi->cursor :NULL)) {
10191029
self->errornumber=CONNECTION_COULD_NOT_RECEIVE;
10201030
self->errormsg=QR_get_message(result_in);
10211031
returnNULL;
@@ -1040,7 +1050,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1];// QR_set_command() dups this string so dont
10401050
returnres;
10411051
default:
10421052
self->errornumber=CONNECTION_BACKEND_CRAZY;
1043-
self->errormsg="Unexpected protocol character from backend";
1053+
self->errormsg="Unexpected protocol character from backend (send_query)";
10441054
CC_set_no_trans(self);
10451055

10461056
mylog("send_query: error - %s\n",self->errormsg);
@@ -1058,7 +1068,6 @@ static char msgbuffer[MAX_MESSAGE_LEN+1];
10581068
inti;
10591069

10601070
mylog("send_function(): conn=%u, fnid=%d, result_is_int=%d, nargs=%d\n",self,fnid,result_is_int,nargs);
1061-
//qlog("conn=%u, func=%d\n", self, fnid);
10621071

10631072
if (SOCK_get_errcode(sock)!=0) {
10641073
self->errornumber=CONNECTION_COULD_NOT_SEND;
@@ -1124,9 +1133,12 @@ int i;
11241133

11251134
return FALSE;
11261135

1136+
case'Z':
1137+
break;
1138+
11271139
default:
11281140
self->errornumber=CONNECTION_BACKEND_CRAZY;
1129-
self->errormsg="Unexpected protocol character from backend";
1141+
self->errormsg="Unexpected protocol character from backend (send_function, args)";
11301142
CC_set_no_trans(self);
11311143

11321144
mylog("send_function: error - %s\n",self->errormsg);
@@ -1178,7 +1190,7 @@ int i;
11781190

11791191
default:
11801192
self->errornumber=CONNECTION_BACKEND_CRAZY;
1181-
self->errormsg="Unexpected protocol character from backend";
1193+
self->errormsg="Unexpected protocol character from backend (send_function, result)";
11821194
CC_set_no_trans(self);
11831195

11841196
mylog("send_function: error - %s\n",self->errormsg);
@@ -1352,107 +1364,3 @@ CC_log_error(char *func, char *desc, ConnectionClass *self)
13521364
qlog("INVALID CONNECTION HANDLE ERROR: func=%s, desc='%s'\n",func,desc);
13531365
}
13541366

1355-
/*
1356-
void
1357-
CC_test(ConnectionClass *self)
1358-
{
1359-
static char *func = "CC_test";
1360-
HSTMT hstmt1;
1361-
RETCODE result;
1362-
char pktab[255], fktab[255], pkcol[255], fkcol[255], tgname[255];
1363-
SDWORD pktab_len, pkcol_len, fktab_len, fkcol_len, ur_len, dr_len, tgname_len;
1364-
SWORD cols, seq;
1365-
SDWORD update_rule, delete_rule;
1366-
1367-
mylog( "%s: entering...\n", func);
1368-
1369-
result = SQLAllocStmt( self, &hstmt1);
1370-
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
1371-
return;
1372-
}
1373-
1374-
result = SQLPrimaryKeys(hstmt1, NULL, 0, NULL, 0, "t1", SQL_NTS);
1375-
1376-
qlog("SQLPrimaryKeys result = %d\n", result);
1377-
1378-
result = SQLNumResultCols(hstmt1, &cols);
1379-
qlog("cols SQLTables result = %d\n", result);
1380-
1381-
result = SQLBindCol(hstmt1, 3, SQL_C_CHAR, pktab, sizeof(pktab), &pktab_len);
1382-
qlog("bind result = %d\n", result);
1383-
1384-
result = SQLBindCol(hstmt1, 4, SQL_C_CHAR, pkcol, sizeof(pkcol), &pkcol_len);
1385-
qlog("bind result = %d\n", result);
1386-
1387-
result = SQLBindCol(hstmt1, 5, SQL_C_SHORT, &seq, 0, NULL);
1388-
qlog("bind result = %d\n", result);
1389-
1390-
result = SQLFetch(hstmt1);
1391-
qlog("SQLFetch result = %d\n", result);
1392-
while (result != SQL_NO_DATA_FOUND) {
1393-
qlog("fetch on stmt1: result = %d, pktab='%s', pkcol='%s', seq=%d\n",
1394-
result, pktab, pkcol, seq);
1395-
1396-
result = SQLFetch(hstmt1);
1397-
}
1398-
qlog("SQLFetch result = %d\n", result);
1399-
1400-
// Test of case #1
1401-
result = SQLForeignKeys(hstmt1, "", SQL_NTS, "", SQL_NTS, "t1", SQL_NTS,
1402-
NULL, 0, NULL, 0, NULL, 0);
1403-
1404-
//Test of case #2
1405-
result = SQLForeignKeys(hstmt1, "", SQL_NTS, "", SQL_NTS, NULL, 0,
1406-
NULL, 0, NULL, 0, "ar_register", SQL_NTS);
1407-
1408-
1409-
//Test of case #3
1410-
result = SQLForeignKeys(hstmt1, NULL, 0, NULL, 0, "employee", SQL_NTS,
1411-
NULL, 0, NULL, 0, "invoice", SQL_NTS);
1412-
1413-
qlog("SQLForeignKeys result = %d\n", result);
1414-
1415-
result = SQLNumResultCols(hstmt1, &cols);
1416-
qlog("cols SQLTables result = %d\n", result);
1417-
1418-
result = SQLBindCol(hstmt1, 3, SQL_C_CHAR, pktab, sizeof(pktab), &pktab_len);
1419-
qlog("bind result = %d\n", result);
1420-
1421-
result = SQLBindCol(hstmt1, 4, SQL_C_CHAR, pkcol, sizeof(pkcol), &pkcol_len);
1422-
qlog("bind result = %d\n", result);
1423-
1424-
result = SQLBindCol(hstmt1, 7, SQL_C_CHAR, fktab, sizeof(fktab), &fktab_len);
1425-
qlog("bind result = %d\n", result);
1426-
1427-
result = SQLBindCol(hstmt1, 8, SQL_C_CHAR, fkcol, sizeof(fkcol), &fkcol_len);
1428-
qlog("bind result = %d\n", result);
1429-
1430-
result = SQLBindCol(hstmt1, 9, SQL_C_SHORT, &seq, 0, NULL);
1431-
qlog("bind result = %d\n", result);
1432-
1433-
result = SQLBindCol(hstmt1, 10, SQL_C_LONG, &update_rule, 0, &ur_len);
1434-
qlog("bind result = %d\n", result);
1435-
1436-
result = SQLBindCol(hstmt1, 11, SQL_C_LONG, &delete_rule, 0, &dr_len);
1437-
qlog("bind result = %d\n", result);
1438-
1439-
result = SQLBindCol(hstmt1, 14, SQL_C_CHAR, tgname, sizeof(tgname), &tgname_len);
1440-
qlog("bind result = %d\n", result);
1441-
1442-
result = SQLFetch(hstmt1);
1443-
qlog("SQLFetch result = %d\n", result);
1444-
while (result != SQL_NO_DATA_FOUND) {
1445-
qlog("fetch on stmt1: result = %d, pktab='%s', pkcol='%s', fktab='%s', fkcol='%s', seq=%d, update_rule=%d, ur_len=%d, delete_rule=%d, dr_len=%d, tgname='%s', tgname_len=%d\n",
1446-
result, pktab, pkcol, fktab, fkcol, seq, update_rule, ur_len, delete_rule, dr_len, tgname, tgname_len);
1447-
1448-
result = SQLFetch(hstmt1);
1449-
}
1450-
qlog("SQLFetch result = %d\n", result);
1451-
1452-
SQLFreeStmt(hstmt1, SQL_DROP);
1453-
1454-
}
1455-
*/
1456-
1457-
1458-

‎src/interfaces/odbc/connection.h

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,34 @@ typedef enum {
3535
}CONN_Status;
3636

3737
/*These errors have general sql error state */
38-
#defineCONNECTION_SERVER_NOT_REACHED1
39-
#defineCONNECTION_MSG_TOO_LONG3
40-
#defineCONNECTION_COULD_NOT_SEND4
41-
#defineCONNECTION_NO_SUCH_DATABASE5
42-
#defineCONNECTION_BACKEND_CRAZY6
43-
#defineCONNECTION_NO_RESPONSE7
44-
#defineCONNECTION_SERVER_REPORTED_ERROR8
45-
#defineCONNECTION_COULD_NOT_RECEIVE9
46-
#defineCONNECTION_SERVER_REPORTED_WARNING10
47-
#defineCONNECTION_NEED_PASSWORD12
38+
#defineCONNECTION_SERVER_NOT_REACHED101
39+
#defineCONNECTION_MSG_TOO_LONG103
40+
#defineCONNECTION_COULD_NOT_SEND104
41+
#defineCONNECTION_NO_SUCH_DATABASE105
42+
#defineCONNECTION_BACKEND_CRAZY106
43+
#defineCONNECTION_NO_RESPONSE107
44+
#defineCONNECTION_SERVER_REPORTED_ERROR108
45+
#defineCONNECTION_COULD_NOT_RECEIVE109
46+
#defineCONNECTION_SERVER_REPORTED_WARNING110
47+
#defineCONNECTION_NEED_PASSWORD112
4848

4949
/*These errors correspond to specific SQL states */
50-
#defineCONN_INIREAD_ERROR1
51-
#defineCONN_OPENDB_ERROR2
52-
#defineCONN_STMT_ALLOC_ERROR3
53-
#defineCONN_IN_USE4
54-
#defineCONN_UNSUPPORTED_OPTION5
50+
#defineCONN_INIREAD_ERROR201
51+
#defineCONN_OPENDB_ERROR202
52+
#defineCONN_STMT_ALLOC_ERROR203
53+
#defineCONN_IN_USE204
54+
#defineCONN_UNSUPPORTED_OPTION205
5555
/* Used by SetConnectoption to indicate unsupported options */
56-
#defineCONN_INVALID_ARGUMENT_NO6
56+
#defineCONN_INVALID_ARGUMENT_NO206
5757
/* SetConnectOption: corresponds to ODBC--"S1009" */
58-
#defineCONN_TRANSACT_IN_PROGRES7
59-
#defineCONN_NO_MEMORY_ERROR8
60-
#defineCONN_NOT_IMPLEMENTED_ERROR9
61-
#defineCONN_INVALID_AUTHENTICATION10
62-
#defineCONN_AUTH_TYPE_UNSUPPORTED11
63-
#defineCONN_UNABLE_TO_LOAD_DLL12
58+
#defineCONN_TRANSACT_IN_PROGRES207
59+
#defineCONN_NO_MEMORY_ERROR208
60+
#defineCONN_NOT_IMPLEMENTED_ERROR209
61+
#defineCONN_INVALID_AUTHENTICATION210
62+
#defineCONN_AUTH_TYPE_UNSUPPORTED211
63+
#defineCONN_UNABLE_TO_LOAD_DLL212
6464

65+
#defineCONN_OPTION_VALUE_CHANGED 213
6566

6667
/* Conn_status defines */
6768
#defineCONN_IN_AUTOCOMMIT 0x01
@@ -200,6 +201,7 @@ typedef BOOL (FAR WINAPI *DriverToDataSourceProc) (UDWORD,
200201
/*******The Connection handle************/
201202
structConnectionClass_ {
202203
HENVhenv;/* environment this connection was created on */
204+
StatementOptionsstmtOptions;
203205
char*errormsg;
204206
interrornumber;
205207
CONN_Statusstatus;
@@ -244,7 +246,7 @@ char CC_connect(ConnectionClass *self, char do_password);
244246
charCC_add_statement(ConnectionClass*self,StatementClass*stmt);
245247
charCC_remove_statement(ConnectionClass*self,StatementClass*stmt);
246248
charCC_get_error(ConnectionClass*self,int*number,char**message);
247-
QResultClass*CC_send_query(ConnectionClass*self,char*query,QResultClass*result_in,char*cursor);
249+
QResultClass*CC_send_query(ConnectionClass*self,char*query,QueryInfo*qi);
248250
voidCC_clear_error(ConnectionClass*self);
249251
char*CC_create_errormsg(ConnectionClass*self);
250252
intCC_send_function(ConnectionClass*conn,intfnid,void*result_buf,int*actual_result_len,intresult_is_int,LO_ARG*argv,intnargs);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp