summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2010-05-20 22:10:46 +0000
committerMichael Meskes <meskes@postgresql.org>2010-05-20 22:10:46 +0000
commit15ab0e9a6051ff5b6c88a729ddd9d57ac44f7a11 (patch)
treefef663d3ac0c32bc07b4702b2924b4e76dd2f943
parentde98ef62c7fe7a2bf02fafab6a95ae2e138ed075 (diff)
Ecpg now accepts "long long" datatypes even if "long" is 64bit wide. This used to cover the equally long "long long" type. This patch closes bug #5464.
-rw-r--r--src/interfaces/ecpg/ecpglib/data.c22
-rw-r--r--src/interfaces/ecpg/ecpglib/descriptor.c10
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c10
-rw-r--r--src/interfaces/ecpg/ecpglib/extern.h7
-rw-r--r--src/interfaces/ecpg/ecpglib/misc.c12
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.header7
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.trailer10
7 files changed, 44 insertions, 34 deletions
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index 5035dbd7053..6088c66aa52 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.51 2010/02/27 21:53:21 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.52 2010/05/20 22:10:45 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -177,12 +177,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long:
*((long *) (ind + ind_offset * act_tuple)) = value_for_indicator;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = value_for_indicator;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_NO_INDICATOR:
if (value_for_indicator == -1)
{
@@ -265,12 +265,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long:
*((long *) (ind + ind_offset * act_tuple)) = size;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = size;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
default:
break;
}
@@ -350,7 +350,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
#ifdef HAVE_STRTOLL
case ECPGt_long_long:
*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
@@ -376,7 +376,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break;
#endif /* HAVE_STRTOULL */
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_float:
case ECPGt_double:
@@ -489,12 +489,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long:
*((long *) (ind + ind_offset * act_tuple)) = size;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = size;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
default:
break;
}
@@ -534,12 +534,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long:
*((long *) (ind + offset * act_tuple)) = variable->len;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
default:
break;
}
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index 21dbe0ce08e..b2edc2850b3 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -1,6 +1,6 @@
/* dynamic SQL support routines
*
- * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.36 2010/02/26 02:01:30 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.37 2010/05/20 22:10:45 meskes Exp $
*/
#define POSTGRES_ECPG_INTERNAL
@@ -127,14 +127,14 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
case ECPGt_unsigned_long:
*(unsigned long *) var = (unsigned long) value;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
*(long long int *) var = (long long int) value;
break;
case ECPGt_unsigned_long_long:
*(unsigned long long int *) var = (unsigned long long int) value;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_float:
*(float *) var = (float) value;
break;
@@ -172,14 +172,14 @@ set_int_item(int lineno, int *target, const void *var, enum ECPGttype vartype)
case ECPGt_unsigned_long:
*target = *(unsigned long *) var;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
*target = *(long long int *) var;
break;
case ECPGt_unsigned_long_long:
*target = *(unsigned long long int *) var;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_float:
*target = *(float *) var;
break;
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 8ae102b4493..60b7c75f0ec 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.95 2010/02/26 02:01:30 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.96 2010/05/20 22:10:45 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@@ -541,13 +541,13 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (*(long *) var->ind_value < 0L)
*tobeinserted_p = NULL;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
if (*(long long int *) var->ind_value < (long long) 0)
*tobeinserted_p = NULL;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_NO_INDICATOR:
if (force_indicator == false)
{
@@ -679,7 +679,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
*tobeinserted_p = mallocedval;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
if (!(mallocedval = ecpg_alloc(asize * 30, lineno)))
return false;
@@ -717,7 +717,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
*tobeinserted_p = mallocedval;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_float:
if (!(mallocedval = ecpg_alloc(asize * 25, lineno)))
return false;
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index 7a5259f793b..d42e9295951 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.39 2010/02/26 02:01:30 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.40 2010/05/20 22:10:45 meskes Exp $ */
#ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H
@@ -13,6 +13,11 @@
#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/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 9fade9ea3c2..92cbad9a188 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.56 2010/02/26 02:01:30 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.57 2010/05/20 22:10:46 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -17,7 +17,7 @@
#include "pgtypes_interval.h"
#include "pg_config_paths.h"
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
#ifndef LONG_LONG_MIN
#ifdef LLONG_MIN
#define LONG_LONG_MIN LLONG_MIN
@@ -327,12 +327,12 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
case ECPGt_date:
*((long *) ptr) = LONG_MIN;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
*((long long *) ptr) = LONG_LONG_MIN;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_float:
memset((char *) ptr, 0xff, sizeof(float));
break;
@@ -399,13 +399,13 @@ ECPGis_noind_null(enum ECPGttype type, void *ptr)
if (*((long *) ptr) == LONG_MIN)
return true;
break;
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
if (*((long long *) ptr) == LONG_LONG_MIN)
return true;
break;
-#endif /* HAVE_LONG_LONG_INT_64 */
+#endif /* HAVE_LONG_LONG */
case ECPGt_float:
return (_check(ptr, sizeof(float)));
break;
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header
index 6b05776ee58..848a3a23dc9 100644
--- a/src/interfaces/ecpg/preproc/ecpg.header
+++ b/src/interfaces/ecpg/preproc/ecpg.header
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.14 2010/03/09 11:09:45 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.15 2010/05/20 22:10:46 meskes Exp $ */
/* Copyright comment */
%{
@@ -7,6 +7,11 @@
#include "extern.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 { \
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index d5e16afab60..1d854d4bbc0 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.24 2010/03/31 08:45:18 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.25 2010/05/20 22:10:46 meskes Exp $ */
statements: /*EMPTY*/
| statements statement
@@ -781,7 +781,7 @@ unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; }
| SQL_UNSIGNED SQL_LONG INT_P { $$ = ECPGt_unsigned_long; }
| SQL_UNSIGNED SQL_LONG SQL_LONG
{
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
$$ = ECPGt_unsigned_long_long;
#else
$$ = ECPGt_unsigned_long;
@@ -789,7 +789,7 @@ unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; }
}
| SQL_UNSIGNED SQL_LONG SQL_LONG INT_P
{
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
$$ = ECPGt_unsigned_long_long;
#else
$$ = ECPGt_unsigned_long;
@@ -805,7 +805,7 @@ signed_type: SQL_SHORT { $$ = ECPGt_short; }
| SQL_LONG INT_P { $$ = ECPGt_long; }
| SQL_LONG SQL_LONG
{
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
$$ = ECPGt_long_long;
#else
$$ = ECPGt_long;
@@ -813,7 +813,7 @@ signed_type: SQL_SHORT { $$ = ECPGt_short; }
}
| SQL_LONG SQL_LONG INT_P
{
-#ifdef HAVE_LONG_LONG_INT_64
+#ifdef HAVE_LONG_LONG
$$ = ECPGt_long_long;
#else
$$ = ECPGt_long;