Line data Source code
1 : /*
2 : * contrib/btree_gist/btree_gist.c
3 : */
4 : #include "postgres.h"
5 :
6 : #include "access/cmptype.h"
7 : #include "access/stratnum.h"
8 : #include "utils/builtins.h"
9 :
10 0 : PG_MODULE_MAGIC_EXT(
11 : .name = "btree_gist",
12 : .version = PG_VERSION
13 : );
14 :
15 0 : PG_FUNCTION_INFO_V1(gbt_decompress);
16 0 : PG_FUNCTION_INFO_V1(gbtreekey_in);
17 0 : PG_FUNCTION_INFO_V1(gbtreekey_out);
18 0 : PG_FUNCTION_INFO_V1(gist_translate_cmptype_btree);
19 :
20 : /**************************************************
21 : * In/Out for keys
22 : **************************************************/
23 :
24 :
25 : Datum
26 0 : gbtreekey_in(PG_FUNCTION_ARGS)
27 : {
28 0 : Oid typioparam = PG_GETARG_OID(1);
29 :
30 0 : ereport(ERROR,
31 : (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
32 : errmsg("cannot accept a value of type %s",
33 : format_type_extended(typioparam, -1,
34 : FORMAT_TYPE_ALLOW_INVALID))));
35 :
36 0 : PG_RETURN_VOID(); /* keep compiler quiet */
37 0 : }
38 :
39 : Datum
40 0 : gbtreekey_out(PG_FUNCTION_ARGS)
41 : {
42 : /* Sadly, we do not receive any indication of the specific type */
43 0 : ereport(ERROR,
44 : (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
45 : errmsg("cannot display a value of type %s", "gbtreekey?")));
46 :
47 0 : PG_RETURN_VOID(); /* keep compiler quiet */
48 : }
49 :
50 :
51 : /*
52 : ** GiST DeCompress methods
53 : ** do not do anything.
54 : */
55 : Datum
56 0 : gbt_decompress(PG_FUNCTION_ARGS)
57 : {
58 0 : PG_RETURN_POINTER(PG_GETARG_POINTER(0));
59 : }
60 :
61 : /*
62 : * Returns the btree number for supported operators, otherwise invalid.
63 : */
64 : Datum
65 0 : gist_translate_cmptype_btree(PG_FUNCTION_ARGS)
66 : {
67 0 : CompareType cmptype = PG_GETARG_INT32(0);
68 :
69 0 : switch (cmptype)
70 : {
71 : case COMPARE_EQ:
72 0 : PG_RETURN_UINT16(BTEqualStrategyNumber);
73 : case COMPARE_LT:
74 0 : PG_RETURN_UINT16(BTLessStrategyNumber);
75 : case COMPARE_LE:
76 0 : PG_RETURN_UINT16(BTLessEqualStrategyNumber);
77 : case COMPARE_GT:
78 0 : PG_RETURN_UINT16(BTGreaterStrategyNumber);
79 : case COMPARE_GE:
80 0 : PG_RETURN_UINT16(BTGreaterEqualStrategyNumber);
81 : default:
82 0 : PG_RETURN_UINT16(InvalidStrategy);
83 : }
84 0 : }
|