]> granicus.if.org Git - postgresql/commitdiff
odbc1.diff changes the text on the Protocol Radio buttons on the driver
authorBruce Momjian <bruce@momjian.us>
Fri, 26 Jan 2001 22:41:59 +0000 (22:41 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 26 Jan 2001 22:41:59 +0000 (22:41 +0000)
dialogue from '6.4/6.5' to '6.5+' and removes some C++ comments from
resource.h (which VC++ insists on putting there).

odbc2.diff adds code to query the PostgreSQL version upon connection. This
is then used to determine what values to return for from SQLGetInfo for
SQL_DBMS_VER, SQL_MAX_ROW_SIZE, SQL_MAX_STATEMENT_LEN, SQL_OJ_CAPABILITIES
and SQL_OUTER_JOINS. The version string as returned by SELECT vERSION() (as
a char array) and the major.minor version number (as a flost) have been
added to the ConnectionClass structure.

Dave Page

src/interfaces/odbc/connection.c
src/interfaces/odbc/connection.h
src/interfaces/odbc/info.c
src/interfaces/odbc/psqlodbc.h
src/interfaces/odbc/psqlodbc.rc
src/interfaces/odbc/resource.h

index d5b0d12dffed1a651c160afc82ab38c3b9e0d15c..fe1344df8abad6b87ae6bda2657789b2e9cd7dc0 100644 (file)
@@ -699,6 +699,7 @@ static char *func="CC_connect";
        */
        CC_send_settings(self);
        CC_lookup_lo(self);             /* a hack to get the oid of our large object oid type */
+       CC_lookup_pg_version(self);     /* Get PostgreSQL version for SQLGetInfo use */
 
        CC_clear_error(self);   /* clear any initial command errors */
        self->status = CONN_CONNECTED;
@@ -1364,6 +1365,62 @@ static char *func = "CC_lookup_lo";
        result = SQLFreeStmt(hstmt, SQL_DROP);
 }
 
+/*     This function gets the version of PostgreSQL that we're connected to.
+    This is used to return the correct info in SQLGetInfo
+       DJP - 25-1-2001
+*/
+void
+CC_lookup_pg_version(ConnectionClass *self) 
+{
+HSTMT hstmt;
+StatementClass *stmt;
+RETCODE result;
+char *szVersion = "0.0";
+static char *func = "CC_lookup_pg_version";
+
+       mylog( "%s: entering...\n", func);
+
+/*     This function must use the local odbc API functions since the odbc state 
+       has not transitioned to "connected" yet.
+*/
+       result = SQLAllocStmt( self, &hstmt);
+       if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
+               return;
+       }
+       stmt = (StatementClass *) hstmt;
+
+       result = SQLExecDirect(hstmt, "select version()", SQL_NTS);
+       if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
+               SQLFreeStmt(hstmt, SQL_DROP);
+               return;
+       }
+
+       result = SQLFetch(hstmt);
+       if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
+               SQLFreeStmt(hstmt, SQL_DROP);
+               return;
+       }
+
+       result = SQLGetData(hstmt, 1, SQL_C_CHAR, self->pg_version, MAX_INFO_STRING, NULL);
+       if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
+               SQLFreeStmt(hstmt, SQL_DROP);
+               return;
+       }
+
+       /* There's proably a nicer way of doing this... */
+       /* Extract the Major and Minor numbers from the string. */
+       /* This assumes the string starts 'Postgresql X.X' */
+       sprintf(szVersion, "%c.%c", self->pg_version[11], self->pg_version[13]);
+       self->pg_version_number = (float) atof(szVersion);
+
+       mylog("Got the PostgreSQL version string: '%s'\n", self->pg_version);
+       mylog("Extracted PostgreSQL version number: '%1.1f'\n", self->pg_version_number);
+       qlog("    [ PostgreSQL version string = '%s' ]\n", self->pg_version);
+       qlog("    [ PostgreSQL version number = '%1.1f' ]\n", self->pg_version_number);
+
+       result = SQLFreeStmt(hstmt, SQL_DROP);
+}
+
 void
 CC_log_error(char *func, char *desc, ConnectionClass *self)
 {
index 99841f33f0c2e2424b0682b3072c9e43af76ee0c..8251271a05c3ab4c19c02528aa3e8cb8fb062045 100644 (file)
@@ -221,6 +221,8 @@ struct ConnectionClass_ {
        DriverToDataSourceProc  DriverToDataSource;
        char                    transact_status;                /* Is a transaction is currently in progress */
        char                    errormsg_created;               /* has an informative error msg been created?  */
+       char                    pg_version[MAX_INFO_STRING];    /* Version of PostgreSQL we're connected to - DJP 25-1-2001 */
+       float                   pg_version_number;
 };
 
 
@@ -255,6 +257,7 @@ char *CC_create_errormsg(ConnectionClass *self);
 int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs);
 char CC_send_settings(ConnectionClass *self);
 void CC_lookup_lo(ConnectionClass *conn);
+void CC_lookup_pg_version(ConnectionClass *conn);
 void CC_log_error(char *func, char *desc, ConnectionClass *self);
 
 
index 52b64bef41c1413647d98243f1ddbd5094debe9c..681c72759d0d38d78d5029a4cf1489577c8121e2 100644 (file)
@@ -191,7 +191,11 @@ RETCODE result;
         break;
 
     case SQL_DBMS_VER: /* ODBC 1.0 */
-               p = DBMS_VERSION;
+               /* The ODBC spec wants ##.##.#### ...whatever... so prepend the driver */
+               /* version number to the dbms version string */
+               p = POSTGRESDRIVERVERSION;
+               strcat(p, " ");
+               strcat(p, conn->pg_version);
         break;
 
     case SQL_DEFAULT_TXN_ISOLATION: /* ODBC 1.0 */
@@ -337,7 +341,11 @@ RETCODE result;
 
     case SQL_MAX_ROW_SIZE: /* ODBC 2.0 */
                len = 4;
-        value = MAX_ROW_SIZE;
+               if (conn->pg_version_number >= (float) 7.1) { /* Large Rowa in 7.1+ */
+                       value = MAX_ROW_SIZE;
+               } else { /* Without the Toaster we're limited to the blocksize */
+                       value = BLCKSZ;
+               }
         break;
 
     case SQL_MAX_ROW_SIZE_INCLUDES_LONG: /* ODBC 2.0 */
@@ -350,7 +358,11 @@ RETCODE result;
     case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */
         /* maybe this should be 0? */
                len = 4;
-        value = MAX_STATEMENT_LEN;
+               if (conn->pg_version_number >= (float) 7.0) { /* Long Queries in 7.0+ */
+                       value = MAX_STATEMENT_LEN;
+               } else { /* Prior to 7.0 we used 2*BLCKSZ */
+                       value = (2*BLCKSZ);
+               }
         break;
 
     case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */
@@ -419,13 +431,17 @@ RETCODE result;
 
        case SQL_OJ_CAPABILITIES: /* ODBC 2.01 */
                len = 4;
-               value = (SQL_OJ_LEFT |
-                               SQL_OJ_RIGHT |
-                               SQL_OJ_FULL |
-                               SQL_OJ_NESTED |
-                               SQL_OJ_NOT_ORDERED |
-                               SQL_OJ_INNER |
-                               SQL_OJ_ALL_COMPARISON_OPS);
+               if (conn->pg_version_number >= (float) 7.1) { /* OJs in 7.1+ */
+                       value = (SQL_OJ_LEFT |
+                                       SQL_OJ_RIGHT |
+                                       SQL_OJ_FULL |
+                                       SQL_OJ_NESTED |
+                                       SQL_OJ_NOT_ORDERED |
+                                       SQL_OJ_INNER |
+                                       SQL_OJ_ALL_COMPARISON_OPS);
+               } else { /* OJs not in <7.1 */
+                       value = 0;
+               }
                break;
 
     case SQL_ORDER_BY_COLUMNS_IN_SELECT: /* ODBC 2.0 */
@@ -433,7 +449,11 @@ RETCODE result;
         break;
 
     case SQL_OUTER_JOINS: /* ODBC 1.0 */
-               p = "Y";
+               if (conn->pg_version_number >= (float) 7.1) { /* OJs in 7.1+ */
+                       p = "Y";
+               } else { /* OJs not in <7.1 */
+                       p = "N";
+               }
         break;
 
     case SQL_OWNER_TERM: /* ODBC 1.0 */
index b686a0e3b7b546e5693339c9999902f184c73863..b0d8539eb79acecb1bae83629521586e99a9e4cb 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Comments:        See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.28 2001/01/26 22:25:36 tgl Exp $
+ * $Id: psqlodbc.h,v 1.29 2001/01/26 22:41:59 momjian Exp $
  */
 
 #ifndef __PSQLODBC_H__
@@ -41,8 +41,7 @@ typedef UInt4 Oid;
 #define DRIVERNAME             "PostgreSQL ODBC"
 #define DBMS_NAME              "PostgreSQL"
 
-#define DBMS_VERSION           "7.1.0000 PostgreSQL 7.1"
-#define POSTGRESDRIVERVERSION  "7.1.0000"
+#define POSTGRESDRIVERVERSION  "07.01.0001"
 
 #ifdef WIN32
 #define DRIVER_FILE_NAME               "PSQLODBC.DLL"
index f8e27f8da64262c20a08f16218c9ee2819a38b9c..1d934106d3be53ba0860f390fff3f56d555243d1 100644 (file)
@@ -145,8 +145,8 @@ BEGIN
     CONTROL         "Show System &Tables",DS_SHOWSYSTEMTABLES,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,25,25,85,10
     GROUPBOX        "Protocol",IDC_STATIC,15,40,180,25
-    CONTROL         "6.5/6.4",DS_PG64,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
-                    25,50,35,10
+    CONTROL         "6.4+",DS_PG64,"Button",BS_AUTORADIOBUTTON | WS_GROUP,25,
+                    50,35,10
     CONTROL         "6.3",DS_PG63,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
                     75,50,26,10
     CONTROL         "6.2",DS_PG62,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,
@@ -204,8 +204,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 7,1,0,0
- PRODUCTVERSION 7,1,0,0
+ FILEVERSION 7,1,0,1
+ PRODUCTVERSION 7,1,0,1
  FILEFLAGSMASK 0x3L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -223,14 +223,14 @@ BEGIN
             VALUE "Comments", "PostgreSQL ODBC driver\0"
             VALUE "CompanyName", "Insight Distribution Systems\0"
             VALUE "FileDescription", "PostgreSQL Driver\0"
-            VALUE "FileVersion", " 7.1.0000\0"
+            VALUE "FileVersion", " 07.01.0001\0"
             VALUE "InternalName", "psqlodbc\0"
             VALUE "LegalCopyright", "\0"
             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"
             VALUE "OriginalFilename", "psqlodbc.dll\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Microsoft Open Database Connectivity\0"
-            VALUE "ProductVersion", " 7.1.0000\0"
+            VALUE "ProductVersion", " 07.01.0001\0"
             VALUE "SpecialBuild", "\0"
         END
     END
index 81e3c9961ff0c92eacef4408b5e59e2b81e86557..c823241d7e41c87d76f6d90aead7d95ab049e525 100644 (file)
@@ -1,7 +1,7 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by psqlodbc.rc
-//
+/* {{NO_DEPENDENCIES}} */
+/* Microsoft Developer Studio generated include file. */
+/* Used by psqlodbc.rc */
+
 #define IDS_BADDSN                      1
 #define IDS_MSGTITLE                    2
 #define DLG_OPTIONS_DRV                 102
@@ -50,8 +50,8 @@
 #define DS_PG64                         1057
 #define DS_PG63                         1058
 
-// Next default values for new objects
-// 
+/* Next default values for new objects */
+
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        104