diff -c psqlodbc.old/connection.c psqlodbc/connection.c
*** psqlodbc.old/connection.c	Mon Jul  6 14:20:38 1998
--- psqlodbc/connection.c	Sat Jul 11 20:13:40 1998
***************
*** 236,241 ****
--- 236,246 ----
  

  		rv->ntables = 0;

  		rv->col_info = NULL;

+ 

+ 		rv->translation_option = 0;

+ 		rv->translation_handle = NULL;

+ 		rv->DataSourceToDriver = NULL;

+ 		rv->DriverToDataSource = NULL;

      } 

      return rv;

  }

***************
*** 374,384 ****
--- 379,432 ----
  			self->stmts[i] = NULL;

  		}

  	}

+ 

+ 	if (NULL != self->translation_handle) {

+ 		FreeLibrary (self->translation_handle);

+ 		self->translation_handle = NULL;

+ 	}

+ 

  	mylog("exit CC_Cleanup\n");

  	return TRUE;

  }

  

+ int

+ CC_set_translation (ConnectionClass *self)

+ {

+   if (self->translation_handle != NULL)

+     {

+       FreeLibrary (self->translation_handle);

+       self->translation_handle = NULL;

+     }

+ 

+   if (self->connInfo.translation_dll[0] == 0)

+     return TRUE;

+ 

+   self->translation_option = atoi (self->connInfo.translation_option);

+ 

+   self->translation_handle = LoadLibrary (self->connInfo.translation_dll);

+   if (self->translation_handle == NULL)

+     {

+       self->errornumber = CONN_UNABLE_TO_LOAD_DLL;

+       self->errormsg = "Could not load the translation DLL.";

+       return FALSE;

+     }

+ 

+   self->DataSourceToDriver

+     = (DataSourceToDriverProc) GetProcAddress (self->translation_handle,

+                                                "SQLDataSourceToDriver");

+   self->DriverToDataSource

+     = (DriverToDataSourceProc) GetProcAddress (self->translation_handle,

+                                                "SQLDriverToDataSource");

+   if (self->DataSourceToDriver == NULL

+       || self->DriverToDataSource == NULL)

+     {

+       self->errornumber = CONN_UNABLE_TO_LOAD_DLL;

+       self->errormsg = "Could not find translation DLL functions.";

+       return FALSE;

+     }

  

+   return TRUE;

+ }

  

  char 

  CC_connect(ConnectionClass *self, char do_password)

***************
*** 607,612 ****
--- 655,661 ----
  

  	mylog("empty query seems to be OK.\n");

  

+ 	CC_set_translation (self);

  

  	/**********************************************/

  	/*******   Send any initial settings  *********/

diff -c psqlodbc.old/connection.h psqlodbc/connection.h
*** psqlodbc.old/connection.h	Mon Jul  6 13:31:42 1998
--- psqlodbc/connection.h	Fri Jul 10 20:39:14 1998
***************
*** 59,64 ****
--- 59,65 ----
  #define CONN_NOT_IMPLEMENTED_ERROR 9

  #define CONN_INVALID_AUTHENTICATION 10

  #define CONN_AUTH_TYPE_UNSUPPORTED 11

+ #define CONN_UNABLE_TO_LOAD_DLL 12

  

  

  /* Conn_status defines */

***************
*** 145,150 ****
--- 146,153 ----
  	char	show_oid_column[SMALL_REGISTRY_LEN];

  	char	row_versioning[SMALL_REGISTRY_LEN];

  	char	show_system_tables[SMALL_REGISTRY_LEN];

+ 	char	translation_dll[MEDIUM_REGISTRY_LEN];

+ 	char	translation_option[SMALL_REGISTRY_LEN];

  	char	focus_password;

  } ConnInfo;

  

***************
*** 160,165 ****
--- 163,190 ----
  };

  

  

+ /* Translation DLL entry points */

+ typedef BOOL (FAR WINAPI *DataSourceToDriverProc) (UDWORD,

+    					           SWORD,

+                                                    PTR,

+ 					           SDWORD,

+ 					           PTR,

+ 					           SDWORD,

+ 					           SDWORD FAR *,

+ 					           UCHAR FAR *,

+ 					           SWORD,

+ 					           SWORD FAR *);

+ typedef BOOL (FAR WINAPI *DriverToDataSourceProc) (UDWORD,

+ 					           SWORD,

+ 					           PTR,

+ 					           SDWORD,

+ 					           PTR,

+ 					           SDWORD,

+ 					           SDWORD FAR *,

+ 					           UCHAR FAR *,

+ 					           SWORD,

+ 					           SWORD FAR *);

+ 

  /*******	The Connection handle	************/

  struct ConnectionClass_ {

  	HENV			henv;					/* environment this connection was created on */

***************
*** 175,180 ****
--- 200,210 ----
  	COL_INFO		**col_info;

  	char			transact_status;		/* Is a transaction is currently in progress */

  	char			errormsg_created;		/* has an informative error msg been created?  */

+ 

+ 	long			translation_option;

+ 	HINSTANCE		translation_handle;

+ 	DataSourceToDriverProc	DataSourceToDriver;

+ 	DriverToDataSourceProc	DriverToDataSource;

  };

  

  

***************
*** 198,203 ****
--- 228,234 ----
  int CC_cursor_count(ConnectionClass *self);

  char CC_cleanup(ConnectionClass *self);

  char CC_abort(ConnectionClass *self);

+ int CC_set_translation (ConnectionClass *self);

  char CC_connect(ConnectionClass *self, char do_password);

  char CC_add_statement(ConnectionClass *self, StatementClass *stmt);

  char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);

diff -c psqlodbc.old/convert.c psqlodbc/convert.c
*** psqlodbc.old/convert.c	Tue Jun 16 11:15:50 1998
--- psqlodbc/convert.c	Tue Jul 14 14:35:16 1998
***************
*** 126,131 ****
--- 126,140 ----
  		return COPY_OK;

  	}

  

+ 	if (stmt->hdbc->DataSourceToDriver != NULL) {

+ 		int length = strlen (value);

+ 		stmt->hdbc->DataSourceToDriver (stmt->hdbc->translation_option,

+ 		                                SQL_CHAR,

+ 		                                value, length,

+ 		                                value, length, NULL,

+ 		                                NULL, 0, NULL);

+ 	}

+ 

  	/********************************************************************

  		First convert any specific postgres types into more

  		useable data.

***************
*** 759,764 ****
--- 768,782 ----
  

  	// make sure new_statement is always null-terminated

  	new_statement[npos] = '\0';

+ 

+ 	if(stmt->hdbc->DriverToDataSource != NULL) {

+ 		int length = strlen (new_statement);

+ 		stmt->hdbc->DriverToDataSource (stmt->hdbc->translation_option,

+ 		                                SQL_CHAR,

+ 		                                new_statement, length,

+ 		                                new_statement, length, NULL,

+ 		                                NULL, 0, NULL);

+ 	}

  

  	return SQL_SUCCESS;

  }

diff -c psqlodbc.old/dlg_specific.c psqlodbc/dlg_specific.c
*** psqlodbc.old/dlg_specific.c	Mon Jul  6 13:31:42 1998
--- psqlodbc/dlg_specific.c	Fri Jul 10 19:41:42 1998
***************
*** 452,457 ****
--- 452,463 ----
  	if ( ci->conn_settings[0] == '\0' || overwrite)

  		SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", ci->conn_settings, sizeof(ci->conn_settings), ODBC_INI);

  

+ 	if ( ci->translation_dll[0] == '\0' || overwrite)

+ 		SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, "", ci->translation_dll, sizeof(ci->translation_dll), ODBC_INI);

+ 

+ 	if ( ci->translation_option[0] == '\0' || overwrite)

+ 		SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI);

+ 

  	qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n", 

  		DSN, 

  		ci->server,

***************
*** 467,472 ****
--- 473,481 ----
  		ci->show_system_tables);

  	qlog("          conn_settings='%s'\n",

  		ci->conn_settings);

+ 	qlog("          translation_dll='%s',translation_option='%s'\n",

+ 		ci->translation_dll,

+ 		ci->translation_option);

  }

  

  

diff -c psqlodbc.old/dlg_specific.h psqlodbc/dlg_specific.h
*** psqlodbc.old/dlg_specific.h	Wed Jun 24 13:57:08 1998
--- psqlodbc/dlg_specific.h	Fri Jul 10 19:31:58 1998
***************
*** 73,78 ****
--- 73,82 ----
  #define INI_PARSE					"Parse"

  #define INI_EXTRASYSTABLEPREFIXES	"ExtraSysTablePrefixes"

  

+ #define INI_TRANSLATIONNAME		"TranslationName"

+ #define INI_TRANSLATIONDLL		"TranslationDLL"

+ #define INI_TRANSLATIONOPTION		"TranslationOption"

+ 

  /*	Connection Defaults */

  #define DEFAULT_PORT					"5432"

  #define DEFAULT_READONLY				1

