mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Allow float8, int8, and related datatypes to be passed by value on machines
where Datum is 8 bytes wide. Since this will break old-style C functions (those still using version 0 calling convention) that have arguments or results of these types, provide a configure option to disable it and retain the old pass-by-reference behavior. Likewise, provide a configure option to disable the recently-committed float4 pass-by-value change. Zoltan Boszormenyi, plus configurability stuff by me.
This commit is contained in:
@ -1,20 +1,25 @@
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_num.h"
|
||||
#include "utils/cash.h"
|
||||
#include "utils/date.h"
|
||||
|
||||
|
||||
GISTENTRY *
|
||||
gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo)
|
||||
{
|
||||
|
||||
if (entry->leafkey)
|
||||
{
|
||||
|
||||
union
|
||||
{
|
||||
int16 i2;
|
||||
int32 i4;
|
||||
int64 i8;
|
||||
float4 f4;
|
||||
float8 f8;
|
||||
DateADT dt;
|
||||
TimeADT tm;
|
||||
Timestamp ts;
|
||||
Cash ch;
|
||||
} v;
|
||||
|
||||
GBT_NUMKEY *r = (GBT_NUMKEY *) palloc0(2 * tinfo->size);
|
||||
@ -30,17 +35,37 @@ gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo
|
||||
v.i4 = DatumGetInt32(entry->key);
|
||||
leaf = &v.i4;
|
||||
break;
|
||||
case gbt_t_int8:
|
||||
v.i8 = DatumGetInt64(entry->key);
|
||||
leaf = &v.i8;
|
||||
break;
|
||||
case gbt_t_oid:
|
||||
v.i4 = DatumGetObjectId(entry->key);
|
||||
leaf = &v.i4;
|
||||
break;
|
||||
case gbt_t_float4:
|
||||
v.f4 = DatumGetFloat4(entry->key);
|
||||
leaf = &v.f4;
|
||||
break;
|
||||
case gbt_t_float8:
|
||||
v.f8 = DatumGetFloat8(entry->key);
|
||||
leaf = &v.f8;
|
||||
break;
|
||||
case gbt_t_date:
|
||||
v.dt = DatumGetDateADT(entry->key);
|
||||
leaf = &v.dt;
|
||||
break;
|
||||
case gbt_t_float4:
|
||||
v.f4 = DatumGetFloat4(entry->key);
|
||||
leaf = &v.f4;
|
||||
case gbt_t_time:
|
||||
v.tm = DatumGetTimeADT(entry->key);
|
||||
leaf = &v.tm;
|
||||
break;
|
||||
case gbt_t_ts:
|
||||
v.ts = DatumGetTimestamp(entry->key);
|
||||
leaf = &v.ts;
|
||||
break;
|
||||
case gbt_t_cash:
|
||||
v.ch = DatumGetCash(entry->key);
|
||||
leaf = &v.ch;
|
||||
break;
|
||||
default:
|
||||
leaf = DatumGetPointer(entry->key);
|
||||
|
Reference in New Issue
Block a user