1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
@@ -90,6 +90,76 @@ static gbtree_vinfo tinfo = NULL };
+/* bpchar needs its own comparison rules */ + +static bool +gbt_bpchargt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo) +{ + return DatumGetBool(DirectFunctionCall2Coll(bpchargt, + collation, + PointerGetDatum(a), + PointerGetDatum(b))); +} + +static bool +gbt_bpcharge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo) +{ + return DatumGetBool(DirectFunctionCall2Coll(bpcharge, + collation, + PointerGetDatum(a), + PointerGetDatum(b))); +} + +static bool +gbt_bpchareq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo) +{ + return DatumGetBool(DirectFunctionCall2Coll(bpchareq, + collation, + PointerGetDatum(a), + PointerGetDatum(b))); +} + +static bool +gbt_bpcharle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo) +{ + return DatumGetBool(DirectFunctionCall2Coll(bpcharle, + collation, + PointerGetDatum(a), + PointerGetDatum(b))); +} + +static bool +gbt_bpcharlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo) +{ + return DatumGetBool(DirectFunctionCall2Coll(bpcharlt, + collation, + PointerGetDatum(a), + PointerGetDatum(b))); +} + +static int32 +gbt_bpcharcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo) +{ + return DatumGetInt32(DirectFunctionCall2Coll(bpcharcmp, + collation, + PointerGetDatum(a), + PointerGetDatum(b))); +} + +static gbtree_vinfo bptinfo = +{ + gbt_t_bpchar, + 0, + false, + gbt_bpchargt, + gbt_bpcharge, + gbt_bpchareq, + gbt_bpcharle, + gbt_bpcharlt, + gbt_bpcharcmp, + NULL +}; +
/************************************************** * Text ops @@ -112,29 +182,8 @@ gbt_text_compress(PG_FUNCTION_ARGS) Datum gbt_bpchar_compress(PG_FUNCTION_ARGS) { - GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - GISTENTRY *retval; - - if (tinfo.eml == 0) - { - tinfo.eml = pg_database_encoding_max_length(); - } - - if (entry->leafkey) - { - - Datum d = DirectFunctionCall1(rtrim1, entry->key); - GISTENTRY trim; - - gistentryinit(trim, d, - entry->rel, entry->page, - entry->offset, true); - retval = gbt_var_compress(&trim, &tinfo); - } - else - retval = entry; - - PG_RETURN_POINTER(retval); + /* This should never have been distinct from gbt_text_compress */ + return gbt_text_compress(fcinfo); }
@@ -179,18 +228,17 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS) bool retval; GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key); GBT_VARKEY_R r = gbt_var_key_readable(key); - void *trim = (void *) DatumGetPointer(DirectFunctionCall1(rtrim1, PointerGetDatum(query)));
/* All cases served by this function are exact */ *recheck = false;
- if (tinfo.eml == 0) + if (bptinfo.eml == 0) { - tinfo.eml = pg_database_encoding_max_length(); + bptinfo.eml = pg_database_encoding_max_length(); }
- retval = gbt_var_consistent(&r, trim, strategy, PG_GET_COLLATION(), - GIST_LEAF(entry), &tinfo, fcinfo->flinfo); + retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(), + GIST_LEAF(entry), &bptinfo, fcinfo->flinfo); PG_RETURN_BOOL(retval); }
@@ -75,8 +75,8 @@ SELECT * FROM chartmp WHERE a BETWEEN '31a' AND '31c'; (2 rows)
SELECT * FROM chartmp WHERE a BETWEEN '31a' AND '31c'; - a
- 31b0 + a +---------------------------------- + 31b0 (1 row)
@@ -75,8 +75,8 @@ SELECT * FROM chartmp WHERE a BETWEEN '31a' AND '31c'; (2 rows)
SELECT * FROM chartmp WHERE a BETWEEN '31a' AND '31c'; - a
- 31b0 + a +---------------------------------- + 31b0 (1 row)
|