diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 846c67cc0c9c4af19f65df459b4ac0ef9cc74b1b..9dc77647aedd56e6ae489db2389e447c6a34f59f 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -2307,4 +2307,7 @@ Wed, 06 Feb 2008 09:04:48 +0100
 	- Fixed segfault in ecpg when using an array element.
 	- Free all memory in auto-prepare mode.
 
+Thu, 14 Feb 2008 13:11:34 +0100
+
+	- Added SQLSTATE macro closing bug #3961.
 
diff --git a/src/interfaces/ecpg/include/datetime.h b/src/interfaces/ecpg/include/datetime.h
index c3a706267555914f1729c31e20f400691cafe6a9..6c64abbd38674cd44ccfb2b84d38da7d7bf80352 100644
--- a/src/interfaces/ecpg/include/datetime.h
+++ b/src/interfaces/ecpg/include/datetime.h
@@ -1,11 +1,11 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/datetime.h,v 1.12 2006/03/11 04:38:39 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/datetime.h,v 1.13 2008/02/14 12:22:36 meskes Exp $ */
 
 #ifndef _ECPG_DATETIME_H
 #define _ECPG_DATETIME_H
 
 #include <ecpg_informix.h>
 
-typedef timestamp dtime_t;
-typedef interval intrvl_t;
+/* typedef timestamp dtime_t;
+typedef interval intrvl_t;*/
 
 #endif   /* ndef _ECPG_DATETIME_H */
diff --git a/src/interfaces/ecpg/include/decimal.h b/src/interfaces/ecpg/include/decimal.h
index 9944f052e33cbcd6fefea8a8449e2c5ae2bf8394..99aac67cb6c278e045e834f0f5cca912e1a83ef8 100644
--- a/src/interfaces/ecpg/include/decimal.h
+++ b/src/interfaces/ecpg/include/decimal.h
@@ -1,10 +1,10 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/decimal.h,v 1.14 2006/03/11 04:38:39 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/decimal.h,v 1.15 2008/02/14 12:22:36 meskes Exp $ */
 
 #ifndef _ECPG_DECIMAL_H
 #define _ECPG_DECIMAL_H
 
 #include <ecpg_informix.h>
 
-typedef decimal dec_t;
+/* typedef decimal dec_t; */
 
 #endif   /* ndef _ECPG_DECIMAL_H */
diff --git a/src/interfaces/ecpg/include/ecpg_informix.h b/src/interfaces/ecpg/include/ecpg_informix.h
index 4441c56b335c566f4c77bb13e1a4bdc57b035292..63862b748a2496b4a9e5520a8e4cb98a4bee56ac 100644
--- a/src/interfaces/ecpg/include/ecpg_informix.h
+++ b/src/interfaces/ecpg/include/ecpg_informix.h
@@ -1,6 +1,6 @@
 /*
  * This file contains stuff needed to be as compatible to Informix as possible.
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.18 2006/03/11 04:38:39 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.19 2008/02/14 12:22:36 meskes Exp $
  */
 #ifndef _ECPG_INFORMIX_H
 #define _ECPG_INFORMIX_H
@@ -82,6 +82,11 @@ extern int	dttofmtasc(timestamp *, char *, int, char *);
 extern int	intoasc(interval *, char *);
 extern int	dtcvfmtasc(char *, char *, timestamp *);
 
+/* we also define Informix datatypes here */
+typedef timestamp dtime_t;
+typedef interval intrvl_t;
+typedef decimal dec_t;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 18cab5029e9efc02d5c07e78a4e597fc971d6831..dcc1d57722b1d38bf2dd2b1b1a4cceb1f4341406 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -1,7 +1,7 @@
 /*
  * this is a small part of c.h since we don't want to leak all postgres
  * definitions into ecpg programs
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.74 2008/01/13 11:53:16 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.75 2008/02/14 12:22:36 meskes Exp $
  */
 
 #ifndef _ECPGLIB_H
@@ -58,7 +58,8 @@ void		sqlprint(void);
 
 /* define this for simplicity as well as compatibility */
 
-#define		  SQLCODE	 sqlca.sqlcode
+#define		SQLCODE		sqlca.sqlcode
+#define		SQLSTATE        sqlca.sqlstate
 
 /* dynamic SQL */
 
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index e5bd28be920a05f118cea85aa50529fc59569ae6..1372543553d06eb3a00fef82fea3ca50b58fe66d 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.159 2008/01/15 10:31:47 meskes Exp $
+ *	  $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.160 2008/02/14 12:22:36 meskes Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1320,7 +1320,7 @@ static bool isdefine(void)
 
 static bool isinformixdefine(void)
 {
-	const char *new = NULL;
+/*	const char *new = NULL;
 
 	if (strcmp(yytext, "dec_t") == 0)
 		new = "decimal";
@@ -1344,7 +1344,7 @@ static bool isinformixdefine(void)
 		yy_scan_string(new);
 		return true;
 	}
-
+*/
 	return false;
 }