@@ -55,16 +55,14 @@ rum_timestamp_extract_query(PG_FUNCTION_ARGS)
55
55
56
56
switch (strategy )
57
57
{
58
- case BTGreaterEqualStrategyNumber :
59
- case BTGreaterStrategyNumber :
60
- entries [0 ] = TimestampGetDatum (DT_NOEND ); /* leftmost */
61
- * ptr_partialmatch = true;
62
- break ;
63
-
64
58
case BTLessStrategyNumber :
65
59
case BTLessEqualStrategyNumber :
60
+ entries [0 ] = TimestampGetDatum (DT_NOBEGIN ); /* leftmost */
61
+ * ptr_partialmatch = true;
62
+ break ;
63
+ case BTGreaterEqualStrategyNumber :
64
+ case BTGreaterStrategyNumber :
66
65
* ptr_partialmatch = true;
67
-
68
66
case BTEqualStrategyNumber :
69
67
case RUM_TMST_DISTANCE :
70
68
case RUM_TMST_LEFT_DISTANCE :
@@ -78,20 +76,6 @@ rum_timestamp_extract_query(PG_FUNCTION_ARGS)
78
76
PG_RETURN_POINTER (entries );
79
77
}
80
78
81
- PG_FUNCTION_INFO_V1 (rum_timestamp_cmp );
82
- Datum
83
- rum_timestamp_cmp (PG_FUNCTION_ARGS )
84
- {
85
- Datum a = PG_GETARG_DATUM (0 );
86
- Datum b = PG_GETARG_DATUM (1 );
87
- int32 cmp ;
88
-
89
- cmp = - DatumGetInt32 (DirectFunctionCall2Coll (timestamp_cmp ,
90
- PG_GET_COLLATION (),
91
- a , b ));
92
- PG_RETURN_INT32 (cmp );
93
- }
94
-
95
79
PG_FUNCTION_INFO_V1 (rum_timestamp_compare_prefix );
96
80
Datum
97
81
rum_timestamp_compare_prefix (PG_FUNCTION_ARGS )
@@ -102,22 +86,22 @@ rum_timestamp_compare_prefix(PG_FUNCTION_ARGS)
102
86
int32 res ,
103
87
cmp ;
104
88
105
- cmp = DatumGetInt32 (DirectFunctionCall2Coll (rum_timestamp_cmp ,
89
+ cmp = DatumGetInt32 (DirectFunctionCall2Coll (timestamp_cmp ,
106
90
PG_GET_COLLATION (),
107
- (data -> strategy == BTGreaterStrategyNumber ||
108
- data -> strategy == BTGreaterEqualStrategyNumber )
91
+ (data -> strategy == BTLessStrategyNumber ||
92
+ data -> strategy == BTLessEqualStrategyNumber )
109
93
? data -> datum : a , b ));
110
94
111
95
switch (data -> strategy )
112
96
{
113
- case BTGreaterStrategyNumber :
97
+ case BTLessStrategyNumber :
114
98
/* If original datum > indexed one then return match */
115
99
if (cmp > 0 )
116
100
res = 0 ;
117
101
else
118
102
res = 1 ;
119
103
break ;
120
- case BTGreaterEqualStrategyNumber :
104
+ case BTLessEqualStrategyNumber :
121
105
/* The same except equality */
122
106
if (cmp >= 0 )
123
107
res = 0 ;
@@ -130,14 +114,14 @@ rum_timestamp_compare_prefix(PG_FUNCTION_ARGS)
130
114
else
131
115
res = 0 ;
132
116
break ;
133
- case BTLessEqualStrategyNumber :
117
+ case BTGreaterEqualStrategyNumber :
134
118
/* If original datum <= indexed one then return match */
135
119
if (cmp <= 0 )
136
120
res = 0 ;
137
121
else
138
122
res = 1 ;
139
123
break ;
140
- case BTLessStrategyNumber :
124
+ case BTGreaterStrategyNumber :
141
125
/* If original datum <= indexed one then return match */
142
126
/* If original datum == indexed one then continue scan */
143
127
if (cmp < 0 )
@@ -281,10 +265,10 @@ rum_timestamp_config(PG_FUNCTION_ARGS)
281
265
config -> addInfoTypeOid = InvalidOid ;
282
266
283
267
config -> strategyInfo [0 ].strategy = RUM_TMST_LEFT_DISTANCE ;
284
- config -> strategyInfo [0 ].direction = ForwardScanDirection ;
268
+ config -> strategyInfo [0 ].direction = BackwardScanDirection ;
285
269
286
270
config -> strategyInfo [1 ].strategy = RUM_TMST_RIGHT_DISTANCE ;
287
- config -> strategyInfo [1 ].direction = BackwardScanDirection ;
271
+ config -> strategyInfo [1 ].direction = ForwardScanDirection ;
288
272
289
273
config -> strategyInfo [2 ].strategy = InvalidStrategy ;
290
274
0 commit comments