aboutsummaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_utils_num.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-04-21 00:26:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-04-21 00:26:47 +0000
commit8472bf7a73487b0535c95e299773b882f7523463 (patch)
treef8cf1ad8529e819aec4d93cdcbf848996f4e3680 /contrib/btree_gist/btree_utils_num.c
parentbe939544a68f852107c912da2f35f5d36958deb2 (diff)
downloadpostgresql-8472bf7a73487b0535c95e299773b882f7523463.tar.gz
postgresql-8472bf7a73487b0535c95e299773b882f7523463.zip
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.
Diffstat (limited to 'contrib/btree_gist/btree_utils_num.c')
-rw-r--r--contrib/btree_gist/btree_utils_num.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c
index c7b41f16c1e..5e227196b65 100644
--- a/contrib/btree_gist/btree_utils_num.c
+++ b/contrib/btree_gist/btree_utils_num.c
@@ -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);