10
* $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.15 2009/03/25 22:19:01 tgl Exp $
10
* $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.16 2009/06/11 14:49:04 momjian Exp $
12
12
*-------------------------------------------------------------------------
23
23
gin_cmp_tslexeme(PG_FUNCTION_ARGS)
25
text *a = PG_GETARG_TEXT_PP(0);
26
text *b = PG_GETARG_TEXT_PP(1);
25
text *a = PG_GETARG_TEXT_PP(0);
26
text *b = PG_GETARG_TEXT_PP(1);
29
29
cmp = tsCompareString(
30
VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a),
31
VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b),
30
VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a),
31
VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b),
36
PG_RETURN_INT32( cmp );
34
PG_FREE_IF_COPY(a, 0);
35
PG_FREE_IF_COPY(b, 1);
40
40
gin_cmp_prefix(PG_FUNCTION_ARGS)
42
text *a = PG_GETARG_TEXT_PP(0);
43
text *b = PG_GETARG_TEXT_PP(1);
42
text *a = PG_GETARG_TEXT_PP(0);
43
text *b = PG_GETARG_TEXT_PP(1);
45
46
StrategyNumber strategy = PG_GETARG_UINT16(2);
46
Pointer extra_data = PG_GETARG_POINTER(3);
47
Pointer extra_data = PG_GETARG_POINTER(3);
50
51
cmp = tsCompareString(
51
VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a),
52
VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b),
56
cmp = 1; /* prevent continue scan */
60
PG_RETURN_INT32( cmp );
52
VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a),
53
VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b),
57
cmp = 1; /* prevent continue scan */
59
PG_FREE_IF_COPY(a, 0);
60
PG_FREE_IF_COPY(b, 1);
96
97
TSQuery query = PG_GETARG_TSQUERY(0);
97
98
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
98
100
/* StrategyNumber strategy = PG_GETARG_UINT16(2); */
99
bool **ptr_partialmatch = (bool**) PG_GETARG_POINTER(3);
100
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
101
bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3);
102
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
101
103
Datum *entries = NULL;
128
130
entries = (Datum *) palloc(sizeof(Datum) * (*nentries));
129
partialmatch = *ptr_partialmatch = (bool*) palloc(sizeof(bool) * (*nentries));
131
partialmatch = *ptr_partialmatch = (bool *) palloc(sizeof(bool) * (*nentries));
132
* Make map to convert item's number to corresponding
133
* operand's (the same, entry's) number. Entry's number
134
* is used in check array in consistent method. We use
135
* the same map for each entry.
134
* Make map to convert item's number to corresponding operand's (the
135
* same, entry's) number. Entry's number is used in check array in
136
* consistent method. We use the same map for each entry.
137
*extra_data = (Pointer*) palloc0(sizeof(Pointer)*(*nentries));
138
*extra_data = (Pointer *) palloc0(sizeof(Pointer) * (*nentries));
138
139
map_item_operand = palloc0(sizeof(int) * (query->size + 1));
140
141
for (i = 0; i < query->size; i++)
146
147
txt = cstring_to_text_with_len(GETOPERAND(query) + val->distance,
148
(*extra_data)[j] = (Pointer)map_item_operand;
149
(*extra_data)[j] = (Pointer) map_item_operand;
149
150
map_item_operand[i] = j;
150
151
partialmatch[j] = val->prefix;
151
152
entries[j++] = PointerGetDatum(txt);
156
(*extra_data)[j] = (Pointer)map_item_operand;
157
(*extra_data)[j] = (Pointer) map_item_operand;
157
158
map_item_operand[i] = j;
158
159
entries[j++] = PointerGetDatum(cstring_to_text_with_len("", 0));
185
186
*(gcv->need_recheck) = true;
187
188
/* convert item's number to corresponding entry's (operand's) number */
188
j = gcv->map_item_operand[ ((QueryItem *) val) - gcv->first_item ];
189
j = gcv->map_item_operand[((QueryItem *) val) - gcv->first_item];
190
191
/* return presence of current entry in indexed value */
191
192
return gcv->check[j];
195
196
gin_tsquery_consistent(PG_FUNCTION_ARGS)
197
198
bool *check = (bool *) PG_GETARG_POINTER(0);
198
200
/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
199
201
TSQuery query = PG_GETARG_TSQUERY(2);
200
203
/* int32 nkeys = PG_GETARG_INT32(3); */
201
Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
204
Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
202
205
bool *recheck = (bool *) PG_GETARG_POINTER(5);
203
206
bool res = FALSE;