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

Commit7942084

Browse files
author
Hiroshi Inoue
committed
1) Support Keyset Driven driver cursors.
2) Supprt ARD precision/scale and SQL_C_NUEMRIC.3) Minimal implementation of SQLGetDiagField().4) SQLRowCount() reports the result of SQLSetPos and SQLBulkOperation.5) int8 -> SQL_NUMERIC for Microsoft Jet.6) Support isolation level change.7) ODBC3.0 SQLSTATE code.8) Append mode log files.
1 parent6c6f395 commit7942084

29 files changed

+1958
-546
lines changed

‎src/interfaces/odbc/bind.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ PGAPI_BindParameter(
6969
opts->parameters[ipar].SQLType=fSqlType;
7070
opts->parameters[ipar].column_size=cbColDef;
7171
opts->parameters[ipar].decimal_digits=ibScale;
72+
opts->parameters[ipar].precision=0;
73+
opts->parameters[ipar].scale=0;
74+
#if (ODBCVER >=0x0300)
75+
switch (fCType)
76+
{
77+
caseSQL_C_NUMERIC:
78+
if (cbColDef>0)
79+
opts->parameters[ipar].precision= (UInt2)cbColDef;
80+
if (ibScale>0)
81+
opts->parameters[ipar].scale=ibScale;
82+
break;
83+
caseSQL_C_TYPE_TIMESTAMP:
84+
if (ibScale>0)
85+
opts->parameters[ipar].precision=ibScale;
86+
break;
87+
}
88+
#endif/* ODBCVER */
7289

7390
/*
7491
* If rebinding a parameter that had data-at-exec stuff in it, then
@@ -210,6 +227,8 @@ inolog("Column 0 is type %d not of type SQL_C_BOOKMARK", fCType);
210227
free(opts->bindings[icol].ttlbuf);
211228
opts->bindings[icol].ttlbuf=NULL;
212229
opts->bindings[icol].ttlbuflen=0;
230+
opts->bindings[icol].precision=0;
231+
opts->bindings[icol].scale=0;
213232
}
214233
else
215234
{
@@ -218,6 +237,13 @@ inolog("Column 0 is type %d not of type SQL_C_BOOKMARK", fCType);
218237
opts->bindings[icol].buffer=rgbValue;
219238
opts->bindings[icol].used=pcbValue;
220239
opts->bindings[icol].returntype=fCType;
240+
#if (ODBCVER >=0x0300)
241+
if (SQL_C_NUMERIC==fCType)
242+
opts->bindings[icol].precision=32;
243+
else
244+
#endif/* ODBCVER */
245+
opts->bindings[icol].precision=0;
246+
opts->bindings[icol].scale=0;
221247

222248
mylog(" bound buffer[%d] = %u\n",icol,opts->bindings[icol].buffer);
223249
}
@@ -460,6 +486,8 @@ reset_a_parameter_binding(APDFields *self, int ipar)
460486
self->parameters[ipar].SQLType=0;
461487
self->parameters[ipar].column_size=0;
462488
self->parameters[ipar].decimal_digits=0;
489+
self->parameters[ipar].precision=0;
490+
self->parameters[ipar].scale=0;
463491
self->parameters[ipar].data_at_exec= FALSE;
464492
self->parameters[ipar].lobj_oid=0;
465493
}

‎src/interfaces/odbc/bind.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct BindInfoClass_
2727
Int2returntype;/* kind of conversion to be applied when
2828
* returning (SQL_C_DEFAULT,
2929
* SQL_C_CHAR...) */
30+
Int2precision;/* the precision for numeric or timestamp type */
31+
Int2scale;/* the scale for numeric type */
3032
};
3133

3234
/*
@@ -40,12 +42,14 @@ struct ParameterInfoClass_
4042
Int2paramType;
4143
Int2CType;
4244
Int2SQLType;
43-
UInt4column_size;
4445
Int2decimal_digits;
46+
UInt4column_size;
4547
Oidlobj_oid;
4648
Int4*EXEC_used;/* amount of data OR the oid of the large
4749
* object */
4850
char*EXEC_buffer;/* the data or the FD of the large object */
51+
Int2precision;/* the precision for numeric or timestamp type */
52+
Int2scale;/* the scale for numeric type */
4953
chardata_at_exec;
5054
};
5155

‎src/interfaces/odbc/connection.c

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ CC_conninfo_init(ConnInfo *conninfo)
237237
{
238238
memset(conninfo,0,sizeof(ConnInfo));
239239
conninfo->disallow_premature=-1;
240-
conninfo->updatable_cursors=-1;
240+
conninfo->allow_keyset=-1;
241241
conninfo->lf_conversion=-1;
242242
conninfo->true_is_minus1=-1;
243243
memcpy(&(conninfo->drivers),&globals,sizeof(globals));
@@ -293,6 +293,7 @@ CC_Constructor()
293293
rv->unicode=0;
294294
rv->result_uncommitted=0;
295295
rv->schema_support=0;
296+
rv->isolation=SQL_TXN_READ_COMMITTED;
296297
#ifdefMULTIBYTE
297298
rv->client_encoding=NULL;
298299
rv->server_encoding=NULL;
@@ -996,6 +997,12 @@ CC_connect(ConnectionClass *self, char do_password)
996997
}
997998
#endif/* UNICODE_SUPPORT */
998999
#endif/* MULTIBYTE */
1000+
ci->updatable_cursors=0;
1001+
#ifdefDRIVER_CURSOR_IMPLEMENT
1002+
if (!ci->drivers.use_declarefetch&&
1003+
PG_VERSION_GE(self,7.0))/* Tid scan since 7.0 */
1004+
ci->updatable_cursors=ci->allow_keyset;
1005+
#endif/* DRIVER_CURSOR_IMPLEMENT */
9991006

10001007
CC_clear_error(self);/* clear any initial command errors */
10011008
self->status=CONN_CONNECTED;
@@ -1130,17 +1137,19 @@ voidCC_on_commit(ConnectionClass *conn)
11301137
}
11311138
conn->result_uncommitted=0;
11321139
}
1133-
voidCC_on_abort(ConnectionClass*conn,BOOLset_no_trans)
1140+
voidCC_on_abort(ConnectionClass*conn,UDWORDopt)
11341141
{
11351142
if (CC_is_in_trans(conn))
11361143
{
11371144
#ifdefDRIVER_CURSOR_IMPLEMENT
11381145
if (conn->result_uncommitted)
11391146
ProcessRollback(conn, TRUE);
11401147
#endif/* DRIVER_CURSOR_IMPLEMENT */
1141-
if (set_no_trans)
1148+
if (0!= (opt&NO_TRANS))
11421149
CC_set_no_trans(conn);
11431150
}
1151+
if (0!= (opt&CONN_DEAD))
1152+
conn->status=CONN_DOWN;
11441153
conn->result_uncommitted=0;
11451154
}
11461155

@@ -1162,8 +1171,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
11621171
BOOLclear_result_on_abort= ((flag&CLEAR_RESULT_ON_ABORT)!=0),
11631172
create_keyset= ((flag&CREATE_KEYSET)!=0),
11641173
issue_begin= ((flag&GO_INTO_TRANSACTION)!=0&& !CC_is_in_trans(self));
1165-
charswallow,
1166-
*wq;
1174+
charswallow,*wq,*ptr;
11671175
intid;
11681176
SocketClass*sock=self->sock;
11691177
intmaxlen,
@@ -1173,8 +1181,8 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
11731181
query_completed= FALSE,
11741182
before_64=PG_VERSION_LT(self,6.4),
11751183
aborted= FALSE,
1176-
used_passed_result_object= FALSE,
1177-
set_no_trans;
1184+
used_passed_result_object= FALSE;
1185+
UDWORDabort_opt;
11781186

11791187
/* ERROR_MSG_LENGTH is suffcient */
11801188
staticcharmsgbuffer[ERROR_MSG_LENGTH+1];
@@ -1201,7 +1209,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12011209
{
12021210
self->errornumber=CONNECTION_COULD_NOT_SEND;
12031211
self->errormsg="Could not send Query to backend";
1204-
CC_on_abort(self,TRUE);
1212+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
12051213
returnNULL;
12061214
}
12071215

@@ -1210,7 +1218,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12101218
{
12111219
self->errornumber=CONNECTION_COULD_NOT_SEND;
12121220
self->errormsg="Could not send Query to backend";
1213-
CC_on_abort(self,TRUE);
1221+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
12141222
returnNULL;
12151223
}
12161224

@@ -1223,7 +1231,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12231231
{
12241232
self->errornumber=CONNECTION_COULD_NOT_SEND;
12251233
self->errormsg="Could not send Query to backend";
1226-
CC_on_abort(self,TRUE);
1234+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
12271235
returnNULL;
12281236
}
12291237

@@ -1260,7 +1268,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12601268
self->errormsg="No response from the backend";
12611269

12621270
mylog("send_query: 'id' - %s\n",self->errormsg);
1263-
CC_on_abort(self,TRUE);
1271+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
12641272
ReadyToReturn= TRUE;
12651273
retres=NULL;
12661274
break;
@@ -1284,7 +1292,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
12841292
self->errornumber=CONNECTION_NO_RESPONSE;
12851293
self->errormsg="No response from backend while receiving a portal query command";
12861294
mylog("send_query: 'C' - %s\n",self->errormsg);
1287-
CC_on_abort(self,TRUE);
1295+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
12881296
ReadyToReturn= TRUE;
12891297
retres=NULL;
12901298
}
@@ -1312,11 +1320,20 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
13121320
elseif (strnicmp(cmdbuffer,"COMMIT",6)==0)
13131321
CC_on_commit(self);
13141322
elseif (strnicmp(cmdbuffer,"ROLLBACK",8)==0)
1315-
CC_on_abort(self,TRUE);
1323+
CC_on_abort(self,NO_TRANS);
13161324
elseif (strnicmp(cmdbuffer,"END",3)==0)
13171325
CC_on_commit(self);
13181326
elseif (strnicmp(cmdbuffer,"ABORT",5)==0)
1319-
CC_on_abort(self, TRUE);
1327+
CC_on_abort(self,NO_TRANS);
1328+
else
1329+
{
1330+
trim(cmdbuffer);/* get rid of trailing space */
1331+
ptr=strrchr(cmdbuffer,' ');
1332+
if (ptr)
1333+
res->recent_processed_row_count=atoi(ptr+1);
1334+
else
1335+
res->recent_processed_row_count=-1;
1336+
}
13201337

13211338
if (QR_command_successful(res))
13221339
QR_set_status(res,PGRES_COMMAND_OK);
@@ -1400,15 +1417,15 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
14001417
qlog("ERROR from backend during send_query: '%s'\n",msgbuffer);
14011418

14021419
/* We should report that an error occured. Zoltan */
1403-
set_no_trans=FALSE;
1420+
abort_opt=0;
14041421
if (!strncmp(msgbuffer,"FATAL",5))
14051422
{
14061423
self->errornumber=CONNECTION_SERVER_REPORTED_ERROR;
1407-
set_no_trans=TRUE;
1424+
abort_opt=NO_TRANS |CONN_DEAD;
14081425
}
14091426
else
14101427
self->errornumber=CONNECTION_SERVER_REPORTED_WARNING;
1411-
CC_on_abort(self,set_no_trans);
1428+
CC_on_abort(self,abort_opt);
14121429
QR_set_status(res,PGRES_FATAL_ERROR);
14131430
QR_set_message(res,msgbuffer);
14141431
QR_set_aborted(res, TRUE);
@@ -1497,7 +1514,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
14971514
default:
14981515
self->errornumber=CONNECTION_BACKEND_CRAZY;
14991516
self->errormsg="Unexpected protocol character from backend (send_query)";
1500-
CC_on_abort(self,TRUE);
1517+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
15011518

15021519
mylog("send_query: error - %s\n",self->errormsg);
15031520
ReadyToReturn= TRUE;
@@ -1585,7 +1602,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
15851602
{
15861603
self->errornumber=CONNECTION_COULD_NOT_SEND;
15871604
self->errormsg="Could not send function to backend";
1588-
CC_on_abort(self,TRUE);
1605+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
15891606
return FALSE;
15901607
}
15911608

@@ -1594,7 +1611,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
15941611
{
15951612
self->errornumber=CONNECTION_COULD_NOT_SEND;
15961613
self->errormsg="Could not send function to backend";
1597-
CC_on_abort(self,TRUE);
1614+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
15981615
return FALSE;
15991616
}
16001617

@@ -1643,7 +1660,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
16431660
case'E':
16441661
SOCK_get_string(sock,msgbuffer,ERROR_MSG_LENGTH);
16451662
self->errormsg=msgbuffer;
1646-
CC_on_abort(self,FALSE);
1663+
CC_on_abort(self,0);
16471664

16481665
mylog("send_function(V): 'E' - %s\n",self->errormsg);
16491666
qlog("ERROR from backend during send_function: '%s'\n",self->errormsg);
@@ -1656,7 +1673,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
16561673
default:
16571674
self->errornumber=CONNECTION_BACKEND_CRAZY;
16581675
self->errormsg="Unexpected protocol character from backend (send_function, args)";
1659-
CC_on_abort(self,TRUE);
1676+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
16601677

16611678
mylog("send_function: error - %s\n",self->errormsg);
16621679
return FALSE;
@@ -1690,7 +1707,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
16901707
case'E':
16911708
SOCK_get_string(sock,msgbuffer,ERROR_MSG_LENGTH);
16921709
self->errormsg=msgbuffer;
1693-
CC_on_abort(self,FALSE);
1710+
CC_on_abort(self,0);
16941711
mylog("send_function(G): 'E' - %s\n",self->errormsg);
16951712
qlog("ERROR from backend during send_function: '%s'\n",self->errormsg);
16961713

@@ -1711,7 +1728,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
17111728
default:
17121729
self->errornumber=CONNECTION_BACKEND_CRAZY;
17131730
self->errormsg="Unexpected protocol character from backend (send_function, result)";
1714-
CC_on_abort(self,TRUE);
1731+
CC_on_abort(self,NO_TRANS |CONN_DEAD);
17151732

17161733
mylog("send_function: error - %s\n",self->errormsg);
17171734
return FALSE;

‎src/interfaces/odbc/connection.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ typedef struct
166166
chartranslation_option[SMALL_REGISTRY_LEN];
167167
charfocus_password;
168168
chardisallow_premature;
169+
charallow_keyset;
169170
charupdatable_cursors;
170171
charlf_conversion;
171172
chartrue_is_minus1;
@@ -290,12 +291,13 @@ struct ConnectionClass_
290291
charresult_uncommitted;
291292
charschema_support;
292293
#ifdefMULTIBYTE
293-
char*client_encoding;
294-
char*server_encoding;
294+
char*client_encoding;
295+
char*server_encoding;
295296
#endif/* MULTIBYTE */
296-
intccsc;
297+
intccsc;
297298
intbe_pid;/* pid returned by backend */
298299
intbe_key;/* auth code needed to send cancel */
300+
UInt4isolation;
299301
};
300302

301303

@@ -339,11 +341,15 @@ voidCC_log_error(const char *func, const char *desc, const ConnectionClass *se
339341
intCC_get_max_query_len(constConnectionClass*self);
340342
intCC_send_cancel_request(constConnectionClass*conn);
341343
voidCC_on_commit(ConnectionClass*conn);
342-
voidCC_on_abort(ConnectionClass*conn,BOOLset_no_trans);
344+
voidCC_on_abort(ConnectionClass*conn,UDWORDopt);
343345
voidProcessRollback(ConnectionClass*conn,BOOLundo);
344346

345-
/*CC_send_query_options */
347+
/*CC_send_query options */
346348
#defineCLEAR_RESULT_ON_ABORT1L
347349
#defineCREATE_KEYSET(1L << 1)/* create keyset for updatable curosrs */
348350
#defineGO_INTO_TRANSACTION(1L << 2)/* issue begin in advance */
349-
#endif
351+
/* CC_on_abort options */
352+
#defineNO_TRANS1L
353+
#defineCONN_DEAD(1L << 1)/* connection is no longer valid */
354+
355+
#endif/* __CONNECTION_H__ */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp