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
#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;
}
......
/* 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;
......
/* $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;
......
/* $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
......
/* $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;
......
/* $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 { \
......
/* $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;
......
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