Debian Codegraph @

contrib/btree_gist/btree_gist.c

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