Commit 15ab0e9a authored by Michael Meskes's avatar Michael Meskes

Ecpg now accepts "long long" datatypes even if "long" is 64bit wide. This used...

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.
parent de98ef62
/* $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 #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -177,12 +177,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -177,12 +177,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
*((long *) (ind + ind_offset * act_tuple)) = value_for_indicator; *((long *) (ind + ind_offset * act_tuple)) = value_for_indicator;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = value_for_indicator; *((long long int *) (ind + ind_offset * act_tuple)) = value_for_indicator;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_NO_INDICATOR: case ECPGt_NO_INDICATOR:
if (value_for_indicator == -1) if (value_for_indicator == -1)
{ {
...@@ -265,12 +265,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -265,12 +265,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
*((long *) (ind + ind_offset * act_tuple)) = size; *((long *) (ind + ind_offset * act_tuple)) = size;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = size; *((long long int *) (ind + ind_offset * act_tuple)) = size;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
default: default:
break; break;
} }
...@@ -350,7 +350,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -350,7 +350,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
} }
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
#ifdef HAVE_STRTOLL #ifdef HAVE_STRTOLL
case ECPGt_long_long: case ECPGt_long_long:
*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10); *((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, ...@@ -376,7 +376,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break; break;
#endif /* HAVE_STRTOULL */ #endif /* HAVE_STRTOULL */
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_float: case ECPGt_float:
case ECPGt_double: case ECPGt_double:
...@@ -489,12 +489,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -489,12 +489,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
*((long *) (ind + ind_offset * act_tuple)) = size; *((long *) (ind + ind_offset * act_tuple)) = size;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = size; *((long long int *) (ind + ind_offset * act_tuple)) = size;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
default: default:
break; break;
} }
...@@ -534,12 +534,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, ...@@ -534,12 +534,12 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
*((long *) (ind + offset * act_tuple)) = variable->len; *((long *) (ind + offset * act_tuple)) = variable->len;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*((long long int *) (ind + ind_offset * act_tuple)) = variable->len; *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
default: default:
break; break;
} }
......
/* dynamic SQL support routines /* 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 #define POSTGRES_ECPG_INTERNAL
...@@ -127,14 +127,14 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value) ...@@ -127,14 +127,14 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
*(unsigned long *) var = (unsigned long) value; *(unsigned long *) var = (unsigned long) value;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
*(long long int *) var = (long long int) value; *(long long int *) var = (long long int) value;
break; break;
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*(unsigned long long int *) var = (unsigned long long int) value; *(unsigned long long int *) var = (unsigned long long int) value;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_float: case ECPGt_float:
*(float *) var = (float) value; *(float *) var = (float) value;
break; break;
...@@ -172,14 +172,14 @@ set_int_item(int lineno, int *target, const void *var, enum ECPGttype vartype) ...@@ -172,14 +172,14 @@ set_int_item(int lineno, int *target, const void *var, enum ECPGttype vartype)
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
*target = *(unsigned long *) var; *target = *(unsigned long *) var;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
*target = *(long long int *) var; *target = *(long long int *) var;
break; break;
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*target = *(unsigned long long int *) var; *target = *(unsigned long long int *) var;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_float: case ECPGt_float:
*target = *(float *) var; *target = *(float *) var;
break; break;
......
/* $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. * 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 ...@@ -541,13 +541,13 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
if (*(long *) var->ind_value < 0L) if (*(long *) var->ind_value < 0L)
*tobeinserted_p = NULL; *tobeinserted_p = NULL;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
if (*(long long int *) var->ind_value < (long long) 0) if (*(long long int *) var->ind_value < (long long) 0)
*tobeinserted_p = NULL; *tobeinserted_p = NULL;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_NO_INDICATOR: case ECPGt_NO_INDICATOR:
if (force_indicator == false) if (force_indicator == false)
{ {
...@@ -679,7 +679,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari ...@@ -679,7 +679,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
*tobeinserted_p = mallocedval; *tobeinserted_p = mallocedval;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
if (!(mallocedval = ecpg_alloc(asize * 30, lineno))) if (!(mallocedval = ecpg_alloc(asize * 30, lineno)))
return false; return false;
...@@ -717,7 +717,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari ...@@ -717,7 +717,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
*tobeinserted_p = mallocedval; *tobeinserted_p = mallocedval;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_float: case ECPGt_float:
if (!(mallocedval = ecpg_alloc(asize * 25, lineno))) if (!(mallocedval = ecpg_alloc(asize * 25, lineno)))
return false; return false;
......
/* $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 #ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H #define _ECPG_LIB_EXTERN_H
...@@ -13,6 +13,11 @@ ...@@ -13,6 +13,11 @@
#include <limits.h> #include <limits.h>
#endif #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 enum COMPAT_MODE
{ {
ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE
......
/* $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 #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "pgtypes_interval.h" #include "pgtypes_interval.h"
#include "pg_config_paths.h" #include "pg_config_paths.h"
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
#ifndef LONG_LONG_MIN #ifndef LONG_LONG_MIN
#ifdef LLONG_MIN #ifdef LLONG_MIN
#define LONG_LONG_MIN LLONG_MIN #define LONG_LONG_MIN LLONG_MIN
...@@ -327,12 +327,12 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr) ...@@ -327,12 +327,12 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
case ECPGt_date: case ECPGt_date:
*((long *) ptr) = LONG_MIN; *((long *) ptr) = LONG_MIN;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
*((long long *) ptr) = LONG_LONG_MIN; *((long long *) ptr) = LONG_LONG_MIN;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_float: case ECPGt_float:
memset((char *) ptr, 0xff, sizeof(float)); memset((char *) ptr, 0xff, sizeof(float));
break; break;
...@@ -399,13 +399,13 @@ ECPGis_noind_null(enum ECPGttype type, void *ptr) ...@@ -399,13 +399,13 @@ ECPGis_noind_null(enum ECPGttype type, void *ptr)
if (*((long *) ptr) == LONG_MIN) if (*((long *) ptr) == LONG_MIN)
return true; return true;
break; break;
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
case ECPGt_long_long: case ECPGt_long_long:
case ECPGt_unsigned_long_long: case ECPGt_unsigned_long_long:
if (*((long long *) ptr) == LONG_LONG_MIN) if (*((long long *) ptr) == LONG_LONG_MIN)
return true; return true;
break; break;
#endif /* HAVE_LONG_LONG_INT_64 */ #endif /* HAVE_LONG_LONG */
case ECPGt_float: case ECPGt_float:
return (_check(ptr, sizeof(float))); return (_check(ptr, sizeof(float)));
break; break;
......
/* $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 */ /* Copyright comment */
%{ %{
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
#include "extern.h" #include "extern.h"
#include <unistd.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 */ /* Location tracking support --- simpler than bison's default */
#define YYLLOC_DEFAULT(Current, Rhs, N) \ #define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \ do { \
......
/* $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: /*EMPTY*/
| statements statement | statements statement
...@@ -781,7 +781,7 @@ unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; } ...@@ -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 INT_P { $$ = ECPGt_unsigned_long; }
| SQL_UNSIGNED SQL_LONG SQL_LONG | SQL_UNSIGNED SQL_LONG SQL_LONG
{ {
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
$$ = ECPGt_unsigned_long_long; $$ = ECPGt_unsigned_long_long;
#else #else
$$ = ECPGt_unsigned_long; $$ = ECPGt_unsigned_long;
...@@ -789,7 +789,7 @@ unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; } ...@@ -789,7 +789,7 @@ unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; }
} }
| SQL_UNSIGNED SQL_LONG SQL_LONG INT_P | SQL_UNSIGNED SQL_LONG SQL_LONG INT_P
{ {
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
$$ = ECPGt_unsigned_long_long; $$ = ECPGt_unsigned_long_long;
#else #else
$$ = ECPGt_unsigned_long; $$ = ECPGt_unsigned_long;
...@@ -805,7 +805,7 @@ signed_type: SQL_SHORT { $$ = ECPGt_short; } ...@@ -805,7 +805,7 @@ signed_type: SQL_SHORT { $$ = ECPGt_short; }
| SQL_LONG INT_P { $$ = ECPGt_long; } | SQL_LONG INT_P { $$ = ECPGt_long; }
| SQL_LONG SQL_LONG | SQL_LONG SQL_LONG
{ {
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
$$ = ECPGt_long_long; $$ = ECPGt_long_long;
#else #else
$$ = ECPGt_long; $$ = ECPGt_long;
...@@ -813,7 +813,7 @@ signed_type: SQL_SHORT { $$ = ECPGt_short; } ...@@ -813,7 +813,7 @@ signed_type: SQL_SHORT { $$ = ECPGt_short; }
} }
| SQL_LONG SQL_LONG INT_P | SQL_LONG SQL_LONG INT_P
{ {
#ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_LONG_LONG
$$ = ECPGt_long_long; $$ = ECPGt_long_long;
#else #else
$$ = ECPGt_long; $$ = ECPGt_long;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment