Redefine Datum as uintptr_t, instead of unsigned long.

This is more in keeping with modern practice, and is a first step towards
porting to Win64 (which has sizeof(pointer) > sizeof(long)).

Tsutomu Yamada, Magnus Hagander, Tom Lane
This commit is contained in:
Tom Lane 2009-12-31 19:41:37 +00:00
parent 8abb011047
commit 85d02a6586
16 changed files with 751 additions and 423 deletions

1039
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.616 2009/12/11 02:21:21 momjian Exp $ dnl $PostgreSQL: pgsql/configure.in,v 1.617 2009/12/31 19:41:33 tgl Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
@ -1095,6 +1095,8 @@ PGAC_STRUCT_SOCKADDR_UN
PGAC_STRUCT_SOCKADDR_STORAGE PGAC_STRUCT_SOCKADDR_STORAGE
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
PGAC_STRUCT_ADDRINFO PGAC_STRUCT_ADDRINFO
AC_TYPE_INTPTR_T
AC_TYPE_UINTPTR_T
AC_CHECK_TYPES([struct cmsgcred, struct fcred, struct sockcred], [], [], AC_CHECK_TYPES([struct cmsgcred, struct fcred, struct sockcred], [], [],
[#include <sys/param.h> [#include <sys/param.h>
@ -1555,12 +1557,10 @@ if test $pgac_need_repl_snprintf = yes; then
AC_LIBOBJ(snprintf) AC_LIBOBJ(snprintf)
fi fi
# Need a #define for the size of Datum (unsigned long) # Check size of void *, size_t (enables tweaks for > 32bit address space)
AC_CHECK_SIZEOF([unsigned long])
# And check size of void *, size_t (enables tweaks for > 32bit address space)
AC_CHECK_SIZEOF([void *]) AC_CHECK_SIZEOF([void *])
AC_CHECK_SIZEOF([size_t]) AC_CHECK_SIZEOF([size_t])
AC_CHECK_SIZEOF([long])
# Decide whether float4 is passed by value: user-selectable, enabled by default # Decide whether float4 is passed by value: user-selectable, enabled by default
AC_MSG_CHECKING([whether to build with float4 passed by value]) AC_MSG_CHECKING([whether to build with float4 passed by value])
@ -1577,7 +1577,7 @@ AC_DEFINE_UNQUOTED([FLOAT4PASSBYVAL], [$float4passbyval], [float4 values are pas
# If sizeof(Datum) >= 8, this is user-selectable, enabled by default. # If sizeof(Datum) >= 8, this is user-selectable, enabled by default.
# If not, trying to select it is an error. # If not, trying to select it is an error.
AC_MSG_CHECKING([whether to build with float8 passed by value]) AC_MSG_CHECKING([whether to build with float8 passed by value])
if test $ac_cv_sizeof_unsigned_long -ge 8 ; then if test $ac_cv_sizeof_void_p -ge 8 ; then
PGAC_ARG_BOOL(enable, float8-byval, yes, [disable float8 passed by value]) PGAC_ARG_BOOL(enable, float8-byval, yes, [disable float8 passed by value])
else else
PGAC_ARG_BOOL(enable, float8-byval, no, [disable float8 passed by value]) PGAC_ARG_BOOL(enable, float8-byval, no, [disable float8 passed by value])

View File

@ -50,7 +50,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.127 2009/06/11 14:48:53 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.128 2009/12/31 19:41:33 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -192,7 +192,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
if (att[i]->attbyval) if (att[i]->attbyval)
{ {
/* pass-by-value */ /* pass-by-value */
data = (char *) att_align_nominal((long) data, att[i]->attalign); data = (char *) att_align_nominal(data, att[i]->attalign);
store_att_byval(data, values[i], att[i]->attlen); store_att_byval(data, values[i], att[i]->attlen);
data_length = att[i]->attlen; data_length = att[i]->attlen;
} }
@ -226,7 +226,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
else else
{ {
/* full 4-byte header varlena */ /* full 4-byte header varlena */
data = (char *) att_align_nominal((long) data, data = (char *) att_align_nominal(data,
att[i]->attalign); att[i]->attalign);
data_length = VARSIZE(val); data_length = VARSIZE(val);
memcpy(data, val, data_length); memcpy(data, val, data_length);
@ -243,7 +243,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
else else
{ {
/* fixed-length pass-by-reference */ /* fixed-length pass-by-reference */
data = (char *) att_align_nominal((long) data, att[i]->attalign); data = (char *) att_align_nominal(data, att[i]->attalign);
Assert(att[i]->attlen > 0); Assert(att[i]->attlen > 0);
data_length = att[i]->attlen; data_length = att[i]->attlen;
memcpy(data, DatumGetPointer(values[i]), data_length); memcpy(data, DatumGetPointer(values[i]), data_length);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.59 2009/06/11 14:48:53 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.60 2009/12/31 19:41:33 tgl Exp $
* *
* NOTES * NOTES
* These functions are stored in pg_amproc. For each operator class * These functions are stored in pg_amproc. For each operator class
@ -319,7 +319,7 @@ hash_any(register const unsigned char *k, register int keylen)
a = b = c = 0x9e3779b9 + len + 3923095; a = b = c = 0x9e3779b9 + len + 3923095;
/* If the source pointer is word-aligned, we use word-wide fetches */ /* If the source pointer is word-aligned, we use word-wide fetches */
if (((long) k & UINT32_ALIGN_MASK) == 0) if (((intptr_t) k & UINT32_ALIGN_MASK) == 0)
{ {
/* Code path for aligned source data */ /* Code path for aligned source data */
register const uint32 *ka = (const uint32 *) k; register const uint32 *ka = (const uint32 *) k;

View File

@ -20,7 +20,7 @@ tas(lock)
* LDCWX requires that we align the "semaphore" to a 16-byte * LDCWX requires that we align the "semaphore" to a 16-byte
* boundary. The actual datum is a single word (4 bytes). * boundary. The actual datum is a single word (4 bytes).
*/ */
lock = ((long) lock + 15) & ~15; lock = ((uintptr_t) lock + 15) & ~15;
/* /*
* The LDCWX instruction atomically clears the target word and * The LDCWX instruction atomically clears the target word and

View File

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.53 2009/01/01 17:23:48 momjian Exp $ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.54 2009/12/31 19:41:34 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -245,7 +245,7 @@ CreateLWLocks(void)
ptr += 2 * sizeof(int); ptr += 2 * sizeof(int);
/* Ensure desired alignment of LWLock array */ /* Ensure desired alignment of LWLock array */
ptr += LWLOCK_PADDED_SIZE - ((unsigned long) ptr) % LWLOCK_PADDED_SIZE; ptr += LWLOCK_PADDED_SIZE - ((uintptr_t) ptr) % LWLOCK_PADDED_SIZE;
LWLockArray = (LWLockPadded *) ptr; LWLockArray = (LWLockPadded *) ptr;

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.529 2009/12/21 01:34:11 rhaas Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.530 2009/12/31 19:41:34 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
@ -87,7 +87,8 @@
#endif #endif
/* upper limit for GUC variables measured in kilobytes of memory */ /* upper limit for GUC variables measured in kilobytes of memory */
#if SIZEOF_SIZE_T > 4 /* note that various places assume the byte size fits in a "long" variable */
#if SIZEOF_SIZE_T > 4 && SIZEOF_LONG > 4
#define MAX_KILOBYTES INT_MAX #define MAX_KILOBYTES INT_MAX
#else #else
#define MAX_KILOBYTES (INT_MAX / 1024) #define MAX_KILOBYTES (INT_MAX / 1024)

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/access/tupmacs.h,v 1.36 2009/01/01 17:23:56 momjian Exp $ * $PostgreSQL: pgsql/src/include/access/tupmacs.h,v 1.37 2009/12/31 19:41:35 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -100,7 +100,8 @@
*/ */
#define att_align_datum(cur_offset, attalign, attlen, attdatum) \ #define att_align_datum(cur_offset, attalign, attlen, attdatum) \
( \ ( \
((attlen) == -1 && VARATT_IS_SHORT(DatumGetPointer(attdatum))) ? (long) (cur_offset) : \ ((attlen) == -1 && VARATT_IS_SHORT(DatumGetPointer(attdatum))) ? \
(intptr_t) (cur_offset) : \
att_align_nominal(cur_offset, attalign) \ att_align_nominal(cur_offset, attalign) \
) )
@ -115,12 +116,13 @@
* aligned 4-byte length word; in either case we need not align.) * aligned 4-byte length word; in either case we need not align.)
* *
* Note: some callers pass a "char *" pointer for cur_offset. This is * Note: some callers pass a "char *" pointer for cur_offset. This is
* a bit of a hack but works OK on all known platforms. It ought to be * a bit of a hack but should work all right as long as intptr_t is the
* cleaned up someday, though. * correct width.
*/ */
#define att_align_pointer(cur_offset, attalign, attlen, attptr) \ #define att_align_pointer(cur_offset, attalign, attlen, attptr) \
( \ ( \
((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? (long) (cur_offset) : \ ((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? \
(intptr_t) (cur_offset) : \
att_align_nominal(cur_offset, attalign) \ att_align_nominal(cur_offset, attalign) \
) )
@ -142,7 +144,7 @@
#define att_align_nominal(cur_offset, attalign) \ #define att_align_nominal(cur_offset, attalign) \
( \ ( \
((attalign) == 'i') ? INTALIGN(cur_offset) : \ ((attalign) == 'i') ? INTALIGN(cur_offset) : \
(((attalign) == 'c') ? (long) (cur_offset) : \ (((attalign) == 'c') ? (intptr_t) (cur_offset) : \
(((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \ (((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \
( \ ( \
AssertMacro((attalign) == 's'), \ AssertMacro((attalign) == 's'), \

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/c.h,v 1.236 2009/06/11 14:49:08 momjian Exp $ * $PostgreSQL: pgsql/src/include/c.h,v 1.237 2009/12/31 19:41:35 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -72,6 +72,9 @@
#ifdef HAVE_STRINGS_H #ifdef HAVE_STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
@ -492,7 +495,7 @@ typedef NameData *Name;
* True iff pointer is properly aligned to point to the given type. * True iff pointer is properly aligned to point to the given type.
*/ */
#define PointerIsAligned(pointer, type) \ #define PointerIsAligned(pointer, type) \
(((long)(pointer) % (sizeof (type))) == 0) (((intptr_t)(pointer) % (sizeof (type))) == 0)
#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid)) #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
@ -538,7 +541,7 @@ typedef NameData *Name;
*/ */
#define TYPEALIGN(ALIGNVAL,LEN) \ #define TYPEALIGN(ALIGNVAL,LEN) \
(((long) (LEN) + ((ALIGNVAL) - 1)) & ~((long) ((ALIGNVAL) - 1))) (((intptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((intptr_t) ((ALIGNVAL) - 1)))
#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
@ -549,7 +552,7 @@ typedef NameData *Name;
#define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN)) #define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN))
#define TYPEALIGN_DOWN(ALIGNVAL,LEN) \ #define TYPEALIGN_DOWN(ALIGNVAL,LEN) \
(((long) (LEN)) & ~((long) ((ALIGNVAL) - 1))) (((intptr_t) (LEN)) & ~((intptr_t) ((ALIGNVAL) - 1)))
#define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN)) #define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))
#define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN)) #define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))
@ -630,7 +633,7 @@ typedef NameData *Name;
int _val = (val); \ int _val = (val); \
Size _len = (len); \ Size _len = (len); \
\ \
if ((((long) _vstart) & LONG_ALIGN_MASK) == 0 && \ if ((((intptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
(_len & LONG_ALIGN_MASK) == 0 && \ (_len & LONG_ALIGN_MASK) == 0 && \
_val == 0 && \ _val == 0 && \
_len <= MEMSET_LOOP_LIMIT && \ _len <= MEMSET_LOOP_LIMIT && \

View File

@ -236,6 +236,9 @@
/* Define to 1 if the system has the type `int8'. */ /* Define to 1 if the system has the type `int8'. */
#undef HAVE_INT8 #undef HAVE_INT8
/* Define to 1 if the system has the type `intptr_t'. */
#undef HAVE_INTPTR_T
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H
@ -599,6 +602,9 @@
/* Define to 1 if the system has the type `uint8'. */ /* Define to 1 if the system has the type `uint8'. */
#undef HAVE_UINT8 #undef HAVE_UINT8
/* Define to 1 if the system has the type `uintptr_t'. */
#undef HAVE_UINTPTR_T
/* Define to 1 if the system has the type `union semun'. */ /* Define to 1 if the system has the type `union semun'. */
#undef HAVE_UNION_SEMUN #undef HAVE_UNION_SEMUN
@ -705,15 +711,15 @@
RELSEG_SIZE requires an initdb. */ RELSEG_SIZE requires an initdb. */
#undef RELSEG_SIZE #undef RELSEG_SIZE
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `off_t', as computed by sizeof. */ /* The size of `off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T #undef SIZEOF_OFF_T
/* The size of `size_t', as computed by sizeof. */ /* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T #undef SIZEOF_SIZE_T
/* The size of `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
/* The size of `void *', as computed by sizeof. */ /* The size of `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P #undef SIZEOF_VOID_P
@ -827,9 +833,17 @@
#undef inline #undef inline
#endif #endif
/* Define to the type of a signed integer type wide enough to hold a pointer,
if such a type exists, and if the system does not define it. */
#undef intptr_t
/* Define to empty if the C compiler does not understand signed types. */ /* Define to empty if the C compiler does not understand signed types. */
#undef signed #undef signed
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
#undef uintptr_t
/* Define to empty if the keyword `volatile' does not work. Warning: valid /* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */ code using `volatile' can become incorrect without. Disable with care. */
#undef volatile #undef volatile

View File

@ -347,7 +347,7 @@
/* #undef HAVE_SRANDOM */ /* #undef HAVE_SRANDOM */
/* Define to 1 if you have the <stdint.h> header file. */ /* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1 /* #undef HAVE_STDINT_H */
/* Define to 1 if you have the <stdlib.h> header file. */ /* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1 #define HAVE_STDLIB_H 1
@ -585,11 +585,14 @@
your system. */ your system. */
/* #undef PTHREAD_CREATE_JOINABLE */ /* #undef PTHREAD_CREATE_JOINABLE */
/* The size of a `size_t', as computed by sizeof. */ /* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4 #define SIZEOF_SIZE_T 4
/* The size of a `unsigned long', as computed by sizeof. */ /* The size of `void *', as computed by sizeof. */
#define SIZEOF_UNSIGNED_LONG 4 #define SIZEOF_VOID_P 4
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1 #define STDC_HEADERS 1

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California * Portions Copyright (c) 1995, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.92 2009/01/01 17:23:55 momjian Exp $ * $PostgreSQL: pgsql/src/include/postgres.h,v 1.93 2009/12/31 19:41:35 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -285,16 +285,10 @@ typedef struct
/* /*
* Port Notes: * Port Notes:
* Postgres makes the following assumption about machines: * Postgres makes the following assumptions about datatype sizes:
*
* sizeof(Datum) == sizeof(long) >= sizeof(void *) >= 4
*
* Postgres also assumes that
* *
* sizeof(Datum) == sizeof(void *) == 4 or 8
* sizeof(char) == 1 * sizeof(char) == 1
*
* and that
*
* sizeof(short) == 2 * sizeof(short) == 2
* *
* When a type narrower than Datum is stored in a Datum, we place it in the * When a type narrower than Datum is stored in a Datum, we place it in the
@ -305,9 +299,9 @@ typedef struct
* or short may contain garbage when called as if it returned Datum. * or short may contain garbage when called as if it returned Datum.
*/ */
typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */ typedef uintptr_t Datum;
#define SIZEOF_DATUM SIZEOF_UNSIGNED_LONG #define SIZEOF_DATUM SIZEOF_VOID_P
typedef Datum *DatumPtr; typedef Datum *DatumPtr;

View File

@ -66,7 +66,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.167 2009/07/27 05:31:05 tgl Exp $ * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.168 2009/12/31 19:41:36 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -683,7 +683,7 @@ typedef struct
int sema[4]; int sema[4];
} slock_t; } slock_t;
#define TAS_ACTIVE_WORD(lock) ((volatile int *) (((long) (lock) + 15) & ~15)) #define TAS_ACTIVE_WORD(lock) ((volatile int *) (((uintptr_t) (lock) + 15) & ~15))
#if defined(__GNUC__) #if defined(__GNUC__)

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.46 2009/11/27 13:32:17 meskes Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.47 2009/12/31 19:41:36 tgl Exp $ */
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
@ -162,12 +162,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (binary) if (binary)
{ {
if (varcharsize == 0 || varcharsize * offset >= size) if (varcharsize == 0 || varcharsize * offset >= size)
memcpy((char *) ((long) var + offset * act_tuple), memcpy(var + offset * act_tuple, pval, size);
pval, size);
else else
{ {
memcpy((char *) ((long) var + offset * act_tuple), memcpy(var + offset * act_tuple, pval, varcharsize * offset);
pval, varcharsize * offset);
if (varcharsize * offset < size) if (varcharsize * offset < size)
{ {
@ -371,7 +369,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_unsigned_char: case ECPGt_unsigned_char:
case ECPGt_string: case ECPGt_string:
{ {
char *str = (char *) ((long) var + offset * act_tuple); char *str = (char *) (var + offset * act_tuple);
if (varcharsize == 0 || varcharsize > size) if (varcharsize == 0 || varcharsize > size)
{ {
strncpy(str, pval, size + 1); strncpy(str, pval, size + 1);
@ -426,7 +424,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
case ECPGt_varchar: case ECPGt_varchar:
{ {
struct ECPGgeneric_varchar *variable = struct ECPGgeneric_varchar *variable =
(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple); (struct ECPGgeneric_varchar *) (var + offset * act_tuple);
variable->len = size; variable->len = size;
if (varcharsize == 0) if (varcharsize == 0)

View File

@ -1,7 +1,7 @@
/********************************************************************** /**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL * plperl.c - perl as a procedural language for PostgreSQL
* *
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.156 2009/12/29 17:40:59 heikki Exp $ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.157 2009/12/31 19:41:37 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
@ -95,7 +95,7 @@ typedef struct plperl_call_data
**********************************************************************/ **********************************************************************/
typedef struct plperl_query_desc typedef struct plperl_query_desc
{ {
char qname[sizeof(long) * 2 + 1]; char qname[20];
void *plan; void *plan;
int nargs; int nargs;
Oid *argtypes; Oid *argtypes;
@ -2337,7 +2337,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
************************************************************/ ************************************************************/
qdesc = (plperl_query_desc *) malloc(sizeof(plperl_query_desc)); qdesc = (plperl_query_desc *) malloc(sizeof(plperl_query_desc));
MemSet(qdesc, 0, sizeof(plperl_query_desc)); MemSet(qdesc, 0, sizeof(plperl_query_desc));
snprintf(qdesc->qname, sizeof(qdesc->qname), "%lx", (long) qdesc); snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
qdesc->nargs = argc; qdesc->nargs = argc;
qdesc->argtypes = (Oid *) malloc(argc * sizeof(Oid)); qdesc->argtypes = (Oid *) malloc(argc * sizeof(Oid));
qdesc->arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo)); qdesc->arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo));

View File

@ -2,7 +2,7 @@
* pltcl.c - PostgreSQL support for Tcl as * pltcl.c - PostgreSQL support for Tcl as
* procedural language (PL) * procedural language (PL)
* *
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.128 2009/06/11 14:49:14 momjian Exp $ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.129 2009/12/31 19:41:37 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
@ -1946,7 +1946,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
* Allocate the new querydesc structure * Allocate the new querydesc structure
************************************************************/ ************************************************************/
qdesc = (pltcl_query_desc *) malloc(sizeof(pltcl_query_desc)); qdesc = (pltcl_query_desc *) malloc(sizeof(pltcl_query_desc));
snprintf(qdesc->qname, sizeof(qdesc->qname), "%lx", (long) qdesc); snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
qdesc->nargs = nargs; qdesc->nargs = nargs;
qdesc->argtypes = (Oid *) malloc(nargs * sizeof(Oid)); qdesc->argtypes = (Oid *) malloc(nargs * sizeof(Oid));
qdesc->arginfuncs = (FmgrInfo *) malloc(nargs * sizeof(FmgrInfo)); qdesc->arginfuncs = (FmgrInfo *) malloc(nargs * sizeof(FmgrInfo));