diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 550f831a58..fb1c0c9f0a 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -1,5 +1,5 @@
 # Macros to detect C compiler features
-# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.20 2010/02/13 02:34:08 tgl Exp $
+# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.21 2010/05/25 14:32:55 meskes Exp $
 
 
 # PGAC_C_SIGNED
@@ -155,3 +155,19 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])],
               [LDFLAGS="$pgac_save_LDFLAGS"
                AC_MSG_RESULT(assuming no)])
 ])# PGAC_PROG_CC_LDFLAGS_OPT
+
+
+
+# PGAC_C_LONG_LONG
+# ----------------
+# Check if the C compiler understands long long type.
+AC_DEFUN([PGAC_C_LONG_LONG],
+[AC_CACHE_CHECK(for long long type, pgac_cv_c_long_long,
+[AC_TRY_COMPILE([],
+[long long l;],
+[pgac_cv_c_long_long=yes],
+[pgac_cv_c_long_long=no])])
+if test x"$pgac_cv_c_long_long" = xyes ; then
+  AC_DEFINE(HAVE_LONG_LONG, 1, [Define to 1 if the C compiler does understand long long type.])
+fi])# PGAC_C_LONG_LONG
+
diff --git a/configure b/configure
index 0eb8a3ec07..5f4af8345b 100755
--- a/configure
+++ b/configure
@@ -2008,7 +2008,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-
 ac_aux_dir=
 for ac_dir in config "$srcdir"/config; do
   if test -f "$ac_dir/install-sh"; then
@@ -14694,6 +14693,63 @@ cat >>confdefs.h <<\_ACEOF
 #define signed /**/
 _ACEOF
 
+fi
+{ $as_echo "$as_me:$LINENO: checking for long long type" >&5
+$as_echo_n "checking for long long type... " >&6; }
+if test "${pgac_cv_c_long_long+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+long long l;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  pgac_cv_c_long_long=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	pgac_cv_c_long_long=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $pgac_cv_c_long_long" >&5
+$as_echo "$pgac_cv_c_long_long" >&6; }
+if test x"$pgac_cv_c_long_long" = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LONG_LONG 1
+_ACEOF
+
 fi
 { $as_echo "$as_me:$LINENO: checking for working volatile" >&5
 $as_echo_n "checking for working volatile... " >&6; }
diff --git a/configure.in b/configure.in
index b733e5f9fb..645030b890 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.627 2010/05/13 22:07:42 tgl Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.628 2010/05/25 14:32:54 meskes Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -1090,6 +1090,7 @@ AC_C_CONST
 PGAC_C_INLINE
 AC_C_STRINGIZE
 PGAC_C_SIGNED
+PGAC_C_LONG_LONG
 AC_C_VOLATILE
 PGAC_C_FUNCNAME_SUPPORT
 PGAC_STRUCT_TIMEZONE
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index a54cae309b..0d564b87de 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -330,6 +330,9 @@
 /* Define to 1 if `long int' works and is 64 bits. */
 #undef HAVE_LONG_INT_64
 
+/* Define to 1 if the C compiler does understand long long type. */
+#undef HAVE_LONG_LONG
+
 /* Define to 1 if `long long int' works and is 64 bits. */
 #undef HAVE_LONG_LONG_INT_64
 
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index d42e929595..1e8f18f965 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.40 2010/05/20 22:10:45 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.41 2010/05/25 14:32:55 meskes Exp $ */
 
 #ifndef _ECPG_LIB_EXTERN_H
 #define _ECPG_LIB_EXTERN_H
@@ -13,11 +13,6 @@
 #include <limits.h>
 #endif
 
-/* Do we know the C99 data type "long long"? */
-#if defined(LLONG_MIN) || defined(LONGLONG_MIN) || defined(HAVE_LONG_LONG_INT_64)
-#define HAVE_LONG_LONG 1
-#endif
-
 enum COMPAT_MODE
 {
 	ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE
diff --git a/src/interfaces/ecpg/include/ecpg_config.h.in b/src/interfaces/ecpg/include/ecpg_config.h.in
index 52ed8c8173..5ee42c8ab7 100644
--- a/src/interfaces/ecpg/include/ecpg_config.h.in
+++ b/src/interfaces/ecpg/include/ecpg_config.h.in
@@ -15,3 +15,6 @@
  *    (--enable-thread-safety) */
 #undef ENABLE_THREAD_SAFETY
 
+/* Define to 1 if the C compiler does understand long long type. */
+#undef HAVE_LONG_LONG
+
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header
index 848a3a23dc..3398f004cf 100644
--- a/src/interfaces/ecpg/preproc/ecpg.header
+++ b/src/interfaces/ecpg/preproc/ecpg.header
@@ -1,17 +1,13 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.15 2010/05/20 22:10:46 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.16 2010/05/25 14:32:55 meskes Exp $ */
 
 /* Copyright comment */
 %{
 #include "postgres_fe.h"
 
 #include "extern.h"
+#include "ecpg_config.h"
 #include <unistd.h>
 
-/* Do we know the C99 datatype "long long"? */
-#if defined(LLONG_MIN) || defined(LONGLONG_MIN) || defined(HAVE_LONG_LONG_INT_64)
-#define HAVE_LONG_LONG 1
-#endif
-
 /* Location tracking support --- simpler than bison's default */
 #define YYLLOC_DEFAULT(Current, Rhs, N) \
 	do { \