mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
ef770cbb69
- Fix wrong index results on text, char, varchar for multibyte strings - Fix some SIGFPE signals - Add support for infinite timestamps - Because of locale settings, btree_gist can not be a prefix index anymore (for text). Each node holds now just the lower and upper boundary.
85 lines
2.2 KiB
C
85 lines
2.2 KiB
C
|
|
typedef char GBT_NUMKEY;
|
|
|
|
/* Better readable key */
|
|
typedef struct
|
|
{
|
|
const GBT_NUMKEY *lower,
|
|
*upper;
|
|
} GBT_NUMKEY_R;
|
|
|
|
|
|
/* for sorting */
|
|
typedef struct
|
|
{
|
|
int i;
|
|
GBT_NUMKEY *t;
|
|
} Nsrt;
|
|
|
|
|
|
/* type description */
|
|
|
|
typedef struct
|
|
{
|
|
|
|
/* Attribs */
|
|
|
|
enum gbtree_type t; /* data type */
|
|
int32 size; /* size of type , 0 means variable */
|
|
|
|
/* Methods */
|
|
|
|
bool (*f_gt) (const void *, const void *); /* greater then */
|
|
bool (*f_ge) (const void *, const void *); /* greater equal */
|
|
bool (*f_eq) (const void *, const void *); /* equal */
|
|
bool (*f_le) (const void *, const void *); /* less equal */
|
|
bool (*f_lt) (const void *, const void *); /* less then */
|
|
int (*f_cmp) (const void *, const void *); /* key compare function */
|
|
} gbtree_ninfo;
|
|
|
|
|
|
/*
|
|
* Numeric btree functions
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
* Note: The factor 0.49 in following macro avoids floating point overflows
|
|
*/
|
|
#define penalty_num(result,olower,oupper,nlower,nupper) do { \
|
|
double tmp = 0.0F; \
|
|
(*(result)) = 0.0F; \
|
|
if ( (nupper) > (oupper) ) \
|
|
tmp += ( ((double)nupper)*0.49F - ((double)oupper)*0.49F ); \
|
|
if ( (olower) > (nlower) ) \
|
|
tmp += ( ((double)olower)*0.49F - ((double)nlower)*0.49F ); \
|
|
if (tmp > 0.0F) \
|
|
{ \
|
|
(*(result)) += FLT_MIN; \
|
|
(*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \
|
|
(*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \
|
|
} \
|
|
} while (0);
|
|
|
|
|
|
extern bool gbt_num_consistent(const GBT_NUMKEY_R * key, const void *query,
|
|
const StrategyNumber *strategy, bool is_leaf,
|
|
const gbtree_ninfo * tinfo);
|
|
|
|
extern GIST_SPLITVEC *gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
|
|
const gbtree_ninfo * tinfo);
|
|
|
|
extern GISTENTRY *gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry,
|
|
const gbtree_ninfo * tinfo);
|
|
|
|
|
|
extern void *gbt_num_union(GBT_NUMKEY * out, const GistEntryVector *entryvec,
|
|
const gbtree_ninfo * tinfo);
|
|
|
|
extern bool gbt_num_same(const GBT_NUMKEY * a, const GBT_NUMKEY * b,
|
|
const gbtree_ninfo * tinfo);
|
|
|
|
extern void gbt_num_bin_union(Datum *u, GBT_NUMKEY * e,
|
|
const gbtree_ninfo * tinfo);
|