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

Commit0c439e5

Browse files
author
Hiroshi Inoue
committed
1) Change all internal SQL function calls from
SQLxxxx() to PGAPI_xxxx().2) Handle an escaped date/time format as a parameter.3) Improve the tuple allocation a little.4) The preparation of ODBC 3.0 a little.5) Updatable cursors(may be deprecated before long).
1 parent58d4f95 commit0c439e5

21 files changed

+1278
-510
lines changed

‎src/interfaces/odbc/bind.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
#include"sql.h"
3434
#include"sqlext.h"
3535
#endif
36+
#include"pgapifunc.h"
3637

3738

3839
/*Bind parameters on a statement handle */
3940
RETCODESQL_API
40-
SQLBindParameter(
41+
PGAPI_BindParameter(
4142
HSTMThstmt,
4243
UWORDipar,
4344
SWORDfParamType,
@@ -50,7 +51,7 @@ SQLBindParameter(
5051
SDWORDFAR*pcbValue)
5152
{
5253
StatementClass*stmt= (StatementClass*)hstmt;
53-
staticchar*func="SQLBindParameter";
54+
staticchar*func="PGAPI_BindParameter";
5455

5556
mylog("%s: entering...\n",func);
5657

@@ -155,15 +156,15 @@ SQLBindParameter(
155156
if (stmt->status==STMT_PREMATURE)
156157
SC_recycle_statement(stmt);
157158

158-
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);
159+
mylog("PGAPI_BindParamater: 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);
159160

160161
returnSQL_SUCCESS;
161162
}
162163

163164

164165
/*Associate a user-supplied buffer with a database column. */
165166
RETCODESQL_API
166-
SQLBindCol(
167+
PGAPI_BindCol(
167168
HSTMThstmt,
168169
UWORDicol,
169170
SWORDfCType,
@@ -172,11 +173,12 @@ SQLBindCol(
172173
SDWORDFAR*pcbValue)
173174
{
174175
StatementClass*stmt= (StatementClass*)hstmt;
175-
staticchar*func="SQLBindCol";
176+
staticchar*func="PGAPI_BindCol";
176177

177178
mylog("%s: entering...\n",func);
178179

179-
mylog("**** SQLBindCol: stmt = %u, icol = %d\n",stmt,icol);
180+
mylog("**** PGAPI_BindCol: stmt = %u, icol = %d\n",stmt,icol);
181+
mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n",fCType,rgbValue,cbValueMax,pcbValue);
180182

181183
if (!stmt)
182184
{
@@ -275,7 +277,7 @@ SQLBindCol(
275277
*data type (most likely varchar).
276278
*/
277279
RETCODESQL_API
278-
SQLDescribeParam(
280+
PGAPI_DescribeParam(
279281
HSTMThstmt,
280282
UWORDipar,
281283
SWORDFAR*pfSqlType,
@@ -284,7 +286,7 @@ SQLDescribeParam(
284286
SWORDFAR*pfNullable)
285287
{
286288
StatementClass*stmt= (StatementClass*)hstmt;
287-
staticchar*func="SQLDescribeParam";
289+
staticchar*func="PGAPI_DescribeParam";
288290

289291
mylog("%s: entering...\n",func);
290292

@@ -297,7 +299,7 @@ SQLDescribeParam(
297299

298300
if ((ipar<1)|| (ipar>stmt->parameters_allocated))
299301
{
300-
stmt->errormsg="Invalid parameter number forSQLDescribeParam.";
302+
stmt->errormsg="Invalid parameter number forPGAPI_DescribeParam.";
301303
stmt->errornumber=STMT_BAD_PARAMETER_NUMBER_ERROR;
302304
SC_log_error(func,"",stmt);
303305
returnSQL_ERROR;
@@ -328,15 +330,18 @@ SQLDescribeParam(
328330

329331
/*Sets multiple values (arrays) for the set of parameter markers. */
330332
RETCODESQL_API
331-
SQLParamOptions(
333+
PGAPI_ParamOptions(
332334
HSTMThstmt,
333335
UDWORDcrow,
334336
UDWORDFAR*pirow)
335337
{
336-
staticchar*func="SQLParamOptions";
338+
staticchar*func="PGAPI_ParamOptions";
339+
StatementClass*stmt= (StatementClass*)hstmt;
337340

338341
mylog("%s: entering...\n",func);
339342

343+
stmt->errornumber=CONN_UNSUPPORTED_OPTION;
344+
stmt->errormsg="Function not implemented";
340345
SC_log_error(func,"Function not implemented", (StatementClass*)hstmt);
341346
returnSQL_ERROR;
342347
}
@@ -352,14 +357,14 @@ SQLParamOptions(
352357
*If the statement does not have parameters, it should just return 0.
353358
*/
354359
RETCODESQL_API
355-
SQLNumParams(
360+
PGAPI_NumParams(
356361
HSTMThstmt,
357362
SWORDFAR*pcpar)
358363
{
359364
StatementClass*stmt= (StatementClass*)hstmt;
360365
charin_quote= FALSE;
361366
unsignedinti;
362-
staticchar*func="SQLNumParams";
367+
staticchar*func="PGAPI_NumParams";
363368

364369
mylog("%s: entering...\n",func);
365370

@@ -382,7 +387,7 @@ SQLNumParams(
382387
if (!stmt->statement)
383388
{
384389
/* no statement has been allocated */
385-
stmt->errormsg="SQLNumParams called with no statement ready.";
390+
stmt->errormsg="PGAPI_NumParams called with no statement ready.";
386391
stmt->errornumber=STMT_SEQUENCE_ERROR;
387392
SC_log_error(func,"",stmt);
388393
returnSQL_ERROR;

‎src/interfaces/odbc/columninfo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include"socket.h"
1818
#include<stdlib.h>
1919
#include<string.h>
20+
#include"pgapifunc.h"
2021

2122
ColumnInfoClass*
2223
CI_Constructor()

‎src/interfaces/odbc/connection.c

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#ifdefWIN32
3737
#include<odbcinst.h>
3838
#endif
39+
#include"pgapifunc.h"
3940

4041
#defineSTMT_INCREMENT 16/* how many statement holders to allocate
4142
* at a time */
@@ -46,13 +47,13 @@ extern GLOBAL_VALUES globals;
4647

4748

4849
RETCODESQL_API
49-
SQLAllocConnect(
50+
PGAPI_AllocConnect(
5051
HENVhenv,
5152
HDBCFAR*phdbc)
5253
{
5354
EnvironmentClass*env= (EnvironmentClass*)henv;
5455
ConnectionClass*conn;
55-
staticchar*func="SQLAllocConnect";
56+
staticchar*func="PGAPI_AllocConnect";
5657

5758
mylog("%s: entering...\n",func);
5859

@@ -85,7 +86,7 @@ SQLAllocConnect(
8586

8687

8788
RETCODESQL_API
88-
SQLConnect(
89+
PGAPI_Connect(
8990
HDBChdbc,
9091
UCHARFAR*szDSN,
9192
SWORDcbDSN,
@@ -96,7 +97,7 @@ SQLConnect(
9697
{
9798
ConnectionClass*conn= (ConnectionClass*)hdbc;
9899
ConnInfo*ci;
99-
staticchar*func="SQLConnect";
100+
staticchar*func="PGAPI_Connect";
100101

101102
mylog("%s: entering...\n",func);
102103

@@ -141,15 +142,15 @@ SQLConnect(
141142

142143

143144
RETCODESQL_API
144-
SQLBrowseConnect(
145+
PGAPI_BrowseConnect(
145146
HDBChdbc,
146147
UCHARFAR*szConnStrIn,
147148
SWORDcbConnStrIn,
148149
UCHARFAR*szConnStrOut,
149150
SWORDcbConnStrOutMax,
150151
SWORDFAR*pcbConnStrOut)
151152
{
152-
staticchar*func="SQLBrowseConnect";
153+
staticchar*func="PGAPI_BrowseConnect";
153154

154155
mylog("%s: entering...\n",func);
155156

@@ -159,11 +160,11 @@ SQLBrowseConnect(
159160

160161
/* Drop any hstmts open on hdbc and disconnect from database */
161162
RETCODESQL_API
162-
SQLDisconnect(
163+
PGAPI_Disconnect(
163164
HDBChdbc)
164165
{
165166
ConnectionClass*conn= (ConnectionClass*)hdbc;
166-
staticchar*func="SQLDisconnect";
167+
staticchar*func="PGAPI_Disconnect";
167168

168169

169170
mylog("%s: entering...\n",func);
@@ -197,11 +198,11 @@ SQLDisconnect(
197198

198199

199200
RETCODESQL_API
200-
SQLFreeConnect(
201+
PGAPI_FreeConnect(
201202
HDBChdbc)
202203
{
203204
ConnectionClass*conn= (ConnectionClass*)hdbc;
204-
staticchar*func="SQLFreeConnect";
205+
staticchar*func="PGAPI_FreeConnect";
205206

206207
mylog("%s: entering...\n",func);
207208
mylog("**** in %s: hdbc=%u\n",func,hdbc);
@@ -272,6 +273,7 @@ CC_Constructor()
272273
rv->translation_handle=NULL;
273274
rv->DataSourceToDriver=NULL;
274275
rv->DriverToDataSource=NULL;
276+
rv->driver_version=ODBCVER;
275277
memset(rv->pg_version,0,sizeof(rv->pg_version));
276278
rv->pg_version_number=.0;
277279
rv->pg_version_major=0;
@@ -1409,15 +1411,15 @@ CC_send_settings(ConnectionClass *self)
14091411
*has not transitioned to "connected" yet.
14101412
*/
14111413

1412-
result=SQLAllocStmt(self,&hstmt);
1414+
result=PGAPI_AllocStmt(self,&hstmt);
14131415
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
14141416
return FALSE;
14151417
stmt= (StatementClass*)hstmt;
14161418

14171419
stmt->internal= TRUE;/* ensure no BEGIN/COMMIT/ABORT stuff */
14181420

14191421
/* Set the Datestyle to the format the driver expects it to be in */
1420-
result=SQLExecDirect(hstmt,"set DateStyle to 'ISO'",SQL_NTS);
1422+
result=PGAPI_ExecDirect(hstmt,"set DateStyle to 'ISO'",SQL_NTS);
14211423
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
14221424
status= FALSE;
14231425

@@ -1426,7 +1428,7 @@ CC_send_settings(ConnectionClass *self)
14261428
/* Disable genetic optimizer based on global flag */
14271429
if (globals.disable_optimizer)
14281430
{
1429-
result=SQLExecDirect(hstmt,"set geqo to 'OFF'",SQL_NTS);
1431+
result=PGAPI_ExecDirect(hstmt,"set geqo to 'OFF'",SQL_NTS);
14301432
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
14311433
status= FALSE;
14321434

@@ -1437,7 +1439,7 @@ CC_send_settings(ConnectionClass *self)
14371439
/* KSQO */
14381440
if (globals.ksqo)
14391441
{
1440-
result=SQLExecDirect(hstmt,"set ksqo to 'ON'",SQL_NTS);
1442+
result=PGAPI_ExecDirect(hstmt,"set ksqo to 'ON'",SQL_NTS);
14411443
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
14421444
status= FALSE;
14431445

@@ -1452,7 +1454,7 @@ CC_send_settings(ConnectionClass *self)
14521454
ptr=strtok(cs,";");
14531455
while (ptr)
14541456
{
1455-
result=SQLExecDirect(hstmt,ptr,SQL_NTS);
1457+
result=PGAPI_ExecDirect(hstmt,ptr,SQL_NTS);
14561458
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
14571459
status= FALSE;
14581460

@@ -1471,7 +1473,7 @@ CC_send_settings(ConnectionClass *self)
14711473
ptr=strtok(cs,";");
14721474
while (ptr)
14731475
{
1474-
result=SQLExecDirect(hstmt,ptr,SQL_NTS);
1476+
result=PGAPI_ExecDirect(hstmt,ptr,SQL_NTS);
14751477
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
14761478
status= FALSE;
14771479

@@ -1484,7 +1486,7 @@ CC_send_settings(ConnectionClass *self)
14841486
}
14851487

14861488

1487-
SQLFreeStmt(hstmt,SQL_DROP);
1489+
PGAPI_FreeStmt(hstmt,SQL_DROP);
14881490

14891491
returnstatus;
14901492
}
@@ -1509,36 +1511,36 @@ CC_lookup_lo(ConnectionClass *self)
15091511
*This function must use the local odbc API functions since the odbc state
15101512
*has not transitioned to "connected" yet.
15111513
*/
1512-
result=SQLAllocStmt(self,&hstmt);
1514+
result=PGAPI_AllocStmt(self,&hstmt);
15131515
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
15141516
return;
15151517
stmt= (StatementClass*)hstmt;
15161518

1517-
result=SQLExecDirect(hstmt,"select oid from pg_type where typname='"PG_TYPE_LO_NAME"'",SQL_NTS);
1519+
result=PGAPI_ExecDirect(hstmt,"select oid from pg_type where typname='"PG_TYPE_LO_NAME"'",SQL_NTS);
15181520
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
15191521
{
1520-
SQLFreeStmt(hstmt,SQL_DROP);
1522+
PGAPI_FreeStmt(hstmt,SQL_DROP);
15211523
return;
15221524
}
15231525

1524-
result=SQLFetch(hstmt);
1526+
result=PGAPI_Fetch(hstmt);
15251527
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
15261528
{
1527-
SQLFreeStmt(hstmt,SQL_DROP);
1529+
PGAPI_FreeStmt(hstmt,SQL_DROP);
15281530
return;
15291531
}
15301532

1531-
result=SQLGetData(hstmt,1,SQL_C_SLONG,&self->lobj_type,sizeof(self->lobj_type),NULL);
1533+
result=PGAPI_GetData(hstmt,1,SQL_C_SLONG,&self->lobj_type,sizeof(self->lobj_type),NULL);
15321534
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
15331535
{
1534-
SQLFreeStmt(hstmt,SQL_DROP);
1536+
PGAPI_FreeStmt(hstmt,SQL_DROP);
15351537
return;
15361538
}
15371539

15381540
mylog("Got the large object oid: %d\n",self->lobj_type);
15391541
qlog(" [ Large Object oid = %d ]\n",self->lobj_type);
15401542

1541-
result=SQLFreeStmt(hstmt,SQL_DROP);
1543+
result=PGAPI_FreeStmt(hstmt,SQL_DROP);
15421544
}
15431545

15441546

@@ -1594,30 +1596,30 @@ CC_lookup_pg_version(ConnectionClass *self)
15941596
*This function must use the local odbc API functions since the odbc state
15951597
*has not transitioned to "connected" yet.
15961598
*/
1597-
result=SQLAllocStmt(self,&hstmt);
1599+
result=PGAPI_AllocStmt(self,&hstmt);
15981600
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
15991601
return;
16001602
stmt= (StatementClass*)hstmt;
16011603

16021604
/* get the server's version if possible */
1603-
result=SQLExecDirect(hstmt,"select version()",SQL_NTS);
1605+
result=PGAPI_ExecDirect(hstmt,"select version()",SQL_NTS);
16041606
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
16051607
{
1606-
SQLFreeStmt(hstmt,SQL_DROP);
1608+
PGAPI_FreeStmt(hstmt,SQL_DROP);
16071609
return;
16081610
}
16091611

1610-
result=SQLFetch(hstmt);
1612+
result=PGAPI_Fetch(hstmt);
16111613
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
16121614
{
1613-
SQLFreeStmt(hstmt,SQL_DROP);
1615+
PGAPI_FreeStmt(hstmt,SQL_DROP);
16141616
return;
16151617
}
16161618

1617-
result=SQLGetData(hstmt,1,SQL_C_CHAR,self->pg_version,MAX_INFO_STRING,NULL);
1619+
result=PGAPI_GetData(hstmt,1,SQL_C_CHAR,self->pg_version,MAX_INFO_STRING,NULL);
16181620
if ((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO))
16191621
{
1620-
SQLFreeStmt(hstmt,SQL_DROP);
1622+
PGAPI_FreeStmt(hstmt,SQL_DROP);
16211623
return;
16221624
}
16231625

@@ -1639,7 +1641,7 @@ CC_lookup_pg_version(ConnectionClass *self)
16391641
qlog(" [ PostgreSQL version string = '%s' ]\n",self->pg_version);
16401642
qlog(" [ PostgreSQL version number = '%1.1f' ]\n",self->pg_version_number);
16411643

1642-
result=SQLFreeStmt(hstmt,SQL_DROP);
1644+
result=PGAPI_FreeStmt(hstmt,SQL_DROP);
16431645
}
16441646

16451647

‎src/interfaces/odbc/connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ struct ConnectionClass_
264264
HINSTANCEtranslation_handle;
265265
DataSourceToDriverProcDataSourceToDriver;
266266
DriverToDataSourceProcDriverToDataSource;
267+
Int2driver_version;/* prepared for ODBC3.0 */
267268
chartransact_status;/* Is a transaction is currently in
268269
* progress */
269270
charerrormsg_created;/* has an informative error msg

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp