diff -cr psqlodbc-orig/connection.c psqlodbc/connection.c
*** psqlodbc-orig/connection.c	Wed Oct 25 14:15:49 2000
--- psqlodbc/connection.c	Thu Jan 25 15:42:40 2001
***************
*** 699,704 ****
--- 699,705 ----
  	*/
  	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;
***************
*** 1360,1365 ****
--- 1361,1422 ----
  
  	mylog("Got the large object oid: %d\n", self->lobj_type);
  	qlog("    [ Large Object oid = %d ]\n", self->lobj_type);
+ 
+ 	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);
  }
diff -cr psqlodbc-orig/connection.h psqlodbc/connection.h
*** psqlodbc-orig/connection.h	Tue Nov 30 02:44:09 1999
--- psqlodbc/connection.h	Thu Jan 25 13:29:02 2001
***************
*** 221,226 ****
--- 221,228 ----
  	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,260 ****
--- 257,263 ----
  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);
  
  
diff -cr psqlodbc-orig/info.c psqlodbc/info.c
*** psqlodbc-orig/info.c	Thu Jan 25 03:28:27 2001
--- psqlodbc/info.c	Thu Jan 25 16:42:10 2001
***************
*** 191,197 ****
          break;
  
      case SQL_DBMS_VER: /* ODBC 1.0 */
! 		p = DBMS_VERSION;
          break;
  
      case SQL_DEFAULT_TXN_ISOLATION: /* ODBC 1.0 */
--- 191,201 ----
          break;
  
      case SQL_DBMS_VER: /* ODBC 1.0 */
! 		/* 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,343 ****
  
      case SQL_MAX_ROW_SIZE: /* ODBC 2.0 */
  		len = 4;
!         value = MAX_ROW_SIZE;
          break;
  
      case SQL_MAX_ROW_SIZE_INCLUDES_LONG: /* ODBC 2.0 */
--- 341,351 ----
  
      case SQL_MAX_ROW_SIZE: /* ODBC 2.0 */
  		len = 4;
! 		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,356 ****
      case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */
          /* maybe this should be 0? */
  		len = 4;
!         value = MAX_STATEMENT_LEN;
          break;
  
      case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */
--- 358,368 ----
      case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */
          /* maybe this should be 0? */
  		len = 4;
! 		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,431 ****
  
  	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);
  		break;
  
      case SQL_ORDER_BY_COLUMNS_IN_SELECT: /* ODBC 2.0 */
--- 431,447 ----
  
  	case SQL_OJ_CAPABILITIES: /* ODBC 2.01 */
  		len = 4;
! 		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,439 ****
          break;
  
      case SQL_OUTER_JOINS: /* ODBC 1.0 */
! 		p = "Y";
          break;
  
      case SQL_OWNER_TERM: /* ODBC 1.0 */
--- 449,459 ----
          break;
  
      case SQL_OUTER_JOINS: /* ODBC 1.0 */
! 		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 */
diff -cr psqlodbc-orig/psqlodbc.h psqlodbc/psqlodbc.h
*** psqlodbc-orig/psqlodbc.h	Thu Jan 25 03:28:27 2001
--- psqlodbc/psqlodbc.h	Thu Jan 25 16:31:55 2001
***************
*** 40,47 ****
  #define DRIVERNAME             "PostgreSQL ODBC"
  #define DBMS_NAME              "PostgreSQL"
  
! #define DBMS_VERSION           "7.1.0000 PostgreSQL 7.1"
! #define POSTGRESDRIVERVERSION  "7.1.0000"
  
  #ifdef WIN32
  #define DRIVER_FILE_NAME		"PSQLODBC.DLL"
--- 40,46 ----
  #define DRIVERNAME             "PostgreSQL ODBC"
  #define DBMS_NAME              "PostgreSQL"
  
! #define POSTGRESDRIVERVERSION  "07.01.0001"
  
  #ifdef WIN32
  #define DRIVER_FILE_NAME		"PSQLODBC.DLL"
diff -cr psqlodbc-orig/psqlodbc.rc psqlodbc/psqlodbc.rc
*** psqlodbc-orig/psqlodbc.rc	Thu Jan 25 10:12:47 2001
--- psqlodbc/psqlodbc.rc	Thu Jan 25 16:43:24 2001
***************
*** 204,211 ****
  //
  
  VS_VERSION_INFO VERSIONINFO
!  FILEVERSION 7,1,0,0
!  PRODUCTVERSION 7,1,0,0
   FILEFLAGSMASK 0x3L
  #ifdef _DEBUG
   FILEFLAGS 0x1L
--- 204,211 ----
  //
  
  VS_VERSION_INFO VERSIONINFO
!  FILEVERSION 7,1,0,1
!  PRODUCTVERSION 7,1,0,1
   FILEFLAGSMASK 0x3L
  #ifdef _DEBUG
   FILEFLAGS 0x1L
***************
*** 223,236 ****
              VALUE "Comments", "PostgreSQL ODBC driver\0"
              VALUE "CompanyName", "Insight Distribution Systems\0"
              VALUE "FileDescription", "PostgreSQL Driver\0"
!             VALUE "FileVersion", " 7.1.0000\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 "SpecialBuild", "\0"
          END
      END
--- 223,236 ----
              VALUE "Comments", "PostgreSQL ODBC driver\0"
              VALUE "CompanyName", "Insight Distribution Systems\0"
              VALUE "FileDescription", "PostgreSQL Driver\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", " 07.01.0001\0"
              VALUE "SpecialBuild", "\0"
          END
      END
