@@ -54,14 +54,16 @@ rum_timestamp_extract_query(PG_FUNCTION_ARGS)
54
54
55
55
switch (strategy )
56
56
{
57
- case BTLessStrategyNumber :
58
- case BTLessEqualStrategyNumber :
59
- entries [0 ] = TimestampGetDatum (DT_NOBEGIN ); /* leftmost */
60
- * ptr_partialmatch = true;
61
- break ;
62
57
case BTGreaterEqualStrategyNumber :
63
58
case BTGreaterStrategyNumber :
59
+ entries [0 ] = TimestampGetDatum (DT_NOEND ); /* leftmost */
64
60
* ptr_partialmatch = true;
61
+ break ;
62
+
63
+ case BTLessStrategyNumber :
64
+ case BTLessEqualStrategyNumber :
65
+ * ptr_partialmatch = true;
66
+
65
67
case BTEqualStrategyNumber :
66
68
case RUM_TMST_DISTANCE :
67
69
case RUM_TMST_LEFT_DISTANCE :
@@ -75,6 +77,20 @@ rum_timestamp_extract_query(PG_FUNCTION_ARGS)
75
77
PG_RETURN_POINTER (entries );
76
78
}
77
79
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
+
78
94
PG_FUNCTION_INFO_V1 (rum_timestamp_compare_prefix );
79
95
Datum
80
96
rum_timestamp_compare_prefix (PG_FUNCTION_ARGS )
@@ -85,22 +101,22 @@ rum_timestamp_compare_prefix(PG_FUNCTION_ARGS)
85
101
int32 res ,
86
102
cmp ;
87
103
88
- cmp = DatumGetInt32 (DirectFunctionCall2Coll (timestamp_cmp ,
104
+ cmp = DatumGetInt32 (DirectFunctionCall2Coll (rum_timestamp_cmp ,
89
105
PG_GET_COLLATION (),
90
- (data -> strategy == BTLessStrategyNumber ||
91
- data -> strategy == BTLessEqualStrategyNumber )
106
+ (data -> strategy == BTGreaterStrategyNumber ||
107
+ data -> strategy == BTGreaterEqualStrategyNumber )
92
108
? data -> datum : a , b ));
93
109
94
110
switch (data -> strategy )
95
111
{
96
- case BTLessStrategyNumber :
112
+ case BTGreaterStrategyNumber :
97
113
/* If original datum > indexed one then return match */
98
114
if (cmp > 0 )
99
115
res = 0 ;
100
116
else
101
117
res = 1 ;
102
118
break ;
103
- case BTLessEqualStrategyNumber :
119
+ case BTGreaterEqualStrategyNumber :
104
120
/* The same except equality */
105
121
if (cmp >= 0 )
106
122
res = 0 ;
@@ -113,14 +129,14 @@ rum_timestamp_compare_prefix(PG_FUNCTION_ARGS)
113
129
else
114
130
res = 0 ;
115
131
break ;
116
- case BTGreaterEqualStrategyNumber :
132
+ case BTLessEqualStrategyNumber :
117
133
/* If original datum <= indexed one then return match */
118
134
if (cmp <= 0 )
119
135
res = 0 ;
120
136
else
121
137
res = 1 ;
122
138
break ;
123
- case BTGreaterStrategyNumber :
139
+ case BTLessStrategyNumber :
124
140
/* If original datum <= indexed one then return match */
125
141
/* If original datum == indexed one then continue scan */
126
142
if (cmp < 0 )
0 commit comments