static const gbtree_vinfo tinfo =
{
gbt_t_bit,
- FALSE,
+ 0,
TRUE,
gbt_bitgt,
gbt_bitge,
static const gbtree_vinfo tinfo =
{
gbt_t_bytea,
- FALSE,
+ 0,
TRUE,
gbt_byteagt,
gbt_byteage,
gbt_cash_penalty(PG_FUNCTION_ARGS)
{
cashKEY *origentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
- cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
- float *result = (float *) PG_GETARG_POINTER(2);
+ cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
+ float *result = (float *) PG_GETARG_POINTER(2);
- Cash res;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
PG_RETURN_POINTER(result);
float4KEY *newentry = (float4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);
- float4 res;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
PG_RETURN_POINTER(result);
float8KEY *newentry = (float8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);
- float8 res;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
PG_RETURN_POINTER(result);
inetKEY *newentry = (inetKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);
- double res;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
-
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
+
PG_RETURN_POINTER(result);
}
gbt_int2_penalty(PG_FUNCTION_ARGS)
{
int16KEY *origentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
- int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
- float *result = (float *) PG_GETARG_POINTER(2);
- int2 res;
+ int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
+ float *result = (float *) PG_GETARG_POINTER(2);
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
PG_RETURN_POINTER(result);
}
gbt_int4_penalty(PG_FUNCTION_ARGS)
{
int32KEY *origentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
- int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
- float *result = (float *) PG_GETARG_POINTER(2);
- int4 res;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
+ float *result = (float *) PG_GETARG_POINTER(2);
+
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
PG_RETURN_POINTER(result);
}
gbt_int8_penalty(PG_FUNCTION_ARGS)
{
int64KEY *origentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
- int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
- float *result = (float *) PG_GETARG_POINTER(2);
- int64 res;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
+ float *result = (float *) PG_GETARG_POINTER(2);
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
+
PG_RETURN_POINTER(result);
-
}
Datum
intvKEY *newentry = (intvKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);
double iorg[2],
- inew[2],
- res;
+ inew[2];
iorg[0] = intr2num(&origentry->lower);
iorg[1] = intr2num(&origentry->upper);
inew[0] = intr2num(&newentry->lower);
inew[1] = intr2num(&newentry->upper);
- penalty_range_enlarge(iorg[0], iorg[1], inew[0], inew[1]);
-
- *result = 0.0;
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / (res + iorg[1] - iorg[0]));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
PG_RETURN_POINTER(result);
float *result = (float *) PG_GETARG_POINTER(2);
uint64 iorg[2],
inew[2];
- uint64 res;
iorg[0] = mac_2_uint64(&origentry->lower);
iorg[1] = mac_2_uint64(&origentry->upper);
inew[0] = mac_2_uint64(&newentry->lower);
inew[1] = mac_2_uint64(&newentry->upper);
- penalty_range_enlarge(iorg[0], iorg[1], inew[0], inew[1]);
-
- *result = 0.0;
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (((double) res) / ((double) res + (double) iorg[1] - (double) iorg[0]));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
PG_RETURN_POINTER(result);
static const gbtree_vinfo tinfo =
{
gbt_t_numeric,
- FALSE,
+ 0,
FALSE,
gbt_numeric_gt,
gbt_numeric_ge,
oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);
- Oid res = 0;
-
- *result = 0.0;
-
- penalty_range_enlarge(origentry->lower, origentry->upper, newentry->lower, newentry->upper);
-
- if (res > 0)
- {
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + origentry->upper - origentry->lower)));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
PG_RETURN_POINTER(result);
}
return DatumGetInt32(DirectFunctionCall2(bttextcmp, PointerGetDatum(a), PointerGetDatum(b)));
}
-static const gbtree_vinfo tinfo =
+static gbtree_vinfo tinfo =
{
gbt_t_text,
- TRUE,
- TRUE,
+ 0,
+ FALSE,
gbt_textgt,
gbt_textge,
gbt_texteq,
};
-
/**************************************************
* Text ops
**************************************************/
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
+ if ( tinfo.eml == 0 )
+ {
+ tinfo.eml = pg_database_encoding_max_length();
+ }
+
PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
}
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *retval;
+ if ( tinfo.eml == 0 )
+ {
+ tinfo.eml = pg_database_encoding_max_length();
+ }
+
if (entry->leafkey)
{
bool retval = FALSE;
GBT_VARKEY_R r = gbt_var_key_readable(key);
+ if ( tinfo.eml == 0 )
+ {
+ tinfo.eml = pg_database_encoding_max_length();
+ }
+
retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
PG_RETURN_BOOL(retval);
bool retval;
GBT_VARKEY_R r = gbt_var_key_readable(key);
+ if ( tinfo.eml == 0 )
+ {
+ tinfo.eml = pg_database_encoding_max_length();
+ }
+
retval = gbt_var_consistent(&r, trim, &strategy, GIST_LEAF(entry), &tinfo);
PG_RETURN_BOOL(retval);
}
*gmt = *ts;
DecodeSpecial(0, "gmt", &val);
- if (!TIMESTAMP_NOT_FINITE(*ts))
+ if ( *ts < DT_NOEND && *ts > DT_NOBEGIN )
{
tz = val * 60;
}
+#define penalty_check_max_float(val) do { \
+ if ( val > FLT_MAX ) \
+ val = FLT_MAX; \
+ if ( val < -FLT_MAX ) \
+ val = -FLT_MAX; \
+} while(false);
+
+
Datum
gbt_ts_penalty(PG_FUNCTION_ARGS)
{
tsKEY *origentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2);
- Interval *intr;
-
-#ifdef HAVE_INT64_TIMESTAMP
- int64 res;
-#else
- double res;
-#endif
- intr = DatumGetIntervalP(DirectFunctionCall2(
- timestamp_mi,
- P_TimestampGetDatum(newentry->upper),
- P_TimestampGetDatum(origentry->upper)
- ));
+ double orgdbl[2],
+ newdbl[2];
- /* see interval_larger */
+ /*
+ We are allways using "double" timestamps here.
+ Precision should be good enough.
+ */
+ orgdbl[0] = ( (double) origentry->lower ) ;
+ orgdbl[1] = ( (double) origentry->upper ) ;
+ newdbl[0] = ( (double) newentry->lower ) ;
+ newdbl[1] = ( (double) newentry->upper ) ;
- res = Max(intr->time + intr->month * (30 * 86400), 0);
+ penalty_check_max_float( orgdbl[0] );
+ penalty_check_max_float( orgdbl[1] );
+ penalty_check_max_float( newdbl[0] );
+ penalty_check_max_float( newdbl[1] );
- intr = DatumGetIntervalP(DirectFunctionCall2(
- timestamp_mi,
- P_TimestampGetDatum(origentry->lower),
- P_TimestampGetDatum(newentry->lower)
- ));
-
- /* see interval_larger */
- res += Max(intr->time + intr->month * (30 * 86400), 0);
-
- *result = 0.0;
-
- if (res > 0)
- {
- intr = DatumGetIntervalP(DirectFunctionCall2(
- timestamp_mi,
- P_TimestampGetDatum(origentry->upper),
- P_TimestampGetDatum(origentry->lower)
- ));
- *result += FLT_MIN;
- *result += (float) (res / ((double) (res + intr->time + intr->month * (30 * 86400))));
- *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
- }
+ penalty_num(result,orgdbl[0],orgdbl[1],newdbl[0],newdbl[1]);
PG_RETURN_POINTER(result);
+
}
*/
-#define penalty_range_enlarge(olower,oupper,nlower,nupper) do { \
- res = 0; \
+
+/*
+ * 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) ) \
- res += ( (nupper) - (oupper) ); \
+ tmp += ( ((double)nupper)*0.49F - ((double)oupper)*0.49F ); \
if ( (olower) > (nlower) ) \
- res += ( (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);
#include "btree_gist.h"
#include "utils/pg_locale.h"
#include "btree_utils_var.h"
+#include "utils/builtins.h"
PG_FUNCTION_INFO_V1(gbt_var_decompress);
Datum gbt_var_decompress(PG_FUNCTION_ARGS);
static int32
gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo)
{
- int32 i;
- int32 s = (tinfo->str) ? (1) : (0);
- GBT_VARKEY_R r = gbt_var_key_readable(node);
- int32 t1len = VARSIZE(r.lower) - VARHDRSZ - s;
- int32 t2len = VARSIZE(r.upper) - VARHDRSZ - s;
- int32 ml = Min(t1len, t2len);
- char *p1 = VARDATA(r.lower),
- *p2 = VARDATA(r.upper);
+ GBT_VARKEY_R r = gbt_var_key_readable(node);
+ int32 i = 0;
+ int32 l = 0;
+ int32 t1len = VARSIZE(r.lower) - VARHDRSZ ;
+ int32 t2len = VARSIZE(r.upper) - VARHDRSZ ;
+ int32 ml = Min(t1len, t2len);
+
+ char *p1 = VARDATA(r.lower);
+ char *p2 = VARDATA(r.upper);
- for (i = 0; i < ml; i++)
+ if ( ml == 0 )
+ return 0;
+
+ while ( i < ml )
{
- if (*p1 != *p2)
- return i;
- p1++;
- p2++;
+ if ( tinfo->eml > 1 && l == 0 )
+ {
+
+ if ( ( l = pg_mblen(p1) ) != pg_mblen(p2) )
+ {
+ return i;
+ }
+ }
+ if (*p1 != *p2)
+ {
+ if( tinfo->eml > 1 )
+ {
+ return (i-l+1);
+ } else {
+ return i;
+ }
+ }
+
+ p1++;
+ p2++;
+ l--;
+ i++;
}
- return (ml);
+ return (ml); /* lower == upper */
}
-
/*
- * returns true, if query matches prefix using common prefix
+ * returns true, if query matches prefix ( common prefix )
*/
-
static bool
gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tinfo)
{
- int k;
- int32 s = (tinfo->str) ? (1) : (0);
- bool out = FALSE;
- int32 qlen = VARSIZE(query) - VARHDRSZ - s;
- int32 nlen = VARSIZE(pf) - VARHDRSZ - s;
+ bool out = FALSE;
+ int32 k = 0;
+ int32 qlen = VARSIZE(query) - VARHDRSZ ;
+ int32 nlen = VARSIZE(pf) - VARHDRSZ ;
if (nlen <= qlen)
{
- char *q = VARDATA(query);
- char *n = VARDATA(pf);
-
- out = TRUE;
- for (k = 0; k < nlen; k++)
- {
- if (*n != *q)
- {
- out = FALSE;
- break;
- }
- if (k < (nlen - 1))
- {
- q++;
- n++;
- }
- }
+ char *q = VARDATA(query);
+ char *n = VARDATA(pf);
+
+ if ( tinfo->eml > 1 )
+ {
+ out = ( varstr_cmp(q, nlen, n, nlen) == 0 );
+ } else {
+ out = TRUE;
+ for (k = 0; k < nlen; k++)
+ {
+ if (*n != *q)
+ {
+ out = FALSE;
+ break;
+ }
+ if (k < (nlen - 1))
+ {
+ q++;
+ n++;
+ }
+ }
+ }
}
return out;
}
-
-
/*
* returns true, if query matches node using common prefix
*/
gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtree_vinfo * tinfo)
{
- return (
+ return ( tinfo->trnc && (
gbt_bytea_pf_match(node->lower, query, tinfo) ||
gbt_bytea_pf_match(node->upper, query, tinfo)
- );
+ ) );
}
/*
* truncates / compresses the node key
+* cpf_length .. common prefix length
*/
static GBT_VARKEY *
-gbt_var_node_truncate(const GBT_VARKEY * node, int32 length, const gbtree_vinfo * tinfo)
+gbt_var_node_truncate(const GBT_VARKEY * node, int32 cpf_length, const gbtree_vinfo * tinfo)
{
-
- int32 s = (tinfo->str) ? (1) : (0);
GBT_VARKEY *out = NULL;
GBT_VARKEY_R r = gbt_var_key_readable(node);
- int32 len1 = VARSIZE(r.lower) - VARHDRSZ;
- int32 len2 = VARSIZE(r.upper) - VARHDRSZ;
- int32 si = 0;
+ int32 len1 = VARSIZE(r.lower) - VARHDRSZ;
+ int32 len2 = VARSIZE(r.upper) - VARHDRSZ;
+ int32 si = 0;
- if (tinfo->str)
- length++; /* because of tailing '\0' */
+ len1 = Min(len1,(cpf_length + 1));
+ len2 = Min(len2,(cpf_length + 1));
- len1 = Min(len1, length);
- len2 = Min(len2, length);
si = 2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2;
out = (GBT_VARKEY *) palloc(si);
out->vl_len = si;
- memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ - s);
- memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ - s);
+ memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ );
+ memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ );
- if (tinfo->str)
- {
- ((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1) - 1] = '\0';
- ((char *) out)[2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2 - 1] = '\0';
- }
*((int32 *) &(((char *) out)[VARHDRSZ])) = len1 + VARHDRSZ;
*((int32 *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)])) = len2 + VARHDRSZ;
GBT_VARKEY_R ok,
nk;
GBT_VARKEY *tmp = NULL;
- int32 s = (tinfo->str) ? (1) : (0);
*res = 0.0;
}
ok = gbt_var_key_readable(orge);
- if ((VARSIZE(ok.lower) - VARHDRSZ) == s && (VARSIZE(ok.upper) - VARHDRSZ) == s)
+ if ((VARSIZE(ok.lower) - VARHDRSZ) == 0 && (VARSIZE(ok.upper) - VARHDRSZ) == 0)
*res = 0.0;
else if (!(
(
{
GBT_VARKEY_R uk = gbt_var_key_readable((GBT_VARKEY *) DatumGetPointer(d));
- if (tinfo->str)
- {
- dres = (VARDATA(ok.lower)[ul] - VARDATA(uk.lower)[ul]) +
- (VARDATA(uk.upper)[ul] - VARDATA(ok.upper)[ul]);
- }
- else
- {
- char tmp[4];
-
- tmp[0] = ((VARSIZE(ok.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.lower)[ul]);
- tmp[1] = ((VARSIZE(uk.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.lower)[ul]);
- tmp[2] = ((VARSIZE(ok.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.upper)[ul]);
- tmp[3] = ((VARSIZE(uk.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.upper)[ul]);
- dres = (tmp[0] - tmp[1]) +
- (tmp[3] - tmp[2]);
- }
+ char tmp[4];
+
+ tmp[0] = ((VARSIZE(ok.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.lower)[ul]);
+ tmp[1] = ((VARSIZE(uk.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.lower)[ul]);
+ tmp[2] = ((VARSIZE(ok.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.upper)[ul]);
+ tmp[3] = ((VARSIZE(uk.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.upper)[ul]);
+ dres = (tmp[0] - tmp[1]) +
+ (tmp[3] - tmp[2]);
dres /= 256.0;
}
+#include "mb/pg_wchar.h"
/* Variable length key */
typedef bytea GBT_VARKEY;
/* Attribs */
enum gbtree_type t; /* data type */
- bool str; /* true, if string ( else binary ) */
+ int32 eml; /* cached pg_database_encoding_max_length (0: undefined) */
bool trnc; /* truncate (=compress) key */
/* Methods */
7c5aba41f53293b712fd
3
166d77ac1b46a1ec38aa
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
2002-10-29 03:21:13
2000-06-22 14:23:04
1981-01-01 00:15:56
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
2001-12-31 12:30:28
2003-09-25 04:51:05
2020-12-07 22:47:38
2002-09-19 07:59:10
2016-03-16 14:50:17
1986-02-06 02:57:29
+-infinity
+-infinity
+-infinity
+-infinity
+-infinity
+-infinity
+-infinity
+-infinity
2018-07-07 23:37:36
1972-02-07 07:48:10
2001-05-06 17:04:36
2008-08-01 06:57:47
2032-11-22 15:34:23
1976-01-04 02:56:30
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
2037-04-11 12:30:59
2011-02-24 11:33:55
1992-11-16 04:53:09
2004-01-28 20:45:12 GMT+0
1991-03-21 13:23:37 GMT-5
2029-07-26 06:01:08 GMT+9
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
2002-11-15 19:24:22 GMT
1987-05-02 16:25:01 GMT-6
1999-04-01 05:54:41 GMT-2
1984-10-17 02:42:50 GMT-7
2001-04-29 03:59:54 GMT-1
1996-08-15 07:16:34 GMT-3
+infinity
+infinity
+infinity
+infinity
+infinity
+infinity
\N
1974-02-10 02:40:01 GMT-11
2033-03-28 21:51:56 GMT+10
1973-06-15 06:34:08 GMT-11
1976-03-21 22:21:06 GMT-10
1976-06-15 07:14:46 GMT-10
+-infinity
+-infinity
+-infinity
+-infinity
+-infinity
+-infinity
1972-01-15 06:30:22 GMT-11
1971-08-06 10:41:43 GMT-11
1995-08-21 21:12:06 GMT-3
SELECT count(*) FROM byteatmp WHERE a < '31b0';
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM byteatmp WHERE a <= '31b0';
count
-------
- 123
+ 589
(1 row)
SELECT count(*) FROM byteatmp WHERE a = '31b0';
SELECT count(*) FROM byteatmp WHERE a < '31b0'::bytea;
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM byteatmp WHERE a <= '31b0'::bytea;
count
-------
- 123
+ 589
(1 row)
SELECT count(*) FROM byteatmp WHERE a = '31b0'::bytea;
SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32);
count
-------
- 121
+ 587
(1 row)
SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32);
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32);
SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32);
count
-------
- 121
+ 587
(1 row)
SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32);
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32);
SELECT count(*) FROM texttmp WHERE a < '31b0';
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM texttmp WHERE a <= '31b0';
count
-------
- 123
+ 589
(1 row)
SELECT count(*) FROM texttmp WHERE a = '31b0';
SELECT count(*) FROM texttmp WHERE a < '31b0'::text;
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM texttmp WHERE a <= '31b0'::text;
count
-------
- 123
+ 589
(1 row)
SELECT count(*) FROM texttmp WHERE a = '31b0'::text;
SELECT count(*) FROM timestamptmp WHERE a < '2004-10-26 08:55:08';
count
-------
- 270
+ 278
(1 row)
SELECT count(*) FROM timestamptmp WHERE a <= '2004-10-26 08:55:08';
count
-------
- 271
+ 279
(1 row)
SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08';
SELECT count(*) FROM timestamptmp WHERE a >= '2004-10-26 08:55:08';
count
-------
- 274
+ 290
(1 row)
SELECT count(*) FROM timestamptmp WHERE a > '2004-10-26 08:55:08';
count
-------
- 273
+ 289
(1 row)
CREATE INDEX timestampidx ON timestamptmp USING gist ( a );
SELECT count(*) FROM timestamptmp WHERE a < '2004-10-26 08:55:08'::timestamp;
count
-------
- 270
+ 278
(1 row)
SELECT count(*) FROM timestamptmp WHERE a <= '2004-10-26 08:55:08'::timestamp;
count
-------
- 271
+ 279
(1 row)
SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08'::timestamp;
SELECT count(*) FROM timestamptmp WHERE a >= '2004-10-26 08:55:08'::timestamp;
count
-------
- 274
+ 290
(1 row)
SELECT count(*) FROM timestamptmp WHERE a > '2004-10-26 08:55:08'::timestamp;
count
-------
- 273
+ 289
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+3';
count
-------
- 385
+ 391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+3';
count
-------
- 386
+ 392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3';
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+3';
count
-------
- 146
+ 158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+3';
count
-------
- 145
+ 157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+2';
count
-------
- 385
+ 391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+2';
count
-------
- 385
+ 391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2';
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+2';
count
-------
- 146
+ 158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+2';
count
-------
- 146
+ 158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+4';
count
-------
- 386
+ 392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+4';
count
-------
- 386
+ 392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4';
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+4';
count
-------
- 145
+ 157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+4';
count
-------
- 145
+ 157
(1 row)
CREATE INDEX timestamptzidx ON timestamptztmp USING gist ( a );
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
- 385
+ 391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
- 386
+ 392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3'::timestamptz;
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
- 146
+ 158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
- 145
+ 157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
- 385
+ 391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
- 385
+ 391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2'::timestamptz;
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
- 146
+ 158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
- 146
+ 158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
- 386
+ 392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
- 386
+ 392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4'::timestamptz;
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
- 145
+ 157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
- 145
+ 157
(1 row)
SELECT count(*) FROM vchartmp WHERE a < '31b0'::varchar(32);
count
-------
- 121
+ 587
(1 row)
SELECT count(*) FROM vchartmp WHERE a <= '31b0'::varchar(32);
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM vchartmp WHERE a = '31b0'::varchar(32);
SELECT count(*) FROM vchartmp WHERE a < '31b0'::varchar(32);
count
-------
- 121
+ 587
(1 row)
SELECT count(*) FROM vchartmp WHERE a <= '31b0'::varchar(32);
count
-------
- 122
+ 588
(1 row)
SELECT count(*) FROM vchartmp WHERE a = '31b0'::varchar(32);