@@ -54,14 +54,16 @@ rum_timestamp_extract_query(PG_FUNCTION_ARGS)
5454
5555switch (strategy )
5656{
57- case BTLessStrategyNumber :
58- case BTLessEqualStrategyNumber :
59- entries [0 ]= TimestampGetDatum (DT_NOBEGIN );/* leftmost */
60- * ptr_partialmatch = true;
61- break ;
6257case BTGreaterEqualStrategyNumber :
6358case BTGreaterStrategyNumber :
59+ entries [0 ]= TimestampGetDatum (DT_NOEND );/* leftmost */
6460* ptr_partialmatch = true;
61+ break ;
62+
63+ case BTLessStrategyNumber :
64+ case BTLessEqualStrategyNumber :
65+ * ptr_partialmatch = true;
66+
6567case BTEqualStrategyNumber :
6668case RUM_TMST_DISTANCE :
6769case RUM_TMST_LEFT_DISTANCE :
@@ -75,6 +77,20 @@ rum_timestamp_extract_query(PG_FUNCTION_ARGS)
7577PG_RETURN_POINTER (entries );
7678}
7779
80+ PG_FUNCTION_INFO_V1 (rum_timestamp_cmp );
81+ Datum
82+ rum_timestamp_cmp (PG_FUNCTION_ARGS )
83+ {
84+ Datum a = PG_GETARG_DATUM (0 );
85+ Datum b = PG_GETARG_DATUM (1 );
86+ int32 cmp ;
87+
88+ cmp = - DatumGetInt32 (DirectFunctionCall2Coll (timestamp_cmp ,
89+ PG_GET_COLLATION (),
90+ a ,b ));
91+ PG_RETURN_INT32 (cmp );
92+ }
93+
7894PG_FUNCTION_INFO_V1 (rum_timestamp_compare_prefix );
7995Datum
8096rum_timestamp_compare_prefix (PG_FUNCTION_ARGS )
@@ -85,22 +101,22 @@ rum_timestamp_compare_prefix(PG_FUNCTION_ARGS)
85101int32 res ,
86102cmp ;
87103
88- cmp = DatumGetInt32 (DirectFunctionCall2Coll (timestamp_cmp ,
104+ cmp = DatumGetInt32 (DirectFunctionCall2Coll (rum_timestamp_cmp ,
89105PG_GET_COLLATION (),
90- (data -> strategy == BTLessStrategyNumber ||
91- data -> strategy == BTLessEqualStrategyNumber )
106+ (data -> strategy == BTGreaterStrategyNumber ||
107+ data -> strategy == BTGreaterEqualStrategyNumber )
92108?data -> datum :a ,b ));
93109
94110switch (data -> strategy )
95111{
96- case BTLessStrategyNumber :
112+ case BTGreaterStrategyNumber :
97113/* If original datum > indexed one then return match */
98114if (cmp > 0 )
99115res = 0 ;
100116else
101117res = 1 ;
102118break ;
103- case BTLessEqualStrategyNumber :
119+ case BTGreaterEqualStrategyNumber :
104120/* The same except equality */
105121if (cmp >=0 )
106122res = 0 ;
@@ -113,14 +129,14 @@ rum_timestamp_compare_prefix(PG_FUNCTION_ARGS)
113129else
114130res = 0 ;
115131break ;
116- case BTGreaterEqualStrategyNumber :
132+ case BTLessEqualStrategyNumber :
117133/* If original datum <= indexed one then return match */
118134if (cmp <=0 )
119135res = 0 ;
120136else
121137res = 1 ;
122138break ;
123- case BTGreaterStrategyNumber :
139+ case BTLessStrategyNumber :
124140/* If original datum <= indexed one then return match */
125141/* If original datum == indexed one then continue scan */
126142if (cmp < 0 )