3636#ifdef WIN32
3737#include <odbcinst.h>
3838#endif
39+ #include "pgapifunc.h"
3940
4041#define STMT_INCREMENT 16/* how many statement holders to allocate
4142 * at a time */
@@ -46,13 +47,13 @@ extern GLOBAL_VALUES globals;
4647
4748
4849RETCODE SQL_API
49- SQLAllocConnect (
50+ PGAPI_AllocConnect (
5051HENV henv ,
5152HDBC FAR * phdbc )
5253{
5354EnvironmentClass * env = (EnvironmentClass * )henv ;
5455ConnectionClass * conn ;
55- static char * func = "SQLAllocConnect " ;
56+ static char * func = "PGAPI_AllocConnect " ;
5657
5758mylog ("%s: entering...\n" ,func );
5859
@@ -85,7 +86,7 @@ SQLAllocConnect(
8586
8687
8788RETCODE SQL_API
88- SQLConnect (
89+ PGAPI_Connect (
8990HDBC hdbc ,
9091UCHAR FAR * szDSN ,
9192SWORD cbDSN ,
@@ -96,7 +97,7 @@ SQLConnect(
9697{
9798ConnectionClass * conn = (ConnectionClass * )hdbc ;
9899ConnInfo * ci ;
99- static char * func = "SQLConnect " ;
100+ static char * func = "PGAPI_Connect " ;
100101
101102mylog ("%s: entering...\n" ,func );
102103
@@ -141,15 +142,15 @@ SQLConnect(
141142
142143
143144RETCODE SQL_API
144- SQLBrowseConnect (
145+ PGAPI_BrowseConnect (
145146HDBC hdbc ,
146147UCHAR FAR * szConnStrIn ,
147148SWORD cbConnStrIn ,
148149UCHAR FAR * szConnStrOut ,
149150SWORD cbConnStrOutMax ,
150151SWORD FAR * pcbConnStrOut )
151152{
152- static char * func = "SQLBrowseConnect " ;
153+ static char * func = "PGAPI_BrowseConnect " ;
153154
154155mylog ("%s: entering...\n" ,func );
155156
@@ -159,11 +160,11 @@ SQLBrowseConnect(
159160
160161/* Drop any hstmts open on hdbc and disconnect from database */
161162RETCODE SQL_API
162- SQLDisconnect (
163+ PGAPI_Disconnect (
163164HDBC hdbc )
164165{
165166ConnectionClass * conn = (ConnectionClass * )hdbc ;
166- static char * func = "SQLDisconnect " ;
167+ static char * func = "PGAPI_Disconnect " ;
167168
168169
169170mylog ("%s: entering...\n" ,func );
@@ -197,11 +198,11 @@ SQLDisconnect(
197198
198199
199200RETCODE SQL_API
200- SQLFreeConnect (
201+ PGAPI_FreeConnect (
201202HDBC hdbc )
202203{
203204ConnectionClass * conn = (ConnectionClass * )hdbc ;
204- static char * func = "SQLFreeConnect " ;
205+ static char * func = "PGAPI_FreeConnect " ;
205206
206207mylog ("%s: entering...\n" ,func );
207208mylog ("**** in %s: hdbc=%u\n" ,func ,hdbc );
@@ -272,6 +273,7 @@ CC_Constructor()
272273rv -> translation_handle = NULL ;
273274rv -> DataSourceToDriver = NULL ;
274275rv -> DriverToDataSource = NULL ;
276+ rv -> driver_version = ODBCVER ;
275277memset (rv -> pg_version ,0 ,sizeof (rv -> pg_version ));
276278rv -> pg_version_number = .0 ;
277279rv -> 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 );
14131415if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
14141416return FALSE;
14151417stmt = (StatementClass * )hstmt ;
14161418
14171419stmt -> 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 );
14211423if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
14221424status = FALSE;
14231425
@@ -1426,7 +1428,7 @@ CC_send_settings(ConnectionClass *self)
14261428/* Disable genetic optimizer based on global flag */
14271429if (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 );
14301432if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
14311433status = FALSE;
14321434
@@ -1437,7 +1439,7 @@ CC_send_settings(ConnectionClass *self)
14371439/* KSQO */
14381440if (globals .ksqo )
14391441{
1440- result = SQLExecDirect (hstmt ,"set ksqo to 'ON'" ,SQL_NTS );
1442+ result = PGAPI_ExecDirect (hstmt ,"set ksqo to 'ON'" ,SQL_NTS );
14411443if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
14421444status = FALSE;
14431445
@@ -1452,7 +1454,7 @@ CC_send_settings(ConnectionClass *self)
14521454ptr = strtok (cs ,";" );
14531455while (ptr )
14541456{
1455- result = SQLExecDirect (hstmt ,ptr ,SQL_NTS );
1457+ result = PGAPI_ExecDirect (hstmt ,ptr ,SQL_NTS );
14561458if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
14571459status = FALSE;
14581460
@@ -1471,7 +1473,7 @@ CC_send_settings(ConnectionClass *self)
14711473ptr = strtok (cs ,";" );
14721474while (ptr )
14731475{
1474- result = SQLExecDirect (hstmt ,ptr ,SQL_NTS );
1476+ result = PGAPI_ExecDirect (hstmt ,ptr ,SQL_NTS );
14751477if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
14761478status = 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
14891491return status ;
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 );
15131515if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
15141516return ;
15151517stmt = (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 );
15181520if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
15191521{
1520- SQLFreeStmt (hstmt ,SQL_DROP );
1522+ PGAPI_FreeStmt (hstmt ,SQL_DROP );
15211523return ;
15221524}
15231525
1524- result = SQLFetch (hstmt );
1526+ result = PGAPI_Fetch (hstmt );
15251527if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
15261528{
1527- SQLFreeStmt (hstmt ,SQL_DROP );
1529+ PGAPI_FreeStmt (hstmt ,SQL_DROP );
15281530return ;
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 );
15321534if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
15331535{
1534- SQLFreeStmt (hstmt ,SQL_DROP );
1536+ PGAPI_FreeStmt (hstmt ,SQL_DROP );
15351537return ;
15361538}
15371539
15381540mylog ("Got the large object oid: %d\n" ,self -> lobj_type );
15391541qlog (" [ 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 );
15981600if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
15991601return ;
16001602stmt = (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 );
16041606if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
16051607{
1606- SQLFreeStmt (hstmt ,SQL_DROP );
1608+ PGAPI_FreeStmt (hstmt ,SQL_DROP );
16071609return ;
16081610}
16091611
1610- result = SQLFetch (hstmt );
1612+ result = PGAPI_Fetch (hstmt );
16111613if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
16121614{
1613- SQLFreeStmt (hstmt ,SQL_DROP );
1615+ PGAPI_FreeStmt (hstmt ,SQL_DROP );
16141616return ;
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 );
16181620if ((result != SQL_SUCCESS )&& (result != SQL_SUCCESS_WITH_INFO ))
16191621{
1620- SQLFreeStmt (hstmt ,SQL_DROP );
1622+ PGAPI_FreeStmt (hstmt ,SQL_DROP );
16211623return ;
16221624}
16231625
@@ -1639,7 +1641,7 @@ CC_lookup_pg_version(ConnectionClass *self)
16391641qlog (" [ PostgreSQL version string = '%s' ]\n" ,self -> pg_version );
16401642qlog (" [ 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