diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 321bd3a63c6d3b8909f1557ac7e7dbeb693a668f..4c5e84b6944fe491f1cf54dd0b8f74dafefbe703 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -1385,6 +1385,12 @@ Sat Mar 29 22:03:16 CET 2003
 Sun Mar 30 13:43:13 CEST 2003
 
 	- Interval datetype now fully functional.
+
+Tue Apr  8 14:03:32 CEST 2003
+
+	- Added rstrdate function.
+	- Made Informix mode honor environment variable to set dbname to
+	  connect to.
 	- Set ecpg version to 2.12.0.
 	- Set ecpg library to 3.4.2.
 	- Set pgtypes library to 1.0.0
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c
index e32c09077c212ad2ce4264e3ea68a3abb94fdd3f..fe12da7b0d58a5062f4df5b4dfbf2752835ab228 100644
--- a/src/interfaces/ecpg/compatlib/informix.c
+++ b/src/interfaces/ecpg/compatlib/informix.c
@@ -223,7 +223,10 @@ rstrdate (char *str, Date *d)
 {
 	Date dat = PGTYPESdate_from_asc(str, NULL);
 
-	/* XXX: ERROR handling hier und in datetime.c */
+	if (errno != PGTYPES_DATE_BAD_DATE && dat == 0)
+		return -1218;
+
+	*d=dat;
 	return 0;
 }
 
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 69433bdc4b1f062ca68096ee0eed265d1c300a2f..ee5ed4711859d5cab12603dc96cd26ab05517958 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.2 2003/04/04 20:42:13 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.3 2003/04/08 12:34:25 meskes Exp $ */
 
 #include "postgres_fe.h"
 
@@ -11,6 +11,8 @@
 static struct connection *all_connections = NULL,
 		   *actual_connection = NULL;
 
+extern enum COMPAT_MODE ecpg_compat_mode;
+
 struct connection *
 ECPGget_connection(const char *connection_name)
 {
@@ -267,13 +269,26 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
 			   *tmp,
 			   *port = NULL,
 			   *realname = NULL,
-			   *options = NULL;
+			   *options = NULL,
+			   *envname;
 
 	ECPGinit_sqlca();
 
 	if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
 		return false;
 
+	if (ecpg_compat_mode == ECPG_COMPAT_INFORMIX)
+	{
+		/* Informix uses an environment variable DBPATH that overrides
+		 * the connection parameters given here */
+		envname = getenv("DBPATH");
+		if (envname)
+		{
+			free(dbname);
+			dbname=strdup(envname);
+		}
+	}
+	
 	if (dbname == NULL && connection_name == NULL)
 		connection_name = "DEFAULT";
 
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index e5c3f19315128e71735729ac64960a73f39fca40..b4700deaff7be575ab04fd556bd783541db4845d 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -74,6 +74,8 @@ bool		ECPGget_desc(int, char *, int,...);
 /* dynamic result allocation */
 void		ECPGfree_auto_mem(void);
 
+enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX};
+
 #ifdef __cplusplus
 }
 
diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c
index 1a9bed268c02f54c4f62ad503b0e393ce65eef1b..1249a606fdbbe24fd2535eb06f230776d968b38b 100644
--- a/src/interfaces/ecpg/pgtypeslib/datetime.c
+++ b/src/interfaces/ecpg/pgtypeslib/datetime.c
@@ -51,17 +51,18 @@ PGTYPESdate_from_asc(char *str, char **endptr)
 	
 	bool		EuroDates = FALSE;
 
+	errno = 0;
 	if (strlen(str) >= sizeof(lowstr))
 	{
 		errno = PGTYPES_DATE_BAD_DATE;
-		return -1;
+		return 0;
 	}
 
 	if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0)
 	 || (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp, EuroDates) != 0))
 	{
 		errno = PGTYPES_DATE_BAD_DATE;
-		return -1;
+		return 0;
 	}
 
 	switch (dtype)
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index fa35b30e7f5f20160c8d64c5581914d89a76a18f..f1c39edba66dd3a617731ee1d37ee028c009004e 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.65 2003/04/04 20:42:13 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.66 2003/04/08 12:34:25 meskes Exp $ */
 
 /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
 /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -332,7 +332,7 @@ main(int argc, char *const argv[])
 				lex_init();
 
 				/* we need several includes */
-				fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
+				fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\nenum COMPAT_MODE ecpg_compat_mode=%d;\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename, compat);
 
 				/* add some compatibility headers */
 				if (compat == ECPG_COMPAT_INFORMIX)