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 64 : PG_MODULE_MAGIC_EXT( 11 : .name = "btree_gist", 12 : .version = PG_VERSION 13 : ); 14 : 15 46 : PG_FUNCTION_INFO_V1(gbt_decompress); 16 12 : PG_FUNCTION_INFO_V1(gbtreekey_in); 17 12 : PG_FUNCTION_INFO_V1(gbtreekey_out); 18 6 : PG_FUNCTION_INFO_V1(gist_stratnum_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 : PG_RETURN_VOID(); /* keep compiler quiet */ 37 : } 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 : PG_RETURN_VOID(); /* keep compiler quiet */ 48 : } 49 : 50 : 51 : /* 52 : ** GiST DeCompress methods 53 : ** do not do anything. 54 : */ 55 : Datum 56 223642 : gbt_decompress(PG_FUNCTION_ARGS) 57 : { 58 223642 : PG_RETURN_POINTER(PG_GETARG_POINTER(0)); 59 : } 60 : 61 : /* 62 : * Returns the btree number for supported operators, otherwise invalid. 63 : */ 64 : Datum 65 10 : gist_stratnum_btree(PG_FUNCTION_ARGS) 66 : { 67 10 : CompareType cmptype = PG_GETARG_INT32(0); 68 : 69 10 : switch (cmptype) 70 : { 71 8 : case COMPARE_EQ: 72 8 : PG_RETURN_UINT16(BTEqualStrategyNumber); 73 0 : case COMPARE_LT: 74 0 : PG_RETURN_UINT16(BTLessStrategyNumber); 75 0 : case COMPARE_LE: 76 0 : PG_RETURN_UINT16(BTLessEqualStrategyNumber); 77 0 : case COMPARE_GT: 78 0 : PG_RETURN_UINT16(BTGreaterStrategyNumber); 79 0 : case COMPARE_GE: 80 0 : PG_RETURN_UINT16(BTGreaterEqualStrategyNumber); 81 2 : default: 82 2 : PG_RETURN_UINT16(InvalidStrategy); 83 : } 84 : }