Commit ef770cbb authored by Teodor Sigaev's avatar Teodor Sigaev

Fixes from Janko Richter <jankorichter@yahoo.de>

- 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.
parent 8f6e8e8f
...@@ -98,7 +98,7 @@ gbt_bit_l2n(GBT_VARKEY * leaf) ...@@ -98,7 +98,7 @@ gbt_bit_l2n(GBT_VARKEY * leaf)
static const gbtree_vinfo tinfo = static const gbtree_vinfo tinfo =
{ {
gbt_t_bit, gbt_t_bit,
FALSE, 0,
TRUE, TRUE,
gbt_bitgt, gbt_bitgt,
gbt_bitge, gbt_bitge,
......
...@@ -65,7 +65,7 @@ gbt_byteacmp(const bytea *a, const bytea *b) ...@@ -65,7 +65,7 @@ gbt_byteacmp(const bytea *a, const bytea *b)
static const gbtree_vinfo tinfo = static const gbtree_vinfo tinfo =
{ {
gbt_t_bytea, gbt_t_bytea,
FALSE, 0,
TRUE, TRUE,
gbt_byteagt, gbt_byteagt,
gbt_byteage, gbt_byteage,
......
...@@ -128,18 +128,7 @@ gbt_cash_penalty(PG_FUNCTION_ARGS) ...@@ -128,18 +128,7 @@ gbt_cash_penalty(PG_FUNCTION_ARGS)
cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
Cash res; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
*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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
......
...@@ -127,18 +127,7 @@ gbt_float4_penalty(PG_FUNCTION_ARGS) ...@@ -127,18 +127,7 @@ gbt_float4_penalty(PG_FUNCTION_ARGS)
float4KEY *newentry = (float4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float4KEY *newentry = (float4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
float4 res; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
*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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
......
...@@ -129,18 +129,7 @@ gbt_float8_penalty(PG_FUNCTION_ARGS) ...@@ -129,18 +129,7 @@ gbt_float8_penalty(PG_FUNCTION_ARGS)
float8KEY *newentry = (float8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float8KEY *newentry = (float8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
float8 res; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
*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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
......
...@@ -194,18 +194,7 @@ gbt_inet_penalty(PG_FUNCTION_ARGS) ...@@ -194,18 +194,7 @@ gbt_inet_penalty(PG_FUNCTION_ARGS)
inetKEY *newentry = (inetKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); inetKEY *newentry = (inetKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
double res; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
*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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
......
...@@ -130,18 +130,8 @@ gbt_int2_penalty(PG_FUNCTION_ARGS) ...@@ -130,18 +130,8 @@ gbt_int2_penalty(PG_FUNCTION_ARGS)
int16KEY *origentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); int16KEY *origentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
int2 res;
*result = 0.0; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
......
...@@ -128,18 +128,8 @@ gbt_int4_penalty(PG_FUNCTION_ARGS) ...@@ -128,18 +128,8 @@ gbt_int4_penalty(PG_FUNCTION_ARGS)
int32KEY *origentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); int32KEY *origentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
int4 res;
*result = 0.0; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
......
...@@ -127,21 +127,10 @@ gbt_int8_penalty(PG_FUNCTION_ARGS) ...@@ -127,21 +127,10 @@ gbt_int8_penalty(PG_FUNCTION_ARGS)
int64KEY *origentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); int64KEY *origentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
int64 res;
*result = 0.0; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
Datum Datum
......
...@@ -203,24 +203,14 @@ gbt_intv_penalty(PG_FUNCTION_ARGS) ...@@ -203,24 +203,14 @@ gbt_intv_penalty(PG_FUNCTION_ARGS)
intvKEY *newentry = (intvKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); intvKEY *newentry = (intvKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
double iorg[2], double iorg[2],
inew[2], inew[2];
res;
iorg[0] = intr2num(&origentry->lower); iorg[0] = intr2num(&origentry->lower);
iorg[1] = intr2num(&origentry->upper); iorg[1] = intr2num(&origentry->upper);
inew[0] = intr2num(&newentry->lower); inew[0] = intr2num(&newentry->lower);
inew[1] = intr2num(&newentry->upper); inew[1] = intr2num(&newentry->upper);
penalty_range_enlarge(iorg[0], iorg[1], inew[0], inew[1]); penalty_num(result,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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
......
...@@ -151,23 +151,13 @@ gbt_macad_penalty(PG_FUNCTION_ARGS) ...@@ -151,23 +151,13 @@ gbt_macad_penalty(PG_FUNCTION_ARGS)
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
uint64 iorg[2], uint64 iorg[2],
inew[2]; inew[2];
uint64 res;
iorg[0] = mac_2_uint64(&origentry->lower); iorg[0] = mac_2_uint64(&origentry->lower);
iorg[1] = mac_2_uint64(&origentry->upper); iorg[1] = mac_2_uint64(&origentry->upper);
inew[0] = mac_2_uint64(&newentry->lower); inew[0] = mac_2_uint64(&newentry->lower);
inew[1] = mac_2_uint64(&newentry->upper); inew[1] = mac_2_uint64(&newentry->upper);
penalty_range_enlarge(iorg[0], iorg[1], inew[0], inew[1]); penalty_num(result,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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
......
...@@ -65,7 +65,7 @@ gbt_numeric_cmp(const bytea *a, const bytea *b) ...@@ -65,7 +65,7 @@ gbt_numeric_cmp(const bytea *a, const bytea *b)
static const gbtree_vinfo tinfo = static const gbtree_vinfo tinfo =
{ {
gbt_t_numeric, gbt_t_numeric,
FALSE, 0,
FALSE, FALSE,
gbt_numeric_gt, gbt_numeric_gt,
gbt_numeric_ge, gbt_numeric_ge,
......
...@@ -129,18 +129,7 @@ gbt_oid_penalty(PG_FUNCTION_ARGS) ...@@ -129,18 +129,7 @@ gbt_oid_penalty(PG_FUNCTION_ARGS)
oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
Oid res = 0; penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
*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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
......
...@@ -62,11 +62,11 @@ gbt_textcmp(const bytea *a, const bytea *b) ...@@ -62,11 +62,11 @@ gbt_textcmp(const bytea *a, const bytea *b)
return DatumGetInt32(DirectFunctionCall2(bttextcmp, PointerGetDatum(a), PointerGetDatum(b))); return DatumGetInt32(DirectFunctionCall2(bttextcmp, PointerGetDatum(a), PointerGetDatum(b)));
} }
static const gbtree_vinfo tinfo = static gbtree_vinfo tinfo =
{ {
gbt_t_text, gbt_t_text,
TRUE, 0,
TRUE, FALSE,
gbt_textgt, gbt_textgt,
gbt_textge, gbt_textge,
gbt_texteq, gbt_texteq,
...@@ -77,7 +77,6 @@ static const gbtree_vinfo tinfo = ...@@ -77,7 +77,6 @@ static const gbtree_vinfo tinfo =
}; };
/************************************************** /**************************************************
* Text ops * Text ops
**************************************************/ **************************************************/
...@@ -88,6 +87,11 @@ gbt_text_compress(PG_FUNCTION_ARGS) ...@@ -88,6 +87,11 @@ gbt_text_compress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); 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)); PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
} }
...@@ -98,6 +102,11 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS) ...@@ -98,6 +102,11 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS)
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *retval; GISTENTRY *retval;
if ( tinfo.eml == 0 )
{
tinfo.eml = pg_database_encoding_max_length();
}
if (entry->leafkey) if (entry->leafkey)
{ {
...@@ -127,6 +136,11 @@ gbt_text_consistent(PG_FUNCTION_ARGS) ...@@ -127,6 +136,11 @@ gbt_text_consistent(PG_FUNCTION_ARGS)
bool retval = FALSE; bool retval = FALSE;
GBT_VARKEY_R r = gbt_var_key_readable(key); 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); retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
PG_RETURN_BOOL(retval); PG_RETURN_BOOL(retval);
...@@ -144,6 +158,11 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS) ...@@ -144,6 +158,11 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS)
bool retval; bool retval;
GBT_VARKEY_R r = gbt_var_key_readable(key); 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); retval = gbt_var_consistent(&r, trim, &strategy, GIST_LEAF(entry), &tinfo);
PG_RETURN_BOOL(retval); PG_RETURN_BOOL(retval);
} }
......
...@@ -114,7 +114,7 @@ tstz_to_ts_gmt(Timestamp *gmt, TimestampTz *ts) ...@@ -114,7 +114,7 @@ tstz_to_ts_gmt(Timestamp *gmt, TimestampTz *ts)
*gmt = *ts; *gmt = *ts;
DecodeSpecial(0, "gmt", &val); DecodeSpecial(0, "gmt", &val);
if (!TIMESTAMP_NOT_FINITE(*ts)) if ( *ts < DT_NOEND && *ts > DT_NOBEGIN )
{ {
tz = val * 60; tz = val * 60;
...@@ -218,6 +218,14 @@ gbt_ts_union(PG_FUNCTION_ARGS) ...@@ -218,6 +218,14 @@ gbt_ts_union(PG_FUNCTION_ARGS)
} }
#define penalty_check_max_float(val) do { \
if ( val > FLT_MAX ) \
val = FLT_MAX; \
if ( val < -FLT_MAX ) \
val = -FLT_MAX; \
} while(false);
Datum Datum
gbt_ts_penalty(PG_FUNCTION_ARGS) gbt_ts_penalty(PG_FUNCTION_ARGS)
{ {
...@@ -225,48 +233,28 @@ gbt_ts_penalty(PG_FUNCTION_ARGS) ...@@ -225,48 +233,28 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
tsKEY *origentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); tsKEY *origentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
Interval *intr;
#ifdef HAVE_INT64_TIMESTAMP
int64 res;
#else
double res;
#endif
intr = DatumGetIntervalP(DirectFunctionCall2( double orgdbl[2],
timestamp_mi, newdbl[2];
P_TimestampGetDatum(newentry->upper),
P_TimestampGetDatum(origentry->upper)
));
/* 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( penalty_num(result,orgdbl[0],orgdbl[1],newdbl[0],newdbl[1]);
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));
}
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
......
...@@ -43,16 +43,26 @@ typedef struct ...@@ -43,16 +43,26 @@ typedef struct
*/ */
#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) ) \ if ( (nupper) > (oupper) ) \
res += ( (nupper) - (oupper) ); \ tmp += ( ((double)nupper)*0.49F - ((double)oupper)*0.49F ); \
if ( (olower) > (nlower) ) \ 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); } while (0);
extern bool gbt_num_consistent(const GBT_NUMKEY_R * key, const void *query, extern bool gbt_num_consistent(const GBT_NUMKEY_R * key, const void *query,
const StrategyNumber *strategy, bool is_leaf, const StrategyNumber *strategy, bool is_leaf,
const gbtree_ninfo * tinfo); const gbtree_ninfo * tinfo);
......
#include "btree_gist.h" #include "btree_gist.h"
#include "utils/pg_locale.h" #include "utils/pg_locale.h"
#include "btree_utils_var.h" #include "btree_utils_var.h"
#include "utils/builtins.h"
PG_FUNCTION_INFO_V1(gbt_var_decompress); PG_FUNCTION_INFO_V1(gbt_var_decompress);
Datum gbt_var_decompress(PG_FUNCTION_ARGS); Datum gbt_var_decompress(PG_FUNCTION_ARGS);
...@@ -90,47 +91,70 @@ gbt_var_leaf2node(GBT_VARKEY * leaf, const gbtree_vinfo * tinfo) ...@@ -90,47 +91,70 @@ gbt_var_leaf2node(GBT_VARKEY * leaf, const gbtree_vinfo * tinfo)
static int32 static int32
gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo) 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); GBT_VARKEY_R r = gbt_var_key_readable(node);
int32 t1len = VARSIZE(r.lower) - VARHDRSZ - s; int32 i = 0;
int32 t2len = VARSIZE(r.upper) - VARHDRSZ - s; int32 l = 0;
int32 t1len = VARSIZE(r.lower) - VARHDRSZ ;
int32 t2len = VARSIZE(r.upper) - VARHDRSZ ;
int32 ml = Min(t1len, t2len); int32 ml = Min(t1len, t2len);
char *p1 = VARDATA(r.lower), char *p1 = VARDATA(r.lower);
*p2 = VARDATA(r.upper); char *p2 = VARDATA(r.upper);
if ( ml == 0 )
return 0;
for (i = 0; i < ml; i++) while ( i < ml )
{ {
if ( tinfo->eml > 1 && l == 0 )
{
if ( ( l = pg_mblen(p1) ) != pg_mblen(p2) )
{
return i;
}
}
if (*p1 != *p2) if (*p1 != *p2)
{
if( tinfo->eml > 1 )
{
return (i-l+1);
} else {
return i; return i;
}
}
p1++; p1++;
p2++; 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 static bool
gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tinfo) 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; bool out = FALSE;
int32 qlen = VARSIZE(query) - VARHDRSZ - s; int32 k = 0;
int32 nlen = VARSIZE(pf) - VARHDRSZ - s; int32 qlen = VARSIZE(query) - VARHDRSZ ;
int32 nlen = VARSIZE(pf) - VARHDRSZ ;
if (nlen <= qlen) if (nlen <= qlen)
{ {
char *q = VARDATA(query); char *q = VARDATA(query);
char *n = VARDATA(pf); char *n = VARDATA(pf);
if ( tinfo->eml > 1 )
{
out = ( varstr_cmp(q, nlen, n, nlen) == 0 );
} else {
out = TRUE; out = TRUE;
for (k = 0; k < nlen; k++) for (k = 0; k < nlen; k++)
{ {
...@@ -146,13 +170,12 @@ gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tin ...@@ -146,13 +170,12 @@ gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tin
} }
} }
} }
}
return out; return out;
} }
/* /*
* returns true, if query matches node using common prefix * returns true, if query matches node using common prefix
*/ */
...@@ -161,44 +184,36 @@ static bool ...@@ -161,44 +184,36 @@ static bool
gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtree_vinfo * tinfo) 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->lower, query, tinfo) ||
gbt_bytea_pf_match(node->upper, query, tinfo) gbt_bytea_pf_match(node->upper, query, tinfo)
); ) );
} }
/* /*
* truncates / compresses the node key * truncates / compresses the node key
* cpf_length .. common prefix length
*/ */
static GBT_VARKEY * 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 *out = NULL;
GBT_VARKEY_R r = gbt_var_key_readable(node); GBT_VARKEY_R r = gbt_var_key_readable(node);
int32 len1 = VARSIZE(r.lower) - VARHDRSZ; int32 len1 = VARSIZE(r.lower) - VARHDRSZ;
int32 len2 = VARSIZE(r.upper) - VARHDRSZ; int32 len2 = VARSIZE(r.upper) - VARHDRSZ;
int32 si = 0; int32 si = 0;
if (tinfo->str) len1 = Min(len1,(cpf_length + 1));
length++; /* because of tailing '\0' */ len2 = Min(len2,(cpf_length + 1));
len1 = Min(len1, length);
len2 = Min(len2, length);
si = 2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2; si = 2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2;
out = (GBT_VARKEY *) palloc(si); out = (GBT_VARKEY *) palloc(si);
out->vl_len = si; out->vl_len = si;
memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + 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 - s); 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])) = len1 + VARHDRSZ;
*((int32 *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)])) = len2 + VARHDRSZ; *((int32 *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)])) = len2 + VARHDRSZ;
...@@ -356,7 +371,6 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree ...@@ -356,7 +371,6 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree
GBT_VARKEY_R ok, GBT_VARKEY_R ok,
nk; nk;
GBT_VARKEY *tmp = NULL; GBT_VARKEY *tmp = NULL;
int32 s = (tinfo->str) ? (1) : (0);
*res = 0.0; *res = 0.0;
...@@ -369,7 +383,7 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree ...@@ -369,7 +383,7 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree
} }
ok = gbt_var_key_readable(orge); 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; *res = 0.0;
else if (!( else if (!(
( (
...@@ -396,13 +410,6 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree ...@@ -396,13 +410,6 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree
{ {
GBT_VARKEY_R uk = gbt_var_key_readable((GBT_VARKEY *) DatumGetPointer(d)); 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]; char tmp[4];
tmp[0] = ((VARSIZE(ok.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.lower)[ul]); tmp[0] = ((VARSIZE(ok.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.lower)[ul]);
...@@ -411,7 +418,6 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree ...@@ -411,7 +418,6 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree
tmp[3] = ((VARSIZE(uk.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.upper)[ul]); tmp[3] = ((VARSIZE(uk.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.upper)[ul]);
dres = (tmp[0] - tmp[1]) + dres = (tmp[0] - tmp[1]) +
(tmp[3] - tmp[2]); (tmp[3] - tmp[2]);
}
dres /= 256.0; dres /= 256.0;
} }
......
#include "mb/pg_wchar.h"
/* Variable length key */ /* Variable length key */
typedef bytea GBT_VARKEY; typedef bytea GBT_VARKEY;
...@@ -27,7 +28,7 @@ typedef struct ...@@ -27,7 +28,7 @@ typedef struct
/* Attribs */ /* Attribs */
enum gbtree_type t; /* data type */ 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 */ bool trnc; /* truncate (=compress) key */
/* Methods */ /* Methods */
......
...@@ -532,3 +532,469 @@ c30f7472766d25af1dc80 ...@@ -532,3 +532,469 @@ c30f7472766d25af1dc80
7c5aba41f53293b712fd 7c5aba41f53293b712fd
3 3
166d77ac1b46a1ec38aa 166d77ac1b46a1ec38aa
...@@ -341,6 +341,14 @@ ...@@ -341,6 +341,14 @@
2002-10-29 03:21:13 2002-10-29 03:21:13
2000-06-22 14:23:04 2000-06-22 14:23:04
1981-01-01 00:15:56 1981-01-01 00:15:56
infinity
infinity
infinity
infinity
infinity
infinity
infinity
infinity
2001-12-31 12:30:28 2001-12-31 12:30:28
2003-09-25 04:51:05 2003-09-25 04:51:05
2020-12-07 22:47:38 2020-12-07 22:47:38
...@@ -557,6 +565,14 @@ ...@@ -557,6 +565,14 @@
2002-09-19 07:59:10 2002-09-19 07:59:10
2016-03-16 14:50:17 2016-03-16 14:50:17
1986-02-06 02:57:29 1986-02-06 02:57:29
-infinity
-infinity
-infinity
-infinity
-infinity
-infinity
-infinity
-infinity
2018-07-07 23:37:36 2018-07-07 23:37:36
1972-02-07 07:48:10 1972-02-07 07:48:10
2001-05-06 17:04:36 2001-05-06 17:04:36
...@@ -590,6 +606,14 @@ ...@@ -590,6 +606,14 @@
2008-08-01 06:57:47 2008-08-01 06:57:47
2032-11-22 15:34:23 2032-11-22 15:34:23
1976-01-04 02:56:30 1976-01-04 02:56:30
infinity
infinity
infinity
infinity
infinity
infinity
infinity
infinity
2037-04-11 12:30:59 2037-04-11 12:30:59
2011-02-24 11:33:55 2011-02-24 11:33:55
1992-11-16 04:53:09 1992-11-16 04:53:09
......
...@@ -393,6 +393,12 @@ ...@@ -393,6 +393,12 @@
2004-01-28 20:45:12 GMT+0 2004-01-28 20:45:12 GMT+0
1991-03-21 13:23:37 GMT-5 1991-03-21 13:23:37 GMT-5
2029-07-26 06:01:08 GMT+9 2029-07-26 06:01:08 GMT+9
infinity
infinity
infinity
infinity
infinity
infinity
2002-11-15 19:24:22 GMT 2002-11-15 19:24:22 GMT
1987-05-02 16:25:01 GMT-6 1987-05-02 16:25:01 GMT-6
1999-04-01 05:54:41 GMT-2 1999-04-01 05:54:41 GMT-2
...@@ -422,6 +428,12 @@ ...@@ -422,6 +428,12 @@
1984-10-17 02:42:50 GMT-7 1984-10-17 02:42:50 GMT-7
2001-04-29 03:59:54 GMT-1 2001-04-29 03:59:54 GMT-1
1996-08-15 07:16:34 GMT-3 1996-08-15 07:16:34 GMT-3
infinity
infinity
infinity
infinity
infinity
infinity
\N \N
1974-02-10 02:40:01 GMT-11 1974-02-10 02:40:01 GMT-11
2033-03-28 21:51:56 GMT+10 2033-03-28 21:51:56 GMT+10
...@@ -475,6 +487,12 @@ ...@@ -475,6 +487,12 @@
1973-06-15 06:34:08 GMT-11 1973-06-15 06:34:08 GMT-11
1976-03-21 22:21:06 GMT-10 1976-03-21 22:21:06 GMT-10
1976-06-15 07:14:46 GMT-10 1976-06-15 07:14:46 GMT-10
-infinity
-infinity
-infinity
-infinity
-infinity
-infinity
1972-01-15 06:30:22 GMT-11 1972-01-15 06:30:22 GMT-11
1971-08-06 10:41:43 GMT-11 1971-08-06 10:41:43 GMT-11
1995-08-21 21:12:06 GMT-3 1995-08-21 21:12:06 GMT-3
......
...@@ -6,13 +6,13 @@ SET enable_seqscan=on; ...@@ -6,13 +6,13 @@ SET enable_seqscan=on;
SELECT count(*) FROM byteatmp WHERE a < '31b0'; SELECT count(*) FROM byteatmp WHERE a < '31b0';
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM byteatmp WHERE a <= '31b0'; SELECT count(*) FROM byteatmp WHERE a <= '31b0';
count count
------- -------
123 589
(1 row) (1 row)
SELECT count(*) FROM byteatmp WHERE a = '31b0'; SELECT count(*) FROM byteatmp WHERE a = '31b0';
...@@ -38,13 +38,13 @@ SET enable_seqscan=off; ...@@ -38,13 +38,13 @@ SET enable_seqscan=off;
SELECT count(*) FROM byteatmp WHERE a < '31b0'::bytea; SELECT count(*) FROM byteatmp WHERE a < '31b0'::bytea;
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM byteatmp WHERE a <= '31b0'::bytea; SELECT count(*) FROM byteatmp WHERE a <= '31b0'::bytea;
count count
------- -------
123 589
(1 row) (1 row)
SELECT count(*) FROM byteatmp WHERE a = '31b0'::bytea; SELECT count(*) FROM byteatmp WHERE a = '31b0'::bytea;
......
...@@ -5,13 +5,13 @@ SET enable_seqscan=on; ...@@ -5,13 +5,13 @@ SET enable_seqscan=on;
SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32); SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32);
count count
------- -------
121 587
(1 row) (1 row)
SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32); SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32);
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32); SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32);
...@@ -37,13 +37,13 @@ SET enable_seqscan=off; ...@@ -37,13 +37,13 @@ SET enable_seqscan=off;
SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32); SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32);
count count
------- -------
121 587
(1 row) (1 row)
SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32); SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32);
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32); SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32);
......
...@@ -6,13 +6,13 @@ SET enable_seqscan=on; ...@@ -6,13 +6,13 @@ SET enable_seqscan=on;
SELECT count(*) FROM texttmp WHERE a < '31b0'; SELECT count(*) FROM texttmp WHERE a < '31b0';
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM texttmp WHERE a <= '31b0'; SELECT count(*) FROM texttmp WHERE a <= '31b0';
count count
------- -------
123 589
(1 row) (1 row)
SELECT count(*) FROM texttmp WHERE a = '31b0'; SELECT count(*) FROM texttmp WHERE a = '31b0';
...@@ -38,13 +38,13 @@ SET enable_seqscan=off; ...@@ -38,13 +38,13 @@ SET enable_seqscan=off;
SELECT count(*) FROM texttmp WHERE a < '31b0'::text; SELECT count(*) FROM texttmp WHERE a < '31b0'::text;
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM texttmp WHERE a <= '31b0'::text; SELECT count(*) FROM texttmp WHERE a <= '31b0'::text;
count count
------- -------
123 589
(1 row) (1 row)
SELECT count(*) FROM texttmp WHERE a = '31b0'::text; SELECT count(*) FROM texttmp WHERE a = '31b0'::text;
......
...@@ -5,13 +5,13 @@ SET enable_seqscan=on; ...@@ -5,13 +5,13 @@ SET enable_seqscan=on;
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 count
------- -------
270 278
(1 row) (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 count
------- -------
271 279
(1 row) (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';
...@@ -23,13 +23,13 @@ SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08'; ...@@ -23,13 +23,13 @@ SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08';
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 count
------- -------
274 290
(1 row) (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 count
------- -------
273 289
(1 row) (1 row)
CREATE INDEX timestampidx ON timestamptmp USING gist ( a ); CREATE INDEX timestampidx ON timestamptmp USING gist ( a );
...@@ -37,13 +37,13 @@ SET enable_seqscan=off; ...@@ -37,13 +37,13 @@ SET enable_seqscan=off;
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 count
------- -------
270 278
(1 row) (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 count
------- -------
271 279
(1 row) (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;
...@@ -55,12 +55,12 @@ SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08'::timestamp; ...@@ -55,12 +55,12 @@ 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; SELECT count(*) FROM timestamptmp WHERE a >= '2004-10-26 08:55:08'::timestamp;
count count
------- -------
274 290
(1 row) (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 count
------- -------
273 289
(1 row) (1 row)
...@@ -5,13 +5,13 @@ SET enable_seqscan=on; ...@@ -5,13 +5,13 @@ SET enable_seqscan=on;
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 count
------- -------
385 391
(1 row) (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 count
------- -------
386 392
(1 row) (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';
...@@ -23,25 +23,25 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3'; ...@@ -23,25 +23,25 @@ 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'; SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+3';
count count
------- -------
146 158
(1 row) (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 count
------- -------
145 157
(1 row) (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 count
------- -------
385 391
(1 row) (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 count
------- -------
385 391
(1 row) (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';
...@@ -53,25 +53,25 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2'; ...@@ -53,25 +53,25 @@ 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'; SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+2';
count count
------- -------
146 158
(1 row) (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 count
------- -------
146 158
(1 row) (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 count
------- -------
386 392
(1 row) (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 count
------- -------
386 392
(1 row) (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';
...@@ -83,13 +83,13 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4'; ...@@ -83,13 +83,13 @@ 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'; SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+4';
count count
------- -------
145 157
(1 row) (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 count
------- -------
145 157
(1 row) (1 row)
CREATE INDEX timestamptzidx ON timestamptztmp USING gist ( a ); CREATE INDEX timestamptzidx ON timestamptztmp USING gist ( a );
...@@ -97,13 +97,13 @@ SET enable_seqscan=off; ...@@ -97,13 +97,13 @@ SET enable_seqscan=off;
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 count
------- -------
385 391
(1 row) (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 count
------- -------
386 392
(1 row) (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;
...@@ -115,25 +115,25 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3'::time ...@@ -115,25 +115,25 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3'::time
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 count
------- -------
146 158
(1 row) (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 count
------- -------
145 157
(1 row) (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 count
------- -------
385 391
(1 row) (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 count
------- -------
385 391
(1 row) (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;
...@@ -145,25 +145,25 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2'::time ...@@ -145,25 +145,25 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2'::time
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 count
------- -------
146 158
(1 row) (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 count
------- -------
146 158
(1 row) (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 count
------- -------
386 392
(1 row) (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 count
------- -------
386 392
(1 row) (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;
...@@ -175,12 +175,12 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4'::time ...@@ -175,12 +175,12 @@ SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4'::time
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 count
------- -------
145 157
(1 row) (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 count
------- -------
145 157
(1 row) (1 row)
...@@ -5,13 +5,13 @@ SET enable_seqscan=on; ...@@ -5,13 +5,13 @@ SET enable_seqscan=on;
SELECT count(*) FROM vchartmp WHERE a < '31b0'::varchar(32); SELECT count(*) FROM vchartmp WHERE a < '31b0'::varchar(32);
count count
------- -------
121 587
(1 row) (1 row)
SELECT count(*) FROM vchartmp WHERE a <= '31b0'::varchar(32); SELECT count(*) FROM vchartmp WHERE a <= '31b0'::varchar(32);
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM vchartmp WHERE a = '31b0'::varchar(32); SELECT count(*) FROM vchartmp WHERE a = '31b0'::varchar(32);
...@@ -37,13 +37,13 @@ SET enable_seqscan=off; ...@@ -37,13 +37,13 @@ SET enable_seqscan=off;
SELECT count(*) FROM vchartmp WHERE a < '31b0'::varchar(32); SELECT count(*) FROM vchartmp WHERE a < '31b0'::varchar(32);
count count
------- -------
121 587
(1 row) (1 row)
SELECT count(*) FROM vchartmp WHERE a <= '31b0'::varchar(32); SELECT count(*) FROM vchartmp WHERE a <= '31b0'::varchar(32);
count count
------- -------
122 588
(1 row) (1 row)
SELECT count(*) FROM vchartmp WHERE a = '31b0'::varchar(32); SELECT count(*) FROM vchartmp WHERE a = '31b0'::varchar(32);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment