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

Commit5a83221

Browse files
committed
odbc1.diff changes the text on the Protocol Radio buttons on the driver
dialogue from '6.4/6.5' to '6.5+' and removes some C++ comments fromresource.h (which VC++ insists on putting there).odbc2.diff adds code to query the PostgreSQL version upon connection. Thisis then used to determine what values to return for from SQLGetInfo forSQL_DBMS_VER, SQL_MAX_ROW_SIZE, SQL_MAX_STATEMENT_LEN, SQL_OJ_CAPABILITIESand SQL_OUTER_JOINS. The version string as returned by SELECT vERSION() (asa char array) and the major.minor version number (as a flost) have beenadded to the ConnectionClass structure.Dave Page
1 parent7edafaf commit5a83221

File tree

6 files changed

+105
-26
lines changed

6 files changed

+105
-26
lines changed

‎src/interfaces/odbc/connection.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ static char *func="CC_connect";
699699
*/
700700
CC_send_settings(self);
701701
CC_lookup_lo(self);/* a hack to get the oid of our large object oid type */
702+
CC_lookup_pg_version(self);/* Get PostgreSQL version for SQLGetInfo use */
702703

703704
CC_clear_error(self);/* clear any initial command errors */
704705
self->status=CONN_CONNECTED;
@@ -1364,6 +1365,62 @@ static char *func = "CC_lookup_lo";
13641365
result=SQLFreeStmt(hstmt,SQL_DROP);
13651366
}
13661367

1368+
/*This function gets the version of PostgreSQL that we're connected to.
1369+
This is used to return the correct info in SQLGetInfo
1370+
DJP - 25-1-2001
1371+
*/
1372+
void
1373+
CC_lookup_pg_version(ConnectionClass*self)
1374+
{
1375+
HSTMThstmt;
1376+
StatementClass*stmt;
1377+
RETCODEresult;
1378+
char*szVersion="0.0";
1379+
staticchar*func="CC_lookup_pg_version";
1380+
1381+
mylog("%s: entering...\n",func);
1382+
1383+
/*This function must use the local odbc API functions since the odbc state
1384+
has not transitioned to "connected" yet.
1385+
*/
1386+
result=SQLAllocStmt(self,&hstmt);
1387+
if((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO)) {
1388+
return;
1389+
}
1390+
stmt= (StatementClass*)hstmt;
1391+
1392+
result=SQLExecDirect(hstmt,"select version()",SQL_NTS);
1393+
if((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO)) {
1394+
SQLFreeStmt(hstmt,SQL_DROP);
1395+
return;
1396+
}
1397+
1398+
result=SQLFetch(hstmt);
1399+
if((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO)) {
1400+
SQLFreeStmt(hstmt,SQL_DROP);
1401+
return;
1402+
}
1403+
1404+
result=SQLGetData(hstmt,1,SQL_C_CHAR,self->pg_version,MAX_INFO_STRING,NULL);
1405+
if((result!=SQL_SUCCESS)&& (result!=SQL_SUCCESS_WITH_INFO)) {
1406+
SQLFreeStmt(hstmt,SQL_DROP);
1407+
return;
1408+
}
1409+
1410+
/* There's proably a nicer way of doing this... */
1411+
/* Extract the Major and Minor numbers from the string. */
1412+
/* This assumes the string starts 'Postgresql X.X' */
1413+
sprintf(szVersion,"%c.%c",self->pg_version[11],self->pg_version[13]);
1414+
self->pg_version_number= (float)atof(szVersion);
1415+
1416+
mylog("Got the PostgreSQL version string: '%s'\n",self->pg_version);
1417+
mylog("Extracted PostgreSQL version number: '%1.1f'\n",self->pg_version_number);
1418+
qlog(" [ PostgreSQL version string = '%s' ]\n",self->pg_version);
1419+
qlog(" [ PostgreSQL version number = '%1.1f' ]\n",self->pg_version_number);
1420+
1421+
result=SQLFreeStmt(hstmt,SQL_DROP);
1422+
}
1423+
13671424
void
13681425
CC_log_error(char*func,char*desc,ConnectionClass*self)
13691426
{

‎src/interfaces/odbc/connection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ struct ConnectionClass_ {
221221
DriverToDataSourceProcDriverToDataSource;
222222
chartransact_status;/* Is a transaction is currently in progress */
223223
charerrormsg_created;/* has an informative error msg been created? */
224+
charpg_version[MAX_INFO_STRING];/* Version of PostgreSQL we're connected to - DJP 25-1-2001 */
225+
floatpg_version_number;
224226
};
225227

226228

@@ -255,6 +257,7 @@ char *CC_create_errormsg(ConnectionClass *self);
255257
intCC_send_function(ConnectionClass*conn,intfnid,void*result_buf,int*actual_result_len,intresult_is_int,LO_ARG*argv,intnargs);
256258
charCC_send_settings(ConnectionClass*self);
257259
voidCC_lookup_lo(ConnectionClass*conn);
260+
voidCC_lookup_pg_version(ConnectionClass*conn);
258261
voidCC_log_error(char*func,char*desc,ConnectionClass*self);
259262

260263

‎src/interfaces/odbc/info.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ RETCODE result;
191191
break;
192192

193193
caseSQL_DBMS_VER:/* ODBC 1.0 */
194-
p=DBMS_VERSION;
194+
/* The ODBC spec wants ##.##.#### ...whatever... so prepend the driver */
195+
/* version number to the dbms version string */
196+
p=POSTGRESDRIVERVERSION;
197+
strcat(p," ");
198+
strcat(p,conn->pg_version);
195199
break;
196200

197201
caseSQL_DEFAULT_TXN_ISOLATION:/* ODBC 1.0 */
@@ -337,7 +341,11 @@ RETCODE result;
337341

338342
caseSQL_MAX_ROW_SIZE:/* ODBC 2.0 */
339343
len=4;
340-
value=MAX_ROW_SIZE;
344+
if (conn->pg_version_number >= (float)7.1) {/* Large Rowa in 7.1+ */
345+
value=MAX_ROW_SIZE;
346+
}else {/* Without the Toaster we're limited to the blocksize */
347+
value=BLCKSZ;
348+
}
341349
break;
342350

343351
caseSQL_MAX_ROW_SIZE_INCLUDES_LONG:/* ODBC 2.0 */
@@ -350,7 +358,11 @@ RETCODE result;
350358
caseSQL_MAX_STATEMENT_LEN:/* ODBC 2.0 */
351359
/* maybe this should be 0? */
352360
len=4;
353-
value=MAX_STATEMENT_LEN;
361+
if (conn->pg_version_number >= (float)7.0) {/* Long Queries in 7.0+ */
362+
value=MAX_STATEMENT_LEN;
363+
}else {/* Prior to 7.0 we used 2*BLCKSZ */
364+
value= (2*BLCKSZ);
365+
}
354366
break;
355367

356368
caseSQL_MAX_TABLE_NAME_LEN:/* ODBC 1.0 */
@@ -419,21 +431,29 @@ RETCODE result;
419431

420432
caseSQL_OJ_CAPABILITIES:/* ODBC 2.01 */
421433
len=4;
422-
value= (SQL_OJ_LEFT |
423-
SQL_OJ_RIGHT |
424-
SQL_OJ_FULL |
425-
SQL_OJ_NESTED |
426-
SQL_OJ_NOT_ORDERED |
427-
SQL_OJ_INNER |
428-
SQL_OJ_ALL_COMPARISON_OPS);
434+
if (conn->pg_version_number >= (float)7.1) {/* OJs in 7.1+ */
435+
value= (SQL_OJ_LEFT |
436+
SQL_OJ_RIGHT |
437+
SQL_OJ_FULL |
438+
SQL_OJ_NESTED |
439+
SQL_OJ_NOT_ORDERED |
440+
SQL_OJ_INNER |
441+
SQL_OJ_ALL_COMPARISON_OPS);
442+
}else {/* OJs not in <7.1 */
443+
value=0;
444+
}
429445
break;
430446

431447
caseSQL_ORDER_BY_COLUMNS_IN_SELECT:/* ODBC 2.0 */
432448
p= (PROTOCOL_62(ci)||PROTOCOL_63(ci)) ?"Y" :"N";
433449
break;
434450

435451
caseSQL_OUTER_JOINS:/* ODBC 1.0 */
436-
p="Y";
452+
if (conn->pg_version_number >= (float)7.1) {/* OJs in 7.1+ */
453+
p="Y";
454+
}else {/* OJs not in <7.1 */
455+
p="N";
456+
}
437457
break;
438458

439459
caseSQL_OWNER_TERM:/* ODBC 1.0 */

‎src/interfaces/odbc/psqlodbc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Comments: See "notice.txt" for copyright and license information.
88
*
9-
* $Id: psqlodbc.h,v 1.28 2001/01/26 22:25:36 tgl Exp $
9+
* $Id: psqlodbc.h,v 1.29 2001/01/26 22:41:59 momjian Exp $
1010
*/
1111

1212
#ifndef__PSQLODBC_H__
@@ -41,8 +41,7 @@ typedef UInt4 Oid;
4141
#defineDRIVERNAME "PostgreSQL ODBC"
4242
#defineDBMS_NAME "PostgreSQL"
4343

44-
#defineDBMS_VERSION "7.1.0000 PostgreSQL 7.1"
45-
#definePOSTGRESDRIVERVERSION "7.1.0000"
44+
#definePOSTGRESDRIVERVERSION "07.01.0001"
4645

4746
#ifdefWIN32
4847
#defineDRIVER_FILE_NAME"PSQLODBC.DLL"

‎src/interfaces/odbc/psqlodbc.rc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ BEGIN
145145
CONTROL "Show System &Tables",DS_SHOWSYSTEMTABLES,"Button",
146146
BS_AUTOCHECKBOX | WS_TABSTOP,25,25,85,10
147147
GROUPBOX "Protocol",IDC_STATIC,15,40,180,25
148-
CONTROL "6.5/6.4",DS_PG64,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
149-
25,50,35,10
148+
CONTROL "6.4+",DS_PG64,"Button",BS_AUTORADIOBUTTON | WS_GROUP,25,
149+
50,35,10
150150
CONTROL "6.3",DS_PG63,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
151151
75,50,26,10
152152
CONTROL "6.2",DS_PG62,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
@@ -204,8 +204,8 @@ END
204204
//
205205

206206
VS_VERSION_INFO VERSIONINFO
207-
FILEVERSION 7,1,0,0
208-
PRODUCTVERSION 7,1,0,0
207+
FILEVERSION 7,1,0,1
208+
PRODUCTVERSION 7,1,0,1
209209
FILEFLAGSMASK 0x3L
210210
#ifdef _DEBUG
211211
FILEFLAGS 0x1L
@@ -223,14 +223,14 @@ BEGIN
223223
VALUE "Comments", "PostgreSQL ODBC driver\0"
224224
VALUE "CompanyName", "Insight Distribution Systems\0"
225225
VALUE "FileDescription", "PostgreSQL Driver\0"
226-
VALUE "FileVersion", "7.1.0000\0"
226+
VALUE "FileVersion", "07.01.0001\0"
227227
VALUE "InternalName", "psqlodbc\0"
228228
VALUE "LegalCopyright", "\0"
229229
VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation. Microsoft� is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0"
230230
VALUE "OriginalFilename", "psqlodbc.dll\0"
231231
VALUE "PrivateBuild", "\0"
232232
VALUE "ProductName", "Microsoft Open Database Connectivity\0"
233-
VALUE "ProductVersion", "7.1.0000\0"
233+
VALUE "ProductVersion", "07.01.0001\0"
234234
VALUE "SpecialBuild", "\0"
235235
END
236236
END

‎src/interfaces/odbc/resource.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//{{NO_DEPENDENCIES}}
2-
// Microsoft Developer Studio generated include file.
3-
// Used by psqlodbc.rc
4-
//
1+
/*{{NO_DEPENDENCIES}} */
2+
/* Microsoft Developer Studio generated include file. */
3+
/* Used by psqlodbc.rc */
4+
55
#defineIDS_BADDSN 1
66
#defineIDS_MSGTITLE 2
77
#defineDLG_OPTIONS_DRV 102
@@ -50,8 +50,8 @@
5050
#defineDS_PG64 1057
5151
#defineDS_PG63 1058
5252

53-
// Next default values for new objects
54-
//
53+
/* Next default values for new objects */
54+
5555
#ifdefAPSTUDIO_INVOKED
5656
#ifndefAPSTUDIO_READONLY_SYMBOLS
5757
#define_APS_NEXT_RESOURCE_VALUE 104

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp